/* AI Hub's staff panel: slate and indigo, dark by default and light on
   request (`data-theme` on <html>, kept by src/theme.rs). Right to left,
   Vazirmatn throughout. Every colour is a token below; components use the
   tokens only, so the two themes stay one design. */

@font-face { font-family: "Vazirmatn"; font-weight: 400; font-display: swap; src: url("/fonts/Vazirmatn-Regular.woff2") format("woff2"); }
@font-face { font-family: "Vazirmatn"; font-weight: 500; font-display: swap; src: url("/fonts/Vazirmatn-Medium.woff2") format("woff2"); }
@font-face { font-family: "Vazirmatn"; font-weight: 600; font-display: swap; src: url("/fonts/Vazirmatn-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Vazirmatn"; font-weight: 700; font-display: swap; src: url("/fonts/Vazirmatn-Bold.woff2") format("woff2"); }
@font-face { font-family: "Vazirmatn"; font-weight: 800; font-display: swap; src: url("/fonts/Vazirmatn-ExtraBold.woff2") format("woff2"); }

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0f1e;
  --bg-glow: radial-gradient(1200px 600px at 85% -10%, rgba(99, 102, 241, 0.14), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(56, 189, 248, 0.06), transparent 60%);
  --sidebar: #0d1326;
  --surface: #111831;
  --surface-2: #16203d;
  --surface-3: #1c2748;
  --hover: rgba(148, 163, 184, 0.08);
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --text: #e5e9f2;
  --text-2: #b4bdd0;
  --muted: #8591a8;
  --faint: #5d6880;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --accent-3: #a5b4fc;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-ring: rgba(129, 140, 248, 0.45);
  --on-accent: #ffffff;
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.14);
  --violet: #c084fc;
  --violet-soft: rgba(192, 132, 252, 0.14);
  --chart-grid: rgba(148, 163, 184, 0.10);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
  --skeleton: linear-gradient(90deg, rgba(148, 163, 184, 0.06), rgba(148, 163, 184, 0.14), rgba(148, 163, 184, 0.06));
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-glow: radial-gradient(1200px 600px at 85% -10%, rgba(99, 102, 241, 0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(56, 189, 248, 0.05), transparent 60%);
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #eef1f8;
  --hover: rgba(15, 23, 42, 0.045);
  --border: #e4e8f1;
  --border-strong: #d3d9e6;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #5b6579;
  --faint: #94a0b6;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-3: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.09);
  --accent-ring: rgba(99, 102, 241, 0.35);
  --on-accent: #ffffff;
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --info: #0284c7;
  --info-soft: rgba(2, 132, 199, 0.09);
  --violet: #9333ea;
  --violet-soft: rgba(147, 51, 234, 0.09);
  --chart-grid: rgba(15, 23, 42, 0.07);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 12px 32px -14px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 30px 60px -24px rgba(15, 23, 42, 0.28);
  --skeleton: linear-gradient(90deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.09), rgba(15, 23, 42, 0.04));
}

:root {
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --sidebar-width: 268px;
  --topbar-height: 68px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --font: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body { background-image: var(--bg-glow); background-attachment: fixed; }

button,
input,
select,
textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

a { color: inherit; text-decoration: none; }

svg { flex-shrink: 0; }

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }

.ltr { direction: ltr; unicode-bidi: isolate; }

.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;
}

/* ------------------------------------------------------------ boot screen */

.boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); z-index: 100;
}
.boot-mark { display: grid; justify-items: center; gap: 18px; color: var(--muted); font-size: 13px; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--accent-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ brand */

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #22d3ee 130%);
  color: #fff; font-weight: 800; font-size: 14px; letter-spacing: 0.5px;
  box-shadow: 0 8px 20px -8px rgba(99, 102, 241, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.brand-name { font-weight: 800; font-size: 16px; line-height: 1.2; }
.brand-name span { color: var(--accent-2); }
.brand-sub { font-size: 11.5px; color: var(--muted); font-weight: 500; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid transparent; background: transparent;
  font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease),
    box-shadow 0.18s var(--ease), transform 0.12s var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: var(--on-accent);
  box-shadow: 0 8px 18px -8px rgba(99, 102, 241, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 24px -8px rgba(99, 102, 241, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.22); filter: brightness(1.06); }
.btn-ghost { color: var(--text-2); border-color: var(--border); background: var(--surface); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-block { width: 100%; height: 46px; font-size: 15px; }
.btn-link { height: auto; padding: 0; color: var(--accent-2); font-weight: 600; }
.btn-link:hover:not(:disabled) { color: var(--accent-3); }

.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2);
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 19px; height: 19px; }

.btn .spinner,
.icon-btn .spinner { width: 16px; height: 16px; border-width: 2px; }
.btn-primary .spinner { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }

/* ----------------------------------------------------------------- inputs */

.field { display: grid; gap: 7px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg {
  position: absolute; inset-inline-start: 14px; width: 18px; height: 18px;
  color: var(--faint); pointer-events: none; transition: color 0.18s var(--ease);
}
.input {
  width: 100%; height: 46px; padding: 0 14px; padding-inline-start: 44px;
  border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); outline: none;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--faint); }
.input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.input-wrap:focus-within > svg { color: var(--accent-2); }
.input.has-end { padding-inline-end: 46px; }
.input-end {
  position: absolute; inset-inline-end: 6px; width: 34px; height: 34px; border: 0;
  border-radius: var(--radius-sm); background: transparent; color: var(--faint);
  display: grid; place-items: center;
}
.input-end:hover { color: var(--text); background: var(--hover); }
.input-end svg { width: 18px; height: 18px; }

/* The six boxes of a one-time code; written left to right like any number. */
.otp { display: flex; gap: 10px; justify-content: center; direction: ltr; }
.otp input {
  width: 52px; height: 60px; text-align: center; font-size: 24px; font-weight: 700;
  border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface-2); outline: none; caret-color: var(--accent-2);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
}
.otp input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.otp input.filled { border-color: var(--accent); }
.otp.shake { animation: shake 0.42s var(--ease); }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px;
  border-radius: var(--radius); font-size: 13.5px; line-height: 1.7;
  border: 1px solid transparent;
}
.alert svg { width: 18px; height: 18px; margin-top: 2px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }

/* ------------------------------------------------------------------ login */

