/* ==========================================================================
   HFAPI — console stylesheet
   --------------------------------------------------------------------------
   Art direction: "ink and paper".

   Deliberately not a gradient-heavy dashboard. The references are editorial
   print and engineering tools: near-monochrome, one accent, type carrying the
   hierarchy, hairline rules instead of drop shadows, and room to breathe.
   Colour appears only where it carries meaning — state, data, the single
   primary action.

     1. tokens
     2. reset and base
     3. shell
     4. typographic blocks
     5. surfaces
     6. data display
     7. controls
     8. overlays
     9. charts
    10. auth
    11. responsive
   ========================================================================== */

/* ---------------------------------------------------------------- 1. tokens */
:root {
  /* Paper and ink. The neutrals are warm — a trace of red at the dark end, a
     trace of yellow at the light end — so surfaces read as material rather than
     as pure #ffffff. */
  --paper:      #fbfaf8;
  --paper-2:    #f4f2ee;
  --surface:    #ffffff;
  --surface-2:  #faf9f7;

  --ink:        #14120f;
  --ink-2:      #4a453e;
  --ink-3:      #8a8378;
  --ink-4:      #bcb5a9;

  --rule:       #e6e2da;
  --rule-soft:  #f1eee8;

  /* One accent. Deep teal reads as considered rather than fashionable, and it
     holds against warm neutrals where violet fights them. */
  --accent:     #0f766e;
  --accent-ink: #0b5d56;
  --accent-bg:  #eef7f5;

  /* Data series and status, kept print-muted. */
  --data-1:     #0f766e;
  --data-2:     #b45309;
  --ok:         #15803d;
  --ok-bg:      #f0f7f1;
  --warn:       #a16207;
  --warn-bg:    #fbf6ea;
  --err:        #b91c1c;
  --err-bg:     #fbf0f0;

  /* Type scale. Real steps, nothing crowding 14 against 15. */
  --t-micro:  10.5px;
  --t-xs:     12px;
  --t-sm:     13px;
  --t-base:   14px;
  --t-md:     15.5px;
  --t-lg:     19px;
  --t-xl:     26px;
  --t-2xl:    38px;

  --tracking-tight: -0.022em;
  --tracking-wide:   0.09em;

  /* Rhythm on a 4px base, but the page breathes on 8 / 12 / 20 / 32. */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 20px;
  --sp-5: 28px;
  --sp-6: 40px;

  /* Radii are architectural: small by default, round only for pills. */
  --r-1: 4px;
  --r-2: 6px;
  --r-3: 8px;
  --r-pill: 999px;

  /* Elevation is barely there; a hairline does most of the work. */
  --lift-1: 0 1px 2px rgba(20, 18, 15, 0.04);
  --lift-2: 0 4px 16px rgba(20, 18, 15, 0.06);
  --lift-3: 0 16px 48px rgba(20, 18, 15, 0.12);

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --d-1: 110ms;
  --d-2: 180ms;

  --side-w: 236px;
  --bar-h: 64px;

  /* Legacy aliases, so older component rules keep resolving. */
  --bg: var(--paper);
  --fg: var(--ink);
  --fg-2: var(--ink-2);
  --fg-3: var(--ink-3);
  --line: var(--rule);
  --line-soft: var(--rule-soft);
  --p: var(--accent);
  --p-soft: var(--accent-bg);
  --p-line: #cfe4e0;
  --radius: var(--r-3);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:     #0c0c0d;
    --paper-2:   #121213;
    --surface:   #161617;
    --surface-2: #1a1a1c;

    --ink:       #f4f2ee;
    --ink-2:     #a8a29a;
    --ink-3:     #6f6a62;
    --ink-4:     #4a463f;

    --rule:      #26252a;
    --rule-soft: #1e1d21;

    --accent:     #2dd4bf;
    --accent-ink: #5eead4;
    --accent-bg:  rgba(45, 212, 191, 0.10);

    --data-1: #2dd4bf;
    --data-2: #f59e0b;
    --ok:     #4ade80;
    --ok-bg:  rgba(74, 222, 128, 0.10);
    --warn:   #fbbf24;
    --warn-bg: rgba(251, 191, 36, 0.10);
    --err:    #f87171;
    --err-bg: rgba(248, 113, 113, 0.10);

    --lift-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --lift-2: 0 4px 16px rgba(0, 0, 0, 0.5);
    --lift-3: 0 16px 48px rgba(0, 0, 0, 0.7);

    --p-line: rgba(45, 212, 191, 0.28);
  }
}

/* ------------------------------------------------------------ 2. reset, base */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--t-base);
  line-height: 1.62;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
}

code, .mono {
  font-family: ui-monospace, 'SF Mono', SFMono-Regular, 'Cascadia Mono',
    Consolas, 'Liberation Mono', monospace;
  font-size: 0.92em;
  font-variant-ligatures: none;
}

/* Numbers align on the decimal everywhere. */
.tile-value, .kv-v, .legend-val, .tbl td, .group-meta {
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

::selection { background: var(--accent); color: var(--paper); }

.hidden { display: none !important; }
.mt { margin-top: var(--sp-3); }
.ml { margin-left: 6px; }
.break { word-break: break-all; }
.muted { font-size: var(--t-xs); color: var(--ink-3); }
.empty {
  padding: var(--sp-5);
  text-align: center;
  color: var(--ink-3);
  font-size: var(--t-sm);
}

/* Scrollbars, kept out of the way. */
* { scrollbar-width: thin; scrollbar-color: var(--ink-4) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--rule);
  border: 3px solid transparent;
  border-radius: var(--r-pill);
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: var(--ink-4);
  background-clip: content-box;
}

/* ----------------------------------------------------------------- 3. shell */
.shell { display: flex; min-height: 100vh; }

.side {
  width: var(--side-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-right: 1px solid var(--rule);
  position: sticky;
  top: 0;
  height: 100vh;
}

/* Mark and wordmark share a baseline; the descriptor tracks out beneath. */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  border-bottom: 1px solid var(--rule-soft);
}

.brand-mark { display: flex; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.brand-name {
  font-size: var(--t-md);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.1;
}

.brand-sub {
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-3);
  line-height: 1.2;
}

.nav { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-2); }

.nav-group {
  padding: var(--sp-4) 10px var(--sp-2);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-4);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 1px;
  border-radius: var(--r-2);
  font-size: var(--t-sm);
  font-weight: 450;
  color: var(--ink-2);
  text-decoration: none;
  position: relative;
  transition: color var(--d-1) var(--ease),
              background var(--d-1) var(--ease);
}

.nav-item svg { flex-shrink: 0; opacity: 0.72; }

.nav-item:hover { color: var(--ink); background: var(--paper-2); }

.nav-item.active {
  color: var(--ink);
  background: var(--surface);
  font-weight: 600;
  box-shadow: var(--lift-1);
}

.nav-item.active svg { opacity: 1; color: var(--accent); }

/* A rule, not a filled block: quieter, and it marks position. */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  border-radius: var(--r-pill);
  background: var(--accent);
}

.side-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--sp-3);
  border-top: 1px solid var(--rule);
}

/* The default avatar, in the footer and in the phone bar. The plate is a warm
   neutral so the cat's white fur does not read as a hole in the page. */
.who-avatar {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  background: var(--paper-2);
  border: 1px solid var(--rule);
}

.who-avatar.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
}

.who { flex: 1; min-width: 0; }

.who-role {
  display: block;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-4);
}

.who-name {
  display: block;
  font-size: var(--t-xs);
  font-weight: 500;
  color: var(--ink-2);
  /* Two lines rather than one truncated one: a long address is the common
     case, and the footer has the vertical room for it. */
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--bar-h);
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 6;
}

.topbar h1 {
  font-size: var(--t-md);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}

.content { padding: var(--sp-6); width: 100%; max-width: 1440px; }

/* -------------------------------------------------- 4. typographic blocks */
.view { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}

.hint {
  margin-top: var(--sp-2);
  font-size: var(--t-xs);
  line-height: 1.75;
  color: var(--ink-3);
}

.hint.center { text-align: center; }
.hint.strong { color: var(--warn); }

.loading {
  padding: var(--sp-6);
  text-align: center;
  color: var(--ink-3);
  font-size: var(--t-sm);
  letter-spacing: 0.02em;
}

.alert {
  padding: 11px 14px;
  border-radius: var(--r-2);
  font-size: var(--t-sm);
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 22%, transparent);
}

.alert.err {
  background: var(--err-bg);
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 22%, transparent);
}

/* Informational, not a warning: this is a trade the user is being offered, so it
   must not read as an error. Accent colour rather than amber. */
.alert.info {
  background: var(--accent-bg);
  color: var(--ink-2);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}

.alert.info b { color: var(--accent-ink); }

/* The 破甲 column: the switch plus the per-request cost under it. */
.unrestrict-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.unrestrict-cost {
  font-size: var(--t-micro);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  cursor: help;
}

/* Shown only while the switch is on: a standing reminder of what it costs. */
.kunrestrict-note {
  margin: 8px 0 2px;
  padding: 8px 10px;
  font-size: var(--t-xs);
  line-height: 1.6;
  color: var(--warn);
  background: var(--warn-bg);
  border-radius: var(--r-1);
}

/* ---- preview mode ------------------------------------------------------- */
/* An admin looking at a customer page. The bar has to be unmissable: the whole
   risk is that the operator forgets they are in a preview and expects a button
   to work. */
.preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--warn-bg);
  border: 1px solid color-mix(in srgb, var(--warn) 26%, transparent);
  border-radius: var(--r-2);
  font-size: var(--t-sm);
  color: var(--ink-2);
}

.preview-bar-tag {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: var(--t-micro);
  font-weight: 650;
  letter-spacing: var(--tracking-wide);
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  border-radius: var(--r-pill);
}

.preview-bar-text { flex: 1 1 auto; min-width: 0; line-height: 1.55; }

/* A disabled control in preview mode: dimmed, but still readable so the
   operator can see what the label says. */
.btn.is-preview {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- mail preview ------------------------------------------------------- */
/* Shows the exact HTML the server will deliver. The iframe-free wrapper is
   deliberate: the mail's own inline styles are what has to be seen, and a
   nested document would need its own stylesheet to look right. */
.mail-preview {
  margin: 14px 0;
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  overflow: hidden;
  background: var(--surface-2);
}

.mail-preview-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule-soft);
  font-size: var(--t-sm);
}

.mail-preview-tag {
  padding: 2px 8px;
  font-size: var(--t-micro);
  font-weight: 650;
  letter-spacing: var(--tracking-wide);
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: var(--r-pill);
}

.mail-preview-frame {
  padding: 0;
  background: #f4f6f9;
}

/* The rendered mail is 560px wide by design; on a narrow console it scales
   rather than overflowing the card. */
.mail-preview-frame > div { max-width: 100% !important; }

/* ---- theme picker ------------------------------------------------------- */
/* One chip per theme. The chip shows the name and a one-line hint; the sample
   render underneath changes on click, so the operator sees the actual mail
   rather than a colour swatch. */
.theme-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.theme-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  font-family: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.theme-chip:hover {
  border-color: var(--ink-4);
  background: var(--surface-2);
}

.theme-chip.on {
  border-color: var(--accent);
  background: var(--accent-bg);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.theme-chip-name {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink);
}

.theme-chip.on .theme-chip-name { color: var(--accent-ink); }

.theme-chip-hint {
  font-size: var(--t-micro);
  color: var(--ink-3);
  line-height: 1.4;
}

.theme-preview {
  margin-bottom: 4px;
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  overflow: hidden;
  background: var(--surface-2);
}

.theme-preview .mail-preview-frame { padding: 0; }

/* --------------------------------------------------------------- 5. surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--rule-soft);
}

.card-head h2 {
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.card-body { padding: var(--sp-4); }

/* ---------------------------------------------------------- 6. data display */
/* Stat tiles: one shared rule grid rather than four floating cards. */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  overflow: hidden;
}

