/* ==========================================================================
   Design system: tokens, base, components, studio layout.
   Two themes ("dark" = darkroom, "light" = lightbox) and six accent colours,
   switched with data-theme / data-accent on <html>.
   ========================================================================== */

/* ---- Typeface: Anek (Ek Type, OFL). Latin plus five Indian scripts that load
        only when a page contains text in that script. ---------------------- */
@font-face { font-family: "Anek"; src: url("../fonts/anek-latin.woff") format("woff"); font-weight: 300 800; font-stretch: 75% 125%; font-display: swap;
  unicode-range: U+0000-024F, U+0259, U+02BB-02BC, U+02C6-02DC, U+0300-036F, U+1E00-1EFF, U+2000-206F, U+2070-209F, U+20A0-20BF, U+2100-214F, U+2190-21FF, U+2200-22FF, U+25A0-25FF, U+FB00-FB06; }
@font-face { font-family: "Anek"; src: url("../fonts/anek-tamil.woff") format("woff"); font-weight: 400 700; font-display: swap; unicode-range: U+0B80-0BFF; }
@font-face { font-family: "Anek"; src: url("../fonts/anek-devanagari.woff") format("woff"); font-weight: 400 700; font-display: swap; unicode-range: U+0900-097F, U+A8E0-A8FF; }
@font-face { font-family: "Anek"; src: url("../fonts/anek-telugu.woff") format("woff"); font-weight: 400 700; font-display: swap; unicode-range: U+0C00-0C7F; }
@font-face { font-family: "Anek"; src: url("../fonts/anek-kannada.woff") format("woff"); font-weight: 400 700; font-display: swap; unicode-range: U+0C80-0CFF; }
@font-face { font-family: "Anek"; src: url("../fonts/anek-malayalam.woff") format("woff"); font-weight: 400 700; font-display: swap; unicode-range: U+0D00-0D7F; }

/* ---- Tokens ------------------------------------------------------------- */
:root {
  --font: "Anek", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --r-s: 6px;
  --r: 8px;
  --r-l: 12px;
  --sidebar-w: 264px;
  --control-h: 38px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1014;
  --surface: #15181e;
  --surface-2: #1b1f27;
  --surface-3: #242a35;
  --line: #272c37;
  --line-strong: #394150;
  --text: #eceef2;
  --text-2: #a9b0bd;
  --text-3: #7f8797;
  --success: #3ccb8c;
  --warning: #f0b341;
  --danger: #f2646b;
  --info: #62a2ff;
  --overlay: rgba(4, 6, 10, .72);
  --shadow: 0 18px 48px rgba(0, 0, 0, .55);
  --accent: #1fc2b7; --accent-ink: #03201e; --accent-text: #3fd6cb;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceff3;
  --line: #e1e5eb;
  --line-strong: #c5ccd7;
  --text: #141920;
  --text-2: #4b5565;
  --text-3: #6b7585;
  --success: #0f7d53;
  --warning: #8f5f00;
  --danger: #c7323a;
  --info: #1f5fd1;
  --overlay: rgba(20, 25, 32, .46);
  --shadow: 0 18px 48px rgba(20, 25, 32, .16);
  --accent: #0a8f87; --accent-ink: #ffffff; --accent-text: #087a73;
}

/* Accent colours. Each sets the fill, the text colour that sits on the fill,
   and a text-safe version for links on the page background. */
