/* ═════════════════════════════════════════════════════════════════════════
   Design system — premium, motion-aware. Font: Anuphan (Thai+Latin).
   ═════════════════════════════════════════════════════════════════════════ */
:root {
  --bg: #f4f5fb; --surface: rgba(255, 255, 255, .86); --surface-solid: #ffffff; --surface-2: #f1f2f9; --surface-3: #e7e9f4;
  --border: rgba(30, 34, 80, .09); --border-strong: rgba(30, 34, 80, .17);
  --text: #12142b; --muted: #5d6283; --faint: #9196b3;
  --brand: #6d4cff; --brand-2: #c048ff; --brand-3: #ff4f9a;
  --brand-hover: #5b3ae8; --brand-ink: #ffffff; --brand-soft: rgba(109, 76, 255, .1); --brand-line: rgba(109, 76, 255, .32);
  --grad: linear-gradient(135deg, #6d4cff 0%, #a64dff 52%, #ff4f9a 100%);
  --grad-soft: linear-gradient(135deg, rgba(109, 76, 255, .12), rgba(255, 79, 154, .1));
  --accent: #6d4cff; --accent-soft: rgba(109, 76, 255, .1);
  --ok: #0c9f6a; --ok-soft: rgba(12, 159, 106, .11); --ok-line: rgba(12, 159, 106, .35);
  --warn: #c26a06; --warn-soft: rgba(245, 158, 11, .14); --bad: #e0344b; --bad-soft: rgba(224, 52, 75, .1);
  --radius: 18px; --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(23, 26, 70, .04), 0 4px 18px -6px rgba(23, 26, 70, .1);
  --shadow-lg: 0 24px 60px -20px rgba(40, 30, 120, .35);
  --glow: 0 10px 30px -10px rgba(109, 76, 255, .55);
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --side: #0c0d1f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080914; --surface: rgba(22, 23, 44, .78); --surface-solid: #15162b; --surface-2: #1b1c36; --surface-3: #25274a;
    --border: rgba(160, 165, 255, .1); --border-strong: rgba(160, 165, 255, .2);
    --text: #eceeff; --muted: #a2a6cc; --faint: #6e7299;
    --brand: #8f75ff; --brand-hover: #a593ff; --brand-ink: #fff; --brand-soft: rgba(143, 117, 255, .16); --brand-line: rgba(143, 117, 255, .4);
    --accent: #a593ff; --accent-soft: rgba(143, 117, 255, .16);
    --ok: #3ee0a1; --ok-soft: rgba(62, 224, 161, .12); --ok-line: rgba(62, 224, 161, .35);
    --warn: #ffb547; --warn-soft: rgba(255, 181, 71, .13); --bad: #ff6b81; --bad-soft: rgba(255, 107, 129, .13);
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8); --side: #06070f; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #080914; --surface: rgba(22, 23, 44, .78); --surface-solid: #15162b; --surface-2: #1b1c36; --surface-3: #25274a;
  --border: rgba(160, 165, 255, .1); --border-strong: rgba(160, 165, 255, .2);
  --text: #eceeff; --muted: #a2a6cc; --faint: #6e7299;
  --brand: #8f75ff; --brand-hover: #a593ff; --brand-ink: #fff; --brand-soft: rgba(143, 117, 255, .16); --brand-line: rgba(143, 117, 255, .4);
  --accent: #a593ff; --accent-soft: rgba(143, 117, 255, .16);
  --ok: #3ee0a1; --ok-soft: rgba(62, 224, 161, .12); --ok-line: rgba(62, 224, 161, .35);
  --warn: #ffb547; --warn-soft: rgba(255, 181, 71, .13); --bad: #ff6b81; --bad-soft: rgba(255, 107, 129, .13);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8); --side: #06070f; color-scheme: dark;
}

