/* Cadi design system. Tokens, reset, typography, components, app shell.
   Light is the default; set data-theme="dark" on <html> for the ink theme.
   Writing rule: no em dashes anywhere. */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #F7F7F9;
  --surface: #FFFFFF;
  --surface-2: #F2F1F6;
  --surface-3: #EAE8F1;
  --hover: #FAFAFC;
  --border: #E7E5EE;
  --border-strong: #D9D6E3;
  --text: #141225;
  --text-2: #55526B;
  --text-3: #6E6B83;
  --placeholder: #8E8BA0;

  --primary: #5B4BE0;          /* violet button background */
  --primary-hover: #4B3BD0;
  --on-primary: #FFFFFF;
  --accent: #5B4BE0;           /* links, active icons, rings */
  --primary-soft: #EEEBFF;
  --primary-soft-text: #3B2FA8;
  --ink: #141225;              /* ink button background */
  --ink-hover: #24213A;
  --on-ink: #FFFFFF;

  --indigo: #3B2FA8;
  --lilac: #8B6CFF;
  --cyan: #22D3EE;
  --success: #0F8A4A; --success-bg: #E7F6EE;
  --warning: #B25E09; --warning-bg: #FFF3E2;
  --danger: #C4322B;  --danger-bg: #FDECEB;
  --mpesa: #3BB54A;

  --scrim: rgba(11, 11, 15, .44);
  --toast-bg: #141225;
  --toast-text: #F4F4F7;

  --font-ui: Manrope, ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-brand: 'Google Sans', Manrope, ui-sans-serif, system-ui, sans-serif;

  --r-xs: 8px; --r-sm: 10px; --r-input: 12px; --r-btn: 12px; --r-lg: 14px;
  --r-card: 20px; --r-modal: 28px; --r-pill: 999px;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 128px;

  --shadow-xs: 0 1px 2px rgba(20, 18, 37, .04);
  --shadow-card: 0 1px 2px rgba(20, 18, 37, .04), 0 8px 24px -8px rgba(20, 18, 37, .08);
  --shadow-hover: 0 2px 4px rgba(20, 18, 37, .04), 0 24px 48px -12px rgba(20, 18, 37, .16);
  --shadow-raised: 0 2px 4px rgba(20, 18, 37, .04), 0 24px 48px -12px rgba(20, 18, 37, .18);
  --shadow-btn: 0 2px 4px rgba(20, 18, 37, .06), 0 10px 20px -8px rgba(20, 18, 37, .22);
  --ring: 0 0 0 4px rgba(91, 75, 224, .22);
  --ring-input: 0 0 0 4px rgba(91, 75, 224, .15);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-hover: 180ms;
  --t-state: 320ms;
  --t-enter: 700ms;

  --side-w: 256px;
  --topbar-h: 60px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0B0F;
  --surface: #131318;
  --surface-2: #1A1A21;
  --surface-3: #22222B;
  --hover: #17171D;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);
  --text: #F4F4F7;
  --text-2: #A3A3B2;
  --text-3: #8C8C9C;
  --placeholder: #77778A;

  --primary: #6E5CF0;
  --primary-hover: #7D6CF5;
  --on-primary: #FFFFFF;
  --accent: #8B7BFF;
  --primary-soft: rgba(139, 123, 255, .14);
  --primary-soft-text: #B9AEFF;
  --ink: #F4F4F7;
  --ink-hover: #FFFFFF;
  --on-ink: #0B0B0F;

  --success: #3DCB7F; --success-bg: rgba(61, 203, 127, .12);
  --warning: #F5B83D; --warning-bg: rgba(245, 184, 61, .12);
  --danger: #F0645C;  --danger-bg: rgba(240, 100, 92, .12);

  --scrim: rgba(0, 0, 0, .6);
  --toast-bg: #1F1F27;
  --toast-text: #F4F4F7;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .03);
  --shadow-hover: 0 24px 48px -16px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .05);
  --shadow-raised: 0 40px 80px -20px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .06);
  --shadow-btn: 0 10px 24px -10px rgba(0, 0, 0, .7);
  --ring: 0 0 0 4px rgba(139, 123, 255, .3);
  --ring-input: 0 0 0 4px rgba(139, 123, 255, .2);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: var(--font-ui); font-size: 15px; font-weight: 500; line-height: 1.6;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; transition: color var(--t-hover) var(--ease); }
