/* =============================================================================
   FXMetaGold gateway — panel design system (RTL, light + dark)
   A flat, bordered "console" style in the tradition of GitHub / Stripe docs:
   the platform's own UI font, neutral greys, a navy ink colour for primary
   actions and the brand gold as the single accent. Served from the same
   origin; the CSP forbids inline styles and third-party resources.
   ============================================================================= */

:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --surface-3: #eef1f4;
  --border: #d8dee4;
  --border-muted: #e6eaee;
  --border-strong: #c2cbd4;
  --text: #1f2328;
  --text-2: #3d4651;
  --muted: #59636e;

  --ink: #10233f;            /* brand navy: primary actions */
  --ink-hover: #1a3459;
  --on-ink: #ffffff;
  --gold: #b7872f;           /* brand accent: indicators, brand mark */
  --gold-text: #8a6116;      /* gold that passes contrast as text */
  --gold-soft: #fbf4e4;
  --link: #1b5aa6;
  --link-hover: #123f75;
  --select: #eef3fa;         /* selected / active backgrounds */

  --success: #1a7f37;
  --success-soft: #dafbe1;
  --success-btn: #1f883d;
  --warning: #9a6700;
  --warning-soft: #fff8c5;
  --danger: #cf222e;
  --danger-soft: #ffebe9;
  --info: #0969da;
  --info-soft: #ddf4ff;
  --orange: #bc4c00;
  --orange-soft: #fff1e5;

  --focus-color: #0969da;
  --focus: 0 0 0 3px rgba(9, 105, 218, .28);
  --radius: 6px;
  --radius-lg: 8px;
  --shadow: none;
  --shadow-lg: 0 8px 24px rgba(66, 74, 83, .16), 0 1px 3px rgba(66, 74, 83, .12);

  /* chart chrome (status series fills are mode-invariant) */
  --viz-grid: #e9ecf1;
  --viz-base: #c3c8d2;
  --viz-completed: #0ca30c;
  --viz-rejected: #898781;
  --viz-open: #fab219;
  --viz-failed: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #151b23;
    --surface-2: #10161d;
    --surface-3: #1f2630;
    --border: #30363d;
    --border-muted: #262c34;
    --border-strong: #3d444d;
    --text: #e6edf3;
    --text-2: #c3ccd5;
    --muted: #8d96a0;

    --ink: #d6a64b;
    --ink-hover: #e3b864;
    --on-ink: #1a1206;
    --gold: #d6a64b;
    --gold-text: #e3b864;
    --gold-soft: #2a2213;
    --link: #6cb6ff;
    --link-hover: #96ccff;
    --select: #1d2633;

    --success: #3fb950;
    --success-soft: #12261b;
    --success-btn: #238636;
    --warning: #d29922;
    --warning-soft: #2a2111;
    --danger: #f85149;
    --danger-soft: #2d1416;
    --info: #4493f8;
    --info-soft: #0f2238;
    --orange: #db6d28;
    --orange-soft: #2b1a10;

    --focus-color: #4493f8;
    --focus: 0 0 0 3px rgba(68, 147, 248, .35);
    --shadow-lg: 0 8px 24px rgba(1, 4, 9, .6), 0 0 0 1px #30363d;
    --viz-grid: #232c39;
    --viz-base: #3a4557;
  }
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.45; font-weight: 600; color: var(--text); }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code, .mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  direction: ltr;
  unicode-bidi: isolate;
}
code {
  background: var(--surface-3);
  border-radius: 4px;
  padding: 1px 5px;
}
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden, [hidden] { display: none !important; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.mt-sm { margin-top: 8px; }
.mb-sm { margin-bottom: 8px; }
.grow-1 { flex: 1; min-width: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--focus-color); outline-offset: 1px; border-radius: 4px; }

.icon { width: 16px; height: 16px; flex: none; vertical-align: middle; }
.icon-sm { width: 14px; height: 14px; flex: none; vertical-align: middle; }
.icon-lg { width: 24px; height: 24px; flex: none; }