.tile {
  padding: var(--sp-4);
  background: var(--surface);
  transition: background var(--d-2) var(--ease);
}

.tile:hover { background: var(--surface-2); }

.tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.tile-title {
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-3);
}

.tile-icon { display: flex; color: var(--ink-4); }
.tile:hover .tile-icon { color: var(--accent); }

.tile-value {
  margin-top: var(--sp-2);
  font-size: var(--t-2xl);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.05;
  color: var(--ink);
}

/* Key/value rows: label small, value on the baseline, hairline between. */
.kv { display: flex; flex-direction: column; }

.kv-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: 9px 0;
  font-size: var(--t-sm);
  border-bottom: 1px solid var(--rule-soft);
}

.kv-row:last-child { border-bottom: none; }

.kv-k {
  flex-shrink: 0;
  min-width: 92px;
  font-size: var(--t-xs);
  color: var(--ink-3);
}

.kv-v { flex: 1; color: var(--ink); word-break: break-word; }
.kv-v.code { font-family: ui-monospace, Consolas, monospace; font-size: var(--t-xs); }

/* Tables: rules only. No zebra, no boxes, no heavy header fill. */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }

.tbl th {
  padding: 9px var(--sp-3);
  text-align: left;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-4);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

.tbl td {
  padding: 12px var(--sp-3);
  font-size: var(--t-sm);
  color: var(--ink);
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: middle;
}

.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background var(--d-1) var(--ease); }
.tbl tbody tr:hover { background: var(--surface-2); }

/* Status: a hairline pill, not a filled badge. */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
  background: var(--paper-2);
  color: var(--ink-2);
  border: 1px solid var(--rule);
}

.tag.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 24%, transparent); }
.tag.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 24%, transparent); }
.tag.err  { background: var(--err-bg);  color: var(--err);  border-color: color-mix(in srgb, var(--err) 24%, transparent); }
.tag.off  { background: transparent;    color: var(--ink-3); }

/* --------------------------------------------------------------- 7. controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--d-1) var(--ease),
              border-color var(--d-1) var(--ease),
              color var(--d-1) var(--ease);
}

.btn:hover { background: var(--paper-2); border-color: var(--ink-4); }

/* The primary action is ink, not a colour. It reads as printed, and it keeps
   the accent reserved for state and data. */
.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-weight: 550;
}

.btn.primary:hover {
  background: color-mix(in srgb, var(--ink) 84%, var(--accent));
  border-color: transparent;
}

.btn.primary:disabled,
.btn.primary[disabled] {
  background: var(--ink-4);
  border-color: var(--ink-4);
  color: var(--surface);
  cursor: not-allowed;
  opacity: 1;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.block { width: 100%; padding: 11px; font-size: var(--t-base); }
.btn.sm { padding: 6px 12px; font-size: var(--t-xs); }

.btn.ghost {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink-2);
}

.btn.ghost:hover { background: var(--paper-2); color: var(--ink); }

.btn-sm {
  padding: 5px 10px;
  font-family: inherit;
  font-size: var(--t-xs);
  font-weight: 500;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--r-1);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--d-1) var(--ease);
}

.btn-sm:hover { color: var(--ink); border-color: var(--ink-4); background: var(--paper-2); }

/* The emphasised small button: used where one action in a row is the intended
   one (加好友 / 加群), so it should not look identical to a plain 复制. */
.btn-sm.primary {
  color: var(--paper);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.btn-sm.primary:hover {
  color: var(--paper);
  background: var(--accent-ink);
  border-color: var(--accent-ink);
}
.btn-sm.danger:hover {
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 40%, transparent);
  background: var(--err-bg);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: var(--ink-3);
  background: transparent;
  border: none;
  border-radius: var(--r-2);
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}

.btn-icon:hover { background: var(--paper-2); color: var(--ink); }
.btn-icon.logout:hover { color: var(--err); }

.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* The user row's five actions. On a wide screen the "更多" popover is simply
   never opened - the button and its menu are laid out inline. On a phone the
   menu drops below the row instead of widening it, which is what used to push
   the table past the right edge. */
.user-actions { position: relative; }
.more-menu { display: none; }
.more-menu.open {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--rule, #e3ded3);
}
/* Desktop: everything fits, so the overflow never appears. */
@media (min-width: 821px) {
  .more-toggle { display: none; }
  .more-menu { display: flex !important; gap: 6px; margin: 0; padding: 0;
               border: none; width: auto; }
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.input, .search, .sel {
  font-family: inherit;
  font-size: var(--t-sm);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  transition: border-color var(--d-1) var(--ease),
              box-shadow var(--d-1) var(--ease);
}

.input { display: block; width: 100%; padding: 11px 13px; font-size: var(--t-md); }
.search { padding: 8px 11px; min-width: 190px; }
.sel { padding: 7px 10px; }
.sel.wide { width: 100%; padding: 9px 11px; }

.input:focus, .search:focus, .sel:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.input::placeholder, .search::placeholder { color: var(--ink-4); }

.lbl {
  display: block;
  margin-bottom: 6px;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-3);
}

.field { margin-bottom: var(--sp-3); }

/* A note under an input: what it accepts, why it is needed. Smaller than the
   label and quieter than the value, so it reads as guidance. */
.field-hint {
  margin-top: 6px;
  font-size: var(--t-xs);
  line-height: 1.65;
  color: var(--ink-3);
}
.field .lbl { margin-top: 0; }

.code-row { display: flex; gap: 8px; align-items: stretch; }
.code-row .input { flex: 1; min-width: 0; }
.code-row .btn { flex-shrink: 0; }

.form-msg { margin-bottom: var(--sp-3); font-size: var(--t-sm); line-height: 1.6; }

.form-msg.err {
  padding: 9px 12px;
  color: var(--err);
  background: var(--err-bg);
  border: 1px solid color-mix(in srgb, var(--err) 22%, transparent);
  border-radius: var(--r-2);
}

.chk {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: var(--sp-3) 0;
  font-size: var(--t-sm);
  color: var(--ink-2);
  cursor: pointer;
}

.chk input { cursor: pointer; accent-color: var(--accent); }

/* Switch: thin track, solid knob. */
.switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  padding: 0;
  background: var(--rule);
  border: none;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--d-2) var(--ease);
}

.switch.on { background: var(--accent); }
.switch.disabled { opacity: 0.4; cursor: not-allowed; }

.knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform var(--d-2) var(--ease);
}

.switch.on .knob { transform: translateX(16px); }

/* -------------------------------------------------------------- 8. overlays */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: color-mix(in srgb, var(--ink) 42%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  box-shadow: var(--lift-3);
}

.modal h3 {
  margin-bottom: var(--sp-3);
  font-size: var(--t-md);
  font-weight: 650;
  letter-spacing: var(--tracking-tight);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: var(--sp-4);
}

.sheet-handle { display: none; }

.secret-box {
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  background: var(--ok-bg);
  border: 1px solid color-mix(in srgb, var(--ok) 26%, transparent);
  border-radius: var(--r-2);
}

.secret-box.hidden { display: none; }
.mono.block { display: block; margin: 8px 0; line-height: 1.7; word-break: break-all; }

/* ------------------------------------------------------- 8b. announcement */
/* A one-shot notice. It borrows .modal-mask so it dims the page the same way
   every other dialog does, but the body is its own element: an announcement
   carries long prose, a header, and two actions that are not symmetric, and
   none of that fits the .modal skeleton without fighting it. */
.announce-mask {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: color-mix(in srgb, var(--ink) 46%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: announce-in 0.18s var(--ease);
}

.announce {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  /* Taller than the other dialogs on purpose: this notice carries the reward
     code and two tappable contact rows inside its body, and at 86vh the code
     fell below the fold on a laptop - which defeats the point of putting it
     there. 92vh keeps the buttons on screen while giving the body room. */
  max-height: 92vh;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  box-shadow: var(--lift-3);
  overflow: hidden;
}

.announce-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--rule-soft);
}

/* The accent rail is the one piece of colour: it marks the notice as
   editorial rather than as a form, which is what it is. */
.announce-mark {
  flex: 0 0 auto;
  width: 3px;
  align-self: stretch;
  margin: 2px 0;
  background: var(--accent);
  border-radius: var(--r-pill);
}

.announce-titles { flex: 1 1 auto; min-width: 0; }

.announce-eyebrow {
  margin-bottom: 3px;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--accent);
}

.announce-title {
  font-size: var(--t-lg);
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
}

.announce-close {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: -4px -8px 0 0;
  padding: 0;
  font-size: 17px;
  line-height: 1;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  border-radius: var(--r-2);
  cursor: pointer;
}

.announce-close:hover { color: var(--ink); background: var(--surface-2); }

.announce-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-5);
  font-size: var(--t-base);
  line-height: 1.72;
  color: var(--ink-2);
  -webkit-overflow-scrolling: touch;
}

.announce-body p { margin: 0 0 11px; }
.announce-body p:last-child { margin-bottom: 0; }
.announce-body b, .announce-body strong { color: var(--ink); font-weight: 650; }
.announce-body ul, .announce-body ol { margin: 0 0 11px; padding-left: 20px; }
.announce-body li { margin-bottom: 5px; }
.announce-body code {
  padding: 1px 5px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.92em;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-1);
}

/* A dated aside - "本次更新" style notes sit here. */
.announce-note {
  margin-top: var(--sp-3);
  padding: 10px var(--sp-3);
  font-size: var(--t-sm);
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--accent-bg);
  border-radius: var(--r-2);
}

.announce-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5) var(--sp-4);
  border-top: 1px solid var(--rule-soft);
  background: var(--surface);
}

/* The two actions are deliberately unequal. "不再显示" is the permanent one and
   gets the weight; "取消" is the deferral and stays quiet on the left. */
.announce-actions {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: var(--sp-2);
}

.announce-actions .btn { flex: 0 0 auto; }
.announce-actions .btn.grow { flex: 1 1 auto; }

/* A button that is not yet answerable. It keeps its box so the row does not
   reflow when it enables - a button that jumps 20px at the moment it becomes
   clickable is exactly when a hurried click lands on the wrong one. */
.btn[data-cooling] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* The remaining seconds, inline in the label. Tabular figures keep the label
   from twitching as the digit changes. */
.btn .cool-num {
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.announce-hint {
  flex: 1 1 auto;
  font-size: var(--t-xs);
  line-height: 1.5;
  color: var(--ink-3);
}

/* The hint and the way out share a line: the footer is the tightest part of the
   dialog, and two stacked lines there cost the body a paragraph of height. */
.announce-hint a { color: var(--accent); font-weight: 600; }

/* ---- inline pieces inside the dialog body ---- */

/* "免费续杯 / 赞助购买" as a labelled pair. A bulleted list would add a second
   indent level inside a dialog that is already narrow; a two-column pair keeps
   the label and the explanation on one line each. */
.announce-pair {
  display: flex;
  gap: 10px;
  margin: 0 0 8px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-2);
}

.announce-pair-k {
  flex: 0 0 60px;
  font-size: var(--t-sm);
  font-weight: 650;
  color: var(--accent);
  line-height: 1.6;
}

.announce-pair-v {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--t-sm);
  line-height: 1.6;
  color: var(--ink-2);
}

/* A tappable contact inside the body. Anchored so the long-press menu offers
   copy; the trailing button is for the desktop where long-press does not exist. */
.announce-contact-row {
  display: block;
  margin: 0 0 8px;
  text-decoration: none;
  color: inherit;
}

.announce-contact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.announce-contact-row:hover .announce-contact {
  background: var(--accent-bg);
  border-color: color-mix(in srgb, var(--accent) 34%, transparent);
}

.announce-contact-ico {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: var(--r-2);
}

.announce-contact-main { flex: 1 1 auto; min-width: 0; }