a:hover { color: var(--primary-hover); }
[data-theme="dark"] a:hover { color: #B9AEFF; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; color: var(--text); font-weight: 750; text-wrap: balance; }
hr { border: 0; }
::selection { background: var(--primary-soft); }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* ---------- Typography ---------- */
.display { font-size: clamp(40px, 6vw, 64px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
h1, .h1 { font-size: clamp(28px, 3.2vw, 36px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.08; }
h2, .h2 { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.15; }
h3, .h3 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
h4, .h4 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.lede { font-size: 15.5px; line-height: 1.6; color: var(--text-2); font-weight: 500; max-width: 640px; }
.small { font-size: 13.5px; }
.mono, .eyebrow, .label, .kbd, .pill { font-family: var(--font-mono); }
.mono { font-size: 13px; font-weight: 500; letter-spacing: 0; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); font-weight: 500; }
.text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); }
.text-accent { color: var(--accent); } .text-danger { color: var(--danger); } .text-success { color: var(--success); }
.wordmark { font-family: var(--font-brand); font-weight: 600; letter-spacing: -0.04em; line-height: 1; color: var(--text); text-transform: lowercase; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Icons and mark ---------- */
.ic { display: inline-block; flex: none; vertical-align: middle; }
.mark { display: inline-flex; flex: none; line-height: 0; }
.mark > svg { display: block; }
.brand-lockup { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--text); }
.brand-lockup:hover { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; min-width: 44px; padding: 0 18px; border-radius: var(--r-btn);
  border: 1px solid transparent; background: var(--surface); color: var(--text);
  font-family: var(--font-ui); font-size: 14.5px; font-weight: 600; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: transform var(--t-hover) var(--ease), box-shadow var(--t-hover) var(--ease),
    background-color var(--t-hover), border-color var(--t-hover), color var(--t-hover), opacity var(--t-state);
}
.btn:hover:not(:disabled):not([aria-disabled="true"]) { transform: translateY(-1px); box-shadow: var(--shadow-btn); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.99); box-shadow: none; }
.btn:focus-visible { box-shadow: var(--ring); border-radius: var(--r-btn); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; }
.btn .ic { margin: 0 -2px; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-ink { background: var(--ink); color: var(--on-ink); border-color: var(--ink); box-shadow: 0 1px 2px rgba(20, 18, 37, .12); }
.btn-ink:hover:not(:disabled) { background: var(--ink-hover); border-color: var(--ink-hover); color: var(--on-ink); }
.btn-sec { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-xs); }
.btn-sec:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); box-shadow: none; transform: none; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { color: #fff; filter: brightness(.95); }
.btn-soft { background: var(--primary-soft); color: var(--primary-soft-text); }
.btn-soft:hover:not(:disabled) { color: var(--primary-soft-text); }
.btn-sm { height: 36px; min-width: 36px; padding: 0 12px; border-radius: var(--r-sm); font-size: 13.5px; }
.btn-lg { height: 52px; padding: 0 22px; border-radius: var(--r-lg); font-size: 16px; }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
/* Small buttons keep a 44px hit area. */
.btn-sm::before { content: ""; position: absolute; inset: -4px; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--on-primary) transparent var(--on-primary) var(--on-primary);
  opacity: .9; animation: spin .7s linear infinite;
}
.btn-sec.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--text) transparent var(--text) var(--text); }
.btn-ink.is-loading::after { border-color: var(--on-ink) transparent var(--on-ink) var(--on-ink); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; }
.link-btn { color: var(--accent); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.label { font-size: 12px; font-weight: 500; color: var(--text-2); line-height: 1.3; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hint { font-size: 13px; color: var(--text-3); line-height: 1.45; }
.field-error { display: none; font-size: 13px; color: var(--danger); line-height: 1.45; font-weight: 600; }
.field.is-invalid .field-error { display: block; }
.field.is-invalid .inp, .field.is-invalid .inp-group { border-color: var(--danger); }
.inp, .inp-group {
  width: 100%; min-width: 0; height: 48px; border: 1px solid var(--border); border-radius: var(--r-input);
  background: var(--surface); color: var(--text); font: 500 15px var(--font-ui);
  transition: border-color var(--t-hover), box-shadow var(--t-hover);
}
.inp { padding: 0 14px; appearance: none; -webkit-appearance: none; }
.inp:hover, .inp-group:hover { border-color: var(--border-strong); }
.inp:focus, .inp:focus-visible, .inp-group:focus-within { outline: none; border-color: var(--accent); box-shadow: var(--ring-input); border-radius: var(--r-input); }
.inp::placeholder, .inp-bare::placeholder { color: var(--placeholder); }
.inp:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
.inp.mono, .inp-bare.mono { font-family: var(--font-mono); font-size: 14px; }
textarea.inp { height: auto; min-height: 104px; padding: 12px 14px; line-height: 1.55; resize: vertical; }
.inp-sm { height: 40px; font-size: 14px; border-radius: var(--r-sm); }
.inp-group { display: flex; align-items: center; overflow: hidden; }
.inp-bare { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; padding: 0 14px; outline: none; font: inherit; color: inherit; }
.inp-bare:focus-visible { box-shadow: none; }
.inp-addon { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; height: 100%; color: var(--text-3); font-family: var(--font-mono); font-size: 13.5px; white-space: nowrap; }
.inp-addon + .inp-bare { padding-left: 0; }
.select { position: relative; display: block; }
.select > select.inp { padding-right: 40px; cursor: pointer; }
.select::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 16px; height: 16px; margin-top: -8px; pointer-events: none;
  background: var(--text-3); -webkit-mask: url(/static/icons/chevron-down.svg) center / contain no-repeat; mask: url(/static/icons/chevron-down.svg) center / contain no-repeat;
}
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 14.5px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); cursor: pointer; }

