/* ==========================================================================
   AVC SMS · "Signal" design system
   Tokens → base → components. Shared by the public site, the client portal and
   the admin panel. Ink + Ceylon saffron on warm paper; a selected dark theme.
   ========================================================================== */

/* ---------- fonts (self-hosted: CSP font-src 'self') ---------- */
@font-face { font-family: "AVC Sans"; src: url("../fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "AVC Sans"; src: url("../fonts/noto-sinhala.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0964-0965, U+0D81-0DF4, U+1CF2, U+200C-200D, U+25CC, U+111E1-111F4; }
@font-face { font-family: "AVC Sans"; src: url("../fonts/noto-tamil.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0964-0965, U+0B82-0BFA, U+200C-200D, U+20B9, U+25CC; }
@font-face { font-family: "AVC Display"; src: url("../fonts/bricolage.woff2") format("woff2"); font-weight: 200 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "AVC Display"; src: url("../fonts/noto-sinhala.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0964-0965, U+0D81-0DF4, U+1CF2, U+200C-200D, U+25CC; }
@font-face { font-family: "AVC Display"; src: url("../fonts/noto-tamil.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0964-0965, U+0B82-0BFA, U+200C-200D, U+25CC; }
@font-face { font-family: "AVC Mono"; src: url("../fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --font-sans: "AVC Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", sans-serif;
  --font-display: "AVC Display", "AVC Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "AVC Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* surfaces */
  --bg: #f6f5f1;
  --bg-elev: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-3: #f2f0eb;
  --surface-inv: #16151a;
  --line: #e8e5de;
  --line-2: #dcd8cf;
  --line-strong: #c9c4b9;
  --overlay: rgba(22, 21, 26, .42);

  /* text */
  --text: #1b1a17;
  --text-2: #4a4842;
  --muted: #5f5c55;
  --faint: #716d65;
  --on-inv: #f4f2ee;

  /* brand */
  --ink: #17161b;
  --ink-hover: #2c2b32;
  --on-ink: #ffffff;
  --accent: #f26b1d;
  --accent-hover: #de5a0e;
  --accent-text: #b8430a;
  --accent-soft: #fff1e6;
  --accent-line: #fbd2b6;
  --on-accent: #1a0d04;
  --focus: #f26b1d;

  /* status (reserved: always with an icon or a word) */
  --ok: #15803d;   --ok-soft: #e9f6ee;   --ok-line: #bfe3cb;   --ok-dot: #22a35a;
  --warn: #a5560a; --warn-soft: #fdf3e2; --warn-line: #f2d6a6; --warn-dot: #e59a17;
  --bad: #b42318;  --bad-soft: #fdeceb;  --bad-line: #f5c4bf;  --bad-dot: #e2483b;
  --info: #1f5fbf; --info-soft: #ebf2fd; --info-line: #c4d8f6; --info-dot: #3a7be0;
  --neutral-soft: #f1efea; --neutral-line: #dfdbd2; --neutral-dot: #a29d92;
  --on-ok: #ffffff; --on-bad: #ffffff;

  /* charts (validated: dataviz validate_palette.js, light surface) */
  --series-1: #eb6834;
  --series-2: #2a78d6;
  --grid: #ece9e2;

  /* shape */
  --r-xs: 6px; --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px; --r-2xl: 26px; --r-pill: 999px;
  --sh-1: 0 1px 0 rgba(27, 26, 23, .04), 0 1px 2px rgba(27, 26, 23, .05);
  --sh-2: 0 1px 2px rgba(27, 26, 23, .06), 0 8px 24px -10px rgba(27, 26, 23, .14);
  --sh-3: 0 2px 6px rgba(27, 26, 23, .06), 0 18px 40px -12px rgba(27, 26, 23, .22);
  --sh-4: 0 24px 70px -18px rgba(27, 26, 23, .38), 0 2px 8px rgba(27, 26, 23, .08);
  --ring: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent);

  /* space (4px grid) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 28px; --s8: 32px; --s10: 40px; --s12: 48px; --s16: 64px; --s20: 80px; --s24: 96px;

  /* type scale */
  --t-2xs: 11px; --t-xs: 12px; --t-sm: 13px; --t-base: 14px; --t-md: 15px; --t-lg: 17px; --t-xl: 20px; --t-2xl: 24px; --t-3xl: 30px; --t-4xl: 38px; --t-5xl: 48px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur-1: 120ms; --dur-2: 200ms; --dur-3: 320ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f11; --bg-elev: #131316; --surface: #17171a; --surface-2: #1c1c20; --surface-3: #232328; --surface-inv: #26252c;
    --line: #2a2a2f; --line-2: #34343a; --line-strong: #46464d; --overlay: rgba(0, 0, 0, .6);
    --text: #f2f0ec; --text-2: #cfccc5; --muted: #a8a59d; --faint: #8a877f; --on-inv: #f2f0ec;
    --ink: #f2f0ec; --ink-hover: #ffffff; --on-ink: #141317;
    --accent: #ff7a2e; --accent-hover: #ff8e4d; --accent-text: #ff9a5f; --accent-soft: rgba(255, 122, 46, .12); --accent-line: rgba(255, 122, 46, .32); --on-accent: #1a0d04; --focus: #ff8a45;
    --ok: #5fd38e; --ok-soft: rgba(57, 196, 113, .12); --ok-line: rgba(57, 196, 113, .3); --ok-dot: #39c471;
    --warn: #f3b552; --warn-soft: rgba(240, 168, 50, .12); --warn-line: rgba(240, 168, 50, .3); --warn-dot: #f0a832;
    --bad: #ff8a80; --bad-soft: rgba(239, 83, 70, .13); --bad-line: rgba(239, 83, 70, .32); --bad-dot: #ef5346;
    --info: #8db8ff; --info-soft: rgba(84, 145, 245, .13); --info-line: rgba(84, 145, 245, .32); --info-dot: #5491f5;
    --neutral-soft: #222226; --neutral-line: #34343a; --neutral-dot: #85827b; --on-ok: #04170b; --on-bad: #1a0705;
    --series-1: #d95926; --series-2: #3987e5; --grid: #26262b;
    --sh-1: 0 0 0 1px rgba(255, 255, 255, .02); --sh-2: 0 10px 30px -12px rgba(0, 0, 0, .7); --sh-3: 0 20px 44px -12px rgba(0, 0, 0, .75); --sh-4: 0 30px 80px -20px rgba(0, 0, 0, .85);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f11; --bg-elev: #131316; --surface: #17171a; --surface-2: #1c1c20; --surface-3: #232328; --surface-inv: #26252c;
  --line: #2a2a2f; --line-2: #34343a; --line-strong: #46464d; --overlay: rgba(0, 0, 0, .6);
  --text: #f2f0ec; --text-2: #cfccc5; --muted: #a8a59d; --faint: #8a877f; --on-inv: #f2f0ec;
  --ink: #f2f0ec; --ink-hover: #ffffff; --on-ink: #141317;
  --accent: #ff7a2e; --accent-hover: #ff8e4d; --accent-text: #ff9a5f; --accent-soft: rgba(255, 122, 46, .12); --accent-line: rgba(255, 122, 46, .32); --on-accent: #1a0d04; --focus: #ff8a45;
  --ok: #5fd38e; --ok-soft: rgba(57, 196, 113, .12); --ok-line: rgba(57, 196, 113, .3); --ok-dot: #39c471;
  --warn: #f3b552; --warn-soft: rgba(240, 168, 50, .12); --warn-line: rgba(240, 168, 50, .3); --warn-dot: #f0a832;
  --bad: #ff8a80; --bad-soft: rgba(239, 83, 70, .13); --bad-line: rgba(239, 83, 70, .32); --bad-dot: #ef5346;
  --info: #8db8ff; --info-soft: rgba(84, 145, 245, .13); --info-line: rgba(84, 145, 245, .32); --info-dot: #5491f5;
  --neutral-soft: #222226; --neutral-line: #34343a; --neutral-dot: #85827b; --on-ok: #04170b; --on-bad: #1a0705;
  --series-1: #d95926; --series-2: #3987e5; --grid: #26262b;
  --sh-1: 0 0 0 1px rgba(255, 255, 255, .02); --sh-2: 0 10px 30px -12px rgba(0, 0, 0, .7); --sh-3: 0 20px 44px -12px rgba(0, 0, 0, .75); --sh-4: 0 30px 80px -20px rgba(0, 0, 0, .85);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: var(--font-sans); font-size: var(--t-base); line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-feature-settings: "cv11", "ss01"; text-rendering: optimizeLegibility; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 650; line-height: 1.2; letter-spacing: -.012em; color: var(--text); }
p { margin: 0 0 var(--s3); }
p:last-child { margin-bottom: 0; }
a { color: var(--accent-text); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
p a:not(.btn), .hint a, li a:not(.btn):not([class]), .page-sub a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
img, svg, video, canvas { display: block; max-width: 100%; }
svg { flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: .92em; }
code { background: var(--surface-3); border: 1px solid var(--line); border-radius: 5px; padding: .08em .38em; color: var(--text); word-break: break-word; }
pre code { background: none; border: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s5) 0; }
ul, ol { padding-left: 1.2rem; margin: 0 0 var(--s3); }
table { border-collapse: collapse; }
::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.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; }
.skip-link { position: absolute; left: var(--s3); top: -60px; z-index: 2000; background: var(--ink); color: var(--on-ink); padding: var(--s2) var(--s4); border-radius: var(--r-sm); font-weight: 600; transition: top var(--dur-2); }
.skip-link:focus { top: var(--s3); text-decoration: none; }

/* icons (Lucide sprite) */
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; display: inline-block; }
.i-xs { width: 14px; height: 14px; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 22px; height: 22px; }
.i-xl { width: 28px; height: 28px; stroke-width: 1.6; }

/* ---------- utilities (deliberately small) ---------- */
.muted { color: var(--muted) !important; }
.faint { color: var(--faint) !important; }
.text-2 { color: var(--text-2); }
.t-ok { color: var(--ok) !important; } .t-bad { color: var(--bad) !important; } .t-warn { color: var(--warn) !important; } .t-accent { color: var(--accent-text) !important; }
.small { font-size: var(--t-sm); }
.xsmall { font-size: var(--t-xs); }
.strong { font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: .9em; letter-spacing: -.01em; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prewrap { white-space: pre-wrap; word-break: break-word; }
.break { word-break: break-all; }
.right { text-align: right; } .center { text-align: center; }
.upper { text-transform: uppercase; }
.upper::placeholder { text-transform: none; letter-spacing: normal; }
.w-full { width: 100%; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: var(--s1); } .mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); } .mt-4 { margin-top: var(--s4); } .mt-5 { margin-top: var(--s5); } .mt-6 { margin-top: var(--s6); } .mt-8 { margin-top: var(--s8); }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: var(--s1); } .mb-2 { margin-bottom: var(--s2); } .mb-3 { margin-bottom: var(--s3); } .mb-4 { margin-bottom: var(--s4); } .mb-5 { margin-bottom: var(--s5); } .mb-6 { margin-bottom: var(--s6); }
.ml-auto { margin-left: auto; }
.stack { display: flex; flex-direction: column; gap: var(--gap, var(--s4)); }
.stack-sm { --gap: var(--s2); } .stack-lg { --gap: var(--s6); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--s2)); }
.cluster-lg { --gap: var(--s4); }
.split { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: var(--gap, var(--s4)); }
.grid-2 { display: grid; gap: var(--gap, var(--s4)); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--gap, var(--s4)); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: var(--gap, var(--s4)); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { display: grid; gap: var(--gap, var(--s4)); grid-template-columns: repeat(auto-fit, minmax(var(--min, 200px), 1fr)); }
.span-2 { grid-column: span 2; } .span-all { grid-column: 1 / -1; }
.cols-main-aside { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); align-items: start; }
.cols-aside-main { display: grid; gap: var(--s5); grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); align-items: start; }
.cols-even { display: grid; gap: var(--s5); grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.cols-aside-main.wide-aside { grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); }
.cols-even.lean-left { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.cols-even.lean-right { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); }
.sticky { position: sticky; top: calc(var(--topbar-h, 0px) + var(--s4)); }
@media (max-width: 1100px) { .cols-main-aside, .cols-aside-main, .cols-aside-main.wide-aside { grid-template-columns: minmax(0, 1fr); } .sticky { position: static; } }
@media (max-width: 860px) { .cols-even.lean-left, .cols-even.lean-right { grid-template-columns: minmax(0, 1fr); } .cols-even, .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3.collapse-1 { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid-2, .cols-even, .grid-3 { grid-template-columns: minmax(0, 1fr); } .span-2 { grid-column: auto; } }

/* ---------- buttons ---------- */
.btn { --b-bg: var(--surface); --b-fg: var(--text); --b-bd: var(--line-2); --b-bg-h: var(--surface-2); --b-bd-h: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: 38px; padding: 0 var(--s4); border-radius: var(--r-md);
  font-size: var(--t-base); font-weight: 600; letter-spacing: -.005em; line-height: 1; white-space: nowrap; text-decoration: none !important; user-select: none;
  background: var(--b-bg); color: var(--b-fg); border: 1px solid var(--b-bd); box-shadow: var(--sh-1);
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1), transform var(--dur-1) var(--ease), box-shadow var(--dur-2); }
.btn:hover { background: var(--b-bg-h); border-color: var(--b-bd-h); color: var(--b-fg); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; box-shadow: none; }
.btn .i { width: 16px; height: 16px; margin: 0 -2px; }
.btn-primary { --b-bg: var(--ink); --b-fg: var(--on-ink); --b-bd: var(--ink); --b-bg-h: var(--ink-hover); --b-bd-h: var(--ink-hover); box-shadow: 0 1px 2px rgba(0,0,0,.16), inset 0 1px 0 rgba(255,255,255,.08); }
.btn-accent { --b-bg: var(--accent); --b-fg: var(--on-accent); --b-bd: var(--accent); --b-bg-h: var(--accent-hover); --b-bd-h: var(--accent-hover); box-shadow: 0 1px 2px rgba(180,60,0,.25), 0 6px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent), inset 0 1px 0 rgba(255,255,255,.25); font-weight: 650; }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; --b-bg-h: var(--surface-3); --b-bd-h: transparent; box-shadow: none; }
.btn-soft { --b-bg: var(--accent-soft); --b-fg: var(--accent-text); --b-bd: var(--accent-line); --b-bg-h: color-mix(in srgb, var(--accent-soft) 60%, var(--accent-line)); --b-bd-h: var(--accent-line); box-shadow: none; }
.btn-danger { --b-bg: var(--bad); --b-fg: var(--on-bad); --b-bd: var(--bad); --b-bg-h: color-mix(in srgb, var(--bad) 88%, #000); --b-bd-h: transparent; }
.btn-danger-soft { --b-bg: transparent; --b-fg: var(--bad); --b-bd: var(--bad-line); --b-bg-h: var(--bad-soft); --b-bd-h: var(--bad-line); box-shadow: none; }
.btn-ok { --b-bg: var(--ok); --b-fg: var(--on-ok); --b-bd: var(--ok); --b-bg-h: color-mix(in srgb, var(--ok) 88%, #000); --b-bd-h: transparent; }
.btn-link { background: none; border: 0; box-shadow: none; height: auto; padding: 0; color: var(--accent-text); font-weight: 600; }
.btn-link:hover { background: none; text-decoration: underline !important; color: var(--accent-text); }
.btn-link.danger { color: var(--bad); }
.btn-sm { height: 32px; padding: 0 var(--s3); font-size: var(--t-sm); border-radius: var(--r-sm); gap: 6px; }
.btn-xs { height: 26px; padding: 0 var(--s2); font-size: var(--t-xs); border-radius: var(--r-xs); gap: 4px; }
.btn-xs .i { width: 14px; height: 14px; }
.btn-lg { height: 46px; padding: 0 var(--s6); font-size: var(--t-md); border-radius: var(--r-lg); }
.btn-xl { height: 54px; padding: 0 var(--s8); font-size: var(--t-lg); border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; } .btn-icon.btn-xs { width: 26px; }
.btn.is-loading { pointer-events: none; color: transparent !important; position: relative; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--b-fg); border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; margin-left: -1px; }
.btn-group > .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); margin-left: 0; }
.btn-group > .btn:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.inline-form { display: inline-flex; margin: 0; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: var(--t-sm); font-weight: 600; color: var(--text-2); display: flex; align-items: baseline; gap: var(--s2); }
.label .opt { font-weight: 450; color: var(--faint); font-size: var(--t-xs); }
.label.req::after { content: "Required"; margin-left: auto; font-size: var(--t-2xs); font-weight: 600; color: var(--faint); letter-spacing: .02em; }
.hint { font-size: var(--t-xs); color: var(--muted); line-height: 1.5; }
.hint.err, .field-error { color: var(--bad); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font-size: var(--t-base); line-height: 1.4; box-shadow: inset 0 1px 1px rgba(27, 26, 23, .03);
  transition: border-color var(--dur-1), box-shadow var(--dur-2), background var(--dur-1); appearance: none; -webkit-appearance: none; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--focus); box-shadow: var(--ring); outline: none; }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.input[readonly] { background: var(--surface-2); }