.announce-contact-title {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink);
}

.announce-contact-sub {
  margin-top: 1px;
  font-size: var(--t-xs);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Explains what the two buttons above do. Small and grey: it is a caption, not
   a call to action. */
.announce-tip {
  margin: 0 0 12px;
  font-size: var(--t-xs);
  line-height: 1.6;
  color: var(--ink-3);
}

/* The reward code inside the dialog: small, inline, tap to enlarge. */
.announce-zanshang {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 12px;
  padding: 10px 12px;
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: var(--r-2);
}

.announce-zanshang img {
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--r-1);
  cursor: zoom-in;
}

.announce-zanshang-cap {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--t-xs);
  line-height: 1.65;
  color: var(--ink-2);
}

.announce-zanshang-cap b { color: var(--ink); }

/* The closing request not to abuse the site. Tinted because it is the one line
   in the notice that is a request rather than information. */
.announce-warn {
  margin-top: 4px;
  padding: 10px 12px;
  font-size: var(--t-sm);
  line-height: 1.7;
  color: var(--ink-2);
  background: var(--warn-bg);
  border-radius: var(--r-2);
}

.announce-warn b { color: var(--warn); }

/* --------------------------------------------------------- 8d. redeem */
/* The code field is monospaced and wide-tracked: a code is read character by
   character when it does not work, and a proportional font makes that harder. */
.code-input {
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.redeem-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.redeem-row .input { flex: 1 1 auto; min-width: 0; }
.redeem-row .btn { flex: 0 0 auto; }

.redeem-balance {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--accent-bg);
  border-radius: var(--r-2);
}

.redeem-balance-k { font-size: var(--t-sm); color: var(--ink-2); }

.redeem-balance-v {
  font-size: var(--t-lg);
  font-weight: 650;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}

/* Codes redeemed in this session. Not a server history - it is here so the
   user can see that the thing they just pasted was accepted, which the toast
   alone does not prove once it fades. */
.redeem-history { margin-top: 10px; }

.redeem-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--rule-soft);
  font-size: var(--t-sm);
}

.redeem-history-code {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono, ui-monospace, monospace);
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.redeem-history-amt {
  flex: 0 0 auto;
  font-weight: 600;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .redeem-row { flex-direction: column; }
  .redeem-row .btn { width: 100%; }
}

/* The public/one-shot switch on the admin redeem page. Boxed because it changes
   what the whole form below it means - it is a mode, not a checkbox. */
.redeem-mode {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-2);
}

.redeem-mode-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.redeem-mode-main { flex: 1 1 auto; min-width: 0; }

.redeem-mode-title {
  font-size: var(--t-base);
  font-weight: 600;
  color: var(--ink);
}

.redeem-mode-sub {
  margin-top: 2px;
  font-size: var(--t-xs);
  line-height: 1.5;
  color: var(--ink-3);
}

.redeem-mode .hint { margin: 8px 0 0; }

/* Publish state strip on the announcement editor: the operator needs to know
   which version users are currently seeing before deciding to push a new one. */
.notice-status {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-2);
  font-size: var(--t-sm);
}

.notice-status-k { color: var(--ink-3); }

.notice-status-v {
  font-weight: 650;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

@keyframes announce-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes announce-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.announce { animation: announce-pop 0.2s var(--ease); }

/* ------------------------------------------------------ 8c. notice page */
/* The announcement as a page, not a dialog.
 *
 * The dialog can be dismissed forever, so anything that lives only in it is
 * unreachable afterwards. The reward code is the case that matters: a user who
 * clicked 不再显示 six months ago still has to be able to find it. So the same
 * content is published as a route, and the dialog is only the first sighting. */
.notice { max-width: 720px; }

.notice-hero {
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
}

.notice-hero h2 {
  margin: 0 0 var(--sp-3);
  font-size: var(--t-xl);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: var(--tracking-tight);
}

.notice-lede {
  margin: 0;
  font-size: var(--t-base);
  line-height: 1.75;
  color: var(--ink-2);
}

.notice-body {
  margin-top: var(--sp-4);
  font-size: var(--t-base);
  line-height: 1.8;
  color: var(--ink-2);
}

.notice-body p { margin: 0 0 var(--sp-3); }
.notice-body p:last-child { margin-bottom: 0; }
.notice-body b { color: var(--ink); font-weight: 650; }

/* ---- the appeal ---- */
/* Set apart on purpose. Asking for money inside a paragraph reads as a trap;
   asking in its own quiet block reads as an ask. */
.notice-ask {
  margin-top: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: var(--r-3);
}

.notice-ask h3 {
  margin: 0 0 var(--sp-2);
  font-size: var(--t-md);
  font-weight: 650;
  color: var(--ink);
}

.notice-ask p {
  margin: 0 0 var(--sp-3);
  font-size: var(--t-sm);
  line-height: 1.75;
  color: var(--ink-2);
}

.notice-ask p:last-of-type { margin-bottom: var(--sp-3); }

/* ---- reward code ---- */
.zanshang {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--sp-4);
}

.zanshang-img {
  flex: 0 0 auto;
  width: 200px;
  max-width: 100%;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  cursor: zoom-in;
}

.zanshang-img img { display: block; width: 100%; height: auto; border-radius: var(--r-1); }

.zanshang-side { flex: 1 1 200px; min-width: 0; }

.zanshang-cap {
  font-size: var(--t-sm);
  line-height: 1.75;
  color: var(--ink-2);
}

.zanshang-cap b { color: var(--ink); }

/* ---- contact rows ---- */
.contact-list { display: flex; flex-direction: column; gap: 8px; margin-top: var(--sp-3); }

.contact-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.contact-row:hover {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--rule));
}

.contact-ico {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: var(--r-2);
}

.contact-main { flex: 1 1 auto; min-width: 0; }

.contact-title {
  font-size: var(--t-base);
  font-weight: 600;
  color: var(--ink);
}

.contact-sub {
  margin-top: 2px;
  font-size: var(--t-xs);
  line-height: 1.5;
  color: var(--ink-3);
  word-break: break-all;
}

.contact-go {
  flex: 0 0 auto;
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--accent);
}

/* A highlighted row: the QQ group is the one that actually gets people their
   tokens, so it gets the emphasis. */
.contact-row.primary {
  background: var(--accent-bg);
  border-color: color-mix(in srgb, var(--accent) 26%, transparent);
}

.contact-row.primary:hover {
  border-color: color-mix(in srgb, var(--accent) 46%, transparent);
}

/* ---- lightbox ---- */
.zanshang-zoom {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: color-mix(in srgb, var(--ink) 76%, transparent);
  cursor: zoom-out;
}

.zanshang-zoom img {
  max-width: min(92vw, 560px);
  max-height: 88vh;
  background: #fff;
  border-radius: var(--r-3);
  box-shadow: var(--lift-3);
}

#toasts {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: 90vw;
  padding: 10px 16px;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  box-shadow: var(--lift-2);
  transition: opacity var(--d-2) var(--ease);
}

.toast.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 34%, transparent); }
.toast.ok  { color: var(--ok);  border-color: color-mix(in srgb, var(--ok) 30%, transparent); }

/* Collapsible account groups. */
.groups {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  background: var(--rule-soft);
  border-radius: var(--r-3);
}

.group { background: var(--surface); }

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px var(--sp-3);
  font-family: inherit;
  font-size: var(--t-sm);
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--d-1) var(--ease);
}

.group-head:hover { background: var(--surface-2); }

.group-chevron { display: flex; flex-shrink: 0; color: var(--ink-4); }
.group-head.open .group-chevron { color: var(--accent); }

.group-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-meta {
  margin-left: auto;
  flex-shrink: 0;
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}

.group-body:empty { display: none; }

/* ----------------------------------------------------------------- 9. charts */
.chart-box { width: 100%; }

/* A viewBox with preserveAspectRatio="none" has no intrinsic height, so the
   canvas owns it; otherwise the SVG can collapse to zero. */
.chart-canvas {
  position: relative;
  width: 100%;
  height: 200px;
  min-height: 200px;
}

.chart-canvas svg { display: block; width: 100%; height: 100%; }

.chart-tip {
  position: absolute;
  top: 4px;
  z-index: 3;
  padding: 8px 11px;
  font-size: var(--t-xs);
  line-height: 1.7;
  color: var(--ink);
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  box-shadow: var(--lift-2);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--d-1) var(--ease);
}

.chart-tip.on { opacity: 1; }
.chart-tip b { display: block; margin-bottom: 2px; font-weight: 600; }
.chart-tip span { display: flex; align-items: center; gap: 5px; color: var(--ink-2); }

.chart-tip .dot-a, .chart-tip .dot-b {
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-radius: 50%;
}

.chart-tip .dot-a { background: var(--data-1); }
.chart-tip .dot-b { background: var(--data-2); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: var(--sp-2);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-3);
}

.chart-legend span { display: flex; align-items: center; gap: 6px; }

.chart-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.chart-dot.a { background: var(--data-1); }
.chart-dot.b { background: var(--data-2); }

.donut-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-4);
}

.donut-svg { flex-shrink: 0; color: var(--ink); }
.donut-svg svg { display: block; }

.donut-legend {
  flex: 1;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-row { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--t-xs); }
.legend-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; }

.legend-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--ink-2);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-val { flex-shrink: 0; font-weight: 600; color: var(--ink); }

.empty-chart { opacity: 0.9; }
.empty-note { font-size: var(--t-xs); line-height: 1.7; color: var(--ink-3); }

.range-switch {
  display: inline-flex;
  gap: 1px;
  padding: 2px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-1);
}

.range-switch button {
  padding: 3px 9px;
  font-family: inherit;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink-3);
  background: transparent;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}

.range-switch button:hover { color: var(--ink); }

.range-switch button.on {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--lift-1);
}

/* ------------------------------------------------------------------- 10. auth */
/* The sign-in page is the one place a large graphic gesture is allowed: a
   horizon of soft light behind a single quiet card. */
.login-wrap {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  overflow: hidden;
  background: var(--paper);
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  opacity: 0.55;
  filter: blur(90px) saturate(120%);
  pointer-events: none;
}

.blob {
  position: absolute;
  width: 52vw;
  height: 52vw;
  max-width: 640px;
  max-height: 640px;
  border-radius: 50%;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  animation-iteration-count: infinite;
}

.b1 {
  background: radial-gradient(circle, rgba(15,118,110,.55) 0%, rgba(15,118,110,0) 68%);
  animation: drift-a 26s infinite;
}

.b2 {
  background: radial-gradient(circle, rgba(180,83,9,.34) 0%, rgba(180,83,9,0) 68%);
  animation: drift-b 32s infinite;
}

.b3 {
  background: radial-gradient(circle, rgba(20,18,15,.22) 0%, rgba(20,18,15,0) 70%);
  animation: drift-c 38s infinite;
}

@media (prefers-color-scheme: dark) {
  .b1 { background: radial-gradient(circle, rgba(45,212,191,.30) 0%, rgba(45,212,191,0) 68%); }
  .b2 { background: radial-gradient(circle, rgba(245,158,11,.18) 0%, rgba(245,158,11,0) 68%); }
  .b3 { background: radial-gradient(circle, rgba(244,242,238,.10) 0%, rgba(244,242,238,0) 70%); }
}

@keyframes drift-a {
  0%   { transform: translate(-18vw, -12vh) scale(1); }
  50%  { transform: translate(6vw, 10vh) scale(1.18); }
  100% { transform: translate(-18vw, -12vh) scale(1); }
}

@keyframes drift-b {
  0%   { transform: translate(22vw, 14vh) scale(1.1); }
  50%  { transform: translate(-4vw, -8vh) scale(0.92); }
  100% { transform: translate(22vw, 14vh) scale(1.1); }
}