/* Switch: <label class="switch"><input type="checkbox"><span class="switch-track"></span><span>Label</span></label> */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 40px; height: 24px; flex: none; border-radius: var(--r-pill); background: var(--surface-3); transition: background-color var(--t-state) var(--ease); }
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(20, 18, 37, .12), 0 4px 10px -4px rgba(20, 18, 37, .25); transition: transform var(--t-state) var(--ease);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }
.switch input:disabled + .switch-track { opacity: .45; }

/* OTP boxes */
.otp { display: flex; gap: 8px; }
.otp .inp { width: 48px; height: 56px; padding: 0; text-align: center; font: 600 20px var(--font-mono); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-card); min-width: 0; }
.card-pad { padding: 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card-body { padding: 20px; }
.card-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.card-flat { box-shadow: none; }
.card-muted { background: var(--hover); box-shadow: none; }
.lift { transition: transform 220ms var(--ease), box-shadow 220ms var(--ease), border-color 220ms; }
.lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
a.card { color: inherit; display: block; }

/* ---------- Chips, pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 13.5px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
  transition: background-color var(--t-hover), border-color var(--t-hover), color var(--t-hover), transform var(--t-hover) var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-on, .chip[aria-pressed="true"], .chip[aria-selected="true"] { background: var(--primary-soft); border-color: transparent; color: var(--primary-soft-text); }
.chip:focus-visible { border-radius: var(--r-pill); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-2); font-size: 11.5px; font-weight: 500; white-space: nowrap; line-height: 1;
}
.pill-soon { background: var(--surface-2); color: var(--text-2); }
.pill-primary { background: var(--primary-soft); color: var(--primary-soft-text); }
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-warning { background: var(--warning-bg); color: var(--warning); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-outline { background: transparent; border: 1px solid var(--border); }
.pill-mpesa { background: var(--mpesa); color: #fff; font-family: var(--font-ui); font-weight: 800; letter-spacing: .02em; }
.pill .dot, .status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* Step indicator: dots, the current one a pill exactly 2x wide at the same height (ui.stepDots). */
.dots { display: inline-flex; align-items: center; gap: 6px; }
.dots .dot { width: 8px; height: 8px; flex: none; border-radius: var(--r-pill); background: var(--border-strong); transition: width var(--t-state) var(--ease), background-color var(--t-state) var(--ease); }
.dots .dot.is-done { background: var(--primary-soft-text); opacity: .45; }
.dots .dot.is-current { width: 16px; background: var(--primary); opacity: 1; }
.dots-lg .dot { width: 10px; height: 10px; } .dots-lg .dot.is-current { width: 20px; }

/* ---------- Avatar ---------- */
.avatar {
  --av: 40px; position: relative; width: var(--av); height: var(--av); flex: none; border-radius: var(--r-pill); overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary-soft-text);
  font-weight: 700; font-size: calc(var(--av) * .38); letter-spacing: -0.01em; line-height: 1; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-xs { --av: 24px; } .avatar-sm { --av: 32px; } .avatar-md { --av: 40px; } .avatar-lg { --av: 56px; } .avatar-xl { --av: 80px; } .avatar-2xl { --av: 112px; }
.avatar-rounded { border-radius: 30%; }
.avatar-square { border-radius: var(--r-sm); }
.avatar-ring { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border); overflow: visible; }
.avatar-ring img { border-radius: inherit; }

