:root {
  /* FNE / Côte d'Ivoire flag palette: orange, white, green */
  --ci-green-900: #00472B;
  --ci-green-800: #00613A;
  --ci-green: #009E60;
  --accent: #F77F00;
  --accent-600: #de7200;
  --accent-50: #fff4e6;
  --accent-100: #ffe3c2;
  --slate-950: #0b1220;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --green: #009E60;
  --green-50: #ecfdf3;
  --red: #dc2626;
  --red-50: #fef2f2;
  --amber: #b45309;
  --amber-50: #fffbeb;
  --blue: #2563eb;
  --blue-50: #eff6ff;
  --violet: #7c3aed;
  --violet-50: #f5f3ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .18);
  --sidebar-w: 240px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--slate-800);
  background: var(--slate-50);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--slate-50); }
a { color: var(--accent-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--slate-500); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- Boot / spinner ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--slate-200); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mock banner ---------- */
.mock-banner {
  background: repeating-linear-gradient(135deg, #fff1db, #fff1db 12px, #ffe7c4 12px, #ffe7c4 24px);
  color: #7a3e00; border-bottom: 1px solid #f5c98e; text-align: center; font-weight: 600; font-size: 12.5px;
  padding: 6px 12px; letter-spacing: .02em;
  position: sticky; top: 0; z-index: 70; height: 30px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.has-mock .topbar { top: 30px; }
.has-mock .sidebar { top: 30px; height: calc(100vh - 30px); }
.has-mock .auth-wrap { min-height: calc(100vh - 30px); }

/* ---------- Auth screens ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background: radial-gradient(1200px 500px at -10% -10%, rgba(247,127,0,.35), transparent 60%), linear-gradient(160deg, var(--ci-green-900), var(--ci-green-800));
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-hero h1 { font-size: 30px; line-height: 1.2; margin: 0 0 12px; font-weight: 700; letter-spacing: -.01em; }
.auth-hero p { color: var(--slate-300); max-width: 460px; margin: 0; }
.auth-hero .facts { display: grid; gap: 14px; margin-top: 36px; }
.auth-hero .fact { display: flex; gap: 12px; align-items: flex-start; color: var(--slate-200); }
.auth-hero .fact .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex: none; }
.auth-panel { display: grid; place-items: center; padding: 32px; background: #fff; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { margin: 0 0 4px; font-size: 22px; }
.auth-card .sub { margin: 0 0 24px; color: var(--slate-500); }
.auth-lang { position: absolute; top: 18px; right: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand .logo { width: 38px; height: 38px; border-radius: 10px; background: #fff; display: grid; place-items: center; padding: 3px; flex: none; }
.brand .logo img { width: 100%; height: 100%; object-fit: contain; }
.brand small { display: block; font-weight: 500; color: var(--slate-400); font-size: 11.5px; letter-spacing: .02em; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--ci-green-900); color: #d7efe3; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { color: #fff; padding: 20px 18px 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.nav { padding: 12px 10px; display: grid; gap: 2px; overflow-y: auto; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--slate-500); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--slate-300); font-weight: 500; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a.active { background: rgba(247,127,0,.14); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 11.5px; color: var(--slate-500); border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-foot .env { display: inline-flex; align-items: center; gap: 6px; }
.sidebar-foot .env i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
.sidebar-foot .env i.off { background: var(--red); }
.sidebar-foot .env i.mock { background: var(--accent); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--slate-200); display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.topbar .title { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-100); color: var(--accent-600); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-chip .who { line-height: 1.2; }
.user-chip .who b { display: block; font-weight: 600; font-size: 13px; }
.user-chip .who span { font-size: 11.5px; color: var(--slate-500); }
.content { padding: 24px; 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 h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.page-head p { margin: 2px 0 0; color: var(--slate-500); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--slate-200); background: #fff; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--slate-50); border-color: var(--slate-300); }
.btn:focus-visible, .input:focus, .select:focus { outline: none; box-shadow: 0 0 0 3px rgba(247,127,0,.25); border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-600); border-color: var(--accent-600); }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--slate-100); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; height: 42px; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 500; font-size: 13px; color: var(--slate-700); }
.field .hint { font-size: 12px; color: var(--slate-500); }
.input, .select { height: 38px; padding: 0 12px; border: 1px solid var(--slate-300); border-radius: 8px; background: #fff; width: 100%; }
.select { padding-right: 28px; }
.input.sm, .select.sm { height: 34px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.error-box { background: var(--red-50); color: var(--red); border: 1px solid #fecaca; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.info-box { background: var(--accent-50); color: #7a3e00; border: 1px solid var(--accent-100); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--slate-200); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 0 10px; height: 30px; cursor: pointer; font-weight: 600; font-size: 12px; color: var(--slate-500); }
.seg button.on { background: var(--ci-green-800); color: #fff; }

/* ---------- Cards ---------- */
.card { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--slate-100); }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-body { padding: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px; position: relative; overflow: hidden; }
.stat .label { color: var(--slate-500); font-size: 12.5px; font-weight: 500; display: flex; gap: 8px; align-items: center; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.stat .foot { color: var(--slate-500); font-size: 12px; margin-top: 2px; }
.stat .ico { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-50); color: var(--accent-600); }
.stat .ico svg { width: 18px; height: 18px; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 18px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 8px 4px 0; }
.chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart .bar i { display: block; width: 100%; max-width: 28px; background: linear-gradient(180deg, var(--accent), #ffa94d); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.chart .bar span { font-size: 10.5px; color: var(--slate-400); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--slate-500); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--slate-200); }
.list-plain li:last-child { border-bottom: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; color: var(--slate-500); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; background: var(--slate-50); border-bottom: 1px solid var(--slate-200); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--slate-100); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover { background: var(--accent-50); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { text-align: center; padding: 40px 16px; color: var(--slate-500); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--slate-100); align-items: center; }
.filters .input, .filters .select { width: auto; min-width: 140px; height: 34px; }
.filters .grow { flex: 1; min-width: 200px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--slate-100); color: var(--slate-500); font-size: 13px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--slate-100); color: var(--slate-600); }
.badge.green { background: var(--green-50); color: var(--green); }
.badge.red { background: var(--red-50); color: var(--red); }
.badge.amber { background: var(--amber-50); color: var(--amber); }
.badge.blue { background: var(--blue-50); color: var(--blue); }
.badge.violet { background: var(--violet-50); color: var(--violet); }
.badge.orange { background: var(--accent-50); color: var(--accent-600); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--slate-300); }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,.12); vertical-align: middle; }
.battery { display: inline-flex; align-items: center; gap: 6px; }
.battery i { width: 26px; height: 11px; border: 1.5px solid var(--slate-400); border-radius: 3px; position: relative; display: inline-block; }
.battery i b { position: absolute; left: 1px; top: 1px; bottom: 1px; border-radius: 1px; background: var(--green); }
.battery i b.low { background: var(--red); }
.battery i b.mid { background: var(--amber); }