@keyframes drift-c {
  0%   { transform: translate(0, 24vh) scale(1); }
  50%  { transform: translate(14vw, -6vh) scale(1.1); }
  100% { transform: translate(0, 24vh) scale(1); }
}

.login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 396px;
  padding: var(--sp-5);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid color-mix(in srgb, var(--surface) 60%, var(--rule));
  border-radius: var(--r-3);
  box-shadow: var(--lift-3);
}

.login-head { margin-bottom: var(--sp-4); text-align: center; }
.login-mark { display: flex; justify-content: center; margin-bottom: var(--sp-3); }

.login-head h1 {
  font-size: var(--t-xl);
  font-weight: 700;
  letter-spacing: -0.035em;
}

.login-head p { margin-top: 4px; font-size: var(--t-sm); color: var(--ink-3); }
.login-head p:empty { display: none; }

.login-body { padding-top: var(--sp-1); }

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: var(--sp-4);
  background: var(--paper-2);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-2);
}

.tab {
  flex: 1;
  padding: 8px 0;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink-3);
  text-align: center;
  border-radius: var(--r-1);
  cursor: pointer;
  user-select: none;
  transition: all var(--d-2) var(--ease);
}

.tab:hover { color: var(--ink); }

.tab.on {
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--lift-1);
}

/* ------------------------------------------------------------- 11. responsive */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ================================================ surfaces that had no CSS ==== */
/* console.js emitted these class names from the start but no rule was ever
   written, so the referral card, the onboarding steps and the entire invite
   page rendered as loose text. */

.promo-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
}

/* A single soft wash from the accent, not a gradient panel: the card should
   read as tinted paper rather than as a banner. */
.promo-glow {
  position: absolute;
  top: -60px;
  right: -40px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-bg) 0%, transparent 70%);
  pointer-events: none;
}

.promo-inner { position: relative; padding: var(--sp-4); }

.promo-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
}

.promo-title {
  font-size: var(--t-md);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
}

.promo-sub {
  margin-top: 3px;
  font-size: var(--t-xs);
  line-height: 1.7;
  color: var(--ink-3);
  max-width: 52ch;
}

.promo-code {
  flex-shrink: 0;
  text-align: right;
  padding-left: var(--sp-4);
  border-left: 1px solid var(--rule-soft);
}

.promo-code-label {
  display: block;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-4);
}

.promo-code-value {
  display: block;
  margin-top: 2px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.promo-rewards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--sp-3);
}

.promo-pill {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--t-xs);
  font-weight: 500;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}

/* Mine reads as accent, theirs as neutral: the reward the reader earns is the
   one that should carry colour. */
.promo-pill.you {
  background: var(--accent-bg);
  color: var(--accent-ink);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}

.promo-pill.them {
  background: var(--paper-2);
  color: var(--ink-2);
  border-color: var(--rule);
}

.promo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}

/* ---- onboarding ---- */
.onboard-lead {
  font-size: var(--t-sm);
  line-height: 1.85;
  color: var(--ink-2);
  max-width: 66ch;
}

.onboard-steps {
  margin: var(--sp-3) 0 0;
  padding-left: 1.35em;
  font-size: var(--t-sm);
  line-height: 1.9;
  color: var(--ink-2);
}

.onboard-steps li { padding-left: 2px; }
.onboard-steps li::marker { color: var(--ink-4); font-weight: 600; }
.onboard-steps b { color: var(--ink); font-weight: 600; }

.onboard-fields {
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--rule-soft);
}

/* ---- invite page ---- */
.invite-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 14px var(--sp-4);
  background: var(--paper-2);
  border: 1px dashed var(--rule);
  border-radius: var(--r-2);
}

.invite-code-value {
  font-family: ui-monospace, Consolas, monospace;
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink);
}

.reward-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}

.reward-item {
  padding: var(--sp-3);
  background: var(--paper-2);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-2);
}

.reward-item.mine {
  background: var(--accent-bg);
  border-color: color-mix(in srgb, var(--accent) 20%, transparent);
}

.reward-who {
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-4);
}

.reward-item.mine .reward-who { color: var(--accent-ink); opacity: 0.75; }

.reward-val {
  margin-top: 3px;
  font-size: var(--t-md);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.reward-item.mine .reward-val { color: var(--accent-ink); }

.reward-sub {
  font-size: var(--t-xs);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.reward-item.mine .reward-sub { color: var(--accent-ink); opacity: 0.8; }

/* The register tab's promo banner. */
.invite-banner {
  position: relative;
  overflow: hidden;
  margin-bottom: var(--sp-3);
  padding: var(--sp-3);
  background: var(--paper-2);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-2);
}

.invite-banner-glow { display: none; }

.invite-banner-body { position: relative; }

.invite-banner-title {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink);
}

.invite-banner-text {
  margin-top: 2px;
  font-size: var(--t-xs);
  line-height: 1.7;
  color: var(--ink-3);
}

.invite-banner-reward {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.reward-pill {
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: var(--t-micro);
  font-weight: 600;
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}

/* The dashed legend marker for the second series. */
.chart-dot.dashed {
  background: transparent !important;
  border: 1.5px dashed var(--data-2);
  width: 9px;
  height: 9px;
}

/* The brand mark's plate. It carries currentColor so the ink token applies. */
.mark-body { color: var(--ink); }

/* ============================================================== mobile ==== */
/* The phone gets its own chrome. Until now the sidebar was translated
   off-screen below 820px and the in-page top bar was hidden, with nothing left
   to open the navigation: a phone could not move between pages at all.
   .mbar (top) and .tabbar (bottom) are inserted by console.js only when the
   viewport is a phone, so the desktop shell is untouched. */
/* Hidden above the breakpoint. Scoped to min-width so it cannot override the
   display:flex inside the phone block above by source order. */
@media (min-width: 821px) {
  .mbar { display: none; }
}

/* Back to top. A hairline plate, not a filled circle: the page already has one
   dark element (the primary button) and a second would compete with it. */
.backtop {
  position: fixed;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 50%;
  box-shadow: var(--lift-2);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity var(--d-2) var(--ease),
              transform var(--d-2) var(--ease),
              visibility var(--d-2);
  -webkit-tap-highlight-color: transparent;
}

.backtop.on { opacity: 1; visibility: visible; transform: translateY(0); }
.backtop:active { background: var(--paper-2); }

/* It is a phone affordance only. */
@media (min-width: 821px) {
  .backtop { display: none; }
}

/* Registration time under the address in the users table. Two pieces: the
   absolute stamp, then how long ago it was - the operator reasons in both. */
.reg-time {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.reg-since {
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 10px;
  white-space: nowrap;
}

/* Read-only state at the top of the admin quota dialog: what the account has
   right now, before the operator changes what it will have tomorrow. */
.qstatus {
  padding: 12px;
  margin-bottom: var(--sp-4);
  background: var(--paper-2);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-2);
}

.qstatus-head {
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 9px;
}

.qstatus-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.qstatus-cell {
  padding: 8px 10px;
  background: var(--surface);
  border-radius: var(--r-1);
}

.qstatus-cell.pool { border-left: 2px solid var(--accent); }

.qstatus-k {
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-4);
}

.qstatus-v {
  margin-top: 2px;
  font-size: var(--t-md);
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.qstatus-v.has { color: var(--accent-ink); }

.qstatus-s {
  font-size: var(--t-micro);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* The line under a status tile that explains how the number behaves over
   time - "resets daily" vs "does not reset". Muted enough not to compete with
   the figure, but present on every tile so the two kinds of allowance are
   never confused. */
.qstatus-hint {
  margin-top: 3px;
  font-size: var(--t-micro);
  color: var(--ink-4);
  opacity: 0.85;
}

.qstatus-title {
  margin-bottom: 8px;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-4);
}

/* The cumulative pool block inside the admin quota dialog. */
.pool-block {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--rule);
}

.pool-head {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.pool-now {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 9px 12px;
  margin-bottom: 10px;
  background: var(--paper-2);
  border-radius: var(--r-2);
}

.pool-now-k {
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-3);
}

.pool-now-v {
  font-size: var(--t-md);
  font-weight: 600;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}

.pool-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.pool-block .input { margin-bottom: 8px; }

/* A pool balance in the users table: a quiet pill, because most rows are zero
   and the ones that are not should be findable at a glance. */
.pool-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--t-micro);
  font-weight: 600;
  background: var(--accent-bg);
  color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  font-variant-numeric: tabular-nums;
}

/* Quota bars. A rule that drains as the allowance is spent: the reader wants
   to know how much is left, so the bar measures what remains, not what is used. */
.qcard { display: flex; flex-direction: column; gap: 14px; }

.qbar-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: 6px;
}

.qbar-k {
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-4);
}

.qbar-v {
  font-size: var(--t-md);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.qbar-v.low { color: var(--err); }

.qbar-track {
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--paper-2);
  overflow: hidden;
}

.qbar-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--accent);
  transition: width var(--d-2) var(--ease);
}

.qbar-fill.low { background: var(--err); }
.qbar-fill.full { background: var(--ink-4); }

.qbar-sub {
  margin-top: 5px;
  font-size: var(--t-xs);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* The pool is separated by a rule, not a box: it is a different kind of
   money, and the rule says so without shouting. */
.qsep { height: 1px; background: var(--rule-soft); }

.qpool-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: 5px;
}

.qpool-v {
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.qpool-v.has { color: var(--accent); }

.qnote {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--rule-soft);
  font-size: var(--t-xs);
  line-height: 1.7;
  color: var(--ink-3);
}

/* The account card: v3's profile block, rebuilt in the ink palette. */
.pcard {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: var(--sp-4);
}

.pcard-top { display: flex; align-items: center; gap: 12px; }

.pcard-avatar {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  background: var(--paper-2);
  border: 1px solid var(--rule);
}

.pcard-id { flex: 1; min-width: 0; }

.pcard-hi {
  font-size: var(--t-md);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pcard-mail {
  font-size: var(--t-xs);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pcard-badge { flex-shrink: 0; }

/* Label over value, two columns: the descriptions block from v3, but as rules
   rather than filled cells so it stays in the print idiom. */
.pcard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 14px;
  background: var(--rule-soft);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-2);
  overflow: hidden;
}

.pcard-cell { padding: 9px 11px; background: var(--surface); }

.pcard-k {
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-4);
}

.pcard-v {
  margin-top: 1px;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* System messages: the notice column from v3's user page. */
.msg-list { display: flex; flex-direction: column; gap: var(--sp-2); }

.msg-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--r-2);
  font-size: var(--t-xs);
  line-height: 1.7;
  background: var(--paper-2);
  color: var(--ink-2);
  border: 1px solid var(--rule-soft);
}

.msg-item .msg-ico { flex-shrink: 0; display: flex; margin-top: 1px; color: var(--ink-4); }
.msg-item b { color: var(--ink); font-weight: 600; }
.msg-item.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.msg-item.warn .msg-ico, .msg-item.warn b { color: var(--warn); }
.msg-item.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.msg-item.ok .msg-ico, .msg-item.ok b { color: var(--ok); }

/* Stacked rows: a table is unreadable at 390px, so the same data becomes rows
   with the value on the right. */
.mlist { display: flex; flex-direction: column; }

.mrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule-soft);
}

.mrow:last-child { border-bottom: none; }
.mrow-main { flex: 1; min-width: 0; }

.mrow-title {
  font-size: var(--t-sm);
  font-weight: 550;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mrow-sub {
  font-size: var(--t-xs);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mrow-val {
  flex-shrink: 0;
  font-size: var(--t-sm);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* The empty key list: a title and a sentence, not one grey line floating in a
   card. On a phone this is the first thing a new account sees. */
.kempty { padding: var(--sp-5) var(--sp-3); text-align: center; }

.kempty-t {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink-2);
}

.kempty-s {
  margin-top: 4px;
  font-size: var(--t-xs);
  line-height: 1.7;
  color: var(--ink-3);
}

/* The capability row inside a phone key card. */
.kcard-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule-soft);
}