/* ---------- Tabs and segmented control (indicator positioned by ui.segmented) ---------- */
.seg { position: relative; display: inline-flex; width: fit-content; padding: 3px; gap: 2px; border-radius: var(--r-lg); background: var(--surface-2); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg-item {
  position: relative; z-index: 1; flex: 1 0 auto; min-height: 38px; padding: 0 14px; border-radius: 11px; color: var(--text-3);
  font-size: 13.5px; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: color var(--t-state) var(--ease);
}
.seg-item:hover { color: var(--text); }
.seg-item[aria-selected="true"], .seg-item.is-on { color: var(--text); }
.seg-ind {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0; width: 0; border-radius: 11px; background: var(--surface);
  box-shadow: 0 1px 2px rgba(20, 18, 37, .08), 0 4px 10px -4px rgba(20, 18, 37, .16);
  transition: transform var(--t-state) var(--ease), width var(--t-state) var(--ease);
}
[data-theme="dark"] .seg-ind { background: #2A2A34; box-shadow: 0 1px 2px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .06); }
.seg-sm .seg-item { min-height: 32px; padding: 0 10px; font-size: 12.5px; }
.tabs { position: relative; display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs .seg-item, .tab { border-radius: 0; min-height: 44px; padding: 0 12px; color: var(--text-3); font-size: 14px; font-weight: 600; flex: none; }
.tabs .seg-item[aria-selected="true"] { color: var(--text); }
.tabs .seg-ind { top: auto; bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); box-shadow: none; }

/* ---------- List rows ---------- */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-card); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 12px 18px; color: inherit; text-align: left; width: 100%;
  transition: background-color var(--t-hover);
}
.list > .row + .row, .list > * + .row { border-top: 1px solid var(--border); }
a.row:hover, button.row:hover, .row.is-interactive:hover { background: var(--hover); color: inherit; }
.row:focus-visible { border-radius: 0; box-shadow: inset var(--ring); }
.row-icon { width: 36px; height: 36px; flex: none; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-size: 14.5px; font-weight: 700; line-height: 1.3; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12.5px; color: var(--text-3); font-family: var(--font-mono); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { display: inline-flex; align-items: center; gap: 8px; flex: none; color: var(--text-3); }
.row.is-disabled { opacity: .6; }

/* ---------- Menu (dropdown) ---------- */
.menu {
  position: fixed; z-index: 70; min-width: 220px; max-width: min(340px, calc(100vw - 24px)); max-height: min(420px, calc(100vh - 24px)); overflow-y: auto;
  padding: 6px; display: flex; flex-direction: column; gap: 1px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-raised); animation: menuIn 180ms var(--ease) both; transform-origin: top left;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--text); font-size: 14px; font-weight: 600; text-align: left; white-space: nowrap; cursor: pointer;
}
.menu-item .ic { color: var(--text-3); }
.menu-item:hover, .menu-item:focus-visible, .menu-item.is-active { background: var(--surface-2); color: var(--text); box-shadow: none; }
.menu-item.is-danger, .menu-item.is-danger .ic { color: var(--danger); }
.menu-item .menu-hint { margin-left: auto; color: var(--text-3); font-family: var(--font-mono); font-size: 12px; font-weight: 500; }
.menu-item .menu-check { margin-left: auto; color: var(--accent); }
.menu-item[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.menu-sep { height: 1px; background: var(--border); margin: 5px -6px; }
.menu-label { padding: 8px 10px 4px; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); }