.login {
  min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1fr) 1.05fr;
}
.login-form-side { display: flex; flex-direction: column; padding: 28px 40px; }
.login-top { display: flex; align-items: center; justify-content: space-between; }
.login-center { flex: 1; display: grid; place-items: center; padding: 40px 0; }
.login-card { width: 100%; max-width: 400px; display: grid; gap: 26px; }
.login-head h1 { margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -0.2px; }
.login-head p { margin: 0; color: var(--muted); font-size: 14px; }
.login-form { display: grid; gap: 18px; }
.login-steps { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.login-steps .step { display: flex; align-items: center; gap: 8px; }
.login-steps .dot {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--muted);
  border: 1px solid var(--border);
}
.login-steps .step.on .dot { background: var(--accent); color: #fff; border-color: transparent; box-shadow: 0 0 0 4px var(--accent-soft); }
.login-steps .step.done .dot { background: var(--success-soft); color: var(--success); border-color: transparent; }
.login-steps .step.on { color: var(--text); font-weight: 600; }
.login-steps .bar { flex: 1; height: 2px; border-radius: 2px; background: var(--border); }
.login-steps .bar.done { background: linear-gradient(90deg, var(--success), var(--accent)); }
.login-sent { text-align: center; color: var(--muted); font-size: 14px; }
.login-sent strong { color: var(--text); font-weight: 700; }
.login-row { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; color: var(--muted); }
.login-foot { text-align: center; font-size: 12px; color: var(--faint); display: flex; justify-content: center; gap: 6px; align-items: center; }
.login-foot svg { width: 14px; height: 14px; }

.login-art {
  position: relative; overflow: hidden; margin: 14px; margin-inline-start: 0;
  border-radius: 28px; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(600px 400px at 20% 10%, rgba(139, 92, 246, 0.55), transparent 60%),
    radial-gradient(500px 420px at 90% 90%, rgba(34, 211, 238, 0.35), transparent 60%),
    radial-gradient(700px 500px at 70% 30%, rgba(99, 102, 241, 0.65), transparent 65%),
    #0b1030;
  color: #eef0ff; isolation: isolate;
}
.login-art::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 40%, #000 30%, transparent 75%);
}
.login-art::after {
  content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%;
  inset-inline-end: -120px; bottom: -160px; z-index: -1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 60px rgba(255, 255, 255, 0.03), 0 0 0 120px rgba(255, 255, 255, 0.02);
}
.art-badge {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
}
.art-badge svg { width: 15px; height: 15px; }
.art-copy h2 { margin: 0 0 14px; font-size: 34px; line-height: 1.45; font-weight: 800; max-width: 460px; }
.art-copy p { margin: 0; max-width: 430px; color: rgba(238, 240, 255, 0.72); font-size: 15px; }
.art-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 520px; }
.art-tile {
  padding: 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12); backdrop-filter: blur(10px);
  display: grid; gap: 8px; font-size: 12.5px; color: rgba(238, 240, 255, 0.8);
}
.art-tile svg { width: 20px; height: 20px; color: #c7d2fe; }
.art-tile strong { color: #fff; font-size: 13.5px; }

/* ------------------------------------------------------------------ shell */

.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar); border-inline-end: 1px solid var(--border);
  padding: 18px 14px; gap: 18px; z-index: 30;
}
.sidebar .brand { padding: 4px 8px 6px; }
.nav { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 18px; margin: 0 -4px; padding: 0 4px; }
.nav-section { display: grid; gap: 3px; }
.nav-title { font-size: 11px; font-weight: 700; color: var(--faint); padding: 0 12px 6px; letter-spacing: 0.3px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px;
  border-radius: var(--radius); color: var(--muted); font-weight: 500; font-size: 14px;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.nav-item svg { width: 19px; height: 19px; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.nav-item[aria-current="page"] svg { color: var(--accent-2); }
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 11px; bottom: 11px; width: 3px;
  border-radius: 3px; background: var(--accent-2);
}
.nav-item.soon { cursor: default; opacity: 0.55; }
.nav-item.soon:hover { background: transparent; color: var(--muted); }
.nav-badge {
  margin-inline-start: auto; font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--faint);
}
.nav-badge.live { background: var(--danger-soft); color: var(--danger); }

.me-card {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-lg);
  background: var(--surface-2); border: 1px solid var(--border);
}
.me-card .who { min-width: 0; flex: 1; }
.me-card .name { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-card .mail { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0;
  font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, #6366f1, #a855f7);
}
.avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 11.5px; }

.role {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px;
}
.role-admin { background: var(--accent-soft); color: var(--accent-2); }
.role-support { background: var(--info-soft); color: var(--info); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-height);
  display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.topbar .crumbs strong { color: var(--text); font-weight: 700; font-size: 15px; }
.topbar .crumbs svg { width: 15px; height: 15px; opacity: 0.6; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.session-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 12.5px;
}
.session-chip svg { width: 15px; height: 15px; }
.session-chip.low { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); background: var(--warning-soft); }

.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 6px; padding-inline-end: 10px;
  border-radius: var(--radius); border: 1px solid transparent; background: transparent;
}
.user-btn:hover,
.user-btn[aria-expanded="true"] { background: var(--surface); border-color: var(--border); }
.user-btn .label { display: grid; text-align: start; line-height: 1.3; }
.user-btn .label b { font-size: 13px; }
.user-btn .label small { font-size: 11px; color: var(--muted); }
.user-btn > svg { width: 16px; height: 16px; color: var(--muted); }
.menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 240px; padding: 6px;
  border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); z-index: 50; animation: pop 0.16s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: grid; gap: 4px; }
