/* 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: #070b17;
  --bg-glow: radial-gradient(1100px 620px at 100% -8%, rgba(99, 102, 241, 0.2), transparent 62%),
    radial-gradient(760px 480px at 0% -6%, rgba(168, 85, 247, 0.09), transparent 60%),
    radial-gradient(900px 600px at 8% 112%, rgba(34, 211, 238, 0.07), transparent 60%);
  --sidebar: rgba(9, 14, 30, 0.8);
  --surface: #0f1630;
  --surface-2: #141c3a;
  --surface-3: #1a2447;
  /* Cards are a shade of glass over the glow; dialogs and menus stay solid. */
  --card: linear-gradient(180deg, rgba(22, 31, 62, 0.74), rgba(13, 20, 42, 0.74));
  --card-edge: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --hover: rgba(148, 163, 184, 0.07);
  --border: rgba(148, 163, 184, 0.11);
  --border-strong: rgba(148, 163, 184, 0.2);
  --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);
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --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));
  --tip-bg: #e9edf5;
  --tip-fg: #0b1020;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-glow: radial-gradient(1100px 620px at 100% -8%, rgba(99, 102, 241, 0.1), transparent 62%),
    radial-gradient(760px 480px at 0% -6%, rgba(168, 85, 247, 0.05), transparent 60%),
    radial-gradient(900px 600px at 8% 112%, rgba(56, 189, 248, 0.06), transparent 60%);
  --sidebar: rgba(255, 255, 255, 0.84);
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #eef1f8;
  --card: #ffffff;
  --card-edge: inset 0 1px 0 #ffffff;
  --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);
  --accent-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --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));
  --tip-bg: #111827;
  --tip-fg: #f8fafc;
}

: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; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* A key to press, as the quick search shows them. */
kbd {
  display: inline-block; font-family: var(--font); font-size: 11px; font-weight: 600; line-height: 1;
  padding: 4px 6px; border-radius: 6px; direction: ltr; white-space: nowrap;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  background: var(--surface-2); color: var(--muted);
}

::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; }

/* Ids and codes, in a face where 0 and O, 1 and l differ. */
.mono,
.copyable .ltr,
.id-line .ltr { font-family: ui-monospace, "Cascadia Code", Consolas, "Liberation Mono", monospace; font-size: 12.5px; }

/* ----------------------------------------------- the frame's small pieces */

/* For the keyboard: straight to the page, past the menus. */
.skip-link {
  position: fixed; top: 10px; inset-inline-start: 10px; z-index: 500; padding: 10px 16px;
  border-radius: var(--radius); background: var(--accent); color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow-lg); transform: translateY(-160%); transition: transform 0.15s var(--ease);
}
.skip-link:focus { transform: none; }
.content:focus { outline: none; }

/* While staff wait on the server: a thin line along the very top, shown
   only for a wait long enough to notice. */
.workbar {
  position: fixed; top: 0; inset-inline: 0; height: 2px; z-index: 400; overflow: hidden;
  pointer-events: none; opacity: 0; transition: opacity 0.3s var(--ease);
}
.workbar.on { opacity: 1; transition-delay: 0.15s; }
.workbar::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -40%;
  background: linear-gradient(90deg, transparent, var(--accent-2), #a855f7, transparent);
  animation: working 1.1s ease-in-out infinite;
}
@keyframes working { to { left: 100%; } }

/* Tooltips (ui.rs TipLayer): one layer over everything, placed by script. */
.tip {
  position: fixed; z-index: 300; pointer-events: none; direction: rtl; white-space: nowrap;
  max-width: min(300px, calc(100vw - 24px)); overflow: hidden; text-overflow: ellipsis;
  padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; line-height: 1.5;
  background: var(--tip-bg); color: var(--tip-fg); box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.45);
  animation: tip-in 0.12s var(--ease);
}
.tip-below { transform: translate(-50%, 0); }
.tip-above { transform: translate(-50%, -100%); }
.tip-left { transform: translate(-100%, -50%); }
@keyframes tip-in { from { opacity: 0; } }