/* ---------- Overlays: modal and sheet ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 24px 16px; animation: fadeIn 220ms var(--ease) both; }
.overlay.is-closing { animation: fadeOut 180ms var(--ease) both; }
.modal {
  position: relative; width: 100%; max-width: 480px; max-height: calc(100vh - 48px); overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-modal); box-shadow: var(--shadow-raised); animation: scaleIn 320ms var(--ease) both;
}
.modal-lg { max-width: 720px; } .modal-sm { max-width: 400px; }
.overlay.is-closing .modal { animation: scaleOut 180ms var(--ease) both; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 24px 24px 0; }
.modal-title { flex: 1; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; }
.modal-sub { margin-top: 4px; font-size: 14px; color: var(--text-2); }
.modal-body { padding: 16px 24px 24px; color: var(--text-2); font-size: 14.5px; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 0 24px 24px; }
.modal-close { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--surface-2); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; transition: background-color var(--t-hover); }
.modal-close::before { content: ""; position: absolute; }
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-close:focus-visible { border-radius: 50%; }
.overlay.is-sheet { align-items: flex-end; padding: 0; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--surface);
  border-radius: var(--r-modal) var(--r-modal) 0 0; box-shadow: 0 -24px 60px -20px rgba(0, 0, 0, .45);
  padding-bottom: env(safe-area-inset-bottom); animation: sheetIn 420ms var(--ease) both;
}
.overlay.is-closing .sheet { animation: sheetOut 220ms var(--ease) both; }
.sheet-grab { display: flex; justify-content: center; padding-top: 10px; }
.sheet-grab::before { content: ""; width: 40px; height: 5px; border-radius: var(--r-pill); background: var(--border-strong); }
.sheet .modal-head { padding-top: 14px; }

/* ---------- Toasts and banner ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 10px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 12px; min-height: 52px; max-width: 100%; padding: 8px 16px 8px 10px;
  border-radius: 16px; background: var(--toast-bg); color: var(--toast-text); font-size: 14px; font-weight: 600; line-height: 1.4;
  box-shadow: 0 24px 48px -12px rgba(20, 18, 37, .45), inset 0 1px 0 rgba(255, 255, 255, .08);
  animation: toastIn 420ms var(--ease) both;
}
.toast.is-leaving { animation: toastOut 240ms var(--ease) both; }
.toast-mark { width: 36px; height: 36px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.toast-msg { min-width: 0; }
.toast-action { margin-left: 4px; min-height: 36px; padding: 0 10px; border-radius: var(--r-sm); color: #B9AEFF; font-weight: 700; font-size: 13.5px; }
.toast-action:hover { background: rgba(255, 255, 255, .08); }
.banner {
  position: fixed; z-index: 85; top: 12px; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 6px 16px 6px 8px; border-radius: var(--r-pill); background: var(--toast-bg); color: var(--toast-text);
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-raised); animation: bannerIn 420ms var(--ease) both; max-width: calc(100vw - 24px);
}
.banner.is-leaving { animation: bannerOut 240ms var(--ease) both; }

/* ---------- Skeleton, divider, kbd, table, empty ---------- */
.skeleton {
  display: block; border-radius: var(--r-sm); min-height: 12px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.skeleton-text { height: 12px; border-radius: 6px; }
.skeleton-title { height: 20px; width: 40%; border-radius: 8px; }
.skeleton-circle { border-radius: 50%; }
.divider { height: 1px; background: var(--border); margin: 0; width: 100%; }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.divider-label { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-family: var(--font-mono); font-size: 12px; }
.divider-label::before, .divider-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; background: var(--surface); color: var(--text-2); font-size: 11.5px; font-weight: 500; line-height: 1; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 12px 16px; font: 500 12px var(--font-mono); color: var(--text-3); border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--hover); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--t-hover); }
.table tbody tr:hover { background: var(--hover); }
.table .num, .table td.num { text-align: right; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 48px 24px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2); color: var(--text-3); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.empty-title { font-size: 17px; font-weight: 750; letter-spacing: -0.02em; color: var(--text); }
.empty-text { font-size: 14px; color: var(--text-2); max-width: 380px; }
.empty .cluster { margin-top: 8px; justify-content: center; }