/* Brand: a navy monogram with gold letters (no gradients). */
.brand-mark {
  width: 30px; height: 30px; border-radius: var(--radius); flex: none;
  display: inline-grid; place-items: center;
  background: #10233f; color: #e2b659;
  font: 700 12.5px/1 var(--font); letter-spacing: .5px; direction: ltr;
}

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  grid-column: 1; grid-row: 1;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border-muted); min-height: 57px; color: inherit; }
.brand:hover { text-decoration: none; background: var(--surface-2); }
.brand-name { font-weight: 600; font-size: 14px; line-height: 1.3; color: var(--text); }
.brand-sub { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.nav { padding: 8px 10px 20px; flex: 1; }
.nav-section {
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 14px 10px 4px;
}
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  min-height: 32px; padding: 5px 10px; margin: 1px 0;
  border-radius: var(--radius); color: var(--text-2); font-size: 14px;
}
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--select); color: var(--text); font-weight: 600; }
.nav a.active .icon { color: var(--text); }
.nav a.active::before {
  content: ""; position: absolute; inset-inline-start: -10px; top: 6px; bottom: 6px;
  width: 4px; border-radius: 4px; background: var(--gold);
}
.sidebar-foot { padding: 12px 16px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border-muted); }

.main { grid-column: 2; grid-row: 1; min-width: 0; display: flex; flex-direction: column; }
/* Mobile-menu overlay: fixed (so it never takes a grid cell) and hidden unless the menu is open. */
.backdrop { display: none; position: fixed; inset: 0; background: rgba(1, 4, 9, .45); z-index: 40; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: 57px; padding: 8px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.menu-toggle { display: none; }
.content { padding: 24px 32px 56px; max-width: 1280px; width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 2em; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  white-space: nowrap;
}
a.chip:hover { text-decoration: none; background: var(--surface-3); color: var(--text); }
.chip-success { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.chip-warning { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.chip-info { color: var(--info); border-color: color-mix(in srgb, var(--info) 40%, transparent); }

/* user menu (details/summary — no JS needed) */
.user-menu { position: relative; }
.user-menu > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px 0 4px; border-radius: 2em;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.user-menu > summary:hover { background: var(--surface-3); }
.user-menu > summary::-webkit-details-marker { display: none; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 11.5px;
  background: var(--gold-soft); color: var(--gold-text); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
}
.user-menu-panel {
  position: absolute; left: 0; top: calc(100% + 6px); min-width: 230px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 30;
}
.user-menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border-muted); margin-bottom: 6px; }
.user-menu-panel a, .user-menu-panel button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 10px; border-radius: var(--radius); color: var(--text);
  font: inherit; background: none; border: 0; cursor: pointer; text-align: right;
}
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--surface-3); text-decoration: none; }

/* ---------------------------------------------------------------- page head */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border-muted); flex-wrap: wrap;
}
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 820px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }
.breadcrumb a { color: var(--link); }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; min-height: 48px;
}
.card-head h2 { font-size: 14px; }
.card-body { padding: 16px; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.card-danger .card-head { background: var(--danger-soft); }
.card-warning { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); background: var(--warning-soft); }

.grid { display: grid; gap: 16px; }
.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)); }
.span-2 { grid-column: span 2; }
.stack > * + * { margin-top: 16px; }

/* KPI tiles: a label, one number, one line of context. */
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi-label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 24px; font-weight: 600; line-height: 1.35; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.kpi-link { color: inherit; display: block; }
.kpi-link:hover { text-decoration: none; }
.kpi-link:hover .card { border-color: var(--border-strong); background: var(--surface-2); }
.kpi-alert { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.kpi-alert .kpi-value { color: var(--danger); }
.kpi-warn .kpi-value { color: var(--warning); }

/* definition list */
.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 10px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv-tight { grid-template-columns: minmax(100px, 150px) 1fr; gap: 6px 14px; margin-top: 10px; }
.kv-tight code { font-size: 13.5px; }

.meta-bar {
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); font-size: 13px; color: var(--text-2);
}
.meta-bar span { display: inline-flex; align-items: center; gap: 6px; }
.meta-bar .icon-sm { color: var(--muted); }