/* ---------- Drawer & modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: #fff; z-index: 51; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--slate-200); display: flex; align-items: center; gap: 12px; }
.drawer-head h3 { margin: 0; font-size: 16px; flex: 1; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-body section { margin-bottom: 22px; }
.drawer-body h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-500); }
.modal { position: fixed; z-index: 51; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto; background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop .15s ease-out; }
@keyframes pop { from { transform: translate(-50%, -48%); opacity: 0; } }
.modal-head { padding: 18px 20px 6px; display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 12px 20px 4px; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.x-btn { width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; color: var(--slate-500); font-size: 20px; line-height: 1; }
.x-btn:hover { background: var(--slate-100); }
.totals-box { background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: 8px; padding: 12px 14px; }
.totals-box .row { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; }
.totals-box .row.big { font-weight: 700; font-size: 15px; border-top: 1px solid var(--slate-200); margin-top: 6px; padding-top: 8px; }
.preview { border: 1px solid var(--slate-200); border-radius: 10px; padding: 14px; background: var(--slate-50); margin-bottom: 14px; }
pre.json { background: var(--slate-900); color: #e2e8f0; padding: 12px; border-radius: 8px; overflow: auto; max-height: 320px; font-size: 12px; margin: 6px 0 0; white-space: pre-wrap; word-break: break-all; }
.ticket-ref { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--slate-100); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--slate-900); color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 380px; animation: pop2 .18s ease-out; }
.toast.error { background: var(--red); }
.toast.ok { background: #15803d; }
@keyframes pop2 { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .user-chip .who { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
}

/* Overflow guards for narrow screens */
.card-head { flex-wrap: wrap; }
.two-col > *, .stats > * { min-width: 0; }
.actions .input, .actions .select { width: auto; max-width: 100%; }
@media (max-width: 520px) {
  .page-head .actions, .page-head .actions .select { width: 100%; min-width: 0 !important; }
  .filters .input, .filters .select { min-width: 0; flex: 1 1 140px; }
}
.topbar .menu-btn { display: none; }
.stat .label { padding-right: 40px; }
@media (max-width: 900px) {
  .topbar .menu-btn { display: inline-flex; }
}
.has-mock .drawer { top: 30px; }

/* ---------- v2: staff management & audit trail ---------- */
.modal.wide { width: min(720px, calc(100vw - 24px)); }
.warn-box { background: var(--amber-50); color: var(--amber); border: 1px solid #fde68a; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.ok-box { background: var(--green-50); color: #166534; border: 1px solid #bbf7d0; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.perm-box { border: 1px solid var(--slate-200); border-radius: 10px; padding: 12px 14px; background: var(--slate-50); margin-bottom: 14px; }
.perm-group + .perm-group { margin-top: 10px; }
.perm-group h5 { margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ci-green-800); }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.perm-grid .check { font-size: 13px; align-items: flex-start; }
.perm-grid .check input { margin-top: 3px; accent-color: var(--ci-green-800); }
.perm-grid .check.added { color: var(--ci-green-800); font-weight: 600; }
.perm-grid .check.removed { color: var(--red); text-decoration: line-through; }
.perm-grid .check.locked { color: var(--slate-400); cursor: not-allowed; }
.perm-diff { font-size: 12px; color: var(--slate-600); margin-top: 8px; }
.diff-table td.before { color: var(--red); background: var(--red-50); }
.diff-table td.after { color: #166534; background: var(--green-50); }
.diff-table td { word-break: break-word; }
.who-cell b { display: block; font-weight: 600; }
.who-cell .badge { margin-top: 2px; }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { padding: 10px 0; border-bottom: 1px solid var(--slate-100); }
.activity-list li:last-child { border-bottom: 0; }
.activity-list .meta { font-size: 12px; color: var(--slate-500); }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { flex: 1; font-size: 16px; letter-spacing: .04em; }
@media (max-width: 600px) { .perm-grid { grid-template-columns: 1fr; } }
.badge svg, .activity-list svg { width: 13px; height: 13px; flex: none; }
.modal-foot { flex-wrap: wrap; }
.ok-box svg, .warn-box svg, .error-box svg, .info-box svg { width: 16px; height: 16px; vertical-align: -3px; }