.is-invalid, .input:user-invalid, .textarea:user-invalid { border-color: var(--bad) !important; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.textarea.mono, .input.mono { font-family: var(--font-mono); font-size: 13px; }
.select { padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a867c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m7 15 5 5 5-5M7 9l5-5 5 5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 15px; cursor: pointer; }
.input-sm, .select.input-sm { min-height: 32px; padding: 5px 10px; font-size: var(--t-sm); border-radius: var(--r-sm); }
.select.input-sm { padding-right: 30px; background-position: right 8px center; }
.input[type="file"] { padding: 6px; cursor: pointer; }
.input[type="file"]::file-selector-button { border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); border-radius: var(--r-sm); padding: 6px 12px; margin-right: 10px; font-weight: 600; font-size: var(--t-sm); cursor: pointer; }
.input[type="date"], .input[type="datetime-local"] { min-height: 40px; }
.input-wrap { position: relative; }
.input-wrap > .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-wrap > .input { padding-left: 38px; }
.input-wrap > .input-action { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-group { display: flex; align-items: stretch; }
.input-group > .addon { display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: var(--t-sm); }
.input-group > .addon:first-child { border-radius: var(--r-md) 0 0 var(--r-md); border-right: 0; }
.input-group > .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; height: auto; }
.form-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.g3-add { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 8px; }
@media (max-width: 640px) { .form-grid, .form-grid.g3, .form-grid.g3-add { grid-template-columns: minmax(0, 1fr); } }
.form-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; padding-top: var(--s2); }
.honeypot { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }

/* checkbox / radio / switch */
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--t-base); line-height: 1.4; user-select: none; }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px; margin: 1px 0 0; border: 1.5px solid var(--line-strong); border-radius: 5px; background: var(--surface); display: grid; place-items: center; transition: background var(--dur-1), border-color var(--dur-1), box-shadow var(--dur-2); cursor: pointer; }
.check input[type="radio"] { border-radius: 50%; }
.check input::after { content: ""; width: 10px; height: 10px; transform: scale(0); transition: transform var(--dur-1) var(--ease-out); background: var(--on-ink); clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 37% 70%); }
.check input[type="radio"]::after { clip-path: circle(50%); width: 8px; height: 8px; }
.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after { transform: scale(1); }
.check input:focus-visible { box-shadow: var(--ring); outline: none; }
.check .sub { display: block; color: var(--muted); font-size: var(--t-xs); margin-top: 2px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { appearance: none; -webkit-appearance: none; width: 36px; height: 20px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background var(--dur-2); cursor: pointer; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--dur-2) var(--ease-out); }
.switch input:checked { background: var(--ok-dot); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { box-shadow: var(--ring); outline: none; }

/* segmented control (radio group) */
.seg { display: inline-flex; align-self: flex-start; padding: 3px; gap: 2px; background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-md); }
.seg label { position: relative; margin: 0; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.seg span { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 var(--s3); border-radius: 7px; font-size: var(--t-sm); font-weight: 600; color: var(--muted); transition: background var(--dur-1), color var(--dur-1), box-shadow var(--dur-1); white-space: nowrap; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--sh-1), 0 0 0 1px var(--line); }
.seg input:focus-visible + span { box-shadow: var(--ring); }
.seg.seg-block { display: flex; } .seg.seg-block label { flex: 1; } .seg.seg-block span { width: 100%; justify-content: center; }

