/* Dashboard styles, served to every brand (keep product names out of this file). Colors and fonts come from /brand/theme.css
   (tokens); a white-label brand overrides --brand-*. Dark sidebar and sign-in panel, paper for the work area. */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-text); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -.04em; line-height: 1.1; margin: 0; }
h2 { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 4px; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---------- shell: dark sidebar ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--dark); color: var(--on-dark); padding: 22px 14px; position: sticky; top: 0;
        height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .logo { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; color: var(--on-dark); }
.side .logo:hover { text-decoration: none; }
.side .logo img { display: block; max-width: 100%; }
.side .logo .name { font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: -.04em; }
.logo img.plate { background: #fff; padding: 6px 10px; border-radius: 9px; box-sizing: content-box; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
              color: var(--on-dark-2); font-weight: 500; text-decoration: none; }
.side nav a:hover { background: var(--dark-2); color: var(--on-dark); }
.side nav a.on { background: var(--dark-2); color: var(--on-dark); font-weight: 600; }
.side nav a svg { width: 18px; height: 18px; flex: none; color: var(--on-dark-3); }
.side nav a.on svg { color: var(--brand); }
.side .foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--dark-line); font-size: 13px; }
.side .foot .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.side .foot .muted { color: var(--on-dark-3); overflow: hidden; text-overflow: ellipsis; }
.side .foot form { margin-top: 8px; }
.side .linkbtn { color: var(--brand); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand-text); font: inherit; font-weight: 600; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
main { padding: 32px 36px 64px; min-width: 0; max-width: 1240px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.head p { margin: 6px 0 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; min-width: 0; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 8px; }
  .side .logo { padding: 0 8px 0 0; }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; min-width: 0; order: 3; }
  .side nav a { white-space: nowrap; padding: 7px 10px; }
  .side nav a svg { display: none; }
  .side .foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; gap: 10px; align-items: center; }
  .side .foot .who, .side .foot .muted { display: none; }
  .side .foot form { margin: 0; }
  main { padding: 22px 16px 48px; }
}

/* ---------- blocks ---------- */
.grid > * { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 22px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.stack > * + * { margin-top: 16px; }
.tile { padding: 20px; }
.tile .label { color: var(--ink-2); font-size: 13px; }
.tile .value { font-family: var(--font-display); font-size: 32px; font-weight: 600; letter-spacing: -.045em; line-height: 1.1; margin: 8px 0 6px; }
.tile .sub { font-size: 13px; color: var(--ink-2); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 32px 0 12px; flex-wrap: wrap; }
.section-title h2 { margin: 0; }

.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 500; }
.flash.ok { background: var(--human-tint); color: var(--human-text); }
.flash.error { background: var(--danger-tint); color: var(--danger-text); }
.notice { background: var(--sun-tint); border-color: #F0DDB0; border-radius: var(--radius-sm); padding: 14px 18px; box-shadow: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--bg); color: var(--ink-2); font-family: var(--font-mono); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FAFBF7; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-2); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-family: var(--font-mono); font-size: 11.5px;
        font-weight: 500; letter-spacing: .04em; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; flex: none; }
.pill.HUMAN, .pill.active { background: var(--human-tint); color: var(--human-text); }
.pill.MACHINE { background: var(--machine-tint); color: var(--machine-text); }
.pill.FALLBACK, .pill.disabled { background: var(--fallback-tint); color: var(--fallback-text); }
.pill.revoked { background: var(--danger-tint); color: var(--danger-text); }
.pill.plain { background: var(--bg); color: var(--ink-2); border: 1px solid var(--border); }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { font-size: 13px; color: var(--ink-2); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 10px 13px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid var(--brand-tint); border-color: var(--brand-2); outline-offset: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 160px; margin-bottom: 0; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 14px; font-weight: 600; padding: 10px 17px;
       border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
       transition: background-color .15s, border-color .15s; }