.kcard-switch-n {
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--ink);
}

.kcard-switch-h {
  margin-top: 1px;
  font-size: var(--t-micro);
  line-height: 1.6;
  color: var(--ink-3);
}

/* The account-defaults editor: label and hint on the left, input on the right. */
.cfg-list { display: flex; flex-direction: column; }

.cfg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 11px 0;
  border-bottom: 1px solid var(--rule-soft);
}

.cfg-row:last-child { border-bottom: none; }
.cfg-label { flex: 1; min-width: 0; }

.cfg-name {
  font-size: var(--t-sm);
  font-weight: 550;
  color: var(--ink);
}

.cfg-hint {
  margin-top: 1px;
  font-size: var(--t-xs);
  line-height: 1.6;
  color: var(--ink-3);
}

.cfg-row .search {
  width: 128px;
  flex-shrink: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Scope picker on the defaults form: "new accounts only" vs "every account".
   Stacked so the explanatory hint under the label stays readable. */
.cfg-scope {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
}

.cfg-radio {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--t-sm);
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}

.cfg-radio input[type="radio"] {
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.cfg-radio:hover { color: var(--ink); }

@media (max-width: 820px) {
  .cfg-row { flex-direction: column; align-items: stretch; gap: 7px; }
  .cfg-row .search { width: 100%; text-align: left; }
  .cfg-scope { flex-direction: row; gap: 16px; }
}

/* One key as a card: name, masked secret, state, then the actions. */
.kcard {
  padding: 13px;
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  background: var(--surface);
}

.kcard + .kcard { margin-top: var(--sp-2); }

.kcard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.kcard-name {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kcard-key {
  margin-top: 4px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: var(--t-xs);
  color: var(--ink-3);
  word-break: break-all;
}

.kcard-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
  font-size: var(--t-micro);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.kcard-meta b { color: var(--ink-2); font-weight: 600; }

.kcard-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule-soft);
}

.kcard-actions .btn { flex: 1; min-height: 34px; font-size: var(--t-xs); }

/* ------------------------------------------------------------- mobile ---- */
/* Below 820px the sidebar becomes a drawer. A horizontal icon strip was tried
   first; with ten management entries it overflowed and left the entries
   unlabelled, so the drawer is used instead. */
.mobile-bar { display: none; }
.drawer-scrim { display: none; }

@media (max-width: 820px) {
  .shell { display: block; }

  /* Top bar: mark, title, menu button. Sticky so the menu is always reachable. */
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 12px;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    position: sticky;
    top: 0;
    z-index: 40;
  }

  .mobile-bar .brand-mark svg { width: 26px; height: 26px; }

  .mobile-title {
    flex: 1;
    min-width: 0;
    font-size: var(--t-sm);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 1px solid var(--rule);
    border-radius: var(--r-2);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
  }

  .mobile-menu:active { background: var(--paper-2); }

  /* v3 hides the sider below its breakpoint and moves navigation into the
     header dropdown. Same here: the sidebar is simply not on a phone. */
  .side { display: none; }

  /* The in-page top bar is redundant now that the mobile bar carries the title. */
  .topbar { display: none; }

  .content { padding: var(--sp-3) var(--sp-3) calc(var(--sp-4) + env(safe-area-inset-bottom)); }
  .card-head { padding: var(--sp-3); }
  .card-body { padding: var(--sp-3); }
  .tile { padding: var(--sp-3); }
  .tile-value { font-size: var(--t-xl); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* ---- top bar (v3 HeaderComponent) ---- */
  .mbar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 56px;
    padding: 0 12px;
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
  }

  .mbar-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    margin-left: -6px;
    padding: 0;
    border: none;
    border-radius: var(--r-2);
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mbar-menu:active { background: var(--paper-2); }

  /* The wordmark sits in the middle of the bar, as v3's does. */
  .mbar-brand {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
    min-width: 0;
    padding: 0;
    border: none;
    background: transparent;
    font-family: inherit;
    color: var(--ink);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mbar-word {
    font-size: var(--t-md);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
  }

  .mbar-account {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 3px 4px 3px 3px;
    border: none;
    border-radius: var(--r-pill);
    background: transparent;
    font-family: inherit;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mbar-account:active { background: var(--paper-2); }

  .mbar-avatar {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
    background: var(--paper-2);
    border: 1px solid var(--rule);
  }

  /* Name over group, exactly the two lines v3 stacks beside the avatar. */
  /* The account menu, anchored under the header's right edge. */
  .amenu {
    position: fixed;
    top: 58px;
    right: 8px;
    z-index: 62;
    width: 186px;
    padding: 5px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 10px;
    box-shadow: var(--lift-3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    transition: opacity var(--d-2) var(--ease),
                transform var(--d-2) var(--ease),
                visibility var(--d-2);
  }

  .amenu.open { opacity: 1; visibility: visible; transform: none; }

  .amenu-head {
    padding: 6px 8px 7px;
    margin-bottom: 3px;
    border-bottom: 1px solid var(--rule-soft);
  }

  .amenu-mail {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .amenu-role {
    font-size: 9.5px;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--ink-4);
  }

  .amenu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 8px;
    border: none;
    border-radius: var(--r-2);
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    color: var(--ink-2);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .amenu-item:active { background: var(--paper-2); }
  .amenu-item svg { flex-shrink: 0; width: 15px; height: 15px; color: var(--ink-4); }
  .amenu-item.danger { color: var(--err); }
  .amenu-item.danger svg { color: var(--err); }

  .mbar-id {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 92px;
    line-height: 1.25;
  }

  .mbar-name {
    font-size: var(--t-xs);
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mbar-group {
    font-size: 10px;
    color: var(--ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ---- tables become cards ---- */
  /* Six columns cannot survive 390px: the status pill wrapped to two lines and
     the account name broke mid-word. Each row is a card and each cell is a
     label/value pair, using the data-label the table builder now emits. */
  .table-wrap { overflow-x: visible; }

  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }

  .tbl thead { display: none; }

  .tbl tr {
    padding: 10px 12px;
    margin-bottom: var(--sp-2);
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-2);
  }

  .tbl tr:last-child { margin-bottom: 0; }
  .tbl tbody tr:hover { background: var(--surface); }

  .tbl td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: 5px 0;
    border-bottom: none;
    font-size: var(--t-sm);
    text-align: right;
    word-break: break-word;
  }

  /* The first cell is the row's identity: full width, no label. */
  .tbl td:first-child {
    display: block;
    padding: 0 0 7px;
    text-align: left;
    font-weight: 600;
  }

  .tbl td:first-child::before { display: none; }

  .tbl td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: var(--t-micro);
    font-weight: 600;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--ink-4);
    text-align: left;
  }

  /* An empty cell would render a label with nothing beside it. */
  .tbl td:empty { display: none; }

  /* Action rows keep their buttons on one line. */
  .tbl td .row-actions { justify-content: flex-end; }

  .tag { white-space: nowrap; }

  /* ---- nothing important is truncated on a phone ---- */
  /* These boxes hold a value the reader came for: a name, an address, a model
     id. An ellipsis there hides information rather than tidying it away. */
  .pcard-hi, .pcard-mail, .pcard-v,
  .mrow-title, .mrow-sub, .kcard-name {
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: clip;
  }

  /* The profile grid is two columns; a long value wraps inside its cell. */
  .pcard-v { line-height: 1.5; }

  /* The header keeps one line - it has a fixed height - but gets the room for
     a full address and falls back to a tighter type size before it truncates. */
  .mbar-id { max-width: 46vw; }

  .mbar-name {
    overflow: visible;
    text-overflow: clip;
    font-size: 11.5px;
  }

  /* A stacked row: value under the title once the title wraps. */
  .mrow {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .mrow-main { flex: 1 1 auto; }
  .mrow-val { flex: 0 0 auto; padding-top: 1px; }

  /* Cards go edge to edge: the gutter is already inside .content. */
  .pcard { padding: var(--sp-3) var(--sp-3) var(--sp-3); }
  .pcard-grid { margin-top: 12px; }

  .promo-head { flex-direction: column; gap: var(--sp-3); }
  .promo-code {
    text-align: left;
    padding-left: 0;
    border-left: none;
    padding-top: var(--sp-3);
    border-top: 1px solid var(--rule-soft);
    width: 100%;
  }
  .promo-inner { padding: var(--sp-4) var(--sp-3); }
  .promo-actions .btn { flex: 1; min-width: 0; }

  .reward-grid { grid-template-columns: minmax(0, 1fr); }

  .invite-code { padding: 12px var(--sp-3); }
  .invite-code-value { font-size: var(--t-md); letter-spacing: 0.06em; }

  .onboard-steps { padding-left: 1.15em; }
  .onboard-lead { font-size: var(--t-sm); }

  .msg-item { padding: 9px 11px; }
}

@media (max-width: 640px) {
  /* Dialogs rise from the bottom: that is where the thumb is. */
  .modal-mask { align-items: flex-end; padding: 0; }

  .modal {
    width: 100%;
    max-width: none;
    max-height: 86vh;
    padding: 10px var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom));
    border-radius: var(--r-3) var(--r-3) 0 0;
    animation: sheet-up 0.26s var(--ease);
  }

  .sheet-handle {
    display: block;
    width: 36px;
    height: 4px;
    margin: 0 auto 14px;
    background: var(--rule);
    border-radius: var(--r-pill);
  }

  .modal-actions {
    position: sticky;
    bottom: 0;
    padding-top: var(--sp-3);
    background: var(--surface);
  }

  .modal-actions .btn { flex: 1; }

  /* The announcement becomes a bottom sheet like every other dialog, but the
     two actions keep their asymmetry: stacked, with the permanent one on top
     where the thumb lands first. */
  .announce-mask { align-items: flex-end; padding: 0; }

  .announce {
    max-width: none;
    max-height: 88vh;
    border-radius: var(--r-3) var(--r-3) 0 0;
  }

  .announce-head { padding: 14px var(--sp-4) 10px; }
  .announce-title { font-size: var(--t-md); }
  .announce-body {
    padding: var(--sp-3) var(--sp-4);
    font-size: 14px;
  }

  .announce-foot {
    flex-direction: column;
    align-items: stretch;
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom));
  }

  .announce-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .announce-actions .btn { width: 100%; }
  .announce-hint { order: -1; margin-bottom: 2px; text-align: center; }

  .notice-hero { padding: var(--sp-4); }
  .notice-hero h2 { font-size: var(--t-lg); }
  .notice-ask { padding: var(--sp-4); }

  /* The code stacks above its caption: side by side, a 200px image leaves the
     caption about 150px wide, which breaks Chinese text every three characters. */
  .zanshang { flex-direction: column; align-items: stretch; }
  .zanshang-img { width: 100%; max-width: 260px; margin: 0 auto; }
  .zanshang-side { flex: 1 1 auto; }

  .contact-row { padding: 11px 12px; }

  /* 16px stops iOS from zooming the page on focus. */
  .input, .search, .sel, textarea.search { min-height: 44px; font-size: 16px; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .btn-icon { width: 40px; height: 40px; }

  .switch { width: 42px; height: 24px; }
  .knob { width: 20px; height: 20px; }
  .switch.on .knob { transform: translateX(18px); }

  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv-k { min-width: 78px; }

  .login-card { max-width: none; padding: var(--sp-4); border-radius: var(--r-3); }
  .login-head h1 { font-size: var(--t-lg); }

  .chart-canvas { height: 168px; min-height: 168px; }
  .chart-tip { padding: 7px 9px; font-size: 11px; }

  .donut-wrap { gap: var(--sp-3); }
  .donut-svg svg { width: 112px; height: 112px; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left { width: 100%; }
  .search { width: 100%; min-width: 0; }
  .row-actions { gap: 5px; }

  /* A cell's value must never force its card wider than the screen. Long
     unbroken strings (an email, a code, a model id) are the usual cause of a
     table that scrolls sideways on a phone. */
  .tbl td { min-width: 0; overflow-wrap: anywhere; }
  .tbl td > * { min-width: 0; }
  .tbl .row-actions { flex-wrap: wrap; justify-content: flex-end; }
  .pool-badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

  /* The amount of a pending QR order is the one thing a buyer must read
     correctly, so it stays large but never overflows. */
  .qr-pending-amt { font-size: 30px; overflow-wrap: anywhere; }
  .code-out { font-size: 12px; }
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@media (max-width: 380px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------- chart crosshair ---- */
/* An HTML overlay rather than an SVG line: the chart is stretched with
   preserveAspectRatio="none", so a viewBox coordinate does not map to pixels. */
.chart-cross {
  position: absolute;
  top: 12px;
  bottom: 28px;
  width: 1px;
  margin-left: -0.5px;
  background: var(--ink-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--d-1) var(--ease);
  z-index: 2;
}

.chart-cross.on { opacity: 0.45; }

/* A hairline dash reads as a guide, not as a series. */
.chart-cross::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    currentColor 0 4px,
    transparent 4px 8px
  );
  opacity: 0.6;
}

.chart-canvas { cursor: crosshair; }

/* ============================================================ launcher ==== */
/* The brand is a button now: it opens the page list. */
.brand {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--d-1) var(--ease);
}