/* ── base ───────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); min-height: 100vh;
  font: 15px/1.6 "Anuphan", "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: rgba(109, 76, 255, .25); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.015em; }
h1 { font-size: 1.6rem; font-weight: 700; } h2 { font-size: 1.06rem; font-weight: 600; } h3 { font-size: .96rem; font-weight: 600; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.gtext { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 200% auto; animation: sheen 6s linear infinite; }
.svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.svg.sm { width: 15px; height: 15px; }

/* ── ambient aurora (moving colour blobs behind everything) ─────────────── */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; will-change: transform; }
.aurora i:nth-child(1) { width: 520px; height: 520px; background: #8b6bff; top: -180px; left: 8%; animation: drift1 26s ease-in-out infinite; }
.aurora i:nth-child(2) { width: 460px; height: 460px; background: #ff7ab6; top: 30%; right: -140px; animation: drift2 32s ease-in-out infinite; opacity: .35; }
.aurora i:nth-child(3) { width: 420px; height: 420px; background: #4cc9ff; bottom: -200px; left: 35%; animation: drift3 38s ease-in-out infinite; opacity: .28; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .aurora i { opacity: .22; } }
:root[data-theme="dark"] .aurora i { opacity: .22; }
@keyframes drift1 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(180px, 120px) scale(1.15); } }
@keyframes drift2 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-220px, -90px) scale(.9); } }
@keyframes drift3 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-160px, -140px) scale(1.2); } }

/* ── motion primitives ──────────────────────────────────────────────────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { opacity: 0; transform: scale(.94); } 100% { opacity: 1; transform: none; } }
@keyframes sheen { to { background-position: 200% center; } }
@keyframes ping { 0% { transform: scale(.6); opacity: .55; } 100% { transform: scale(2); opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
@keyframes flip { 0% { transform: rotateX(90deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
.enter > * { animation: fadeUp .55s var(--ease) both; }
.enter > *:nth-child(2) { animation-delay: .05s; } .enter > *:nth-child(3) { animation-delay: .1s; }
.enter > *:nth-child(4) { animation-delay: .15s; } .enter > *:nth-child(5) { animation-delay: .2s; }
.enter > *:nth-child(6) { animation-delay: .25s; } .enter > *:nth-child(n+7) { animation-delay: .3s; }
.stagger > * { animation: fadeUp .5s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: .06s; } .stagger > *:nth-child(3) { animation-delay: .12s; }
.stagger > *:nth-child(4) { animation-delay: .18s; } .stagger > *:nth-child(5) { animation-delay: .24s; } .stagger > *:nth-child(n+6) { animation-delay: .3s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ── admin shell ────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #c9cbef; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; isolation: isolate; }
.side::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(240px 200px at 20% 0%, rgba(139, 107, 255, .35), transparent 70%), radial-gradient(220px 220px at 100% 100%, rgba(255, 79, 154, .18), transparent 70%); }
.side .logo { font-weight: 700; font-size: 1.05rem; padding: 2px 10px 22px; display: flex; gap: 11px; align-items: center; color: #fff; }
.side .logo i { width: 34px; height: 34px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; box-shadow: var(--glow); background-size: 200% 200%; animation: sheen 5s linear infinite; }
.side .logo small { display: block; font-size: .72rem; font-weight: 500; color: #8f92c2; letter-spacing: .02em; }
.nav a { position: relative; display: flex; gap: 11px; align-items: center; padding: 9px 12px; border-radius: 11px; color: #a9acd6; margin-bottom: 3px; font-weight: 500; font-size: .93rem; transition: background .2s, color .2s, transform .2s var(--ease); }
.nav a .svg { opacity: .8; }
.nav a .badge { margin-left: auto; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; transform: translateX(2px); }
.nav a.on { color: #fff; background: linear-gradient(90deg, rgba(139, 107, 255, .32), rgba(139, 107, 255, .06)); font-weight: 600; }
.nav a.on::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--grad); box-shadow: var(--glow); }
.nav a.on .svg { opacity: 1; }
.nav .sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 12px 6px; }
.nav .cap { font-size: .7rem; letter-spacing: .08em; color: #6c6f9c; padding: 6px 12px 4px; font-weight: 600; }
main { padding: 30px 34px 70px; max-width: 1260px; width: 100%; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.top p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; padding: 10px 10px 8px; }
  .side .logo { padding: 0 6px 8px; }
  .side .logo small { display: none; }
  .nav { display: flex; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .nav a { white-space: nowrap; margin: 0; }
  .nav a.on::before { display: none; }
  .nav .sep, .nav .cap { display: none; }
  main { padding: 18px 16px 60px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g4.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── surfaces ───────────────────────────────────────────────────────────── */