[data-theme="dark"][data-accent="peacock"] { --accent: #1fc2b7; --accent-ink: #03201e; --accent-text: #3fd6cb; }
[data-theme="light"][data-accent="peacock"] { --accent: #0a8f87; --accent-ink: #ffffff; --accent-text: #087a73; }
[data-theme="dark"][data-accent="rani"] { --accent: #f0569a; --accent-ink: #2a0716; --accent-text: #f779ae; }
[data-theme="light"][data-accent="rani"] { --accent: #c92a73; --accent-ink: #ffffff; --accent-text: #b7205f; }
[data-theme="dark"][data-accent="marigold"] { --accent: #f2b01e; --accent-ink: #261b00; --accent-text: #f5bf45; }
[data-theme="light"][data-accent="marigold"] { --accent: #e5a50a; --accent-ink: #261b00; --accent-text: #8a5d00; }
[data-theme="dark"][data-accent="indigo"] { --accent: #8b93ff; --accent-ink: #0d1033; --accent-text: #a3a9ff; }
[data-theme="light"][data-accent="indigo"] { --accent: #4f55e0; --accent-ink: #ffffff; --accent-text: #4349cf; }
[data-theme="dark"][data-accent="emerald"] { --accent: #34d399; --accent-ink: #052e1f; --accent-text: #55dcab; }
[data-theme="light"][data-accent="emerald"] { --accent: #0d8a5f; --accent-ink: #ffffff; --accent-text: #0a7650; }
[data-theme="dark"][data-accent="coral"] { --accent: #ff7a59; --accent-ink: #2e0d04; --accent-text: #ff9478; }
[data-theme="light"][data-accent="coral"] { --accent: #d94a26; --accent-ink: #ffffff; --accent-text: #c03d1c; }

:root {
  --accent-soft: rgba(127, 127, 127, .14);
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 45%, transparent);
  --danger-soft: color-mix(in srgb, var(--danger) 12%, transparent);
  --warning-soft: color-mix(in srgb, var(--warning) 13%, transparent);
  --success-soft: color-mix(in srgb, var(--success) 13%, transparent);
  --info-soft: color-mix(in srgb, var(--info) 13%, transparent);
}

/* ---- Base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font);
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--accent-ink); }
.icon { flex: none; }
.num, .table td.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .92em; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent-text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout helpers */
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: grid; gap: 16px; }
.stack-s { display: grid; gap: 8px; }
.stack-l { display: grid; gap: 24px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
@media (max-width: 980px) { .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: minmax(0, 1fr); } }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--control-h); padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface-2); color: var(--text);
  font-weight: 550; font-size: 14.5px; line-height: 1; white-space: nowrap;
  text-decoration: none; transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); border-color: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
[data-theme="dark"] .btn-danger { color: #2b0507; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #fff); }
.btn-danger-outline { background: transparent; border-color: color-mix(in srgb, var(--danger) 50%, transparent); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-soft); }
.btn-whatsapp { background: #1faa59; border-color: #1faa59; color: #fff; }
.btn-whatsapp:hover { background: #23b862; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13.5px; border-radius: var(--r-s); gap: 6px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15.5px; }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-text); font-weight: 550; }
.link-btn:hover { text-decoration: underline; }

/* ---- Forms -------------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 14px; font-weight: 550; color: var(--text); }
.label .req, .field > label .req { color: var(--danger); margin-left: 3px; }
.hint { font-size: 13px; color: var(--text-3); }
.field-error { font-size: 13px; color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: var(--control-h); padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r);
  color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 84px; padding: 9px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[disabled], .input[readonly], .select[disabled] { color: var(--text-3); background: var(--surface); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon > .input { padding-left: 36px; }
.input-group { display: flex; }
.input-group > .select, .input-group > .input-addon { width: auto; flex: none; border-radius: var(--r) 0 0 var(--r); border-right: 0; }
.input-group > .input { border-radius: 0 var(--r) var(--r) 0; }
.input-addon { display: inline-flex; align-items: center; height: var(--control-h); padding: 0 12px; background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--text-2); font-size: 14px; }
.input-sm { height: 30px; font-size: 13.5px; border-radius: var(--r-s); }

/* Toggle switch: <label class="switch"><input type="checkbox"><span></span></label> */
.switch { position: relative; display: inline-flex; flex: none; width: 38px; height: 22px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { width: 100%; height: 100%; border-radius: 999px; background: var(--line-strong); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s var(--ease); box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + span { opacity: .45; cursor: not-allowed; }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }

/* Number stepper: <div class="stepper"><button>-</button><output>2,500</output><button>+</button></div> */
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper button { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: var(--r-s); background: var(--surface-2); color: var(--text); }
.stepper button:hover { background: var(--surface-3); }
.stepper button[disabled] { opacity: .4; cursor: not-allowed; }
.stepper output { min-width: 76px; text-align: center; font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }

.range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--line-strong) var(--fill, 50%)); outline-offset: 6px; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); cursor: pointer; }
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); cursor: pointer; }

/* Setting row: label + hint on the left, a control on the right */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting-text strong { display: block; font-weight: 550; font-size: 14.5px; }
.setting-text span { display: block; font-size: 13px; color: var(--text-3); }
.setting.is-disabled .setting-text { opacity: .55; }

/* ---- Cards, sections ---------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-head h2, .card-head h3 { font-size: 17px; }
.card-head p { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.card-body { padding: 16px 20px 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.card-inset { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.card-danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: color-mix(in srgb, var(--danger) 5%, var(--surface)); }
.card-danger h2, .card-danger h3 { color: var(--danger); }
.section-title { font-size: 18px; }
.section-sub { color: var(--text-2); font-size: 14.5px; margin-top: 2px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 16px 0; }

/* Empty state */
.empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 48px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r-l); }
.empty.is-plain { border: 0; }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-3); margin-bottom: 8px; }
.empty-icon.is-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.empty h3 { font-size: 16px; }
.empty p { color: var(--text-2); font-size: 14px; max-width: 46ch; }
.empty .btn { margin-top: 10px; }