.brand:hover { background: var(--paper-2); }
.brand:active { background: var(--surface-2); }

.brand-caret {
  display: flex;
  margin-left: auto;
  color: var(--ink-4);
  flex-shrink: 0;
  transition: transform var(--d-2) var(--ease), color var(--d-1) var(--ease);
}

.brand:hover .brand-caret { color: var(--ink-2); }

/* The floating panel. */
.launcher {
  position: fixed;
  top: 74px;
  left: 12px;
  z-index: 70;
  width: 228px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  box-shadow: var(--lift-3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top left;
  transition: opacity var(--d-2) var(--ease),
              transform var(--d-2) var(--ease),
              visibility var(--d-2);
}

.launcher.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.launcher-group {
  padding: 9px 9px 5px;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-4);
}

.launcher-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: var(--r-2);
  font-size: var(--t-sm);
  font-weight: 450;
  color: var(--ink-2);
  text-decoration: none;
  transition: background var(--d-1) var(--ease), color var(--d-1) var(--ease);
}

.launcher-item:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.launcher-item.active {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
}

.launcher-icon {
  display: flex;
  flex-shrink: 0;
  color: var(--ink-4);
}

.launcher-item.active .launcher-icon { color: var(--accent); }

.launcher-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.launcher-dot {
  width: 5px;
  height: 5px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
}

.launcher-scrim {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--d-1) var(--ease);
}

.launcher-scrim.on {
  opacity: 1;
  pointer-events: auto;
}

/* On a phone the panel anchors under the button and sizes to its content
   rather than stretching across the screen. A full-width sheet reads as a
   modal - it covers the page the operator was looking at - while a compact
   popover leaves the context visible, which is what a menu should do. */
@media (max-width: 820px) {
  .launcher {
    left: 8px;
    right: auto;
    width: min(240px, calc(100vw - 16px));
    top: 60px;
    max-height: calc(100vh - 80px);
    padding: 5px;
    border-radius: 10px;
  }

  .launcher-group { padding: 7px 8px 4px; font-size: 10.5px; }
  .launcher-item { padding: 8px 8px; font-size: 13.5px; gap: 8px; }
  .launcher-icon svg { width: 15px; height: 15px; }
}

/* Reduced motion: show and hide without the scale. */
@media (prefers-reduced-motion: reduce) {
  .launcher { transition: opacity var(--d-1) linear, visibility var(--d-1); }
  .launcher.open { transform: none; }
}

/* ------------------------------------------------------------ price editor */
/* "X 元 = Y 万 token" as one line: the two fields are a single fact seen from
   two sides, so they sit side by side with the equals sign between them. */
.price-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.price-field {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 140px;
  min-width: 0;
}
.price-field .input { flex: 1 1 auto; min-width: 0; }
.price-field .lbl {
  position: absolute;
  margin-top: -46px;
  font-size: 11.5px;
  color: var(--ink-4);
}
.price-unit {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--ink-3);
}
.price-eq {
  flex-shrink: 0;
  padding-bottom: 9px;
  font-size: 16px;
  color: var(--ink-4);
}