/* ---------------------------------------------------------------- flash messages */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid transparent; margin-bottom: 16px; font-size: 14px;
}
.alert .icon { margin-top: 3px; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.alert-text { flex: 1; color: var(--text); }
.alert-close { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; opacity: .7; }
.alert-close:hover { opacity: 1; }

/* ---------------------------------------------------------------- labels (badges) */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 22px; padding: 0 8px; border-radius: 2em;
  font-size: 12px; font-weight: 500; line-height: 20px; white-space: nowrap;
  border: 1px solid var(--border-strong); color: var(--text-2); background: transparent;
}
.badge-pending { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.badge-info { color: var(--info); border-color: color-mix(in srgb, var(--info) 40%, transparent); }
.badge-success { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, transparent); }
.badge-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.badge-warn { color: var(--orange); border-color: color-mix(in srgb, var(--orange) 45%, transparent); }
.badge-muted { color: var(--muted); border-color: var(--border); }
.badge-wallet { color: var(--gold-text); border-color: color-mix(in srgb, var(--gold) 50%, transparent); background: var(--gold-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-success { background: var(--success); }
.dot-danger { background: var(--danger); }
.dot-muted { background: var(--muted); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 12px; border-radius: var(--radius);
  font: inherit; font-weight: 500; font-size: 14px; line-height: 1.4;
  border: 1px solid var(--border); cursor: pointer; white-space: nowrap;
  background: var(--surface-2); color: var(--text); text-decoration: none;
}
.btn:hover { text-decoration: none; background: var(--surface-3); color: var(--text); }
.btn:disabled, .btn.is-busy { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); color: var(--on-ink); }
.btn-success { background: var(--success-btn); border-color: rgba(31, 35, 40, .15); color: #fff; }
.btn-success:hover { background: #1a7f37; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); background: var(--danger); color: #fff; }
.btn-outline { background: var(--surface); }
.btn-outline:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger-outline { color: var(--danger); background: var(--surface-2); }
.btn-danger-outline:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: 13px; }
.btn-lg { min-height: 40px; padding: 0 18px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { min-height: 32px; padding: 0 7px; }
.inline-form { display: inline; margin: 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row .input { flex: 1; min-width: 0; }
.small-kpi { font-size: 18px; }

/* ---------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-weight: 600; font-size: 13.5px; color: var(--text); }
.label .req { color: var(--danger); }
.help { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.input, .select, .textarea {
  width: 100%; font: inherit; font-size: 14px;
  min-height: 34px; padding: 5px 12px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.select { padding-inline-end: 8px; }
.textarea { min-height: 90px; resize: vertical; line-height: 1.7; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus-color); box-shadow: var(--focus); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12.5px; }
.input-ltr { direction: ltr; text-align: left; }
.input-code {
  direction: ltr; text-align: center; font-size: 26px; letter-spacing: 10px; font-weight: 600;
  padding: 10px; font-family: var(--font-mono);
}
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 5px; width: 16px; height: 16px; flex: none; accent-color: var(--ink); }
.check-title { font-weight: 600; }
.check-help { display: block; }
.check code { font-size: 11.5px; }
.check-title + code { display: block; width: fit-content; max-width: 100%; margin: 3px 0 1px; overflow-wrap: anywhere; direction: ltr; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; align-items: center; flex-wrap: wrap; }

.cap-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.cap-group { margin: 0; padding: 10px 14px 12px; border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.cap-group legend { font-weight: 600; font-size: 13px; color: var(--muted); padding: 0 6px; }
.cap-group .check + .check { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-muted); }

/* "generate / set manually" password chooser — pure CSS (radio + sibling selectors) */
.pw-choice { display: grid; gap: 10px; }
.pw-radio { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.pw-option {
  position: relative; display: flex; flex-direction: column; gap: 2px; cursor: pointer;
  padding: 10px 42px 10px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.pw-option::before {
  content: ""; position: absolute; right: 14px; top: 14px; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-strong); background: var(--surface); box-sizing: border-box;
}
.pw-radio:checked + .pw-option { border-color: var(--ink); background: var(--select); }
.pw-radio:checked + .pw-option::before { border-color: var(--ink); background: var(--ink); box-shadow: inset 0 0 0 3px var(--surface); }
.pw-radio:focus-visible + .pw-option { box-shadow: var(--focus); }
.pw-fields { display: none; margin-top: 4px; }
.pw-radio-manual:checked ~ .pw-fields { display: grid; }

/* ---------------------------------------------------------------- filters & tabs */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 16px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
}
.filters .field { min-width: 150px; }
.filters .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.filters .grow { flex: 1; min-width: 200px; }
.status-tabs {
  display: flex; gap: 2px; margin-bottom: 16px; border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: thin;
}
.status-tabs a {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 8px 12px; margin-bottom: -1px; font-size: 14px;
  color: var(--text-2); border-bottom: 2px solid transparent;
}
.status-tabs a:hover { text-decoration: none; color: var(--text); border-bottom-color: var(--border-strong); }
.status-tabs a.active { color: var(--text); font-weight: 600; border-bottom-color: var(--gold); }
.status-tabs .count {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 2em; text-align: center;
  font-size: 12px; font-weight: 600; line-height: 18px; background: var(--surface-3); color: var(--text-2);
}
.status-tabs a.tab-alert .count { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: right; font-weight: 600; font-size: 12.5px; color: var(--muted);
  padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border-muted); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table-compact td, .table-compact th { padding: 6px 12px; }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-link { color: var(--text); font-weight: 600; }
.row-link:hover { color: var(--link); }
.cell-sub { display: block; font-size: 12.5px; color: var(--muted); }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.empty .icon-lg { color: var(--border-strong); margin-bottom: 8px; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; }
.pagination a, .pagination span.cur {
  min-width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0 8px;
  border-radius: var(--radius); border: 1px solid transparent; color: var(--text-2); font-size: 13px;
}
.pagination a:hover { text-decoration: none; border-color: var(--border); background: var(--surface-3); color: var(--text); }
.pagination span.cur { background: var(--ink); border-color: var(--ink); color: var(--on-ink); font-weight: 600; }

/* ---------------------------------------------------------------- secrets / copy */
.secret-box {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px dashed var(--border-strong);
}
.secret-box code { background: none; border: 0; padding: 0; font-size: 14px; flex: 1; overflow-wrap: anywhere; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.codes li {
  font-family: var(--font-mono); font-size: 15px; letter-spacing: 1px;
  padding: 8px 10px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); text-align: center; direction: ltr;
}

/* ---------------------------------------------------------------- auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card.wide { max-width: 560px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 20px; }
.auth-brand .brand-mark { width: 36px; height: 36px; font-size: 14px; }
.auth-brand .brand-name { color: var(--text); font-size: 17px; }
.auth-card .card-body { padding: 24px; }
.auth-title { font-size: 18px; margin-bottom: 4px; }
.auth-icon {
  width: 40px; height: 40px; border-radius: var(--radius); display: grid; place-items: center; margin-bottom: 12px;
  background: var(--surface-3); color: var(--text-2);
}
.auth-sub { color: var(--muted); margin-bottom: 18px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.steps { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }
.steps span { width: 28px; height: 4px; border-radius: 4px; background: var(--border); }
.steps span.on { background: var(--gold); }
.qr-wrap { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: var(--radius); border: 1px solid var(--border); margin: 0 auto 14px; width: 220px; }
.qr { width: 190px; height: 190px; display: block; }
.enroll-steps { margin: 0 0 16px; padding-right: 18px; color: var(--text-2); }
.enroll-steps li { margin-bottom: 6px; }

/* ---------------------------------------------------------------- callouts */
.callout {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2);
}
.callout > .icon { margin-top: 3px; color: var(--muted); }
.callout-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.callout-warning > .icon { color: var(--warning); }
.callout-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.callout-danger > .icon { color: var(--danger); }
.callout-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.callout-success > .icon { color: var(--success); }
.callout-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.callout-info > .icon { color: var(--info); }
.plain-list { margin: 0; padding-inline-start: 20px; line-height: 2; }
.plain-list li + li { margin-top: 4px; }
.callout h3 { margin-bottom: 4px; }
.callout p:last-child { margin-bottom: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-muted); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; min-width: 120px; font-variant-numeric: tabular-nums; }
.timeline .what { flex: 1; min-width: 0; }
.meta-json {
  margin-top: 4px; font-size: 12px; color: var(--muted); direction: ltr; text-align: left;
  font-family: var(--font-mono); overflow-wrap: anywhere; white-space: pre-wrap;
}

.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-muted); align-items: flex-start; }
.check-list li:last-child { border-bottom: 0; }
.check-list .state { flex: none; margin-top: 3px; }
.check-list .body { flex: 1; min-width: 0; }
.check-list .title { font-weight: 600; }
.check-list .detail { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.state-pass { color: var(--success); }
.state-warn { color: var(--warning); }
.state-fail { color: var(--danger); }
.state-info { color: var(--info); }

.perm-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.perm-group-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.perm-group .check { padding: 4px 0; }
.perm-list { display: flex; flex-wrap: wrap; gap: 6px; }
.provider-order { display: flex; flex-direction: column; gap: 2px; }

.driver-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.driver-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; color: var(--text); }
.driver-card:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-2); }