/* Banner / alert */
.alert { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2); font-size: 14.5px; }
.alert-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; }
.alert strong { display: block; }
.alert span { color: var(--text-2); font-size: 13.5px; }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.alert-warning .alert-icon { background: color-mix(in srgb, var(--warning) 22%, transparent); color: var(--warning); }
.alert-warning strong { color: var(--warning); }
.alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.alert-danger .alert-icon { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.alert-success .alert-icon { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.alert-info .alert-icon { background: color-mix(in srgb, var(--info) 20%, transparent); color: var(--info); }

/* ---- Badges, chips ------------------------------------------------------ */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge-live, .badge-success { background: var(--success-soft); color: var(--success); }
.badge-draft, .badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger, .badge-expired { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-outline { background: transparent; border: 1px solid var(--line-strong); color: var(--text-2); }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 13px; color: var(--text-2); white-space: nowrap; }
.pill strong { color: var(--text); font-weight: 600; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 600; }
.is-active > .count, .count.is-accent { background: var(--accent-soft); color: var(--accent-text); }
.kbd { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--text); }

/* ---- Tabs --------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--r); background: none; color: var(--text-2); font-weight: 550; font-size: 14.5px; white-space: nowrap; text-decoration: none; }
.tab:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.tab.is-active { color: var(--text); background: var(--surface-3); border-color: var(--line-strong); }
.tab.is-active .icon { color: var(--accent-text); }
.tabs-sm { display: inline-flex; border-radius: var(--r); }
.tabs-sm .tab { flex: none; height: 32px; padding: 0 12px; font-size: 13.5px; border-radius: var(--r-s); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.seg button, .seg a { height: 30px; padding: 0 12px; border: 0; border-radius: var(--r-s); background: none; color: var(--text-2); font-size: 13.5px; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.seg .is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.seg-block { display: flex; }
.seg-block > * { flex: 1; justify-content: center; }

/* ---- Tables ------------------------------------------------------------- */
.table-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--r-l); overflow-x: auto; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-weight: 600; font-size: 13.5px; color: var(--text-2); padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .actions { text-align: right; white-space: nowrap; }
.table th.num, .table td.num { text-align: right; }

/* Key/value list (plan limits and similar) */
.kv { display: grid; gap: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; font-size: 14.5px; }
.kv > div > span:first-child { color: var(--text-2); }
.kv > div > span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Stat tile */
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-height: 104px; display: flex; flex-direction: column; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 550; }
.stat-value { font-size: 26px; font-weight: 650; font-stretch: 112%; letter-spacing: -.01em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 12.5px; color: var(--text-3); margin-top: auto; padding-top: 4px; }
.stat.is-success { background: var(--success-soft); border-color: transparent; } .stat.is-success .stat-top { color: var(--success); }
.stat.is-warning { background: var(--warning-soft); border-color: transparent; } .stat.is-warning .stat-top { color: var(--warning); }
.stat.is-danger { background: var(--danger-soft); border-color: transparent; } .stat.is-danger .stat-top { color: var(--danger); }