.menu-head .mail { font-size: 12px; color: var(--muted); }
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2);
  font-size: 13.5px; font-weight: 500; text-align: start;
}
.menu-item:hover { background: var(--hover); color: var(--text); }
.menu-item svg { width: 17px; height: 17px; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }

.scrim { display: none; }
/* Under the open menu, over the page: a click anywhere else closes it. */
.menu-catcher { position: fixed; inset: 0; z-index: 19; }

.content { padding: 28px; display: grid; gap: 22px; align-content: start; max-width: 1480px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.2px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; align-items: center; gap: 10px; }
.stamp { font-size: 12.5px; color: var(--faint); display: inline-flex; align-items: center; gap: 6px; }
.stamp svg { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap;
  padding: 18px 20px 0;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.card-body { padding: 18px 20px 20px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 18px 20px; display: grid; gap: 14px; position: relative; overflow: hidden; }
.kpi::after {
  content: ""; position: absolute; width: 140px; height: 140px; border-radius: 50%;
  inset-inline-end: -50px; top: -60px; background: var(--tone-soft); opacity: 0.6; pointer-events: none;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.chip {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--tone-soft); color: var(--tone);
}
.chip svg { width: 20px; height: 20px; }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -0.4px; line-height: 1.1; }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-inline-start: 6px; letter-spacing: 0; }
.kpi-foot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.tone-indigo { --tone: var(--accent-2); --tone-soft: var(--accent-soft); }
.tone-emerald { --tone: var(--success); --tone-soft: var(--success-soft); }
.tone-amber { --tone: var(--warning); --tone-soft: var(--warning-soft); }
.tone-sky { --tone: var(--info); --tone-soft: var(--info-soft); }
.tone-violet { --tone: var(--violet); --tone-soft: var(--violet-soft); }
.tone-rose { --tone: var(--danger); --tone-soft: var(--danger-soft); }