.btn:hover { text-decoration: none; }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { background: #26322D; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn.secondary:hover { border-color: var(--ink); }
.btn.danger { background: var(--danger-tint); color: var(--danger-text); border-color: #F1C9CC; }
.btn.danger:hover { background: #FBE3E5; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- sign-in pages: dark panel with a live waveform, form on paper ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: var(--dark); color: var(--on-dark); padding: 40px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.auth-side .logo { display: flex; align-items: center; color: var(--on-dark); }
.auth-side .logo:hover { text-decoration: none; }
.auth-side .logo .name { font-family: var(--font-display); font-weight: 600; font-size: 24px; letter-spacing: -.04em; }
.auth-wave { display: flex; align-items: center; gap: 4px; height: 120px; margin-bottom: 28px; }
.auth-wave i { flex: 1 1 0; border-radius: 2px; background: var(--brand); transform-origin: center; }
.auth-wave i.rest { background: #3A4A43; }
.auth-line { font-family: var(--font-display); font-size: clamp(32px, 3.4vw, 46px); font-weight: 600; letter-spacing: -.05em; line-height: 1.02; margin: 0; max-width: 520px; }
.auth-line span { color: var(--brand); }
.auth-foot { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--on-dark-3); margin: 0; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth .box { width: 100%; max-width: 400px; }
.auth .card { background: none; border: 0; box-shadow: none; padding: 0; }
.auth h1 { font-size: 36px; margin-bottom: 8px; }
.auth h1 + .muted { margin-bottom: 22px; }
.auth input[type=text], .auth input[type=email], .auth input[type=password] { padding: 12px 14px; }
.auth .btn { width: 100%; justify-content: center; margin-top: 6px; padding: 13px 18px; font-size: 15px; }
.auth .alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--ink-2); }
@media (prefers-reduced-motion: no-preference) {
  .auth-wave i { animation: auth-bar 1.1s ease-in-out infinite alternate; }
}
@keyframes auth-bar { from { transform: scaleY(.45) } to { transform: scaleY(1) } }
@media (max-width: 860px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { padding: 18px 20px; }
  .auth-side > div, .auth-foot { display: none; }
  .auth-main { align-items: flex-start; padding: 36px 20px 48px; }
}

/* ---------- charts (plain HTML bars) ---------- */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 8px; border-bottom: 1px solid var(--border); }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 3px; position: relative; }
.bars .b i { display: block; background: var(--brand-bright); border-radius: 3px 3px 0 0; min-height: 0; }
.bars .b i.h { background: var(--human); border-radius: 0; }
.bars .b:hover i { filter: brightness(.92); }
.axis { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); margin-top: 8px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--brand-bright); vertical-align: -1px; }
.legend span.h::before { background: var(--human); }
.hbar { display: grid; grid-template-columns: 110px 1fr 70px; gap: 10px; align-items: center; font-size: 14px; margin: 9px 0; }
.hbar .track { background: var(--bg); border-radius: 999px; height: 8px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 999px; background: var(--machine); }
.hbar .fill.HUMAN { background: var(--human); }
.hbar .fill.fb { background: var(--fallback); }
.meter { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; height: 10px; overflow: hidden; margin: 10px 0 6px; }
.meter i { display: block; height: 100%; background: var(--brand-bright); border-radius: 999px; }
.meter i.warn { background: var(--fallback); }

/* ---------- keys ---------- */
.keybox { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px dashed var(--brand-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.keybox code { flex: 1; font-family: var(--font-mono); font-size: 14px; word-break: break-all; }
pre.code { background: var(--dark); color: #DDE5D9; border-radius: var(--radius-sm); padding: 16px 18px; overflow-x: auto;
           font-family: var(--font-mono); font-size: 13px; line-height: 1.65; margin: 0; }
details.inline summary { cursor: pointer; color: var(--brand-text); font-weight: 600; font-size: 13px; }
details.inline[open] { margin-top: 6px; }
audio { height: 32px; max-width: 220px; vertical-align: middle; }
.danger-zone { border-color: #F1C9CC; }

/* ---------- plan cards (Billing), same layout as the website's pricing ---------- */
.plan-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(185px, 100%), 1fr)); align-items: stretch; }
.plan-card { display: flex; flex-direction: column; padding: 24px 22px; position: relative; }
.plan-card.current { border: 2px solid var(--ink); }
.plan-card.popular { border: 2px solid var(--brand-2); }
.plan-tag { position: absolute; top: -11px; left: 20px; background: var(--brand-bright); color: var(--on-brand); font-family: var(--font-mono); font-size: 10px;
            font-weight: 500; padding: 4px 10px; border-radius: 999px; letter-spacing: .12em; text-transform: uppercase; }
.plan-card.current .plan-tag { background: var(--ink); color: var(--bg); }
.plan-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.plan-top h2 { margin: 0; font-size: 19px; }
.plan-price { font-family: var(--font-display); font-size: 38px; font-weight: 600; letter-spacing: -.05em; margin: 14px 0 2px; line-height: 1.1; }
.plan-price small { font-family: var(--font); font-size: 15px; color: var(--ink-2); font-weight: 500; letter-spacing: 0; }
.plan-note { font-size: 13px; color: var(--ink-2); margin: 0 0 18px; }
.ticks { list-style: none; padding: 0; margin: 0 0 22px; font-size: 14px; }
.ticks li { position: relative; padding-left: 28px; margin: 0 0 11px; line-height: 1.45; }
.ticks li::before { content: ""; position: absolute; left: 0; top: 1px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--human-tint) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='%231E6B43' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat; }
.plan-action { margin-top: auto; }
.btn.wide { width: 100%; justify-content: center; }

/* ---------- platform admin ---------- */
.flash.viewas { background: var(--brand-tint); color: var(--brand-text); }
.side .tag { display: inline-block; font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
             color: #FFB3B9; background: rgba(217, 67, 79, .2); border-radius: 999px; padding: 3px 9px; margin: 0 0 12px 10px;
             align-self: flex-start; }