/* ---------------------------------------------------------------- chart */
.viz { position: relative; }
.viz-legend { list-style: none; margin: 0 0 8px; padding: 0; display: flex; gap: 16px; flex-wrap: wrap; justify-content: flex-end; direction: rtl; font-size: 12.5px; color: var(--text-2); }
.viz-legend li { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.viz-frame { position: relative; }
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz-base { stroke: var(--viz-base); }
.viz-tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.viz-tick-today { fill: var(--text); font-weight: 700; }
.viz-label { fill: var(--text-2); font-size: 11.5px; font-weight: 700; font-family: var(--font); }
.viz-hit { fill: transparent; }
.viz-col { outline: none; cursor: default; }
.viz-col:hover .viz-hit, .viz-col:focus .viz-hit { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.viz-col:focus-visible .viz-hit { stroke: var(--focus-color); stroke-width: 1.5; }
.viz-s-completed { fill: var(--viz-completed); background: var(--viz-completed); }
.viz-s-rejected { fill: var(--viz-rejected); background: var(--viz-rejected); }
.viz-s-open { fill: var(--viz-open); background: var(--viz-open); }
.viz-s-failed { fill: var(--viz-failed); background: var(--viz-failed); }
.viz-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 170px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 10px 12px; font-size: 12.5px; direction: rtl;
}
.viz-tip-title { font-weight: 600; margin-bottom: 6px; color: var(--text); }
.viz-tip-row { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.viz-tip-row strong { color: var(--text); min-width: 28px; font-variant-numeric: tabular-nums; }
.viz-key { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.viz-table { margin-top: 10px; }
.viz-table summary { cursor: pointer; color: var(--link); font-size: 12.5px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .cap-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; right: 0; top: 0; bottom: 0; width: 272px; z-index: 50;
    transform: translateX(100%); transition: transform .2s ease;
  }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-open .backdrop { display: block; }
  .main { grid-column: 1; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 8px 16px; }
  .content { padding: 18px 16px 40px; }
  .grid-2, .grid-3, .grid-4, .form-grid, .cap-groups { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .hide-sm { display: none; }
  .codes { grid-template-columns: minmax(0, 1fr); }
  .filters { padding: 10px; }
  .filters .field { min-width: 0; flex: 1 1 140px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  .sidebar, .topbar, .page-actions, .filters, .pagination, .btn { display: none !important; }
  .shell { display: block; }
}