.delta {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.delta svg { width: 14px; height: 14px; }
.delta.up { background: var(--success-soft); color: var(--success); }
.delta.down { background: var(--danger-soft); color: var(--danger); }
.delta.flat { background: var(--surface-3); color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--muted);
}
.pill.warn { background: var(--warning-soft); color: var(--warning); }
.pill .led { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ----------------------------------------------------------------- charts */

/* Time runs left to right whatever the page's direction; the scale sits on
   the left, in a gutter of its own. */
.chart { direction: ltr; padding-left: 52px; }
.chart-plot { position: relative; height: 230px; }
.chart-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .area-line { fill: none; stroke: var(--accent-2); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .bar { fill: var(--success); opacity: 0.88; transition: opacity 0.15s var(--ease); }
.chart .bar.dim { opacity: 0.32; }
.chart .bar-empty { fill: var(--chart-grid); }
.chart .hit { fill: transparent; cursor: crosshair; }
.y-label {
  position: absolute; right: calc(100% + 10px); transform: translateY(-50%);
  font-size: 11px; color: var(--faint); white-space: nowrap; direction: rtl;
}
.x-axis { position: relative; height: 26px; margin-top: 8px; }
.x-label { position: absolute; top: 0; font-size: 11px; color: var(--faint); white-space: nowrap; direction: rtl; }
.chart-guide {
  position: absolute; top: 0; bottom: 0; width: 0; pointer-events: none;
  border-left: 1px dashed var(--border-strong);
}
.chart-dot {
  position: absolute; width: 12px; height: 12px; border-radius: 50%; pointer-events: none;
  transform: translate(-50%, -50%); background: var(--surface);
  border: 2.5px solid var(--accent-2); box-shadow: 0 0 0 5px var(--accent-soft);
}
.chart-total { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.chart-total b { font-size: 22px; font-weight: 800; }
.chart-total span { font-size: 12.5px; color: var(--muted); }
.tooltip {
  position: absolute; transform: translate(-50%, calc(-100% - 14px)); pointer-events: none; direction: rtl;
  padding: 8px 12px; border-radius: var(--radius); background: var(--surface-3);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow); white-space: nowrap;
  font-size: 12px; color: var(--muted); display: grid; gap: 2px; z-index: 5;
}
.tooltip b { color: var(--text); font-size: 14px; }
.tooltip.below { transform: translate(-50%, 14px); }

.donut-wrap { display: grid; grid-template-columns: 160px 1fr; gap: 20px; align-items: center; }
.donut { position: relative; width: 160px; height: 160px; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut .track { fill: none; stroke: var(--surface-3); }
.donut .seg { fill: none; transition: opacity 0.15s var(--ease); }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center b { font-size: 26px; font-weight: 800; line-height: 1.1; }
.donut-center span { font-size: 12px; color: var(--muted); }
.legend { display: grid; gap: 10px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend-row .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-row .nm { color: var(--text-2); flex: 1; }
.legend-row .vl { font-weight: 700; }
.legend-row .pc { color: var(--faint); font-size: 12px; min-width: 42px; text-align: end; }

/* ------------------------------------------------------------ lists, misc */

.stat-list { display: grid; gap: 16px; }
.stat-row { display: grid; gap: 8px; }
.stat-row .top { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.stat-row .top svg { width: 17px; height: 17px; color: var(--muted); }
.stat-row .top .nm { flex: 1; color: var(--text-2); }
.stat-row .top b { font-weight: 700; }
.meter { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.activity { display: grid; }
.activity-row { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); align-items: flex-start; }
.activity-row:first-child { border-top: 0; padding-top: 0; }
.activity-row .what { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.7; }
.activity-row .what b { font-weight: 700; }
.activity-row .what .why { display: block; font-size: 12.5px; color: var(--muted); }
.activity-row time { font-size: 12px; color: var(--faint); white-space: nowrap; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: 4px; }
.tile .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.tile .k svg { width: 15px; height: 15px; }
.tile .v { font-size: 20px; font-weight: 800; }

.empty { display: grid; justify-items: center; gap: 10px; padding: 26px 10px; text-align: center; color: var(--muted); font-size: 13.5px; }
.empty .chip { width: 46px; height: 46px; }

.error-card { padding: 28px; display: grid; justify-items: center; gap: 12px; text-align: center; }
.error-card h2 { margin: 0; font-size: 17px; }
.error-card p { margin: 0; color: var(--muted); font-size: 14px; }

.skeleton { border-radius: var(--radius-sm); background: var(--skeleton); background-size: 300% 100%; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.toasts { position: fixed; bottom: 22px; inset-inline-start: 22px; display: grid; gap: 10px; z-index: 200; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; padding: 12px 14px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop 0.2s var(--ease);
}
.toast svg { width: 18px; height: 18px; }
.toast.error svg { color: var(--danger); }
.toast.ok svg { color: var(--success); }

/* ------------------------------------------------------------- responsive */

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
}

@media (max-width: 1024px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw);
    transform: translateX(105%); transition: transform 0.25s var(--ease); box-shadow: var(--shadow-lg);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 25; background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(2px); animation: fade 0.2s var(--ease);
  }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
}
@keyframes fade { from { opacity: 0; } }

@media (max-width: 640px) {
  .kpis,
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .legend { width: 100%; }
  .user-btn .label,
  .session-chip,
  .crumbs .crumb-root,
  .crumbs > svg { display: none; }
  .topbar { gap: 10px; }
  .login-form-side { padding: 20px; }
  .otp { gap: 7px; }
  .otp input { width: 44px; height: 54px; font-size: 21px; }
  /* Three dates under a narrow chart: the first, one between, the last. */
  .x-label:nth-child(2),
  .x-label:nth-child(4),
  .x-label:nth-child(5) { display: none; }
  .chart { padding-left: 46px; }
  .page-head h1 { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