.card { background: var(--surface); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; transition: transform .25s var(--ease), box-shadow .25s; }
.card > h2, .card > h3 { margin-bottom: 14px; }
.card.lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat { position: relative; overflow: hidden; display: flex; gap: 14px; align-items: center; }
.stat .ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: var(--grad); box-shadow: var(--glow); flex: none; }
.stat .ic .svg { width: 22px; height: 22px; }
.stat.c2 .ic { background: linear-gradient(135deg, #10b981, #34d3c9); box-shadow: 0 10px 30px -10px rgba(16, 185, 129, .6); }
.stat.c3 .ic { background: linear-gradient(135deg, #f59e0b, #ff6b6b); box-shadow: 0 10px 30px -10px rgba(245, 158, 11, .6); }
.stat.c4 .ic { background: linear-gradient(135deg, #3b82f6, #7c5cff); box-shadow: 0 10px 30px -10px rgba(59, 130, 246, .6); }
.stat .n { font-size: 1.85rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: .84rem; }
.stat::after { content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; background: var(--grad-soft); }

.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-solid); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .74rem; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr, table tr { transition: background .15s; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--brand-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── forms ──────────────────────────────────────────────────────────────── */
label { display: block; font-size: .84rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-solid);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px 13px; outline: none; transition: border-color .2s, box-shadow .2s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; flex: none; accent-color: var(--brand); }
.field { margin-bottom: 15px; }
.check { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: .93rem; cursor: pointer; }
.search { position: relative; }
.search .svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 40px; }

.btn {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2;
  border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text); border-radius: var(--radius-sm); padding: 10px 16px;
  cursor: pointer; white-space: nowrap; transition: background .2s, border-color .2s, transform .15s var(--ease), box-shadow .2s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary, .btn.accent { background: var(--grad); background-size: 160% 160%; border-color: transparent; color: #fff; box-shadow: var(--glow); }
.btn.primary::after, .btn.accent::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .45) 50%, transparent 65%); transform: translateX(-120%); transition: transform .7s var(--ease); }
.btn.primary:hover, .btn.accent:hover { background-position: 100% 0; box-shadow: 0 14px 34px -10px rgba(109, 76, 255, .7); }
.btn.primary:hover::after, .btn.accent:hover::after { transform: translateX(120%); }
.btn.line { background: linear-gradient(135deg, #06c755, #00b4a0); border-color: transparent; color: #fff; box-shadow: 0 10px 26px -10px rgba(6, 199, 85, .6); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; box-shadow: 0 10px 26px -12px rgba(224, 52, 75, .6); }
.btn.sm { padding: 7px 12px; font-size: .83rem; border-radius: 10px; }
.btn.lg { padding: 13px 22px; font-size: 1rem; border-radius: 14px; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { padding: 8px; }
.btn.block { width: 100%; }
.btn[disabled] .svg.spin, .spin { animation: spin .8s linear infinite; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; line-height: 1.45; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--brand-soft); color: var(--brand); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pips { display: inline-flex; gap: 3px; }
.pips i { width: 11px; height: 11px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border-strong); }
.pips i.assigned { background: var(--grad); border-color: transparent; }
.pips i.needs_cleanup { background: var(--warn); border-color: var(--warn); }
.pips i.blocked { background: var(--faint); border-color: var(--faint); }

.otp { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.otp .code { font-family: var(--mono); font-size: 1.6rem; font-weight: 700; letter-spacing: .12em; }
.list { display: grid; gap: 10px; }

.msg { white-space: pre-wrap; font-family: var(--mono); font-size: .84rem; line-height: 1.6; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; max-height: 380px; overflow: auto; }
.empty { text-align: center; color: var(--muted); padding: 40px 14px; }
.empty .svg { width: 38px; height: 38px; color: var(--faint); margin-bottom: 8px; }
.loading { display: grid; place-items: center; padding: 70px 0; }
.loading i { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); animation: spin .7s linear infinite; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-color: var(--brand); font-weight: 600; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; font-size: .93rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.secret { font-family: var(--mono); background: var(--surface-2); padding: 2px 8px; border-radius: 7px; }
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 14px; background: var(--grad-soft); border: 1px solid var(--brand-line); font-size: .9rem; }
.callout .svg { color: var(--brand); margin-top: 2px; }
.callout.warn { background: var(--warn-soft); border-color: rgba(245, 158, 11, .35); }
.callout.warn .svg { color: var(--warn); }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 2px; }
.seg button { font: inherit; font-size: .85rem; font-weight: 500; border: 0; background: transparent; color: var(--muted); padding: 7px 13px; border-radius: 9px; cursor: pointer; white-space: nowrap; transition: all .2s; }
.seg button.on { background: var(--surface-solid); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* live dot */
.live { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); font-weight: 500; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); position: relative; }
.live i::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; background: var(--ok); animation: ping 1.6s ease-out infinite; }

/* toast */
.toastbox, #toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); }
.toastbox div, #toast div { display: flex; gap: 10px; align-items: center; background: rgba(18, 20, 43, .94); backdrop-filter: blur(10px); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); font-size: .92rem; animation: rise .3s var(--ease); }
.toastbox div::before, #toast div::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #3ee0a1; flex: none; box-shadow: 0 0 10px #3ee0a1; }
.toastbox div.err::before, #toast div.err::before { background: #ff6b81; box-shadow: 0 0 10px #ff6b81; }

/* dialog */
dialog { border: 1px solid var(--border); border-radius: 22px; padding: 0; width: min(540px, calc(100% - 24px)); background: var(--surface-solid); color: var(--text); box-shadow: 0 30px 90px -20px rgba(20, 10, 80, .45); }
dialog[open] { animation: pop .28s var(--ease); }
dialog::backdrop { background: rgba(10, 8, 30, .5); backdrop-filter: blur(4px); }
dialog .hd { padding: 20px 22px 6px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
dialog .bd { padding: 8px 22px 18px; max-height: 70vh; overflow-y: auto; }
.merr { flex: 1 1 100%; margin: 0 0 4px; padding: 9px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: .88rem; font-weight: 500; }
.merr[hidden] { display: none; }
dialog .ft { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 22px 22px; }
.sumlist { display: grid; gap: 8px; margin: 4px 0 6px; }
.sumlist .r { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); font-size: .93rem; }
.sumlist .r.total { background: var(--grad-soft); border: 1px solid var(--brand-line); font-weight: 700; font-size: 1.05rem; }

/* standalone pages */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth { width: min(410px, 100%); }

/* ── profit chart (dataviz: blue = revenue, orange = cost; validated both modes) ── */
:root { --s1: #2a78d6; --s2: #eb6834; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --s1: #3987e5; --s2: #d95926; } }
:root[data-theme="dark"] { --s1: #3987e5; --s2: #d95926; }
.legend { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 6px; }
.sw.s1 { background: var(--s1); } .sw.s2 { background: var(--s2); }
.pchart-wrap { position: relative; }
.pchart { width: 100%; height: auto; display: block; overflow: visible; }
.pchart .s1 { fill: var(--s1); } .pchart .s2 { fill: var(--s2); }
.pchart .grid { stroke: var(--border); stroke-width: 1; }
.pchart .base { stroke: var(--border-strong); stroke-width: 1; }
.pchart .ax { fill: var(--muted); font-size: 11px; font-family: inherit; }
.pchart .dl { fill: var(--text); font-size: 11px; font-weight: 600; font-family: inherit; }
.pchart .sel { fill: var(--brand-soft); }
.pchart .hit { fill: transparent; cursor: pointer; }
.pchart .hit.on { fill: rgba(109, 76, 255, .06); }
.ptip { position: absolute; width: 170px; pointer-events: none; background: var(--surface-solid); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 10px 12px; font-size: .84rem; z-index: 5; }
.ptip b { display: block; margin-bottom: 4px; }
.ptip div { display: flex; align-items: center; gap: 6px; }
.ptip div span { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.ptip .sw { margin-left: 0; }
.ptip .pf { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }

/* toasts raised while a dialog is open render inside it (top layer) — show them at the top so they never cover the dialog buttons */
dialog .toastbox { bottom: auto; top: 18px; }

/* admin: problem reports inbox */
.rp-admin { display: grid; gap: 12px; }
.rp-card { display: grid; gap: 6px; border-left: 4px solid var(--border); }
.rp-card.new { border-left-color: var(--bad); } .rp-card.seen { border-left-color: var(--warn); } .rp-card.resolved { border-left-color: var(--ok); opacity: .85; }
.rp-who { font-size: .88rem; color: var(--muted); }
.rp-d { margin: 4px 0 0; white-space: pre-line; }
.rp-img { max-width: 220px; max-height: 160px; border-radius: 10px; border: 1px solid var(--border); object-fit: cover; }
.rp-ctx { display: grid; gap: 4px; font-size: .84rem; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.rp-ctx .svg { vertical-align: -2px; }
.rp-reply { display: flex; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--ok-soft); font-size: .9rem; }
.rp-reply .svg { color: var(--ok); flex: none; margin-top: 2px; }

/* ══ admin analytics v2 ═══════════════════════════════════════════════════ */
:root { --vz-cost: #eb6834; --vz-profit: #6250d6; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) { --vz-cost: #d95926; --vz-profit: #9085e9; } }
:root[data-theme="dark"] { --vz-cost: #d95926; --vz-profit: #9085e9; }
.neg { color: var(--bad) !important; } .pos { color: var(--ok); } .nw { white-space: nowrap; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-head { align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.ad-tools { display: flex; gap: 8px; align-items: center; }
.ad-tools select { width: auto; }
.ad-fx { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: .9rem; color: var(--muted); margin: 0; }
.ad-fx input { width: 78px; }
.ad-note { display: block; font-size: .88rem; padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--text); margin-bottom: 14px; }
.ad-note .svg { color: var(--warn); vertical-align: -2px; }
.ad-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.ad-kpi { display: grid; gap: 3px; padding: 16px 18px 0; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.ad-kpi > small { color: var(--muted); font-weight: 600; font-size: .82rem; }
.ad-kpi > b { font-size: 1.7rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.ad-kf { display: flex; gap: 6px; align-items: center; font-size: .78rem; flex-wrap: wrap; }
.ad-sub { font-size: .8rem; color: var(--muted); }
.dl { font-weight: 700; font-size: .78rem; padding: 1px 7px; border-radius: 6px; }
.dl.up { color: var(--ok); background: var(--ok-soft); } .dl.dn { color: var(--bad); background: var(--bad-soft); }
.ad-spark { display: block; width: calc(100% + 36px); margin: 8px -18px 0; height: 38px; }
.ad-spark .sl { fill: none; stroke: var(--vz-profit); stroke-width: 2; } .ad-spark .sa { fill: var(--vz-profit); opacity: .1; }
.ad-spark.cost .sl { stroke: var(--vz-cost); } .ad-spark.cost .sa { fill: var(--vz-cost); }
.ad-spark .sm { stroke: var(--text); stroke-width: 1; stroke-dasharray: 2 2; opacity: .35; }
@media (max-width: 1000px) { .ad-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.ad-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 14px; margin-bottom: 14px; align-items: stretch; }
@media (max-width: 1000px) { .ad-main { grid-template-columns: 1fr; } }
.ad-chart { position: relative; }
.ad-ch-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ad-ch-head h2 { margin: 0; }
.ad-lg { display: flex; gap: 14px; align-items: center; font-size: .82rem; color: var(--muted); }
.ad-lg span { display: inline-flex; align-items: center; gap: 6px; }
.ln { width: 18px; height: 0; display: inline-block; border-top: 2.5px solid; }
.ln.s { border-color: var(--vz-profit); } .ln.c { border-color: var(--vz-cost); }
.ad-plot { width: 100%; }
.ad-svg { display: block; }
.ad-grid { stroke: var(--border); } .ad-ax { fill: var(--faint); font: 500 11px var(--font); } .ad-ax.on { fill: var(--text); font-weight: 700; }
.ad-band { fill: var(--vz-profit); opacity: .1; }
.ad-ls { fill: none; stroke: var(--vz-profit); stroke-width: 2.5; stroke-linejoin: round; }
.ad-lc { fill: none; stroke: var(--vz-cost); stroke-width: 2; stroke-linejoin: round; }
.ad-ds { fill: var(--surface-solid, #fff); stroke: var(--vz-profit); stroke-width: 2; } .ad-dc { fill: var(--surface-solid, #fff); stroke: var(--vz-cost); stroke-width: 2; }
.ad-sel { fill: var(--brand-soft); }
.ad-cross { stroke: var(--border-strong); }
.vz-tip { position: absolute; z-index: 5; pointer-events: none; display: grid; gap: 1px; padding: 9px 12px; border-radius: 12px; min-width: 140px; background: var(--surface-solid, #fff); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); font-size: .82rem; }
.vz-tip[hidden] { display: none; }
.vz-tip small, .vz-tip span { color: var(--muted); } .vz-tip b { font-size: 1.02rem; }

.ad-health { display: grid; gap: 4px; align-content: start; }
.ad-health h2 { margin-bottom: 6px; }
.ad-hrow { display: flex; gap: 10px; align-items: center; padding: 9px 8px; border-radius: 12px; color: inherit; text-decoration: none; }
a.ad-hrow:hover { background: var(--surface-2); }
.ad-hrow b { display: block; font-size: .92rem; } .ad-hrow small { font-size: .78rem; }
.ad-big { font-size: 1.4rem !important; }
.ad-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ad-dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); } .ad-dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); } .ad-dot.bad { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.ad-rep { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.ad-rp { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr auto; gap: 8px; align-items: center; font-size: .82rem; }
.ad-rp-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; } .ad-rp-bar i { display: block; height: 100%; background: var(--warn); border-radius: 99px; }

.ad-flags { display: flex; gap: 4px; flex-wrap: wrap; }
.ad-flags .badge { white-space: nowrap; }
.ad-list { display: grid; gap: 12px; }
.ad-li-h { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.ad-li-h > span { color: var(--muted); white-space: nowrap; }
.ad-pair { display: grid; grid-template-columns: 1fr 72px; gap: 8px; align-items: center; margin-top: 4px; }
.ad-pair i { display: block; height: 10px; border-radius: 0 4px 4px 0; min-width: 3px; }
.ad-pair i.vz-p { background: var(--vz-profit); } .ad-pair i.vz-c { background: var(--vz-cost); }
.ad-pair small { text-align: right; color: var(--muted); font-size: .78rem; }
.sw.vz-p { background: var(--vz-profit); } .sw.vz-c { background: var(--vz-cost); }
.vz-legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
.vz-legend span { display: inline-flex; align-items: center; gap: 6px; } .vz-legend .sw { width: 10px; height: 10px; margin: 0; border-radius: 3px; }
.ad-shop { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; padding: 6px; border-radius: 12px; }
.ad-shop:hover { background: var(--surface-2); }
.ad-rk { width: 22px; text-align: center; font-weight: 700; color: var(--faint); flex: none; }
.ad-bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 5px 0 3px; }
.ad-bar i { display: block; height: 100%; border-radius: 99px; background: var(--vz-profit); }
.ad-shop small { font-size: .78rem; }

.ap-box { padding: 10px 12px; border-radius: 12px; background: #fff7f1; border: 1px solid #fbd3b8; margin: 8px 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ap-box { background: rgba(243, 112, 33, .1); border-color: rgba(243, 112, 33, .3); } }
:root[data-theme="dark"] .ap-box { background: rgba(243, 112, 33, .1); border-color: rgba(243, 112, 33, .3); }
