/* BO Administration & Control Center — interface web (Phase 5) */
:root {
  --navy: #0f1b2d;
  --navy-2: #16263d;
  --navy-3: #22385a;
  --accent: #1d4f91;
  --accent-2: #163f75;
  --accent-soft: #e8f0fb;
  --gold: #e8a317;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #14202e;
  --muted: #5b6b7c;
  --line: #e2e7ee;
  --line-2: #eef1f5;
  --ok: #1f8a4c;
  --ok-soft: #e7f5ed;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --bad: #c0392b;
  --bad-soft: #fdecea;
  --info: #2a6fb5;
  --info-soft: #e8f1fb;
  --grey-soft: #eef1f5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 27, 45, .06), 0 4px 14px rgba(16, 27, 45, .05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", "SFMono-Regular", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.noscript { padding: 24px; text-align: center; }
.hidden { display: none !important; }

/* ---------- Démarrage / connexion ---------- */
.boot, .auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% 0%, #1b3357 0%, var(--navy) 60%); }
.boot-card { color: #c9d4e3; text-align: center; }
.brand-mark { font-weight: 800; font-size: 30px; letter-spacing: 1px; color: #fff; }
.brand-mark span { color: var(--gold); }
.auth-card { background: var(--card); width: 100%; max-width: 410px; border-radius: 14px; padding: 34px 34px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.auth-card .brand-mark { color: var(--accent); font-size: 32px; }
.auth-card h1 { font-size: 19px; margin: 6px 0 2px; }
.auth-card .sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 6px; padding: 11px; }
.auth-foot { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line-2); color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- Mise en page ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #c9d4e3; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 22px 22px 18px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.sidebar .brand .brand-mark { font-size: 24px; }
.sidebar .brand small { display: block; font-size: 11px; color: #8ea0b8; letter-spacing: .4px; text-transform: uppercase; margin-top: 2px; }
.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #6f839e; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: #c9d4e3; font-weight: 500; }
.nav a:hover { background: var(--navy-2); text-decoration: none; color: #fff; }
.nav a.active { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.sidebar .side-foot { padding: 14px 22px; font-size: 11px; color: #6f839e; border-top: 1px solid rgba(255, 255, 255, .06); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; padding: 0 26px; position: sticky; top: 0; z-index: 20; gap: 12px; }
.topbar .title { font-size: 17px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 8px 5px 5px; border-radius: 999px; border: 1px solid transparent; position: relative; background: none; }
.user-chip:hover { border-color: var(--line); background: var(--bg); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.user-chip .who { text-align: left; line-height: 1.25; }
.user-chip .who b { display: block; font-size: 13px; }
.user-chip .who span { font-size: 12px; color: var(--muted); }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(16, 27, 45, .14); min-width: 230px; padding: 6px; z-index: 50; }
.dropdown .dd-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.dropdown .dd-head b { color: var(--text); font-size: 13px; display: block; }
.dropdown button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.dropdown button:hover { background: var(--bg); }
.dropdown button.danger { color: var(--bad); }

.content { padding: 24px 26px 40px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; font-weight: 650; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cartes / grilles ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line-2); gap: 10px; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.card-head .hint { color: var(--muted); font-size: 12px; }
.card-body { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: 1.6fr 1fr; margin-bottom: 16px; }
.grid.half { grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.kpi .detail { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.kpi.k-ok::before { background: var(--ok); }
.kpi.k-gold::before { background: var(--gold); }
.kpi.k-info::before { background: #5b8fd1; }
.kpi.k-bad::before { background: var(--bad); }

.stat-list { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.stat-list > div { padding: 6px 4px; }
.stat-list > div + div { border-left: 1px solid var(--line-2); }
.stat-list b { display: block; font-size: 24px; }
.stat-list span { font-size: 12px; color: var(--muted); }

/* ---------- Alertes ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.alert.warn { background: var(--warn-soft); border-color: #f3d9a6; color: #6b4200; }
.alert.bad { background: var(--bad-soft); border-color: #f2c4bd; color: #7d2117; }
.alert.ok { background: var(--ok-soft); border-color: #bfe3cd; color: #155f35; }
.alert.info { background: var(--info-soft); border-color: #c5dbf2; color: #1d4f7d; }
.alert b { font-weight: 650; }

/* ---------- Boutons / formulaires ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--card); padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--bg); border-color: #cfd7e2; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: #a63024; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--grey-soft); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: #334457; }
.field .help { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input { border: 1px solid #cfd7e2; border-radius: 8px; padding: 8px 11px; background: #fff; width: 100%; min-height: 38px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 79, 145, .15); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-error { color: var(--bad); font-size: 13px; margin: -4px 0 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.filters .field { margin: 0; min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 200px; }
.filters .input { min-height: 36px; padding: 6px 10px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:hover td { background: #fafcff; }
.table tr.clickable { cursor: pointer; }
.table tr.detail-row td { background: #f8fafc; padding: 0; }
.table tr.detail-row:hover td { background: #f8fafc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .muted, .muted { color: var(--muted); }
.table .nowrap { white-space: nowrap; }
.table .actions-cell { text-align: right; white-space: nowrap; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--muted); }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; opacity: .45; display: block; margin: 0 auto 8px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; color: var(--muted); font-size: 13px; gap: 10px; flex-wrap: wrap; }
.pager .btns { display: flex; gap: 6px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.detail-box { padding: 14px 18px 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 22px; }
.detail-box div span { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.detail-box div b { font-weight: 550; word-break: break-word; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap; background: var(--grey-soft); color: #44546a; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.gold { background: #fdf3dc; color: #8a5d00; }
.badge.violet { background: #f0ebfb; color: #5b3fa3; }

/* ---------- Graphique ---------- */
.chart { width: 100%; height: 230px; display: block; }
.chart .grid-line { stroke: var(--line-2); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar-a { fill: var(--accent); }
.chart .bar-b { fill: var(--gold); }
.chart .bar-value { fill: #334457; font-size: 10.5px; font-weight: 600; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Activité récente ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.feed li:last-child { border-bottom: 0; }
.feed .ico { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.feed .ico svg { width: 16px; height: 16px; }
.feed .ico.export { background: #fdf3dc; color: #8a5d00; }
.feed .ico.correct { background: #f0ebfb; color: #5b3fa3; }
.feed .ico.system { background: var(--grey-soft); color: #5b6b7c; }
.feed .txt { flex: 1; min-width: 0; }
.feed .txt b { font-weight: 600; }
.feed .txt .meta { font-size: 12px; color: var(--muted); }
.feed time { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- Fenêtres ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 27, 45, .5); display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 16px 16px; z-index: 100; overflow-y: auto; animation: fade .12s ease-out; }
.modal { background: var(--card); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 30px 70px rgba(0, 0, 0, .3); animation: pop .14s ease-out; }
.modal.wide { max-width: 720px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px 6px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; }
.close-x { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.close-x:hover { background: var(--grey-soft); }
.secret-box { display: flex; gap: 8px; align-items: center; background: #0f1b2d; color: #fff; border-radius: 8px; padding: 12px 14px; margin: 6px 0 14px; }
.secret-box code { flex: 1; font-family: var(--mono); font-size: 18px; letter-spacing: 1px; word-break: break-all; }
.secret-box .btn { background: #22385a; border-color: #22385a; color: #fff; }
.scope-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Notifications ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 380px;
  font-size: 13.5px; animation: pop .15s ease-out; border-left: 4px solid var(--ok); }
.toast.error { border-left-color: #e66b5b; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: -4px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Écrans étroits ---------- */
@media (max-width: 1100px) {
  .grid.two, .grid.half { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 60; transform: translateX(-100%); transition: transform .18s; }
  .layout.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .topbar { padding: 0 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 18px 16px 32px; }
  .user-chip .who { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .scope-row { grid-template-columns: 1fr; }
}

/* Les éléments de grille ne doivent jamais élargir la page (tableaux, graphiques). */
.grid > *, .main, .content { min-width: 0; }
.page-head .actions .input { width: auto; }
@media (max-width: 600px) {
  .page-head .actions { width: 100%; }
  .page-head .actions > * { flex: 1 1 auto; }
  .user-chip { padding: 3px; }
}