.copy-btn {
  width: 26px; height: 26px; display: inline-grid; place-items: center; flex-shrink: 0; vertical-align: middle;
  border: 0; border-radius: 7px; background: transparent; color: var(--faint);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.copy-btn:hover { background: var(--hover); color: var(--text); }
.copy-btn svg { width: 14px; height: 14px; }
.copyable { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.copyable .ltr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.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: var(--accent-grad);
  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);
  backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
  padding: 18px 14px; gap: 18px; z-index: 30; overflow: hidden;
}
.sidebar-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px 6px; padding-inline-end: 0; }
.rail-btn { width: 34px; height: 34px; margin-inline-start: auto; background: transparent; border-color: transparent; color: var(--faint); }
.rail-btn svg { width: 18px; height: 18px; }
.rail-btn:hover { background: var(--hover); border-color: var(--border); }
.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; white-space: nowrap;
  transition: background 0.16s var(--ease), color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.nav-item svg { width: 19px; height: 19px; transition: color 0.16s var(--ease); }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[aria-current="page"] {
  background: linear-gradient(to left, color-mix(in srgb, var(--accent) 24%, transparent), color-mix(in srgb, var(--accent) 5%, transparent));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-2) 20%, transparent);
  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: 10px; bottom: 10px; width: 3px;
  border-radius: 3px; background: var(--accent-2); box-shadow: 0 0 10px 1px 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: color-mix(in srgb, var(--surface-2) 70%, transparent); 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: 50%; display: grid; place-items: center; flex-shrink: 0;
  font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.avatar.sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.avatar.hue-0 { background: linear-gradient(135deg, #4f46e5, #9333ea); }
.avatar.hue-1 { background: linear-gradient(135deg, #0284c7, #4f46e5); }
.avatar.hue-2 { background: linear-gradient(135deg, #047857, #0284c7); }
.avatar.hue-3 { background: linear-gradient(135deg, #c2410c, #dc2626); }
.avatar.hue-4 { background: linear-gradient(135deg, #db2777, #7c3aed); }
.avatar.hue-5 { background: linear-gradient(135deg, #0f766e, #15803d); }
.avatar.hue-6 { background: linear-gradient(135deg, #e11d48, #a21caf); }
.avatar.hue-7 { background: linear-gradient(135deg, #475569, #4338ca); }

.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; white-space: nowrap; }
.topbar .crumbs strong { color: var(--text); font-weight: 700; font-size: 15px; min-width: 0; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.topbar .crumbs svg { width: 15px; height: 15px; opacity: 0.6; }
.topbar .crumbs a { border-radius: 6px; padding: 2px 5px; margin: -2px -5px; transition: color 0.15s var(--ease), background 0.15s var(--ease); }
.topbar .crumbs a:hover { color: var(--text); background: var(--hover); }
.crumb-sep { display: inline-flex; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.search-trigger {
  display: inline-flex; align-items: center; gap: 10px; height: 40px; width: 260px; padding: 0 12px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  color: var(--faint); font-size: 13px; text-align: start;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease), background 0.18s var(--ease);
}
.search-trigger svg { width: 17px; height: 17px; }
.search-trigger .search-text { flex: 1; }
.search-trigger:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--muted); }
.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-kbd { margin-inline-start: auto; }
.menu-theme { display: grid; gap: 8px; padding: 8px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.theme-options {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px;
  border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
}
.theme-option {
  display: grid; justify-items: center; gap: 3px; padding: 7px 4px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 600;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.theme-option svg { width: 16px; height: 16px; }
.theme-option:hover { color: var(--text); }
.theme-option[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.theme-option[aria-checked="true"] svg { color: var(--accent-2); }
.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%; }
/* A page's parts rise into place one after another as it opens (`entering`,
   set by the shell for a moment after each page change). Backwards only:
   once risen, nothing stays on them (a transform would hold dialogs). A
   dialog opened meanwhile has its own way in: given this one too, it would
   play its own again once the moment passed, and flicker. */
.content.entering > :not(.dialog-scrim) { animation: rise 0.36s var(--ease) backwards; }
.content.entering > :nth-child(2):not(.dialog-scrim) { animation-delay: 0.04s; }
.content.entering > :nth-child(3):not(.dialog-scrim) { animation-delay: 0.08s; }
.content.entering > :nth-child(4):not(.dialog-scrim) { animation-delay: 0.12s; }
.content.entering > :nth-child(n + 5):not(.dialog-scrim) { animation-delay: 0.16s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.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-head .greeting { display: grid; gap: 2px; color: var(--text-2); font-weight: 500; }
.greeting-sub { font-size: 12.5px; color: var(--faint); font-weight: 400; }
.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(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--card-edge), 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: 12px; position: relative; overflow: hidden;
  background: radial-gradient(130% 90% at 100% 0%, var(--tone-soft), transparent 55%), var(--card);
}
/* A thread of the card's colour along its top edge. */
.kpi::before {
  content: ""; position: absolute; inset-inline: 18px; top: 0; height: 1px; pointer-events: none;
  background: linear-gradient(to left, transparent, var(--tone), transparent); opacity: 0.55;
}
.kpi-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.kpi-top .chip { width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
/* The trend sits across from the name, at the far end of the card's head. */
.spark { width: 96px; height: 32px; min-width: 48px; flex-shrink: 1; margin-inline-start: auto; overflow: visible; }
.spark-line { fill: none; stroke: var(--tone); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chip {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--tone-soft); color: var(--tone);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone, var(--accent-2)) 18%, transparent);
}
.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: 52px; height: 52px; border-radius: 16px;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--tone, var(--accent-2)) 8%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--tone, var(--accent-2)) 18%, transparent);
}

.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 {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 400px; padding: 10px;
  padding-inline-start: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop 0.2s var(--ease);
}
.toast-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.toast-icon svg { width: 16px; height: 16px; }
.toast.ok .toast-icon { background: var(--success-soft); color: var(--success); }
.toast.error .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast-text { flex: 1; min-width: 0; line-height: 1.6; }
.toast-close {
  width: 28px; height: 28px; display: grid; place-items: center; flex-shrink: 0;
  border: 0; border-radius: 7px; background: transparent; color: var(--faint);
}
.toast-close:hover { background: var(--hover); color: var(--text); }
.toast-close svg { width: 14px; height: 14px; }
.toast::after {
  content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 2px; opacity: 0.6;
  transform-origin: right; animation: toast-time var(--toast-ms, 4500ms) linear forwards;
}
.toast.ok::after { background: var(--success); }
.toast.error::after { background: var(--danger); }
@keyframes toast-time { to { transform: scaleX(0); } }

/* ---------------------------------------------------------- users: lists */

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px;
}
.toolbar .search { flex: 1 1 260px; min-width: 0; }
.toolbar .search .input { height: 42px; }
.select {
  height: 42px; padding: 0 12px; padding-inline-end: 34px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background-color: var(--surface-2); color: var(--text);
  font-size: 13.5px; cursor: pointer; outline: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: left 16px center, left 11px center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.select:hover { border-color: var(--faint); }
.select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft); }
.select.on { border-color: var(--accent); background-color: var(--accent-soft); }
.select option { background: var(--surface); color: var(--text); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: start; font-weight: 600; font-size: 12px; color: var(--faint); white-space: nowrap;
  padding: 11px 16px; background: color-mix(in srgb, var(--surface-2) 65%, transparent); border-bottom: 1px solid var(--border);
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.link { cursor: pointer; transition: background 0.12s var(--ease); }
.table tbody tr.link:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
/* A mark at the row's start while the pointer is on it. */
.table tbody tr.link:hover td:first-child { box-shadow: inset -2px 0 0 var(--accent-2); }
.table tbody tr.link:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: -2px; }
.table .muted { color: var(--muted); }
.table .end { text-align: end; }
.table .chev { color: var(--faint); width: 32px; }
.table .chev svg { width: 16px; height: 16px; }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person .avatar { width: 34px; height: 34px; font-size: 12px; }
.person .who { min-width: 0; display: grid; line-height: 1.45; }
.table .person .who { min-width: 120px; }
.person .who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.person .who span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  background: var(--tone-soft, var(--surface-3)); color: var(--tone, var(--muted));
}
.tag .led { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag svg { width: 12px; height: 12px; }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted);
}
.pager .pages { display: flex; align-items: center; gap: 8px; }
.pager .icon-btn { width: 36px; height: 36px; }
.pager .icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --------------------------------------------------------- users: account */

.back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.back:hover { color: var(--text); }
.back svg { width: 16px; height: 16px; }

.profile { padding: 22px; display: grid; gap: 18px; position: relative; overflow: hidden; }
.profile-cover {
  position: absolute; inset-inline: 0; top: 0; height: 104px; pointer-events: none;
  background:
    radial-gradient(420px 150px at 92% -20%, rgba(139, 92, 246, 0.42), transparent 70%),
    radial-gradient(520px 170px at 30% -40%, rgba(34, 211, 238, 0.2), transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 20%, transparent), transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 50%, transparent);
  mask-image: linear-gradient(to bottom, #000 50%, transparent);
}
.profile-top { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; position: relative; padding-top: 30px; }
.id-line .ltr { color: var(--faint); }
.profile-top .avatar {
  width: 76px; height: 76px; font-size: 23px; margin-top: -8px;
  box-shadow: 0 0 0 4px var(--surface), 0 14px 30px -12px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.profile-id { flex: 1; min-width: 220px; display: grid; gap: 8px; }
.profile-id h1 { margin: 0; font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.contact { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13.5px; color: var(--text-2); }
.contact > span,
.contact .ok,
.contact .no { display: inline-flex; align-items: center; gap: 6px; }
.contact svg { width: 15px; height: 15px; color: var(--muted); }
.contact .ok { color: var(--success); }
.contact .no { color: var(--faint); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); background: var(--warning-soft); }
.btn-warn:hover:not(:disabled) { border-color: var(--warning); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-soft); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { filter: brightness(1.08); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.fact { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: 2px; }
.fact .k { font-size: 12px; color: var(--muted); }
.fact .v { font-size: 14px; font-weight: 700; }
.notice {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-lg); align-items: flex-start;
  background: var(--tone-soft); border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent); color: var(--text-2); font-size: 13.5px;
}
.notice > svg { width: 20px; height: 20px; color: var(--tone); margin-top: 2px; }
.notice b { color: var(--text); }
.notice .meta { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tab {
  position: relative; height: 46px; padding: 0 14px; border: 0; background: transparent; color: var(--muted);
  font-weight: 600; font-size: 13.5px; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; inset-inline: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent-2);
}
.tab .count { font-size: 11px; padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.tab svg { width: 16px; height: 16px; opacity: 0.8; }
.tab[aria-selected="true"] svg { color: var(--accent-2); opacity: 1; }
.tab-body { padding: 20px; }

.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.panel-box { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: grid; gap: 12px; align-content: start; }
.panel-box h3 { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.panel-box h3 svg { width: 16px; height: 16px; color: var(--muted); }
.big { font-size: 22px; font-weight: 800; }
.kv { display: grid; gap: 8px; font-size: 13.5px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; }

.timeline { display: grid; }
.event { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); align-items: start; }
.event:first-child { border-top: 0; padding-top: 0; }
.event .dot { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); }
.event .dot svg { width: 15px; height: 15px; }
.event .what { font-size: 13.5px; line-height: 1.7; min-width: 0; }
.event .what .why { display: block; color: var(--muted); font-size: 12.5px; }
.event time { font-size: 12px; color: var(--faint); white-space: nowrap; }

/* ----------------------------------------------------------------- dialog */

.dialog-scrim {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px;
  background: rgba(2, 6, 23, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade 0.16s var(--ease);
}
.dialog {
  width: min(480px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--card-edge); animation: pop 0.18s var(--ease);
}
.dialog-head { display: flex; gap: 14px; align-items: flex-start; padding: 20px 22px 0; }
.dialog-head .chip { flex-shrink: 0; }
.dialog-head h2 { margin: 2px 0 4px; font-size: 17px; font-weight: 800; }
.dialog-head p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.8; }
.dialog-body { padding: 18px 22px; display: grid; gap: 14px; }
.dialog-foot { display: flex; justify-content: flex-start; gap: 10px; padding: 0 22px 20px; flex-direction: row-reverse; }
.textarea {
  width: 100%; min-height: 92px; padding: 10px 12px; border-radius: var(--radius); resize: vertical;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); outline: none; line-height: 1.8;
}
.textarea:focus, .input.plain:focus { border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.input.plain { padding-inline-start: 14px; }
.hint { font-size: 12px; color: var(--faint); }
.choices { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); cursor: pointer; font-size: 13.5px;
}
.choice:has(input:checked) { border-color: var(--accent-2); background: var(--accent-soft); }
.choice input { accent-color: var(--accent); }
.choice small { display: block; color: var(--muted); font-size: 12px; }
.readonly-note { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.readonly-note svg { width: 15px; height: 15px; }

/* ---------------------------------------------- payments and subscriptions */

.seg {
  display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--radius-lg); justify-self: start;
  background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; overflow-x: auto;
}
.seg-item {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.seg-item svg { width: 16px; height: 16px; }
.seg-item:hover { color: var(--text); }
.seg-item[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.stat .chip { width: 42px; height: 42px; flex-shrink: 0; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 800; letter-spacing: -0.2px; }
.stat .f { font-size: 12px; color: var(--faint); margin-top: 2px; }
.dialog-wide { width: min(560px, 100%); }
.receipt-hero {
  display: grid; justify-items: center; gap: 6px; text-align: center; padding: 18px 16px 20px;
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: radial-gradient(320px 120px at 50% -20%, var(--accent-soft), transparent 75%), var(--surface-2);
}
.receipt-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.receipt-amount { font-size: 30px; font-weight: 800; letter-spacing: -0.4px; line-height: 1.25; }
.receipt-hero .tags { justify-content: center; }
.receipt-plan { font-size: 13px; color: var(--muted); }
.receipt-lines { padding: 2px 2px 0; }
.receipt-total { padding-top: 10px; border-top: 1px dashed var(--border-strong); }
.receipt-total span { color: var(--text-2); font-weight: 700; }
.receipt-total .total { font-size: 16px; }
.receipt-meta b { font-weight: 600; min-width: 0; }
.dialog .kv + .kv { border-top: 1px solid var(--border); padding-top: 14px; }
.kv .total { font-size: 16px; font-weight: 800; }
.link-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-2); font-weight: 600; font-size: 13px; }
.link-inline:hover { text-decoration: underline; }
.link-inline svg { width: 14px; height: 14px; }
.box-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.stack { display: grid; gap: 16px; }
.stack > .link-inline { justify-self: start; }
.choices.row { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick .btn[aria-pressed="true"] { border-color: var(--accent-2); background: var(--accent-soft); color: var(--text); }
.event .what .amount { font-weight: 800; }

/* ---------------------------------------------------------------- support */

.who-ticket { display: grid; line-height: 1.5; min-width: 0; }
.who-ticket b { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.who-ticket span { font-size: 12px; }
.table .prio { color: var(--violet); display: inline-flex; }
.table .prio svg { width: 14px; height: 14px; }
.table .from { display: block; font-size: 11.5px; color: var(--faint); }
.ticket-top { padding: 20px 22px; display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.ticket-title { flex: 1; min-width: 240px; display: grid; gap: 8px; }
.ticket-title h1 { margin: 0; font-size: 20px; font-weight: 800; }
.ticket-title .muted { font-size: 12.5px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ticket-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.ticket-side { display: grid; gap: 16px; }
.ticket-side .panel-box { background: var(--surface); }
.ticket-side .muted { color: var(--muted); font-size: 12.5px; }
.conversation { display: grid; gap: 12px; padding: 20px; }
.msg {
  max-width: 82%; padding: 12px 14px; border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: var(--surface-2); display: grid; gap: 6px;
}
.msg.mine { justify-self: start; }
.msg.staff { justify-self: end; background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent-2) 30%, transparent); }
.msg-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.ticket-id .ltr { font-size: 12px; }
.msg-head time { margin-inline-start: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.msg-body { font-size: 14px; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { border-top: 1px solid var(--border); padding: 16px 20px 20px; display: grid; gap: 12px; }
.composer .textarea { min-height: 120px; }
.composer-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 1100px) {
  .ticket-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .msg { max-width: 94%; }
  .conversation { padding: 14px; }
  .composer { padding: 14px; }
}

/* ------------------------------------------------------ keyboard shortcuts */

.dialog.shortcuts { width: min(580px, 100%); }
.shortcut-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.shortcut-groups h3 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.shortcut {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px;
}
.shortcut:last-child { border-bottom: 0; }
.shortcut-keys { display: inline-flex; align-items: center; gap: 4px; color: var(--faint); font-size: 12px; white-space: nowrap; }

/* ----------------------------------------------------------- quick search */

.palette-scrim {
  position: fixed; inset: 0; z-index: 90; display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh 16px 16px; background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade 0.14s var(--ease);
}
.palette {
  width: min(600px, 100%); overflow: hidden; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--card-edge); animation: pop 0.18s var(--ease);
}
.palette-field { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.palette-field > svg { width: 20px; height: 20px; color: var(--accent-2); }
.palette-field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font-size: 16px; }
.palette-field input::placeholder { color: var(--faint); }
.palette-list { list-style: none; margin: 0; padding: 8px; max-height: min(380px, 55vh); overflow-y: auto; }
.palette-item {
  display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 10px; border-radius: var(--radius);
  color: var(--text-2); font-size: 14px; cursor: pointer;
}
.palette-item[aria-selected="true"] { background: var(--accent-soft); color: var(--text); }
.palette-icon {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-3); color: var(--muted); transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.palette-icon svg { width: 16px; height: 16px; }
.palette-item[aria-selected="true"] .palette-icon { background: var(--accent-grad); color: #fff; }
.palette-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-hint { font-size: 12px; color: var(--faint); white-space: nowrap; }
.palette-foot {
  display: flex; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent); font-size: 12px; color: var(--faint);
}
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* -------------------------------------------- the sidebar narrowed to icons */

@media (min-width: 1025px) {
  .shell { transition: grid-template-columns 0.25s var(--ease); }
  .shell.rail { grid-template-columns: 78px minmax(0, 1fr); }
  .shell.rail .sidebar { padding-inline: 12px; }
  .shell.rail .sidebar-head { flex-direction: column; gap: 12px; padding: 4px 0 6px; }
  .shell.rail .brand-text { display: none; }
  .shell.rail .rail-btn { margin: 0; }
  .shell.rail .nav-title { height: 1px; padding: 0; margin: 0 12px 6px; overflow: hidden; color: transparent; background: var(--border); }
  .shell.rail .nav-item { justify-content: center; gap: 0; padding: 0; }
  /* Still read out, and shown on hover (the item's title). */
  .shell.rail .nav-label {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
  }
  .shell.rail .nav-item.soon .nav-badge { display: none; }
  .shell.rail .nav-badge.live {
    position: absolute; top: 4px; inset-inline-end: 6px; min-width: 17px; padding: 0 4px; line-height: 17px;
    text-align: center; font-size: 10px; background: var(--danger); color: #fff;
    box-shadow: 0 0 0 2px var(--bg);
  }
  .shell.rail .me-card { justify-content: center; padding: 6px; background: transparent; border-color: transparent; }
  .shell.rail .me-card .who,
  .shell.rail .me-card .role { display: none; }
}

/* ------------------------------------------------------------- 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); }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: repeat(2, 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; }
  .rail-btn { display: none; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
}
@keyframes fade { from { opacity: 0; } }

@media (max-width: 860px) {
  .search-trigger { width: 40px; padding: 0; justify-content: center; }
  .search-trigger .search-text,
  .search-trigger kbd { display: none; }
}

@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; }
  .toolbar .select { flex: 1 1 140px; }
  .table .wide-only { display: none; }
  .profile { padding: 16px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tab-body { padding: 14px; }
  .palette-foot { display: none; }
  .palette-scrim { padding-top: 8vh; }
  .crumbs .crumb-mid,
  .crumbs .crumb-sep { display: none; }
  .topbar .crumbs strong { max-width: 150px; }
  .shortcut-groups { grid-template-columns: minmax(0, 1fr); }
  .table.cards thead { display: none; }
  .table.cards,
  .table.cards tbody { display: block; width: 100%; }
  .table.cards tr { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .table.cards tbody tr:last-child { border-bottom: 0; }
  .table.cards td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 0; border: 0; white-space: normal; text-align: end; min-width: 0;
  }
  .table.cards td[data-label]::before { content: attr(data-label); color: var(--faint); font-size: 12px; font-weight: 600; flex-shrink: 0; }
  .table.cards td.lead { order: -1; justify-content: flex-start; text-align: start; padding-bottom: 2px; }
  .table.cards td.wide-only { display: flex; }
  .table.cards td.chev { display: none; }
  .table.cards td[colspan] { display: block; }
  .table.cards tbody tr.link:hover td:first-child { box-shadow: none; }
  .profile-top { padding-top: 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .stat .chip { width: 34px; height: 34px; }
  .stat .v { font-size: 16px; }
  .profile-top .avatar { width: 64px; height: 64px; font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  /* Still, not sweeping: the whole line while the wait lasts. */
  .workbar::before { animation: none !important; left: 0; width: 100%; }
  .toast::after { display: none; }
}
