/* Wisper AI — User Dashboard. Obsidian/Manrope, exact admin tokens.
   Sized per SIZINGGUIDE.md: root clip, minmax(0,1fr) tracks, clamp() type/space,
   auto-fit minmax(min(100%,Npx)), env() safe areas. Centered on every width. */
:root {
  --bg: #060606; --surface: #111113; --surface-2: #1c1c1f; --hover: #27272b; --nav: #0a0a0b;
  --fg: #ededee; --muted: #9a9a9e;
  --success: #4ade80; --warning: #facc15; --danger: #f87171;
  --accent: #d4d4d8; --accent-soft: #26262a; --border: #242427; --border-strong: #3a3a3f;
  --radius-sm: 7px; --radius: 11px; --radius-lg: 15px;
  --font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  --topbar-h: 64px; --content-w: 960px;
}
* { box-sizing: border-box; border-color: var(--border); }
html { background: var(--bg); color-scheme: dark; overflow-x: clip; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; overflow-x: clip;
  background: var(--bg); color: var(--fg); font-family: var(--font-sans); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
p { margin: 0; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.thin { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.thin::-webkit-scrollbar { width: 10px; height: 10px; }
.thin::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.thin::-webkit-scrollbar-track { background: transparent; }
::selection { background: var(--accent-soft); color: var(--fg); }

.ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.app-loading { display: grid; place-items: center; min-height: 100dvh; color: var(--muted); padding: 52px; }

.mark { width: 34px; height: 34px; border-radius: 9px; background: var(--fg); color: var(--bg); display: grid; place-items: center; font-weight: 800; font-size: 17px; letter-spacing: -0.04em; flex-shrink: 0; }

/* ── Inputs / buttons ──────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
input {
  width: 100%; height: 48px; padding: 0 15px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--fg); font-family: var(--font-sans); font-size: 16px; outline: none;
  transition: border-color .15s ease;
}
input:focus { border-color: var(--border-strong); }
input::placeholder { color: var(--muted); }
.form-error { color: var(--danger); font-size: 14px; margin: 2px 0 16px; min-height: 19px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; height: 46px; padding: 0 20px;
  border-radius: var(--radius-sm); font-family: var(--font-sans); font-size: 15px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: background-color .15s ease, border-color .15s ease, color .15s ease; white-space: nowrap;
}
.btn .ic svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--bg); } .btn-primary:hover { background: rgba(212,212,216,.9); }
.btn-secondary { border-color: var(--border-strong); background: var(--surface); color: var(--fg); } .btn-secondary:hover { background: var(--hover); }
.btn-sm { height: 38px; padding: 0 14px; font-size: 13.5px; gap: 7px; }
.btn-sm .ic svg { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ── Login (centered both axes) ────────────────────────────────────── */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: clamp(16px,5vw,32px); padding-top: calc(clamp(16px,5vw,32px) + env(safe-area-inset-top)); padding-bottom: calc(clamp(16px,5vw,32px) + env(safe-area-inset-bottom)); }
.login-card { width: 100%; max-width: 420px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: clamp(26px,5vw,38px); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brandword { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.login-card h1 { font-size: 1.5rem; }
.login-card p.sub { margin: 6px 0 26px; font-size: 15px; color: var(--muted); }
.login-foot { margin-top: 20px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }

/* ── Topbar ────────────────────────────────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 40; min-height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 clamp(16px,4vw,28px); padding-top: env(safe-area-inset-top); background: var(--nav); border-bottom: 1px solid var(--border); }
.topbar .brand { display: flex; align-items: center; gap: 11px; }
.topbar .brand .mark { width: 30px; height: 30px; font-size: 15px; }
.topbar .brand b { font-weight: 700; font-size: 16.5px; letter-spacing: -0.02em; }
.topbar .brand b span { color: var(--muted); font-weight: 600; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.keychip { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-2); font-family: var(--font-mono); font-size: 13px; color: var(--fg); max-width: 46vw; overflow: hidden; }
.keychip .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Content column (centered) ─────────────────────────────────────── */
.page { max-width: var(--content-w); margin: 0 auto; padding: clamp(22px,3.5vw,40px) clamp(16px,4vw,28px) calc(72px + env(safe-area-inset-bottom)); }
.viewnav { display: flex; gap: 6px; padding: 5px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); margin-bottom: clamp(20px,3vw,28px); width: fit-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.viewnav::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 9px; padding: 9px 16px; border-radius: var(--radius-sm); font-size: 14.5px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; border: 1px solid transparent; transition: color .15s ease, background-color .15s ease; }
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); background: var(--surface-2); border-color: var(--border); }
.tab .ic svg { width: 17px; height: 17px; }

/* ── Hero balance ──────────────────────────────────────────────────── */
.hero { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: clamp(24px,4vw,36px); }
.hero .l { font-size: 12px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.hero .big { margin-top: 12px; font-size: clamp(2.6rem,9vw,4rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.hero .cr { margin-top: 14px; font-size: clamp(14px,2.4vw,16px); color: var(--muted); }
.hero .cr b { color: var(--fg); font-weight: 600; }

/* ── Cards / grid ──────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%,260px),1fr)); margin-top: clamp(16px,3vw,20px); }
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 11px; padding: 15px clamp(16px,3vw,22px); border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.card-body { padding: clamp(16px,3vw,22px); }

.kv { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 13px 18px; align-items: baseline; }
.kv dt { color: var(--muted); font-size: 13.5px; }
.kv dd { margin: 0; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.kv dd.mono { font-size: 13.5px; }

.planrow { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.planrow .name { font-size: clamp(1.3rem,3vw,1.6rem); font-weight: 700; letter-spacing: -0.025em; }
.planrow .price { color: var(--muted); font-size: 15px; }
.planmeta { margin-top: 14px; font-size: 14px; color: var(--muted); }
.planmeta b { color: var(--fg); font-weight: 600; }

/* ── Stat tiles ────────────────────────────────────────────────────── */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%,180px),1fr)); margin-top: clamp(16px,3vw,20px); }
.stat { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: clamp(16px,3vw,22px); display: flex; flex-direction: column; align-items: flex-start; }
.stat .l { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat .v { margin-top: 10px; font-size: clamp(1.6rem,4.5vw,2.1rem); font-weight: 700; letter-spacing: -0.025em; }
.stat .v small { font-size: .5em; font-weight: 600; color: var(--muted); margin-left: 6px; letter-spacing: 0; }

.section-label { font-size: 12px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: clamp(26px,4vw,34px) 0 4px; }

/* ── Live indicator ────────────────────────────────────────────────── */
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.live .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--muted); position: relative; }
.live.on { color: var(--success); }
.live.on .dot { background: var(--success); box-shadow: 0 0 0 0 rgba(74,222,128,.55); animation: livepulse 2s ease-out infinite; }
.live.off { color: var(--warning); }
.live.off .dot { background: var(--warning); }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(74,222,128,.5); } 70% { box-shadow: 0 0 0 7px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }

/* ── Tables ────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 13px clamp(13px,2.5vw,20px); vertical-align: middle; white-space: nowrap; }
thead th { background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
tbody tr { border-top: 1px solid var(--border); }
tbody tr:hover { background: rgba(255,255,255,.02); }
td.delta-neg { color: var(--danger); } td.delta-pos { color: var(--success); }
.empty { padding: 40px; text-align: center; color: var(--muted); font-size: 15px; }
.feed-new { animation: flashin .9s ease; }
@keyframes flashin { from { background: rgba(212,212,216,.08); } to { background: transparent; } }

/* ── Toast ─────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 13px 20px; font-size: 15px; box-shadow: 0 12px 40px rgba(0,0,0,.5); z-index: 400; max-width: calc(100vw - 24px); }
.toast.ok { border-left: 3px solid var(--success); }
.toast.err { border-left: 3px solid var(--danger); }

@media (max-width: 460px) {
  .topbar .brand b span { display: none; }
  .keychip { max-width: 38vw; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(min(100%,140px),1fr)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