/* ---------- Stat tile ---------- */
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-label { font: 500 12px var(--font-mono); color: var(--text-3); }
.stat-value { font: 600 28px var(--font-mono); letter-spacing: -0.02em; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; }

/* ---------- Country picker ---------- */
.flag { width: 20px; height: 20px; flex: none; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px rgba(20, 18, 37, .10); }
.flag-fb { width: 20px; height: 20px; flex: none; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font: 600 8px var(--font-mono); display: inline-flex; align-items: center; justify-content: center; }
.cc-btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; min-width: 44px; margin-left: 4px; padding: 0 8px; border-radius: var(--r-xs); color: var(--text); font: 500 13.5px var(--font-mono); flex: none; }
.cc-btn:hover { background: var(--surface-2); }
.cc-btn .ic { color: var(--text-3); }

/* ---------- Layout helpers ---------- */
.stack { display: flex; flex-direction: column; gap: var(--gap, 16px); min-width: 0; }
.stack-xs { --gap: 4px; } .stack-sm { --gap: 8px; } .stack-md { --gap: 16px; } .stack-lg { --gap: 24px; } .stack-xl { --gap: 32px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, 10px); min-width: 0; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--gap, 12px); min-width: 0; flex-wrap: wrap; }
.grid { display: grid; gap: var(--gap, 16px); grid-template-columns: repeat(auto-fit, minmax(min(var(--min, 280px), 100%), 1fr)); }
.grid-2 { --min: 360px; } .grid-3 { --min: 260px; } .grid-4 { --min: 200px; }
.grow { flex: 1; min-width: 0; }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); background: var(--bg); }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px 16px; background: var(--surface); border-right: 1px solid var(--border); scrollbar-width: thin;
}
.side-brand { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; min-height: 32px; }
.side-brand .brand-lockup .wordmark { font-size: 22px; }
.beta { font: 500 11px var(--font-mono); color: var(--text-3); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; }
.card-switch {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: var(--r-btn); background: var(--surface); color: var(--text); text-align: left; box-shadow: var(--shadow-xs);
  transition: border-color var(--t-hover), box-shadow var(--t-hover) var(--ease), transform var(--t-hover) var(--ease);
}
.card-switch:hover { border-color: var(--border-strong); box-shadow: var(--shadow-btn); transform: translateY(-1px); }
.card-switch:focus-visible { border-radius: var(--r-btn); }
.card-switch-icon { width: 28px; height: 28px; flex: none; border-radius: 8px; background: var(--primary-soft); color: var(--primary-soft-text); display: inline-flex; align-items: center; justify-content: center; }
.card-switch-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.card-switch-name { font-size: 13.5px; font-weight: 700; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-switch-meta { font: 500 11.5px var(--font-mono); color: var(--text-3); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-switch > .ic { color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 20px; }
.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font: 500 11.5px var(--font-mono); color: var(--text-3); padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 14px; font-weight: 500; transition: background-color var(--t-hover), color var(--t-hover);
}
.nav-item .ic { color: var(--text-3); transition: color var(--t-hover); }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 700; }
.nav-item[aria-current="page"] .ic { color: var(--accent); }
.nav-item .pill { margin-left: auto; height: 20px; font-size: 11px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.plan-card { display: block; border: 1px solid var(--border); border-radius: 16px; padding: 14px; background: var(--hover); color: inherit; transition: border-color var(--t-hover), transform var(--t-hover) var(--ease); }
a.plan-card:hover { border-color: var(--border-strong); color: inherit; transform: translateY(-1px); }
.plan-card-head { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.plan-card-head span { font: 500 12px var(--font-mono); color: var(--text-2); }
.plan-card p { margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.side-user {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 8px 6px; border-top: 1px solid var(--border);
  padding-top: 14px; color: var(--text); text-align: left; border-radius: 0; transition: background-color var(--t-hover);
}
.side-user:hover .side-user-name { color: var(--accent); }
.side-user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.side-user-name { font-size: 13.5px; font-weight: 700; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color var(--t-hover); }
.side-user-handle { font: 500 11.5px var(--font-mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user > .ic { color: var(--text-3); }
.topbar {
  display: none; position: sticky; top: 0; z-index: 40; height: var(--topbar-h); align-items: center; gap: 10px; padding: 0 12px 0 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand-lockup .wordmark { font-size: 20px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.main { min-width: 0; }
.page { max-width: 1180px; margin: 0 auto; padding: 36px 40px 80px; }
.page-narrow { max-width: 760px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-head .lede { margin-top: 10px; }
.crumbs { display: flex; align-items: center; gap: 8px; font: 500 12px var(--font-mono); color: var(--text-3); margin-bottom: 10px; }
.crumbs .sep { color: var(--border-strong); }
.mobile-nav { padding: 0; display: flex; flex-direction: column; gap: 16px; }
.mobile-nav .nav-item { min-height: 48px; font-size: 15px; }

@media (max-width: 899.98px) {
  .shell { display: block; }
  .side { display: none; }
  .topbar { display: flex; }
  .page { padding: 24px 16px 64px; }
  .page-head { margin-bottom: 20px; }
  .hide-mobile { display: none !important; }
  .toasts { bottom: 16px; }
  .modal-head { padding: 20px 20px 0; } .modal-body { padding: 14px 20px 20px; } .modal-foot { padding: 0 20px 20px; }
  .container { padding: 0 16px; }
}
@media (min-width: 900px) { .hide-desktop { display: none !important; } }

/* ---------- Splash (feedback.pageIntro) ---------- */
.splash { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; background: var(--bg); animation: fadeIn 200ms var(--ease) both; }
.splash.is-leaving { animation: splashOut 420ms var(--ease) both; }
.splash .wordmark { font-size: 28px; animation: fadeUp 700ms var(--ease) 400ms both; }
.splash-skip { position: absolute; right: 16px; bottom: 16px; }

/* ---------- Motion utilities ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes scaleOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(.97); } }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetOut { from { transform: none; } to { transform: translateY(100%); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes bannerOut { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -12px); } }
@keyframes splashOut { from { opacity: 1; } to { opacity: 0; transform: scale(1.02); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.fu { animation: fadeUp var(--t-enter) var(--ease) backwards; }
.si { animation: scaleIn 600ms var(--ease) backwards; }
.fi { animation: fadeIn 500ms var(--ease) backwards; }
.d1 { animation-delay: .04s; } .d2 { animation-delay: .10s; } .d3 { animation-delay: .16s; } .d4 { animation-delay: .22s; }
.d5 { animation-delay: .28s; } .d6 { animation-delay: .34s; } .d7 { animation-delay: .40s; } .d8 { animation-delay: .46s; } .d9 { animation-delay: .52s; }
.float { animation: float 6s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .skeleton { animation: none; }
}


/* Pro / Business badge (early access: features are free, the badge stays) */
.pill-pro{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px 0 6px;border-radius:999px;background:#EEEBFF;color:#4B3BD0;font-family:'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;font-weight:500;line-height:1;white-space:nowrap}
.pill-pro svg{width:12px;height:12px;flex:none}
[data-theme=dark] .pill-pro{background:rgba(139,123,255,.18);color:#C9C1FF}