.price-rate {
  margin-top: 14px;
  padding: 9px 11px;
  border-radius: 6px;
  background: var(--paper-2, #faf8f3);
  font-size: 13px;
  color: var(--ink-2);
}
.price-rate.bad { color: var(--err); }
.price-rate strong { color: var(--ink); }

.price-min {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
}
.price-min .input { flex: 1 1 auto; min-width: 0; }

.price-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.price-example {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--line, #e3ded3);
  border-radius: 6px;
  font-size: 12.5px;
  background: var(--surface);
}
.pe-cny { font-weight: 600; color: var(--ink); }
.pe-arrow { color: var(--ink-4); }
.pe-tok { color: var(--ink-2); }

@media (max-width: 820px) {
  .price-form { gap: 8px; }
  .price-field { flex: 1 1 100%; }
  .price-eq { display: none; }
  .price-field .lbl { position: static; margin: 0 0 4px; }
  .price-field { flex-wrap: wrap; }
  .price-example { padding: 5px 8px; font-size: 12px; }
}

/* ------------------------------------------------------------ purchase page */
/* The quoted amount is the moment the user decides to pay, so it gets the
   largest type on the page and a rule above it to separate it from the input. */
.buy-quote {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 18px 0 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line, #e3ded3);
}
.buy-quote-k {
  font-size: 13px;
  color: var(--ink-3, #8a8578);
  letter-spacing: .02em;
}
.buy-quote-cny {
  margin-left: auto;
  font-size: 15px;
  color: var(--ink-3, #8a8578);
}
.buy-price {
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3, #8a8578);
}
.buy-price.has {
  color: var(--ink, #23201a);
}

/* Payment instructions: informational, not alarming - a muted panel rather than
   a warning box, because nothing is wrong at this point. */
.buy-note {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line, #e3ded3);
  border-radius: 3px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-2, #57534a);
  background: var(--paper-2, #faf8f3);
}
.buy-note-t {
  font-weight: 600;
  color: var(--ink, #23201a);
  margin-bottom: 4px;
}

/* The escape hatch for a buyer who cannot or will not use the primary channel.
   Separated by a rule so it reads as a second option, not as fine print. */
.buy-alt {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line, #e3ded3);
  font-size: 13px;
  line-height: 1.7;
}
.buy-alt-t {
  font-weight: 600;
  color: var(--ink, #23201a);
  margin-bottom: 2px;
}

/* Payment method chooser (WeChat / Alipay). A segmented control rather than a
   dropdown: there are only ever two options and both should be visible. */
.pay-types {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.pay-type {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line, #e3ded3);
  border-radius: 3px;
  background: var(--paper, #fffdf8);
  color: var(--ink-2, #57534a);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.pay-type:hover { border-color: var(--ink-3, #8a8578); }
.pay-type.on {
  border-color: var(--ink, #23201a);
  color: var(--ink, #23201a);
  background: var(--paper-2, #faf8f3);
  font-weight: 600;
}

/* QR codes shown on the purchase page. */
.qr-row {
  display: flex;
  gap: 20px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.qr-cell { text-align: center; }
.qr-img {
  width: 150px;
  height: 150px;
  object-fit: contain;
  border: 1px solid var(--line, #e3ded3);
  border-radius: 3px;
  background: #fff;
}
.qr-cap {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-2, #57534a);
}

/* Admin: payment mode selector. Cards, because each option needs a line of
   explanation that a radio button cannot carry. */
.pay-modes {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}
.pay-mode {
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line, #e3ded3);
  border-radius: 3px;
  background: var(--paper, #fffdf8);
  font: inherit;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.pay-mode:hover { border-color: var(--ink-3, #8a8578); }
.pay-mode.on {
  border-color: var(--ink, #23201a);
  background: var(--paper-2, #faf8f3);
}
.pay-mode-t {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #23201a);
}
.pay-mode-d {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ink-3, #8a8578);
  line-height: 1.6;
}
.pay-section { margin-top: 16px; }
.hook-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.hook-row .input { flex: 1; font-size: 12px; }

/* Fixed packages on the purchase page. A marketplace listing has one price, so
   the buyer picks a package instead of naming an amount. */
.tier-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.tier {
  flex: 1 1 120px;
  padding: 10px 12px;
  border: 1px solid var(--line, #e3ded3);
  border-radius: 3px;
  background: var(--paper, #fffdf8);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tier:hover { border-color: var(--ink-3, #8a8578); }
.tier.on {
  border-color: var(--ink, #23201a);
  background: var(--paper-2, #faf8f3);
}
.tier-n {
  font-size: 13px;
  color: var(--ink, #23201a);
  font-weight: 600;
}
.tier-p {
  margin-top: 2px;
  font-size: 15px;
  color: var(--ink-2, #57534a);
  font-variant-numeric: tabular-nums;
}

/* Admin: one editable row per package. */
.tier-edit { margin-top: 8px; }
.tier-line {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.tier-line .input { flex: 1; min-width: 0; }
.tier-line .input[type="number"] { flex: 0 0 140px; }

/* A redemption code is read character by character; monospace and selectable. */
.code-out {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  user-select: all;
}
.code-cell {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  user-select: all;
}
.pay-checks {
  display: flex;
  gap: 18px;
  margin-top: 6px;
}
.pay-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--ink-2, #57534a);
  cursor: pointer;
}
.pay-status {
  padding: 8px 12px;
  border-radius: 3px;
  font-size: 13px;
  border: 1px solid;
}
.pay-status.ok {
  color: #1a6b3c;
  background: #eef7f1;
  border-color: #c3e2d0;
}
.pay-status.warn {
  color: #8a5a12;
  background: #fdf6e8;
  border-color: #ecdcb8;
}

/* The amount to transfer, once a QR order exists. It has to be impossible to
   miss or to confuse with the round quote, because paying the round figure
   means the payment cannot be matched and the tokens never arrive. */
.qr-pending {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid #d8c9a6;
  border-radius: 3px;
  background: #fdf8ec;
  text-align: center;
}
.qr-pending-t {
  font-size: 13px;
  color: var(--ink-2, #57534a);
  letter-spacing: .02em;
}
.qr-pending-amt {
  margin: 6px 0 8px;
  font-size: 34px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--ink, #23201a);
  user-select: all;
}

@media (max-width: 820px) {
  .buy-price { font-size: 26px; }
  .buy-quote { margin-top: 14px; padding-top: 12px; }
  .pay-types { flex-direction: column; }
  .qr-img { width: 130px; height: 130px; }
}

/* HFAPI console — Apple / iOS visual finish.
   Light, neutral, readable: the page stays light even when the OS is dark.
   This layer is appended to console.css, so it adds no extra HTTP request. */
:root {
  /* Follow the OS. A bare `light` also forced the browser's own
     widgets (scrollbars, inputs, status bar) into light on phones. */
  color-scheme: light dark;
  --paper: #f5f6f8;
  --paper-2: #eceef1;
  --surface: #fff;
  --surface-2: #f8f9fa;
  --ink: #1d1d1f;
  --ink-2: #3a3a3c;
  --ink-3: #6e6e73;
  --ink-4: #a1a1a6;
  --rule: #e2e4e8;
  --rule-soft: #eef0f2;
  --accent: #0071e3;
  --accent-ink: #0060b9;
  --accent-bg: #eaf3ff;
  --data-1: #0071e3;
  --data-2: #5e5ce6;
  --ok: #248a3d;
  --ok-bg: #edf8ef;
  --warn: #b25000;
  --warn-bg: #fff6e5;
  --err: #d70015;
  --err-bg: #fff0ef;
  --t-micro: 12px;
  --t-xs: 13px;
  --t-sm: 14px;
  --t-base: 15px;
  --t-md: 17px;
  --t-lg: 21px;
  --t-xl: 28px;
  --t-2xl: 38px;
  --tracking-tight: -0.022em;
  --tracking-wide: 0.02em;
  --sp-1: 6px;
  --sp-2: 10px;
  --sp-3: 14px;
  --sp-4: 22px;
  --sp-5: 30px;
  --sp-6: 44px;
  --r-1: 8px;
  --r-2: 12px;
  --r-3: 16px;
  --r-pill: 999px;
  --lift-1: 0 1px 2px rgba(0,0,0,.03);
  --lift-2: 0 6px 20px rgba(0,0,0,.06);
  --lift-3: 0 18px 50px rgba(0,0,0,.14);
  --ease: cubic-bezier(.25,.1,.25,1);
  --d-1: 150ms;
  --d-2: 250ms;
  --side-w: 244px;
  --bar-h: 66px;
  --bg: var(--paper);
  --fg: var(--ink);
  --fg-2: var(--ink-2);
  --fg-3: var(--ink-3);
  --line: var(--rule);
  --line-soft: var(--rule-soft);
  --p: var(--accent);
  --p-soft: var(--accent-bg);
  --p-line: #c4ddfb;
  --radius: var(--r-2);
}
body {
  background: var(--paper);
  color: var(--ink);
  font-size: var(--t-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-weight: 600; letter-spacing: -.022em; }
::selection { background: #b7dafe; color: #12385c; }
.shell { min-height: 100vh; }
.side {
  background: rgba(255,255,255,.86);
  border-right: 1px solid var(--rule);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.brand { padding: 24px 22px 20px; border-bottom: 1px solid var(--rule-soft); }
.brand-name { font-size: 19px; font-weight: 650; letter-spacing: -.03em; }
.brand-sub { font-size: 11px; font-weight: 500; color: var(--ink-3); }
.nav { padding: 12px 10px; }
.nav-group {
  padding: 20px 12px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}
.nav-item {
  min-height: 40px;
  padding: 10px 12px;
  gap: 11px;
  margin-bottom: 2px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}
.nav-item:hover { background: var(--paper-2); color: var(--ink); }
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: none;
}
.nav-item.active::before { display: none; }
.nav-item.active svg { color: var(--accent); opacity: 1; }
.side-foot { padding: 16px; border-top: 1px solid var(--rule-soft); gap: 10px; }
.who-role { font-size: 11px; color: var(--ink-3); }
.who-name { font-size: 13px; color: var(--ink); }
.topbar {
  height: var(--bar-h);
  padding: 0 32px;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--rule);
}
.topbar h1 { font-size: 22px; font-weight: 600; letter-spacing: -.025em; }
.content { padding: 32px 32px 56px; max-width: 1440px; }
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  box-shadow: var(--lift-1);
  overflow: hidden;
}
.card-head { padding: 20px 24px; border-bottom: 1px solid var(--rule-soft); }
.card-head h2 { font-size: 18px; font-weight: 600; }
.card-body { padding: 24px; }
.tiles {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 16px;
  background: transparent;
  border: none;
  overflow: visible;
}
.tile {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  box-shadow: var(--lift-1);
  transition: border-color var(--d-1) var(--ease), box-shadow var(--d-1) var(--ease);
}
.tile:hover { background: var(--surface); border-color: #cbd6e0; box-shadow: var(--lift-2); }
.tile-title {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-3);
}
.tile-icon { color: var(--accent); }
.tile-value { margin-top: 10px; font-size: 32px; font-weight: 600; line-height: 1.1; }
.tbl th {
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.tbl td { padding: 14px; font-size: 14px; border-bottom: 1px solid var(--rule-soft); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tag {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  border: 1px solid transparent;
}
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.err { background: var(--err-bg); color: var(--err); }
.tag.off { background: var(--paper-2); color: var(--ink-3); }
.btn {
  min-height: 40px;
  padding: 10px 18px;
  border-radius: var(--r-2);
  background: var(--surface-2);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--d-1) var(--ease), border-color var(--d-1) var(--ease);
}
.btn:hover { background: var(--paper-2); border-color: #cdd3da; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,113,227,.2);
}
.btn.primary:hover { background: #0066cc; color: #fff; border-color: #0066cc; }
.btn.primary:disabled { background: var(--ink-4); border-color: var(--ink-4); color: #fff; }
.btn.ghost { background: transparent; color: var(--accent); border-color: transparent; }
.btn.ghost:hover { background: var(--accent-bg); color: var(--accent-ink); }
.btn-sm {
  min-height: 34px;
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  color: var(--ink-2);
}
.btn-sm.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-sm.danger:hover { color: var(--err); background: var(--err-bg); }
.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.btn-icon:hover { background: var(--paper-2); color: var(--ink); }
.input,.search,.sel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  color: var(--ink);
  font-size: 15px;
  min-height: 44px;
}
.input { padding: 11px 14px; }
.search { padding: 10px 13px; }
.input:focus,.search:focus,.sel:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,113,227,.15);
  outline: none;
}
.alert { border-radius: var(--r-2); padding: 13px 16px; font-size: 14px; }
.modal-mask { background: rgba(20,26,34,.32); backdrop-filter: blur(6px); }
.modal {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  box-shadow: var(--lift-3);
}
.modal h3 { font-size: 20px; font-weight: 600; }
.kcard { border: 1px solid var(--rule); border-radius: var(--r-3); background: var(--surface); }
.kcard-name { font-size: 15px; }
.kcard-key { color: var(--ink-3); font-size: 13px; }
.qbar-track { height: 7px; border-radius: var(--r-pill); background: var(--paper-2); }
.qbar-fill { background: var(--accent); }
.qpool-v.has { color: var(--accent); }
@media (max-width:1100px) {
  .tiles { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .content { padding: 28px 24px 48px; }
}
@media (max-width:820px) {
  .shell { display: block; }
  .side { display: none; }
  .topbar { display: none; }
  .mbar,.mobile-bar {
    height: 58px;
    padding: 0 14px;
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border-bottom: 1px solid var(--rule);
  }
  .mbar-menu,.mobile-menu {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    color: var(--accent);
    background: transparent;
  }
  .mbar-menu:active,.mobile-menu:active { background: var(--accent-bg); }
  .mbar-word { font-size: 18px; font-weight: 650; }
  .mbar-name { font-size: 13px; font-weight: 500; }
  .mbar-group { font-size: 11px; color: var(--ink-3); }
  .mbar-avatar { width: 34px; height: 34px; border-radius: 50%; }
  .content { padding: 18px 14px calc(36px + env(safe-area-inset-bottom)); }
  .card-head { padding: 18px; }
  .card-body { padding: 18px; }
  .tiles { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
  .tile { padding: 18px; border-radius: var(--r-3); }
  .tile-value { font-size: 27px; }
  .tile-title { font-size: 12px; }
  .btn { min-height: 44px; font-size: 15px; padding: 11px 18px; }
  .btn-sm { min-height: 40px; font-size: 13px; padding: 9px 13px; }
  .btn-icon { width: 42px; height: 42px; }
  .input,.search,.sel { min-height: 48px; font-size: 16px; }
  .tbl tr { border-radius: var(--r-3); padding: 14px; margin-bottom: 10px; }
  .tbl td { padding: 7px 0; font-size: 14px; }
  .tbl td::before { font-size: 12px; color: var(--ink-3); }
  .kcard { padding: 16px; }
  .kcard-actions .btn { min-height: 42px; }
  .amenu,.launcher { border-radius: 16px; background: var(--surface); }
  .amenu-item { min-height: 48px; font-size: 15px; border-radius: 10px; }
  .modal { border-radius: var(--r-3) var(--r-3) 0 0; }
}
@media (max-width:420px) {
  .tiles { grid-template-columns: 1fr; }
  .tile-value { font-size: 28px; }
}
@media (prefers-reduced-motion:reduce) {
  *,*::before,*::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* ---------------------------------------------------------- dark mode ------
   Follows the OS on every device. Kept last so it wins over the light tokens
   above; the base stylesheet's own dark block is not enough because this layer
   redefines the same custom properties. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --paper:      #000000;
    --paper-2:    #1c1c1e;
    --surface:    #1c1c1e;
    --surface-2:  #2c2c2e;

    --ink:        #f2f2f7;
    --ink-2:      #d1d1d6;
    --ink-3:      #aeaeb2;
    --ink-4:      #636366;

    --rule:       #38383a;
    --rule-soft:  #2c2c2e;

    --accent:     #0a84ff;
    --accent-ink: #64a9ff;
    --accent-bg:  rgba(10, 132, 255, 0.16);

    --data-1: #0a84ff;
    --data-2: #5e5ce6;
    --ok:     #30d158;
    --ok-bg:  rgba(48, 209, 88, 0.14);
    --warn:   #ff9f0a;
    --warn-bg: rgba(255, 159, 10, 0.14);
    --err:    #ff453a;
    --err-bg: rgba(255, 69, 58, 0.14);

    --lift-1: 0 1px 2px rgba(0, 0, 0, 0.55);
    --lift-2: 0 4px 18px rgba(0, 0, 0, 0.5);
    --lift-3: 0 16px 48px rgba(0, 0, 0, 0.72);

    --p-line: rgba(10, 132, 255, 0.32);
  }

  body { background: var(--paper); color: var(--ink); }

  /* Surfaces that were hardcoded white in the light layer. */
  .side {
    background: rgba(28, 28, 30, 0.86);
    border-right-color: var(--rule);
  }
  .topbar {
    background: rgba(0, 0, 0, 0.78);
    border-bottom-color: var(--rule);
  }

  /* The phone bars sit inside a max-width query above, so they need their own
     dark background or mobile stays a white strip on a black page. */
  .mbar, .mobile-bar {
    background: rgba(28, 28, 30, 0.88);
    border-bottom-color: var(--rule);
  }

  .card, .tile, .kcard, .modal, .amenu, .launcher {
    background: var(--surface);
    border-color: var(--rule);
  }
  .tile:hover { background: var(--surface); border-color: #48484a; }

  .input, .search, .sel {
    background: var(--surface-2);
    border-color: var(--rule);
    color: var(--ink);
  }

  .tbl th { background: var(--surface-2); color: var(--ink-3); }
  .tbl td { border-bottom-color: var(--rule-soft); }
  .tbl tbody tr:hover { background: var(--surface-2); }

  .btn {
    background: var(--surface-2);
    border-color: var(--rule);
    color: var(--ink);
  }
  .btn:hover { background: var(--paper-2); border-color: #48484a; }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  .btn.primary:hover { background: #0070e0; color: #fff; }
  .btn-icon { background: var(--surface-2); color: var(--ink-2); }
  .btn-icon:hover { background: var(--paper-2); color: var(--ink); }
  .btn-sm { background: var(--surface-2); border-color: var(--rule); color: var(--ink-2); }
  .btn-sm.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

  .modal-mask { background: rgba(0, 0, 0, 0.58); }
  ::selection { background: #1d3d6b; color: #eaf2ff; }

  .qbar-track { background: var(--paper-2); }
  .tag.off { background: var(--surface-2); color: var(--ink-3); }

  .amenu-item:hover, .amenu-item:active { background: var(--paper-2); }
}

/* ------------------------------------------------------------- check-in */
/* CHECKIN-STANDALONE-CSS
   The check-in page uses the console's own card / tiles / mrow / kv / modal
   components, so only a few small helpers are needed here. Every colour and
   radius resolves through the site variables - no separate palette, no
   gradient, no oversized radius. */
.ck-card { display: none; }              /* legacy overview card, retired */
.btn.primary.is-done {
  background: var(--surface-2);
  border-color: var(--rule);
  color: var(--ink-3);
  box-shadow: none;
}
.ck-list {
  display: flex;
  flex-direction: column;
}
/* CHECKIN-SPACING: .hint carries a top margin meant for inline use; the
   first element in a card body must not add that gap on top of the
   card's own padding. */
.view .card .card-body > .hint:first-child,
.view .card .card-body > div > .hint:first-child,
.view .card .card-body > p.hint:first-child {
  margin-top: 0;
}
.view .card .card-body > .kv { margin-top: 0; }
.ck-list .mrow:first-child { border-top: 0; }
.ck-list .mrow {
  border-top: 1px solid var(--rule-soft);
}
/* The dialg badge is gone; keep the old class names harmless if a cached
   client still renders them for one page load. */
.ck-btn, .ck-overlay, .ck-dialog, .ck-badge, .ck-dialog-btn { display: none; }

/* PAID-BAR-FULLWIDTH: paid model rows must own the whole card width.
   The generic .paid-lines grid used for plain text squeezed each bar into a
   narrow column, so the track and its label were cut off. */
.paid-lines {
  display: block;
  width: 100%;
}
.paid-lines > .paid-line {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
}
.paid-stat {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 0;
  border-top: 1px solid rgba(60, 60, 67, .08);
}
.paid-stat:first-child { border-top: 0; padding-top: 4px; }
.paid-stat > .qsep { display: none; }
.paid-stat .qpool-top {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.paid-stat .qbar-track {
  width: 100%;
  display: block;
  margin-top: 10px;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
}
.paid-stat .qbar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width .35s ease;
}
.paid-stat .qbar-sub {
  width: 100%;
  margin-top: 7px;
  white-space: normal;
  word-break: break-word;
}
@media (max-width: 640px) {
  .paid-stat .qpool-top { flex-wrap: wrap; gap: 4px; }
}


/* ===== QUOTA-PAGE (quota wallet / pools / paid / free) ===== */
.qcard { display: flex; flex-direction: column; gap: 14px; }
.qbar { display: flex; flex-direction: column; gap: 6px; }
.qbar-top { display: flex; justify-content: space-between; align-items: baseline; }
.qbar-k { font-size: 13px; color: var(--ink-2, #555); }
.qbar-v { font-size: 17px; font-weight: 600; color: var(--ink, #111); }
.qbar-v.has { color: var(--accent, #2563eb); }
.qbar-track { height: 6px; background: var(--rule, #e5e7eb); border-radius: 3px; overflow: hidden; }
.qbar-fill { height: 100%; background: var(--accent, #2563eb); border-radius: 3px; }
.qbar-fill.low { background: #f59e0b; }
.qbar-sub { font-size: 12px; color: var(--ink-3, #888); line-height: 1.5; }
.qpool { display: flex; flex-direction: column; gap: 6px; }
.qpool-top { display: flex; justify-content: space-between; align-items: baseline; }
.qpool-v { font-size: 17px; font-weight: 600; color: var(--ink, #111); }
.qpool-v.has { color: var(--accent, #2563eb); }
.qsep { height: 1px; background: var(--rule, #eef0f3); margin: 2px 0; }
.qnote { font-size: 12px; color: var(--ink-3, #888); line-height: 1.6; margin: 6px 0 0; }

/* paid / free model rows */
.paid-rows { display: flex; flex-direction: column; gap: 12px; }
.paid-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: baseline; }
.paid-row-name { font-size: 13px; color: var(--ink-2, #555); }
.paid-row-val { font-size: 16px; font-weight: 600; color: var(--ink, #111); text-align: right; }
.paid-row-val.has { color: var(--accent, #2563eb); }
.paid-row-sub { grid-column: 1 / -1; font-size: 12px; color: var(--ink-3, #888); }
.quota-details { display: flex; flex-direction: column; gap: 10px; margin-top: 10px;
                 padding-top: 10px; border-top: 1px solid var(--rule, #eef0f3); }


/* ===== MODEL DETAIL PAGE ===== */
.mdl-group { margin-bottom: 18px; }
.mdl-group-title { font-size: 13px; font-weight: 600; color: var(--ink-2, #555);
                   text-transform: uppercase; letter-spacing: .04em;
                   margin: 0 0 10px; }
.mdl-table { width: 100%; border-collapse: collapse; }
.mdl-table th { text-align: left; font-size: 12px; font-weight: 600;
                color: var(--ink-3, #888); padding: 6px 10px 8px;
                border-bottom: 1px solid var(--rule, #eef0f3); white-space: nowrap; }
.mdl-table td { padding: 10px; font-size: 13px; color: var(--ink, #222);
                border-bottom: 1px solid var(--rule, #f4f5f7); vertical-align: top; }
.mdl-table tr:last-child td { border-bottom: none; }
.mdl-name { font-weight: 600; }
.mdl-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
          font-size: 11px; color: var(--ink-3, #999); }
.mdl-price { white-space: nowrap; font-variant-numeric: tabular-nums; }
.mdl-badge { display: inline-block; padding: 1px 7px; border-radius: 999px;
             font-size: 11px; font-weight: 600; white-space: nowrap; }
.mdl-badge.free { background: #e8f5e9; color: #1b7a2f; }
.mdl-badge.paid { background: #fff4e5; color: #a35b00; }
.mdl-badge.ok   { background: #e7f0ff; color: #1a56c4; }
.mdl-badge.no   { background: #f2f3f5; color: #888; }
.mdl-notes { font-size: 12px; color: var(--ink-3, #888); line-height: 1.6; margin-top: 6px; }




/* ===== VIP / PRIVILEGE (v4.1flash unlimited) ===== */
.priv-pill { display: inline-flex; align-items: center; gap: 5px;
             padding: 2px 9px 2px 7px; border-radius: 999px;
             font-size: 11px; font-weight: 800; letter-spacing: .01em;
             white-space: nowrap; line-height: 1.5;
             background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 55%, #d97706 100%);
             color: #fff; border: 0;
             box-shadow: 0 1px 2px rgba(180,83,9,.28), inset 0 1px 0 rgba(255,255,255,.35);
             text-shadow: 0 1px 1px rgba(120,53,15,.35); }
.priv-pill .priv-dot { width: 6px; height: 6px; border-radius: 50%;
                       background: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.35);
                       flex: 0 0 auto; }
.priv-pill.lg { font-size: 12px; padding: 3px 12px 3px 10px; }

/* hero: two-column on desktop, stacked on a phone */
.priv-hero { display: flex; align-items: center; gap: 16px; padding: 16px 18px;
             border-radius: 14px; position: relative; overflow: hidden;
             background: linear-gradient(120deg, #fffbeb 0%, #fef3c7 45%, #fde68a 78%, #fcd34d 100%);
             border: 1px solid #fbbf24;
             box-shadow: 0 2px 10px rgba(180,83,9,.10), inset 0 1px 0 rgba(255,255,255,.6); }
.priv-hero::after { content: ''; position: absolute; right: -30px; top: -30px;
                    width: 130px; height: 130px; border-radius: 50%;
                    background: radial-gradient(circle, rgba(251,191,36,.35), transparent 70%);
                    pointer-events: none; }
.priv-hero-icon { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 13px;
                  display: grid; place-items: center; position: relative; z-index: 1;
                  background: linear-gradient(135deg, #f59e0b, #b45309); color: #fffbeb;
                  font-size: 22px; font-weight: 700;
                  box-shadow: 0 3px 8px rgba(180,83,9,.30), inset 0 1px 0 rgba(255,255,255,.35); }
.priv-hero-main { flex: 1 1 auto; min-width: 0; position: relative; z-index: 1; }
.priv-hero-title { font-size: 15px; font-weight: 800; color: #78350f;
                   margin: 0 0 4px; display: flex; align-items: center;
                   gap: 8px; flex-wrap: wrap; }
.priv-hero-sub { font-size: 12px; color: #92400e; line-height: 1.6; margin: 0; }
.priv-hero-tag { flex: 0 0 auto; font-size: 11px; font-weight: 800; padding: 4px 12px;
                 border-radius: 999px; background: linear-gradient(135deg,#b45309,#78350f);
                 color: #fffbeb; white-space: nowrap; position: relative; z-index: 1;
                 box-shadow: 0 2px 5px rgba(120,53,15,.28); }

/* a compact privilege strip for the phone */
.priv-strip { display: flex; align-items: center; gap: 8px; padding: 9px 12px;
              border-radius: 10px; font-size: 12px; font-weight: 600; color: #78350f;
              background: linear-gradient(120deg,#fef3c7,#fde68a);
              border: 1px solid #fbbf24; }
.priv-strip .priv-strip-dot { width: 7px; height: 7px; border-radius: 50%;
                              background: #f59e0b; flex: 0 0 auto;
                              box-shadow: 0 0 0 3px rgba(245,158,11,.20); }

/* ===== MOBILE ADAPTATION for everything added recently ===== */
@media (max-width: 820px) {
  /* --- vip --- */
  .priv-hero { flex-wrap: wrap; gap: 10px; padding: 13px 14px; border-radius: 12px; }
  .priv-hero-icon { width: 38px; height: 38px; border-radius: 11px; font-size: 18px; }
  .priv-hero-main { flex: 1 1 100%; order: 3; min-width: 0; }
  .priv-hero-title { font-size: 14px; margin-bottom: 3px; }
  .priv-hero-sub { font-size: 11.5px; line-height: 1.55; }
  .priv-hero-tag { margin-left: auto; font-size: 10.5px; padding: 3px 10px; }
  .priv-pill { font-size: 10.5px; padding: 1.5px 8px 1.5px 6px; }

  /* --- quota page rows --- */
  .paid-rows { gap: 10px; }
  .paid-row { grid-template-columns: 1fr auto; gap: 3px 8px; }
  .paid-row-name { font-size: 12.5px; }
  .paid-row-val { font-size: 15px; }
  .paid-row-sub { font-size: 11.5px; }
  .qbar-k { font-size: 12.5px; }
  .qbar-v, .qpool-v { font-size: 15.5px; }
  .qbar-sub { font-size: 11.5px; }
  .quota-details { gap: 8px; }

  /* --- model detail table becomes stacked cards --- */
  .mdl-group { margin-bottom: 14px; }
  .mdl-group-title { font-size: 12px; margin-bottom: 8px; }
  .mdl-table, .mdl-table thead, .mdl-table tbody,
  .mdl-table tr, .mdl-table td { display: block; width: 100%; }
  .mdl-table thead { display: none; }
  .mdl-table tr { border: 1px solid var(--rule, #eef0f3); border-radius: 10px;
                  padding: 10px 12px; margin-bottom: 8px; background: var(--surface, #fff); }
  .mdl-table td { border: 0; padding: 2px 0; }
  .mdl-table td.mdl-price { font-size: 12.5px; color: var(--ink-2, #555); }
  .mdl-name { font-size: 13.5px; }
  .mdl-id { font-size: 10.5px; margin-top: 1px; }
  .mdl-notes { font-size: 11.5px; margin-top: 2px; }
  /* label the stacked cells so the values keep their meaning */
  .mdl-table td.mdl-price::before { content: attr(data-label) " "; }
  .mdl-badge { font-size: 10.5px; padding: 1px 7px; }

  /* --- boot skeleton --- */
  .boot-skel { flex-direction: column; }
  .boot-side { display: none; }
  .boot-main { padding: 18px 14px; gap: 12px; }
  .skel-card { height: 88px; }
  .skel-card.tall { height: 132px; }
  .content-skel .skel { height: 78px; }
  .content-skel .skel.short { height: 56px; }
}

@media (max-width: 420px) {
  .priv-hero { padding: 12px; }
  .priv-hero-title { font-size: 13.5px; }
  .paid-row-val { font-size: 14px; }
  .qbar-v, .qpool-v { font-size: 14.5px; }
  .mdl-table tr { padding: 9px 10px; }
}
