/* ==========================================================================
   Adelphi Africa — design system
   Tokens → base → layout → components → utilities. Light/dark via [data-theme].
   ========================================================================== */
:root {
  --font-sans: "Inter", "SF Pro Text", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #e4e9f0;
  --border-strong: #cfd7e2;
  --text: #0f1b2d;
  --text-2: #4b5a6e;
  --text-3: #7d8a9c;
  --text-inverse: #ffffff;

  --primary: #0b3a5c;
  --primary-600: #10507d;
  --primary-500: #1b6aa5;
  --primary-100: #e3eef8;
  --primary-50: #f1f6fb;
  --accent: #0e9f6e;
  --accent-100: #def7ec;
  --warning: #c27803;
  --warning-100: #fdf6b2;
  --danger: #c81e1e;
  --danger-100: #fde8e8;
  --info: #1c64f2;
  --info-100: #e1effe;
  --muted: #64748b;
  --muted-100: #eef1f5;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 1px rgba(15, 27, 45, .04);
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .06), 0 1px 3px rgba(15, 27, 45, .04);
  --shadow: 0 2px 6px -1px rgba(15, 27, 45, .08), 0 8px 24px -8px rgba(15, 27, 45, .10);
  --shadow-lg: 0 20px 50px -20px rgba(15, 27, 45, .25);
  --ring: 0 0 0 3px rgba(27, 106, 165, .22);

  --sidebar-w: 264px;
  --topbar-h: 64px;
  --content-max: 1360px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}
[data-theme="dark"] {
  --bg: #0a111c;
  --surface: #111a29;
  --surface-2: #16213300;
  --surface-2: #162133;
  --surface-3: #1b283d;
  --border: #223047;
  --border-strong: #32425d;
  --text: #e8eef7;
  --text-2: #a9b6c9;
  --text-3: #74839a;
  --primary: #4f9ad6;
  --primary-600: #3b86c4;
  --primary-500: #5aa5e0;
  --primary-100: #16304a;
  --primary-50: #122538;
  --accent: #34d399;
  --accent-100: #0f3b2e;
  --warning: #fbbf24;
  --warning-100: #3d2e0a;
  --danger: #f87171;
  --danger-100: #3f1515;
  --info: #60a5fa;
  --info-100: #142847;
  --muted: #94a3b8;
  --muted-100: #1b283d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 4px 16px -4px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, .7);
  --ring: 0 0 0 3px rgba(79, 154, 214, .3);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-sans); color: var(--text); background: var(--bg);
  line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--primary-500); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; } h4 { font-size: .9rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--font-mono); font-size: .86em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