.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 7px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { width: 240px; max-width: 100%; }
.filters select { width: auto; }
details.panel { margin-top: 16px; }
details.panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 22px; font-weight: 600; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "+"; font-size: 20px; color: var(--ink-2); line-height: 1; }
details.panel[open] > summary::after { content: "–"; }
details.panel > .body { padding: 0 22px 22px; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); vertical-align: -2px; margin-right: 6px; }
.mini-bars { display: flex; align-items: flex-end; gap: 3px; height: 70px; }
.mini-bars i { flex: 1; background: var(--brand-bright); border-radius: 2px 2px 0 0; min-height: 1px; }
.mini-bars i.zero { background: var(--border); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong);
           border-radius: var(--radius-sm); padding: 10px 13px; min-height: 90px; resize: vertical; }
.radio { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; margin: 6px 0; cursor: pointer; }
.radio input { margin-top: 4px; accent-color: var(--ink); }
.inline-form { display: inline; }

/* phones: these come last so they win over the block styles above */
@media (max-width: 860px) {
  .shell { align-content: start; }  /* short pages: extra height goes below, not into the header */
  .side .tag { margin: 0; align-self: center; }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 16px; }
  .tile .value { font-size: 26px; }
  h1 { font-size: 26px; }
}

/* ---------- light theme: every white-label brand's portal (body.light) ----------
   Clean and neutral; the partner's own colors arrive through the --brand-* tokens (theme_css in web/app.py targets
   body.light so they win over these defaults). No dark surfaces. */
body.light {
  --brand: #2563EB; --brand-bright: #2563EB; --brand-bright-hover: #1D4ED8; --brand-2: #2563EB;
  --brand-text: #1D4ED8; --brand-tint: #EFF4FF; --on-brand: #FFFFFF;
  --ink: #111827; --ink-2: #5B6472; --ink-3: #9AA3AF; --bg: #F6F7F9; --surface: #FFFFFF;
  --border: #E5E7EB; --border-strong: #D1D5DB;
  --font-display: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .04);
}
.light h1 { letter-spacing: -.025em; }
.light h2 { letter-spacing: -.01em; }
.light .side { background: var(--surface); color: var(--ink); border-right: 1px solid var(--border); }
.light .side .logo, .light .side .logo .name { color: var(--ink); }
.light .logo img.plate { background: none; padding: 0; }
.light .side nav a { color: var(--ink-2); }
.light .side nav a:hover { background: var(--bg); color: var(--ink); }
.light .side nav a.on { background: var(--brand-tint); color: var(--brand-text); }
.light .side nav a svg { color: var(--ink-3); }
.light .side nav a.on svg { color: var(--brand-text); }
.light .side .foot { border-top-color: var(--border); }
.light .side .foot .muted { color: var(--ink-2); }
.light .side .linkbtn { color: var(--brand-text); }
.light .side .tag { color: var(--brand-text); background: var(--brand-tint); }
.light .btn.primary { background: var(--brand-text); color: #FFFFFF; }
.light .btn.primary:hover { background: var(--brand-text); filter: brightness(.9); }
.light .btn.secondary:hover { border-color: var(--ink-2); }
.light pre.code { background: #0F172A; color: #E2E8F0; }
.light .plan-card.popular { border-color: var(--brand-text); }
.light .plan-tag { background: var(--brand-text); color: #FFFFFF; }
.light .keybox { border-color: var(--brand-text); }
.light input:focus, .light select:focus, .light textarea:focus { border-color: var(--brand-text); }
.light .check input, .light .radio input { accent-color: var(--brand-text); }
.light tbody tr:hover { background: #FAFBFC; }

/* the light sign-in pages: one centered card, the partner's logo above it, a thin bar in its color */
.auth-clean { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 48px 16px; background: var(--bg); }
.auth-clean .box { width: 100%; max-width: 420px; }
.auth-clean .logo { display: flex; justify-content: center; align-items: center; margin-bottom: 26px; color: var(--ink); }
.auth-clean .logo .name { font-weight: 700; font-size: 24px; letter-spacing: -.02em; }
.auth-clean .card { padding: 32px; border-top: 3px solid var(--brand); }
.auth-clean h1 { font-size: 24px; margin-bottom: 6px; }
.auth-clean h1 + .muted { margin-bottom: 20px; }
.auth-clean input[type=text], .auth-clean input[type=email], .auth-clean input[type=password] { padding: 11px 13px; }
.auth-clean .btn { width: 100%; justify-content: center; margin-top: 6px; padding: 12px 18px; font-size: 15px; }
.auth-clean .alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--ink-2); }
.auth-clean .powered { text-align: center; margin-top: 28px; font-size: 12px; color: var(--ink-3); }

/* partner console bits */
.steps-list { list-style: none; padding: 0; margin: 0; counter-reset: st; }
.steps-list li { counter-increment: st; position: relative; padding: 0 0 14px 38px; }
.steps-list li::before { content: counter(st); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
                         background: var(--brand-tint); color: var(--brand-text); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.steps-list li.done::before { content: "✓"; background: var(--human-tint); color: var(--human-text); }
.copyline { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }
.copyline code { flex: 1; font-family: var(--font-mono); font-size: 13px; word-break: break-all; }