/* selectable cards (radio/checkbox) */
.option-card { position: relative; display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); cursor: pointer; transition: border-color var(--dur-1), background var(--dur-1), box-shadow var(--dur-2); }
.option-card:hover { border-color: var(--line-strong); }
.option-card:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); background: var(--surface-2); }
.option-card:has(input:focus-visible) { box-shadow: var(--ring); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--sh-1); min-width: 0; }
.card-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); min-height: 56px; }
.card-head.flat { border-bottom: 0; padding-bottom: 0; min-height: 0; }
.card-title { font-size: var(--t-md); font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: var(--s2); margin: 0; }
.card-title .i { color: var(--muted); }
.card-sub { font-size: var(--t-sm); color: var(--muted); margin: 2px 0 0; }
.card-head .actions { margin-left: auto; display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.card-body { padding: var(--s5); }
.card-body.tight { padding: var(--s4); }
.card-foot { padding: var(--s3) var(--s5); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); font-size: var(--t-sm); color: var(--muted); display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.card-link { display: inline-flex; align-items: center; gap: 4px; font-size: var(--t-sm); font-weight: 600; }
.card.is-hover { transition: border-color var(--dur-2), box-shadow var(--dur-2), transform var(--dur-2) var(--ease); }
.card.is-hover:hover { border-color: var(--line-2); box-shadow: var(--sh-2); transform: translateY(-1px); }
.card-inset { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4); }
.divide > * + * { border-top: 1px solid var(--line); }