/* Progress bar */
.bar { height: 6px; border-radius: 999px; background: var(--line-strong); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* Avatars */
.avatar-gen { border-radius: var(--r-s); flex: none; }
.avatar-gen.is-round { border-radius: 50%; }
.avatar-initial { display: inline-grid; place-items: center; flex: none; border-radius: var(--r-s); color: #fff; font-weight: 650; line-height: 1; }
.avatar-img { border-radius: var(--r-s); object-fit: cover; flex: none; }

/* ---- Modal, drawer ------------------------------------------------------ */
.modal { position: fixed; inset: 0; z-index: 60; display: none; align-items: flex-start; justify-content: center; padding: 6vh 16px 24px; background: var(--overlay); overflow-y: auto; }
.modal.is-open { display: flex; }
.modal-dialog { width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-l); box-shadow: var(--shadow); animation: pop .16s var(--ease); }
.modal-dialog.is-wide { max-width: 880px; }
.modal-dialog.is-mid { max-width: 660px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 0; }
.modal-head h2 { font-size: 19px; }
.modal-head p { color: var(--text-2); font-size: 14px; margin-top: 3px; }
.modal-close { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--r-s); background: none; color: var(--text-2); flex: none; }
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 18px 22px; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

.drawer { position: fixed; inset: 0; z-index: 60; display: none; background: var(--overlay); }
.drawer.is-open { display: block; }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(760px, 100%); background: var(--surface); border-left: 1px solid var(--line-strong); display: flex; flex-direction: column; animation: slide .2s var(--ease); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; display: grid; gap: 18px; align-content: start; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Dropdown menu: .menu-wrap > button[data-menu] + .menu */
.menu-wrap { position: relative; display: inline-block; }
.menu { position: absolute; z-index: 40; top: calc(100% + 6px); right: 0; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow); display: none; }
.menu.is-open { display: block; animation: pop .12s var(--ease); }
.menu.is-up { top: auto; bottom: calc(100% + 6px); }
.menu.is-left { right: auto; left: 0; }
.menu-label { padding: 6px 10px 4px; font-size: 12.5px; color: var(--text-3); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-s); background: none; color: var(--text); font-size: 14.5px; text-align: left; text-decoration: none; }
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item small { display: block; color: var(--text-3); font-size: 12.5px; }
.menu-item.is-danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }

/* Toasts */
.toasts { position: fixed; z-index: 90; right: 20px; bottom: 20px; display: grid; gap: 10px; max-width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); border-radius: var(--r); box-shadow: var(--shadow); font-size: 14.5px; animation: pop .18s var(--ease); }
.toast.is-error { border-left-color: var(--danger); }
.toast.is-success { border-left-color: var(--success); }