small, .text-sm { font-size: .86rem; }
.text-xs { font-size: .78rem; }
.text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); }
.text-danger { color: var(--danger); } .text-success { color: var(--accent); } .text-warning { color: var(--warning); }
.fw-600 { font-weight: 600; } .fw-500 { font-weight: 500; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 15px; height: 15px; } .icon-lg { width: 24px; height: 24px; } .icon-xl { width: 36px; height: 36px; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 0 .75rem 1rem;
  transition: transform .25s var(--ease);
}
.brand { display: flex; align-items: center; gap: .65rem; height: var(--topbar-h); padding: 0 .5rem; border-bottom: 1px solid var(--border); margin-bottom: .75rem; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 auto; display: block; }
.brand-mark .bm-tile { fill: var(--primary); }
.brand-mark .bm-a1 { fill: none; stroke: #ffffff; stroke-width: 6.5; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark .bm-a2 { fill: none; stroke: var(--accent); stroke-width: 6.5; stroke-linecap: round; stroke-linejoin: round; }
.brand-name-light { font-weight: 500; color: var(--text-2); }
[data-theme="dark"] .brand-mark .bm-tile { fill: #ffffff; }
[data-theme="dark"] .brand-mark .bm-a1 { stroke: #0b3a5c; }
.brand-name { font-weight: 700; font-size: 1rem; line-height: 1.1; }
.brand-sub { font-size: .7rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; }
.nav-group { margin: .25rem 0 .75rem; }
.nav-label { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3); padding: .5rem .75rem .35rem; }
.nav-item {
  display: flex; align-items: center; gap: .65rem; padding: .5rem .75rem; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: .92rem; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-50); color: var(--primary); }
[data-theme="dark"] .nav-item.active { background: var(--primary-100); color: #fff; }
.nav-item .icon { color: inherit; opacity: .85; }
.nav-item .nav-count { margin-left: auto; font-size: .72rem; background: var(--surface-3); color: var(--text-2); padding: .1rem .45rem; border-radius: 999px; font-weight: 600; }
.nav-sub { padding-left: 2.3rem; display: flex; flex-direction: column; gap: .1rem; margin: .1rem 0 .35rem; }
.nav-sub a { font-size: .86rem; color: var(--text-2); padding: .3rem .5rem; border-radius: var(--radius-xs); }
.nav-sub a:hover, .nav-sub a.active { background: var(--surface-3); color: var(--text); text-decoration: none; }
.sidebar-footer { margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: .6rem; padding: .5rem .5rem; border-radius: var(--radius-sm); }
.user-card:hover { background: var(--surface-3); text-decoration: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-100); color: var(--primary); display: grid; place-items: center; font-weight: 600; font-size: .8rem; flex: none; }
[data-theme="dark"] .avatar { color: #cfe3f5; }
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem;
}
.topbar-title { font-weight: 600; font-size: 1.02rem; }
.topbar-spacer { flex: 1; }
.env-pill { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: .2rem .5rem; border-radius: 999px; background: var(--warning-100); color: var(--warning); }
.env-pill.production { background: var(--accent-100); color: var(--accent); }
.content { padding: 1.5rem; max-width: var(--content-max); width: 100%; margin: 0 auto; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-header p { color: var(--text-2); margin: .25rem 0 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.breadcrumb { display: flex; gap: .4rem; font-size: .82rem; color: var(--text-3); margin-bottom: .35rem; }
.breadcrumb a { color: var(--text-3); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.sidebar-toggle { display: none; }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(5, 10, 20, .45); z-index: 29; }

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { font-size: .98rem; }
.card-body { padding: 1.25rem; }
.card-body.flush { padding: 0; }
.card-footer { padding: .85rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-0 { margin-bottom: 0; }

/* ---------- KPI tiles ---------- */
.kpi { padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .35rem; position: relative; overflow: hidden; }
.kpi-label { font-size: .8rem; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: .4rem; }
.kpi-value { font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-value.unavailable { font-size: 1rem; font-weight: 500; color: var(--text-3); }
.kpi-meta { font-size: .78rem; color: var(--text-3); }
.kpi-icon { position: absolute; right: 1rem; top: 1rem; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
[data-theme="dark"] .kpi-icon { background: var(--primary-100); color: #cfe3f5; }
.kpi-icon.accent { background: var(--accent-100); color: var(--accent); }
.kpi-icon.warning { background: var(--warning-100); color: var(--warning); }
.kpi-icon.danger { background: var(--danger-100); color: var(--danger); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .4rem; font-size: .74rem; font-weight: 600; padding: .22rem .55rem .22rem .45rem; border-radius: 999px; white-space: nowrap; line-height: 1.2; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--accent-100); color: var(--accent); }
.badge-warning { background: var(--warning-100); color: var(--warning); }
.badge-danger { background: var(--danger-100); color: var(--danger); }
.badge-info { background: var(--info-100); color: var(--info); }
.badge-muted { background: var(--muted-100); color: var(--muted); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-primary { background: var(--primary-100); color: var(--primary); }
.chip { display: inline-flex; align-items: center; font-size: .76rem; padding: .18rem .5rem; border-radius: var(--radius-xs); background: var(--surface-3); color: var(--text-2); font-weight: 500; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .52rem .95rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; font-size: .9rem;
  cursor: pointer; transition: background .15s, border-color .15s, transform .05s, box-shadow .15s; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
[data-theme="dark"] .btn-primary { background: var(--primary-600); color: #fff; }
.btn-success { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-outline-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; }
.btn-outline-danger:hover { background: var(--danger-100); }
.btn-sm { padding: .35rem .65rem; font-size: .82rem; }
.btn-lg { padding: .7rem 1.25rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn .spinner { display: none; }
.btn.is-loading { pointer-events: none; opacity: .8; }
.btn.is-loading .spinner { display: inline-block; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.form-grid { display: grid; gap: 1rem 1.25rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label, .label { font-size: .85rem; font-weight: 500; color: var(--text); }
.field .hint { font-size: .78rem; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font: inherit; font-size: .92rem; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary-500); box-shadow: var(--ring); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d8a9c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right .6rem center; padding-right: 2.2rem; }
.field-error { color: var(--danger); font-size: .8rem; margin: 0; }
.check { display: flex; align-items: flex-start; gap: .55rem; font-size: .9rem; cursor: pointer; }
.check input { margin-top: .2rem; accent-color: var(--primary-500); width: 16px; height: 16px; }
.input-group { display: flex; } .input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); } .input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; align-items: center; margin-top: 1.25rem; }
.search { position: relative; } .search .icon { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--text-3); } .search .input { padding-left: 2.2rem; }
.password-meter { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-top: .3rem; }
.password-meter span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .25s, background .25s; }
.file-drop { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 1.25rem; text-align: center; color: var(--text-2); background: var(--surface-2); }
.file-drop input { display: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; padding: .7rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table a.row-link { color: var(--text); font-weight: 500; }
.cell-primary { font-weight: 500; color: var(--text); } .cell-sub { font-size: .78rem; color: var(--text-3); }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.25rem; border-top: 1px solid var(--border); font-size: .84rem; color: var(--text-2); }
.pagination { display: flex; gap: .25rem; }
.pagination a, .pagination span { padding: .3rem .6rem; border-radius: var(--radius-xs); border: 1px solid var(--border); color: var(--text-2); font-size: .82rem; }
.pagination a:hover { background: var(--surface-3); text-decoration: none; }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.filters { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .85rem 1.25rem; border-bottom: 1px solid var(--border); }
.filters .input, .filters .select { width: auto; min-width: 160px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; color: var(--text-2); font-weight: 500; font-size: .9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { margin-left: .35rem; font-size: .72rem; background: var(--surface-3); padding: .05rem .4rem; border-radius: 999px; color: var(--text-2); }
.subnav { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.subnav a { padding: .4rem .8rem; border-radius: 999px; font-size: .85rem; font-weight: 500; color: var(--text-2); border: 1px solid var(--border); background: var(--surface); }
.subnav a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.subnav a:hover { text-decoration: none; border-color: var(--border-strong); }

/* ---------- alerts / toasts ---------- */
.alert { display: flex; gap: .65rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid; font-size: .9rem; margin-bottom: 1rem; }
.alert .icon { margin-top: .1rem; }
.alert-success { background: var(--accent-100); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--accent); }
.alert-warning { background: var(--warning-100); border-color: color-mix(in srgb, var(--warning) 35%, transparent); color: var(--warning); }
.alert-danger { background: var(--danger-100); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.alert-info { background: var(--info-100); border-color: color-mix(in srgb, var(--info) 35%, transparent); color: var(--info); }
.alert strong { color: inherit; }
.toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 60; display: flex; flex-direction: column; gap: .5rem; max-width: 380px; }
.toast { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: .9rem; animation: toast-in .25s var(--ease); }
.toast.hide { opacity: 0; transform: translateY(6px); transition: all .25s; }
.toast .icon { margin-top: .1rem; }
.toast-success .icon { color: var(--accent); } .toast-warning .icon { color: var(--warning); } .toast-danger .icon { color: var(--danger); } .toast-info .icon { color: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- empty / unavailable states ---------- */
.empty { text-align: center; padding: 2.5rem 1.5rem; color: var(--text-2); }
.empty .icon-wrap { width: 52px; height: 52px; border-radius: 14px; background: var(--surface-3); color: var(--text-3); display: grid; place-items: center; margin: 0 auto .85rem; }
.empty h3 { color: var(--text); margin-bottom: .3rem; }
.empty p { max-width: 460px; margin: 0 auto .9rem; font-size: .9rem; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding-left: 2rem; padding-bottom: 1.1rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .dot { position: absolute; left: 3px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary-500); }
.timeline .dot.success { border-color: var(--accent); } .timeline .dot.danger { border-color: var(--danger); } .timeline .dot.warning { border-color: var(--warning); } .timeline .dot.muted { border-color: var(--border-strong); }
.timeline .tl-title { font-weight: 500; font-size: .9rem; }
.timeline .tl-meta { font-size: .78rem; color: var(--text-3); }
.timeline .tl-body { font-size: .86rem; color: var(--text-2); margin-top: .15rem; }

/* ---------- definition lists ---------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.25rem; font-size: .9rem; margin: 0; }
.dl dt { color: var(--text-3); font-weight: 500; } .dl dd { margin: 0; color: var(--text); word-break: break-word; }

/* ---------- dropdown / dialog ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .35rem; display: none; z-index: 30; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: .55rem; width: 100%; text-align: left; padding: .5rem .65rem; border-radius: var(--radius-xs); color: var(--text); font: inherit; font-size: .88rem; background: none; border: 0; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); text-decoration: none; }
.dropdown-menu .danger { color: var(--danger); }
dialog.modal { border: 0; border-radius: var(--radius-lg); padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(520px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgba(5, 10, 20, .5); backdrop-filter: blur(2px); }
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: .85rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- auth & public ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside { background: radial-gradient(1200px 600px at 20% 10%, rgba(27,106,165,.35), transparent 60%), linear-gradient(160deg, #06243b, #0b3a5c 60%, #0e4b74); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside h2 { font-size: 1.9rem; font-weight: 650; letter-spacing: -.02em; max-width: 440px; line-height: 1.2; }
.auth-aside p { color: rgba(255,255,255,.75); max-width: 440px; }
.auth-aside .brand { border: 0; margin: 0; padding: 0; height: auto; }
.auth-aside .brand-name, .auth-aside .brand-sub { color: #fff; }
.auth-aside .brand-mark .bm-tile { fill: #ffffff; }
.auth-aside .brand-mark .bm-a1 { stroke: #0b3a5c; }
.auth-aside .brand-name-light { color: rgba(255,255,255,.75); }
.auth-points { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .65rem; }
.auth-points li { display: flex; gap: .6rem; align-items: center; color: rgba(255,255,255,.85); font-size: .92rem; }
.auth-points .icon { color: #5fd4a8; }
.auth-main { display: grid; place-items: center; padding: 2rem; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 1.45rem; margin-bottom: .25rem; }
.auth-card .lead { color: var(--text-2); margin-bottom: 1.5rem; }
.auth-footer { font-size: .82rem; color: var(--text-3); margin-top: 1.5rem; text-align: center; }
.public-nav { display: flex; align-items: center; justify-content: space-between; padding: 1rem 2rem; max-width: 1200px; margin: 0 auto; }
.public-nav .brand { border: 0; margin: 0; height: auto; padding: 0; }
.hero { max-width: 1200px; margin: 0 auto; padding: 4rem 2rem 3rem; display: grid; grid-template-columns: 1.1fr 1fr; gap: 3rem; align-items: center; }
.hero h1 { font-size: 2.6rem; letter-spacing: -.03em; line-height: 1.1; margin-bottom: 1rem; }
.hero .lead { font-size: 1.1rem; color: var(--text-2); max-width: 540px; }
.flow { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow); font-family: var(--font-mono); font-size: .85rem; }
.flow .node { padding: .6rem .85rem; border-radius: var(--radius-sm); background: var(--surface-3); margin: .35rem 0; display: flex; justify-content: space-between; align-items: center; }
.flow .node.hl { background: var(--primary); color: #fff; }
.flow .arrow { text-align: center; color: var(--text-3); line-height: 1; }
.features { max-width: 1200px; margin: 0 auto; padding: 1rem 2rem 4rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.feature { padding: 1.25rem; }
.feature .icon-wrap { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; margin-bottom: .75rem; }
[data-theme="dark"] .feature .icon-wrap { background: var(--primary-100); color: #cfe3f5; }
.feature h3 { margin-bottom: .3rem; } .feature p { color: var(--text-2); font-size: .9rem; margin: 0; }
.public-footer { border-top: 1px solid var(--border); padding: 1.5rem 2rem; font-size: .82rem; color: var(--text-3); text-align: center; }
.register-wrap { max-width: 860px; margin: 0 auto; padding: 2rem; }
.steps { display: flex; gap: .5rem; margin-bottom: 1.5rem; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--border); } .steps span.done { background: var(--primary-500); }

/* ---------- error page ---------- */
.error-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.error-card { text-align: center; max-width: 520px; }
.error-code { font-size: 4rem; font-weight: 700; letter-spacing: -.04em; color: var(--primary); line-height: 1; margin-bottom: .5rem; }
.error-card pre { text-align: left; background: var(--surface-2); padding: 1rem; border-radius: var(--radius-sm); overflow: auto; font-size: .78rem; max-height: 400px; }

/* ---------- misc ---------- */
.progress-steps { display: flex; gap: 0; align-items: center; overflow-x: auto; padding-bottom: .25rem; }
.progress-steps .step { display: flex; align-items: center; gap: .45rem; font-size: .8rem; color: var(--text-3); white-space: nowrap; }
.progress-steps .step .n { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; font-size: .7rem; font-weight: 600; }
.progress-steps .step.done { color: var(--text-2); } .progress-steps .step.done .n { background: var(--accent); border-color: var(--accent); color: #fff; }
.progress-steps .step.current { color: var(--primary); font-weight: 600; } .progress-steps .step.current .n { border-color: var(--primary); color: var(--primary); }
.progress-steps .sep { width: 28px; height: 2px; background: var(--border); margin: 0 .5rem; flex: none; }
.mono-key { font-family: var(--font-mono); font-size: .8rem; background: var(--surface-3); padding: .15rem .4rem; border-radius: var(--radius-xs); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: .65rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 1rem; align-items: center; font-size: .9rem; }
.list-plain li:last-child { border-bottom: 0; }
.perm-group { margin-bottom: 1rem; }
.perm-group h4 { text-transform: capitalize; margin-bottom: .4rem; color: var(--text-2); }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem .75rem; }
details.details summary { cursor: pointer; font-size: .85rem; color: var(--primary-500); font-weight: 500; }
.json { font-family: var(--font-mono); font-size: .76rem; background: var(--surface-2); padding: .6rem .75rem; border-radius: var(--radius-xs); white-space: pre-wrap; word-break: break-word; margin: .4rem 0 0; }
.status-box { padding: 1rem 1.25rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 1rem; align-items: center; }
.status-box .icon-wrap { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
  .features { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; width: var(--sidebar-w); transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .backdrop { display: block; }
  .sidebar-toggle { display: inline-grid; }
  .content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .auth-wrap { grid-template-columns: 1fr; } .auth-aside { display: none; }
  .hero { grid-template-columns: 1fr; padding-top: 2rem; } .hero h1 { font-size: 2rem; }
  .features { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: span 1; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .perm-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) { .grid-4 { grid-template-columns: 1fr; } .kpi-value { font-size: 1.35rem; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