/* list rows inside cards */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s5); border-top: 1px solid var(--line); min-height: 52px; }
.list > li:first-child { border-top: 0; }
.list .grow { min-width: 0; }
.list .title { font-weight: 600; }
.list .meta { font-size: var(--t-xs); color: var(--muted); }
.list a.row-link { color: inherit; display: flex; align-items: center; gap: var(--s3); width: 100%; text-decoration: none; }
.list > li.is-active, .list a.is-active { background: var(--surface-2); }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.table { width: 100%; font-size: var(--t-sm); color: var(--text); }
.table th { text-align: left; font-size: var(--t-2xs); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px var(--s4); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table td { padding: 12px var(--s4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: var(--s5); }
.table th:last-child, .table td:last-child { padding-right: var(--s5); }
.table tbody tr { transition: background var(--dur-1); }
.table.hover tbody tr:hover { background: var(--surface-2); }
.table .cell-title { font-weight: 600; color: var(--text); }
.table a.cell-title:hover { color: var(--accent-text); }
.table .cell-sub { display: block; font-size: var(--t-xs); color: var(--muted); margin-top: 1px; font-weight: 400; }
.table .cell-msg { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.table .actions-cell { text-align: right; white-space: nowrap; }
.table.compact td { padding-top: 8px; padding-bottom: 8px; }
.table tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--line); }
.table .empty-row td { text-align: center; color: var(--muted); padding: var(--s10) var(--s4); }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--r-xl); }
.card > .table-wrap:first-child .table th:last-child { border-top-right-radius: var(--r-xl); }
.id-link { color: var(--muted); font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: var(--t-xs); }
/* stacked cards on phones (labels filled in by ui.js from the header row) */
@media (max-width: 720px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack td { border: 0; padding: 3px 0 !important; display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); text-align: right; }
  .table-stack td::before { content: attr(data-label); font-size: var(--t-xs); font-weight: 600; color: var(--muted); text-align: left; flex: none; }
  .table-stack td[data-label=""]::before { content: none; }
  .table-stack td.num { white-space: normal; }
  .table-stack td.cell-primary { font-size: var(--t-base); text-align: left; padding-bottom: 6px !important; }
  .table-stack td.cell-primary::before { content: none; }
  .table-stack td.actions-cell { justify-content: flex-end; padding-top: var(--s2) !important; }
  .table-stack .cell-msg { max-width: 62vw; }
  .table-stack .empty-row td { display: block; text-align: center; }
  .table-stack .empty-row td::before { content: none; }
}

/* ---------- badges & tags ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 8px; border-radius: var(--r-pill); font-size: var(--t-xs); font-weight: 600; line-height: 1; white-space: nowrap; border: 1px solid var(--neutral-line); background: var(--neutral-soft); color: var(--text-2); letter-spacing: -.003em; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--neutral-dot); flex: none; }
.badge.b-ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); } .badge.b-ok::before { background: var(--ok-dot); }
.badge.b-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); } .badge.b-warn::before { background: var(--warn-dot); }
.badge.b-bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); } .badge.b-bad::before { background: var(--bad-dot); }
.badge.b-info { background: var(--info-soft); border-color: var(--info-line); color: var(--info); } .badge.b-info::before { background: var(--info-dot); }
.badge.b-live::before { animation: pulse-dot 1.6s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 40%, transparent); } 50% { box-shadow: 0 0 0 4px transparent; } }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px; font-size: var(--t-2xs); font-weight: 650; letter-spacing: .02em; text-transform: uppercase; background: var(--surface-3); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.tag.accent { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.tag.ink { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface); font-size: var(--t-sm); font-weight: 550; color: var(--text-2); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; font-size: var(--t-2xs); font-weight: 700; background: var(--accent); color: var(--on-accent); font-variant-numeric: tabular-nums; }
.kbd, kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--surface); font-size: 11px; font-family: var(--font-sans); font-weight: 600; color: var(--muted); }

/* ---------- alerts ---------- */
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-lg); border: 1px solid var(--line-2); background: var(--surface); font-size: var(--t-sm); line-height: 1.5; color: var(--text); }
.alert > .i { margin-top: 1px; flex: none; }
.alert .alert-body { flex: 1; min-width: 0; }
.alert .alert-title { font-weight: 650; display: block; margin-bottom: 2px; }
.alert .alert-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-left: auto; }
.alert a:not(.btn) { color: inherit; font-weight: 650; text-decoration: underline; }
.alert-info { background: var(--info-soft); border-color: var(--info-line); } .alert-info > .i { color: var(--info); }
.alert-ok, .alert-success { background: var(--ok-soft); border-color: var(--ok-line); } .alert-ok > .i, .alert-success > .i { color: var(--ok); }
.alert-warn, .alert-warning { background: var(--warn-soft); border-color: var(--warn-line); } .alert-warn > .i, .alert-warning > .i { color: var(--warn); }
.alert-bad, .alert-danger { background: var(--bad-soft); border-color: var(--bad-line); } .alert-bad > .i, .alert-danger > .i { color: var(--bad); }
.alert-accent { background: var(--accent-soft); border-color: var(--accent-line); } .alert-accent > .i { color: var(--accent-text); }
.alerts { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s5); }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 1500; right: var(--s5); bottom: var(--s5); display: flex; flex-direction: column; gap: var(--s2); width: min(400px, calc(100vw - 32px)); pointer-events: none; }
.toast { border: 1px solid color-mix(in srgb, var(--on-inv) 10%, transparent); pointer-events: auto; display: flex; gap: var(--s3); align-items: flex-start; padding: 12px 12px 12px 14px; border-radius: var(--r-lg); background: var(--surface-inv); color: var(--on-inv); box-shadow: var(--sh-4); font-size: var(--t-sm); line-height: 1.45; animation: toast-in var(--dur-3) var(--ease-out) both; position: relative; overflow: hidden; }
.toast > .i { margin-top: 1px; flex: none; }
.toast.t-success > .i { color: #4ade80; } .toast.t-danger > .i { color: #ff7b72; } .toast.t-warning > .i { color: #fbbf24; } .toast.t-info > .i { color: #7cb1ff; }
.toast .toast-msg { flex: 1; min-width: 0; padding-top: 1px; }
.toast .toast-x { flex: none; width: 26px; height: 26px; border: 0; border-radius: 7px; background: transparent; color: inherit; opacity: .6; display: grid; place-items: center; margin: -3px -3px 0 0; }
.toast .toast-x:hover { opacity: 1; background: color-mix(in srgb, var(--on-inv) 12%, transparent); }
.toast .toast-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); animation: toast-bar linear forwards; transform-origin: left; }
.toast.is-leaving { animation: toast-out var(--dur-2) var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 640px) { .toasts { left: 16px; right: 16px; bottom: 16px; width: auto; } }