/* ---- Studio layout ------------------------------------------------------ */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { flex: none; color: var(--accent); }
.brand-mark img { height: 28px; width: auto; }
.brand-name { font-size: 18px; font-weight: 700; font-stretch: 112%; letter-spacing: -.01em; }
.brand-studio { margin-left: 2px; padding-left: 10px; border-left: 1px solid var(--line-strong); color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { flex: 1; overflow-y: auto; padding: 8px 10px 16px; }
.nav-label { padding: 16px 8px 6px; font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: var(--r-s); background: none; color: var(--text-2); font-size: 14.5px; font-weight: 500; text-decoration: none; text-align: left; }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.nav-item.is-active > .icon:first-child { color: var(--accent-text); }
.nav-item .chev { margin-left: auto; color: var(--text-3); transition: transform .15s; }
.nav-parent[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.nav-sub { margin: 2px 0 2px 18px; padding-left: 10px; border-left: 1px solid var(--line-strong); }
.nav-parent[aria-expanded="false"] + .nav-sub { display: none; }
.sidebar-tools { display: flex; gap: 4px; padding: 8px 12px; }
.tool-btn { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--r-s); background: none; color: var(--text-2); }
.tool-btn:hover { background: var(--surface-3); color: var(--text); }
.tool-dot { position: absolute; top: 5px; right: 5px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 15px; text-align: center; }
.user-card { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; }
.user-card:hover { background: var(--surface-2); }
.user-card .who { min-width: 0; flex: 1; }
.user-card .who strong { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .who span { display: block; font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu { left: 10px; right: 10px; bottom: 64px; top: auto; }
.notif-panel { position: absolute; left: 10px; bottom: 112px; width: 340px; max-width: calc(100vw - 20px); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-l); box-shadow: var(--shadow); display: none; z-index: 45; }
.notif-panel.is-open { display: block; animation: pop .14s var(--ease); }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item.is-unread strong::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.notif-item strong { display: block; font-size: 14px; font-weight: 600; }
.notif-item span { display: block; font-size: 13px; color: var(--text-2); }
.notif-item time { font-size: 12px; color: var(--text-3); }

.sidebar-scrim { display: none; }
.main { min-width: 0; }
.topbar { display: none; align-items: center; gap: 12px; height: 56px; padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.page { padding: 26px 28px 56px; max-width: 1480px; }
.page.is-narrow { max-width: 1180px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { display: flex; align-items: flex-start; gap: 12px; }
.page-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.page-title h1 { font-size: 27px; font-weight: 700; font-stretch: 112%; letter-spacing: -.015em; }
.page-title p { color: var(--text-2); margin-top: 2px; font-size: 15px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 14px; margin-bottom: 14px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input-icon { width: 240px; max-width: 100%; }
.toolbar .spacer { flex: 1; }
.impersonation { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 16px; background: var(--warning); color: #201500; font-size: 14px; font-weight: 550; }
.impersonation a { color: #201500; text-decoration: underline; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: min(var(--sidebar-w), 86vw); transform: translateX(-102%); transition: transform .2s var(--ease); }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow); }
  .topbar { display: flex; }
  .page { padding: 18px 16px 48px; }
  .page-title h1 { font-size: 23px; }
  .sidebar-scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 25; display: none; }
  .sidebar.is-open + .sidebar-scrim { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---- Auth pages --------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 520px); }
.auth-art { position: relative; overflow: hidden; background: var(--surface); border-right: 1px solid var(--line); padding: 44px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art h2 { font-size: clamp(30px, 3.6vw, 48px); font-weight: 700; font-stretch: 118%; letter-spacing: -.02em; line-height: 1.06; max-width: 13ch; }
.auth-art p { color: var(--text-2); max-width: 44ch; margin-top: 14px; font-size: 16px; }
.auth-side { display: flex; flex-direction: column; justify-content: center; padding: 40px clamp(20px, 5vw, 64px); }
.auth-form { width: 100%; max-width: 380px; margin: 0 auto; display: grid; gap: 16px; }
.auth-form h1 { font-size: 26px; font-weight: 700; font-stretch: 112%; }
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 13px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sheet { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; max-width: 520px; }
.sheet i { display: block; aspect-ratio: 3 / 2; border-radius: 4px; background: var(--surface-3); position: relative; }
.sheet i.is-picked { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: 2px; }
.sheet i.is-picked::after { content: ""; position: absolute; right: 5px; bottom: 5px; width: 12px; height: 7px; border-left: 2.5px solid var(--accent); border-bottom: 2.5px solid var(--accent); transform: rotate(-45deg); }
@media (max-width: 900px) { .auth { grid-template-columns: minmax(0, 1fr); } .auth-art { display: none; } }

/* ---- Charts (server-rendered SVG) --------------------------------------- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .bar-fill { fill: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* Sign-in with a WhatsApp code */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 14px; border: 1px solid var(--line); background: var(--surface-2); }
.notice svg { flex: none; margin-top: 2px; }
.notice-warning { border-color: #d99a1c; background: rgba(217, 154, 28, .12); }
.otp-input { font-size: 24px; letter-spacing: .45em; text-align: center; font-variant-numeric: tabular-nums; height: 52px; }
.link-btn:disabled { color: var(--text-3); cursor: default; text-decoration: none; }