/* ---------- dialogs & drawers ---------- */
.dialog { border: 0; padding: 0; margin: auto; width: min(540px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); background: var(--surface); color: var(--text); border-radius: var(--r-2xl); box-shadow: var(--sh-4); overflow: hidden; }
.dialog.dialog-sm { width: min(420px, calc(100vw - 32px)); }
.dialog::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
.dialog[open] { animation: dialog-in var(--dur-3) var(--ease-out); display: flex; flex-direction: column; }
.dialog[open]::backdrop { animation: fade-in var(--dur-2) ease; }
.dialog-head { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s5) var(--s6) var(--s3); }
.dialog-title { font-size: var(--t-lg); font-weight: 650; letter-spacing: -.015em; }
.dialog-head .btn-icon { margin: -6px -10px 0 auto; }
.dialog-body { padding: var(--s2) var(--s6) var(--s5); overflow-y: auto; color: var(--text-2); }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s6); background: var(--surface-2); border-top: 1px solid var(--line); flex-wrap: wrap; }
.dialog-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); flex: none; }
.dialog-icon.bad { background: var(--bad-soft); color: var(--bad); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 640px) {
  .dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-2xl) var(--r-2xl) 0 0; max-height: 92dvh; }
  .dialog[open] { animation: sheet-in var(--dur-3) var(--ease-out); }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
}

/* ---------- menus (dropdowns) ---------- */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 1200; min-width: 240px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3); transform-origin: top right; animation: menu-in var(--dur-2) var(--ease-out); }
.menu[hidden] { display: none; }
.menu-head { padding: var(--s2) var(--s3) var(--s3); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head .strong { display: block; }
.menu a, .menu button.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: transparent; color: var(--text); font-size: var(--t-sm); font-weight: 500; text-align: left; text-decoration: none; }
.menu a:hover, .menu button.menu-item:hover, .menu a:focus-visible, .menu button.menu-item:focus-visible { background: var(--surface-3); outline: none; text-decoration: none; }
.menu .i { color: var(--muted); width: 16px; height: 16px; }
.menu .danger, .menu .danger .i { color: var(--bad); }
.menu hr { margin: 4px 0; }
.menu form { margin: 0; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- tooltips (CSS only) ---------- */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); background: var(--surface-inv); color: var(--on-inv); font-size: var(--t-xs); font-weight: 550; line-height: 1.35; padding: 6px 9px; border-radius: 7px; white-space: nowrap; max-width: 260px; pointer-events: none; z-index: 1300; box-shadow: var(--sh-2); display: none; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { display: block; animation: tip-in var(--dur-2) var(--ease-out) 250ms both; }
.topbar [data-tip]::after, .mk-header [data-tip]::after, .auth-top [data-tip]::after { bottom: auto; top: calc(100% + 8px); }
.topbar-actions [data-tip]::after, .mk-cta [data-tip]::after, .auth-top [data-tip]::after { left: auto; right: 0; transform: none; }
@keyframes tip-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; gap: var(--s4); grid-template-columns: repeat(var(--kpi-cols, 4), minmax(0, 1fr)); }
.kpis.k3 { --kpi-cols: 3; } .kpis.k5 { --kpi-cols: 5; } .kpis.k6 { --kpi-cols: 6; }
@media (max-width: 1200px) { .kpis.k6, .kpis.k5 { --kpi-cols: 3; } }
@media (max-width: 980px) {
  .kpis { --kpi-cols: 2 !important; }
  .kpis > .kpi.is-accent:first-child, .kpis:has(> .kpi.is-accent:first-child) > .kpi:last-child:nth-child(even) { grid-column: 1 / -1; }
}
@media (max-width: 420px) { .kpis { gap: var(--s3); } }
.kpi { position: relative; display: flex; flex-direction: column; gap: 6px; padding: var(--s4) var(--s5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--sh-1); min-width: 0; color: inherit; text-decoration: none !important; overflow: hidden; }
a.kpi { transition: border-color var(--dur-2), box-shadow var(--dur-2), transform var(--dur-2) var(--ease); }
a.kpi:hover { border-color: var(--line-2); box-shadow: var(--sh-2); transform: translateY(-1px); }
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: var(--t-sm); font-weight: 550; color: var(--muted); }
.kpi-label .i { width: 16px; height: 16px; }
.kpi-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); margin-left: auto; flex: none; }
.kpi-ico .i { width: 16px; height: 16px; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.025em; line-height: 1.1; color: var(--text); overflow-wrap: anywhere; }
.kpi-value small { font-size: 14px; font-weight: 550; color: var(--muted); letter-spacing: 0; }
.kpi-meta { font-size: var(--t-xs); color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.kpi .progress { margin-top: 4px; }
.kpi.is-ink { background: var(--surface-inv); border-color: var(--surface-inv); color: var(--on-inv); }
.kpi.is-ink .kpi-label, .kpi.is-ink .kpi-meta { color: color-mix(in srgb, var(--on-inv) 66%, transparent); }
.kpi.is-ink .kpi-value { color: var(--on-inv); }
.kpi.is-ink .kpi-value small, .kpi.is-accent .kpi-value small { color: inherit; opacity: .8; }
.kpi.is-ink .kpi-ico { background: color-mix(in srgb, var(--on-inv) 10%, transparent); color: var(--on-inv); }
.kpi.is-accent { background: linear-gradient(150deg, #ff8a3d 0%, var(--accent) 55%, #e8600f 100%); border-color: transparent; color: #1a0d04; box-shadow: 0 10px 30px -14px rgba(226, 85, 12, .8); }
.kpi.is-accent .kpi-label, .kpi.is-accent .kpi-meta { color: rgba(26,13,4,.78); }
.kpi.is-accent .kpi-value { color: #1a0d04; }
.kpi.is-accent .kpi-ico { background: rgba(255,255,255,.28); color: #1a0d04; }
.kpi.is-accent a { color: #1a0d04 !important; }
.kpi.is-accent::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,255,255,.18), transparent); pointer-events: none; }
.val-ok { color: var(--ok) !important; } .val-bad { color: var(--bad) !important; }

/* progress & meters */
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: flex; }
.progress > span { display: block; height: 100%; background: var(--ink); border-radius: 99px; transition: width var(--dur-3) var(--ease-out); }
.progress.split-bar > span { border-radius: 0; }
.progress.split-bar > span + span { margin-left: 2px; }
.progress .ok { background: var(--ok-dot); } .progress .bad { background: var(--bad-dot); } .progress .warn { background: var(--warn-dot); } .progress .accent { background: var(--accent); } .progress .info { background: var(--info-dot); }
.kpi.is-accent .progress, .kpi.is-ink .progress { background: rgba(255,255,255,.2); }
.kpi.is-accent .progress > span { background: #1a0d04; }

/* ---------- empty states ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s2); padding: var(--s12) var(--s6); color: var(--muted); }
.empty-ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); margin-bottom: var(--s2); box-shadow: inset 0 0 0 1px var(--line); }
.empty-ico .i { width: 24px; height: 24px; }
.empty h3, .empty .empty-title { font-size: var(--t-md); font-weight: 650; color: var(--text); }
.empty p { max-width: 380px; font-size: var(--t-sm); margin: 0; }
.empty .btn { margin-top: var(--s3); }
.empty.sm { padding: var(--s8) var(--s4); }

/* ---------- skeletons ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 6px; min-height: 12px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- definition lists ---------- */
.kv { display: grid; grid-template-columns: minmax(110px, 34%) minmax(0, 1fr); gap: 0; margin: 0; font-size: var(--t-sm); }
.kv dt, .kv dd { padding: 10px 0; border-top: 1px solid var(--line); margin: 0; }
.kv dt:first-of-type, .kv dt:first-of-type + dd { border-top: 0; }
.kv dt { color: var(--muted); font-weight: 500; padding-right: var(--s3); }
.kv dd { color: var(--text); word-break: break-word; }
@media (max-width: 480px) { .kv { grid-template-columns: minmax(0, 1fr); } .kv dd { border-top: 0; padding-top: 0; } }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 10px 12px; font-size: var(--t-sm); font-weight: 600; color: var(--muted); background: none; border: 0; white-space: nowrap; text-decoration: none; }
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs .is-active, .tabs [aria-selected="true"] { color: var(--text); }
.tabs .is-active::after, .tabs [aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.pills { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.pills a { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 99px; font-size: var(--t-sm); font-weight: 600; color: var(--muted); border: 1px solid transparent; text-decoration: none; }
.pills a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.pills a.is-active { background: var(--surface); border-color: var(--line-2); color: var(--text); box-shadow: var(--sh-1); }

/* ---------- code ---------- */
.code { position: relative; margin: 0; background: #121216; color: #e6e3dc; border-radius: var(--r-lg); padding: var(--s4) var(--s5); font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7; overflow: auto; border: 1px solid #25252b; tab-size: 2; scrollbar-width: thin; scrollbar-color: #3a3a42 transparent; }
.code .t-c { color: #959189; font-style: italic; } .code .t-k { color: #ff9b5e; } .code .t-s { color: #9fd9a3; } .code .t-n { color: #f7c86b; } .code .t-p { color: #8ec2ff; } .code .t-f { color: #e7b6ff; } .code .t-m { color: #ff9b5e; font-weight: 700; }
.code-block { position: relative; }
.code-block .copy-btn { position: absolute; top: 8px; right: 8px; opacity: .0; transition: opacity var(--dur-2); }
.code-block:hover .copy-btn, .code-block:focus-within .copy-btn, .code-block .copy-btn.is-done { opacity: 1; }
@media (hover: none) { .code-block .copy-btn { opacity: 1; } }
.copy-btn { height: 28px; padding: 0 10px; border-radius: 7px; border: 1px solid #34343b; background: #1d1d23; color: #d9d6cf; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.copy-btn:hover { background: #2a2a31; }
.copy-btn .i { width: 14px; height: 14px; }
.endpoint { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px 4px 4px; color: var(--text); }
.method { display: inline-grid; place-items: center; height: 22px; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 750; letter-spacing: .03em; background: var(--info-soft); color: var(--info); font-family: var(--font-sans); }
.method.post { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- avatar ---------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; font-weight: 650; color: #fff; background: linear-gradient(140deg, #f58a3d, #d9480f); flex: none; letter-spacing: 0; }
.avatar.sq { border-radius: 10px; }
.avatar.lg { width: 44px; height: 44px; font-size: 16px; border-radius: 14px; }
.avatar.neutral { background: var(--surface-3); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- message bubble (shared) ---------- */
.bubble { position: relative; display: inline-block; max-width: 100%; background: var(--surface-3); color: var(--text); border-radius: 18px 18px 18px 6px; padding: 10px 14px; white-space: pre-wrap; word-break: break-word; font-size: var(--t-md); line-height: 1.5; }
.bubble-meta { font-size: var(--t-xs); color: var(--muted); margin-top: 6px; }

/* ---------- API docs (portal + public) ---------- */
.docs-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--s10); align-items: start; }
.docs-toc { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); padding-left: 2px; }
.docs-toc-t { font-size: var(--t-2xs); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--faint); padding: 0 12px 8px; }
.docs-toc a { font-size: var(--t-sm); color: var(--muted); padding: 5px 12px; border-left: 2px solid transparent; margin-left: -3px; text-decoration: none; }
.docs-toc a:hover { color: var(--text); }
.docs-toc a.is-active { color: var(--text); border-left-color: var(--accent); font-weight: 600; }
.docs { max-width: 860px; min-width: 0; }
.docs section { padding: var(--s8) 0; border-top: 1px solid var(--line); scroll-margin-top: 84px; }
.docs section:first-child { padding-top: 0; border-top: 0; }
.docs h2 { font-family: var(--font-display); font-size: 24px; font-weight: 650; letter-spacing: -.025em; margin-bottom: var(--s3); }
.docs h3 { font-size: var(--t-md); font-weight: 650; margin: var(--s5) 0 var(--s2); display: flex; align-items: center; gap: 8px; }
.docs p { color: var(--text-2); }
.docs .code-tabs .tabs { margin-bottom: var(--s3); }
.docs-list { display: grid; gap: 8px; color: var(--text-2); }
.status-flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
@media (max-width: 900px) { .docs-layout { grid-template-columns: minmax(0, 1fr); } .docs-toc { display: none; } }

/* funnel rows (delivery breakdowns) */
.funnel { display: flex; flex-direction: column; gap: var(--s3); }
.funnel-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: var(--s3); font-size: var(--t-sm); }
.funnel-row .nm { color: var(--text-2); font-weight: 550; display: flex; align-items: center; gap: 8px; }
.funnel-row .nm i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.funnel-row .v { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 64px; text-align: right; }
.funnel-row .progress { height: 8px; }
.dot-ok { background: var(--ok-dot); } .dot-bad { background: var(--bad-dot); } .dot-warn { background: var(--warn-dot); } .dot-info { background: var(--info-dot); } .dot-neutral { background: var(--neutral-dot); }

/* encoding pill (composer, calculator) */
.enc-pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line); color: var(--text-2); font-weight: 600; }
.enc-pill.uni { background: var(--info-soft); border-color: var(--info-line); color: var(--info); }

/* ---------- reveal motion ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s var(--ease-out), transform .7s var(--ease-out); transition-delay: var(--d, 0ms); }
.reveal.in { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}
@media (forced-colors: active) {
  .badge::before, .progress > span { forced-color-adjust: none; }
  .btn, .card, .input, .select, .textarea { border: 1px solid CanvasText; }
}

/* Hotline pill (site + portal headers): partials/hotline.php */
.hotline { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 5px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); text-decoration: none; white-space: nowrap; transition: border-color .15s, background .15s; }
.hotline:hover { border-color: var(--accent); background: var(--accent-soft); }
.hotline:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hotline .hl-ic { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--accent); color: var(--on-accent); }
.hotline .hl-tx { display: grid; line-height: 1.1; }
.hotline small { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hotline b { font-size: 13.5px; font-weight: 700; }
.hotline.is-wide { height: 52px; padding-right: 18px; justify-content: center; }
.hotline.is-wide .hl-ic { width: 38px; height: 38px; }
.hotline.is-wide b { font-size: 16px; }
@media (max-width: 640px) { .hotline:not(.is-wide) { padding: 0; width: 40px; justify-content: center; border-color: var(--accent-line); background: var(--accent-soft); } .hotline:not(.is-wide) .hl-tx { display: none; } }
