/* aigw console — Apple-style cards, restrained type, light & dark. */

:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --bg-sidebar: rgba(246, 246, 248, 0.78);
  --card: #ffffff;
  --card-2: #fbfbfd;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-2: rgba(118, 118, 128, 0.08);
  --fill-hover: rgba(118, 118, 128, 0.16);
  --sep: rgba(60, 60, 67, 0.12);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --accent: #0071e3;
  --accent-tint: rgba(0, 113, 227, 0.1);
  --accent-text: #0066cc;
  --green: #248a3d;
  --green-tint: rgba(52, 199, 89, 0.14);
  --orange: #b25000;
  --orange-tint: rgba(255, 159, 10, 0.16);
  --red: #d70015;
  --red-tint: rgba(255, 59, 48, 0.12);
  --series-1: #2a78d6;
  --grid: rgba(60, 60, 67, 0.09);
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.02), 0 2px 8px rgba(0, 0, 0, 0.04), 0 0 0 0.5px rgba(0, 0, 0, 0.05);
  --shadow-pop: 0 10px 40px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB",
    "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", Inter, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --bg-sidebar: rgba(28, 28, 30, 0.72);
    --card: #1c1c1e;
    --card-2: #232325;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.16);
    --fill-hover: rgba(118, 118, 128, 0.32);
    --sep: rgba(84, 84, 88, 0.5);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --accent: #0a84ff;
    --accent-tint: rgba(10, 132, 255, 0.18);
    --accent-text: #409cff;
    --green: #30d158;
    --green-tint: rgba(48, 209, 88, 0.16);
    --orange: #ffb340;
    --orange-tint: rgba(255, 159, 10, 0.18);
    --red: #ff6961;
    --red-tint: rgba(255, 69, 58, 0.18);
    --series-1: #3987e5;
    --grid: rgba(235, 235, 245, 0.1);
    --shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.06);
    --shadow-pop: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.1);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-sidebar: rgba(28, 28, 30, 0.72);
  --card: #1c1c1e;
  --card-2: #232325;
  --fill: rgba(118, 118, 128, 0.24);
  --fill-2: rgba(118, 118, 128, 0.16);
  --fill-hover: rgba(118, 118, 128, 0.32);
  --sep: rgba(84, 84, 88, 0.5);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --accent: #0a84ff;
  --accent-tint: rgba(10, 132, 255, 0.18);
  --accent-text: #409cff;
  --green: #30d158;
  --green-tint: rgba(48, 209, 88, 0.16);
  --orange: #ffb340;
  --orange-tint: rgba(255, 159, 10, 0.18);
  --red: #ff6961;
  --red-tint: rgba(255, 69, 58, 0.18);
  --series-1: #3987e5;
  --grid: rgba(235, 235, 245, 0.1);
  --shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.06);
  --shadow-pop: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 var(--font);
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 12px 14px;
  background: var(--bg-sidebar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 0.5px solid var(--sep);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 600; font-size: 14px; }
.brand small { font-weight: 400; color: var(--text-3); font-size: 12px; }
.mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(145deg, #5e9cff, #2a5bd7 55%, #6a4ce0);
  box-shadow: inset 0 0 0 0.5px rgba(255,255,255,.25), 0 1px 2px rgba(0,0,0,.15);
  display: grid; place-items: center; color: #fff;
}
.mark svg { width: 15px; height: 15px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--text); font-size: 13px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
}
.nav-item svg { width: 17px; height: 17px; color: var(--text-2); flex: none; }
.nav-item:hover { background: var(--fill-2); text-decoration: none; }
.nav-item.active { background: var(--accent-tint); color: var(--accent-text); }
.nav-item.active svg { color: var(--accent-text); }
.nav-gap { flex: 1; }
.nav-label { padding: 14px 10px 4px; font-size: 11px; color: var(--text-3); font-weight: 500; }

.me-chip {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 10px;
  border: 0; background: none; width: 100%; text-align: left; cursor: pointer;
}
.me-chip:hover { background: var(--fill-2); }
.me-chip .who { min-width: 0; line-height: 1.3; }
.me-chip .who b { display: block; font-weight: 500; font-size: 13px; }
.me-chip .who span { font-size: 11px; color: var(--text-3); }

.main { min-width: 0; padding: 22px 32px 48px; }
.page { max-width: 1120px; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 36px; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.topbar .sub { color: var(--text-3); font-size: 12px; }
.topbar .spacer { flex: 1; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card.flush .card-head { padding: 16px 20px 0; margin-bottom: 8px; }
.card-head h2 { margin: 0; font-size: 13px; font-weight: 600; }
.card-head .hint { color: var(--text-3); font-size: 12px; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 14px; }
#page > * + *, .portal > * + * { margin-top: 14px; }
#page > .topbar + *, .portal > .portal-bar + * { margin-top: 0; }
#page > .banner + * { margin-top: 0; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }

.stat .label { color: var(--text-2); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 3px; letter-spacing: 0; }
.stat .foot { margin-top: 4px; font-size: 12px; color: var(--text-3); }
.delta { font-weight: 500; }
.delta.up { color: var(--orange); }
.delta.down { color: var(--green); }

/* ---------- lists ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 20px; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 20px; right: 0; height: 0.5px; background: var(--sep); }
.row.inset + .row.inset::before { left: 64px; }
.row.inset:has(.avatar.sm) + .row.inset::before { left: 58px; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.clickable { cursor: pointer; }
.row.clickable:hover { background: var(--fill-2); }
.card:not(.flush) .rows .row { padding-left: 0; padding-right: 0; }
.card:not(.flush) .rows .row + .row::before { left: 0; }
.right { text-align: right; }
.empty { padding: 28px 20px; text-align: center; color: var(--text-3); font-size: 12px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 600;
  background: linear-gradient(145deg, var(--a1, #8e8e93), var(--a2, #636366));
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.t th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 11.5px; padding: 8px 12px; white-space: nowrap; }
.t td { padding: 10px 12px; border-top: 0.5px solid var(--sep); white-space: nowrap; }
.t th:first-child, .t td:first-child { padding-left: 20px; }
.t th:last-child, .t td:last-child { padding-right: 20px; }
.t tr:hover td { background: var(--fill-2); }
.t .r { text-align: right; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 14px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--fill); color: var(--text); font-weight: 500; font-size: 13px; white-space: nowrap;
  transition: background .15s, transform .05s, opacity .15s;
}
.btn:hover { background: var(--fill-hover); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; }
.btn.ghost { background: none; color: var(--accent-text); padding: 0 8px; }
.btn.ghost:hover { background: var(--accent-tint); }
.btn.icon { width: 30px; padding: 0; }
.btn.sm { height: 26px; padding: 0 11px; font-size: 12px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.field { display: grid; gap: 6px; }
.field + .field { margin-top: 14px; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field .tip { font-size: 11.5px; color: var(--text-3); }
.input, select.input {
  width: 100%; height: 34px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 0; background: var(--fill-2); outline: none;
  box-shadow: inset 0 0 0 0.5px var(--sep);
  transition: box-shadow .15s, background .15s;
}
.input:focus { background: var(--card); box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-tint); }
.input::placeholder { color: var(--text-3); }
select.input { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%238e8e93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input.inline { width: auto; height: 28px; font-size: 12px; border-radius: 8px; }
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-fields .field + .field { margin-top: 0; }

.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--fill-2); gap: 2px; }
.seg button { border: 0; background: none; padding: 0 12px; height: 26px; border-radius: 7px; font-size: 12px; font-weight: 500; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 0.5px rgba(0,0,0,.04); }

.switch { position: relative; width: 38px; height: 23px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--fill-hover); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: #34c759; }
.switch input:checked + span::after { transform: translateX(15px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 4px var(--accent-tint); }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 500; background: var(--fill-2); color: var(--text-2); white-space: nowrap; }
.badge.blue { background: var(--accent-tint); color: var(--accent-text); }
.badge.green { background: var(--green-tint); color: var(--green); }
.badge.orange { background: var(--orange-tint); color: var(--orange); }
.badge.red { background: var(--red-tint); color: var(--red); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.green { background: #34c759; }
.dot.orange { background: #ff9f0a; }
.dot.red { background: #ff3b30; }

.meter { height: 6px; border-radius: 999px; background: var(--fill-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s ease; }
.meter.warn i { background: #ff9f0a; }
.meter.over i { background: #ff3b30; }

.code {
  position: relative; background: var(--fill-2); border-radius: 12px; padding: 14px 16px; padding-right: 48px;
  font-family: var(--mono); font-size: 12px; line-height: 1.7; white-space: pre-wrap; word-break: break-all;
  box-shadow: inset 0 0 0 0.5px var(--sep);
}
.code .c { color: var(--text-3); }
.code .copy { position: absolute; top: 8px; right: 8px; }

.banner {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 12px;
  background: var(--orange-tint); color: var(--text); font-size: 12px; margin-bottom: 14px;
}
.banner .spacer { flex: 1; }

/* ---------- chart ---------- */
.chart { position: relative; height: 196px; }
.card.fill { display: flex; flex-direction: column; }
.card.fill .chart { flex: 1; min-height: 196px; height: auto; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .axis { fill: var(--text-3); font-size: 10.5px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .bar { fill: var(--series-1); transition: opacity .15s; }
.chart.hovering .bar { opacity: .45; }
.chart.hovering .bar.hot { opacity: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, calc(-100% - 10px));
  background: var(--card); box-shadow: var(--shadow-pop); border-radius: 10px; padding: 8px 11px; font-size: 12px; white-space: nowrap;
}
.chart-tip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tip .faint { margin-bottom: 2px; }

.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.hbar + .hbar { margin-top: 12px; }
.hbar .name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .val { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.hbar .track { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--fill-2); overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--series-1); border-radius: 999px; }

/* ---------- overlays ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.28); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade .18s ease;
}
.sheet {
  width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow-pop); padding: 22px 22px 18px;
  animation: pop .22s cubic-bezier(.2, .9, .3, 1.2);
}
.sheet h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.sheet .lead { margin: 0 0 18px; color: var(--text-2); font-size: 12.5px; }
.sheet .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.account-import-file {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 8px 10px 8px 12px;
  border: 1px solid var(--sep); border-radius: 12px; background: var(--fill-2);
}
.account-import-file [data-file-name] {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-2); font-size: 12.5px;
}
.account-import-file .btn { flex: none; }
.account-import-preview { margin-top: 16px; }
.account-import-error { margin: 10px 0 0; color: var(--red); font-size: 12.5px; }
.secret {
  display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; border-radius: 12px; background: var(--fill-2);
  font-family: var(--mono); font-size: 12.5px; word-break: break-all; box-shadow: inset 0 0 0 0.5px var(--sep);
}
.secret span { flex: 1; }

.menu {
  position: fixed; z-index: 60; min-width: 168px; padding: 5px; border-radius: 12px;
  background: var(--card); box-shadow: var(--shadow-pop); animation: pop .14s ease;
}
.menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: 7px; font-size: 13px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--accent); color: #fff; }
.menu button.danger { color: var(--red); }
.menu button.danger:hover { background: var(--red); color: #fff; }
.menu hr { border: 0; height: 0.5px; background: var(--sep); margin: 4px 6px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 70;
  background: rgba(30, 30, 32, 0.92); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 12.5px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); backdrop-filter: blur(10px); animation: rise .25s ease;
}
.toast.err { background: rgba(215, 0, 21, 0.94); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

.skeleton { background: linear-gradient(90deg, var(--fill-2), var(--fill), var(--fill-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(94, 156, 255, 0.16), transparent 60%), var(--bg); }
.login { width: min(360px, 100%); }
.login .card { padding: 26px 24px 22px; border-radius: 20px; }
.login .mark { width: 40px; height: 40px; border-radius: 11px; margin: 0 auto 14px; }
.login .mark svg { width: 22px; height: 22px; }
.login h1 { text-align: center; font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.login .lead { text-align: center; color: var(--text-3); font-size: 12px; margin: 0 0 20px; }
.login .btn { width: 100%; height: 36px; margin-top: 18px; }
.login .err { color: var(--red); font-size: 12px; margin-top: 10px; text-align: center; min-height: 18px; }
.login .foot { text-align: center; color: var(--text-3); font-size: 11.5px; margin-top: 14px; }

/* ---------- member portal ---------- */
.portal { max-width: 920px; margin: 0 auto; padding: 18px 24px 56px; }
.portal-bar { display: flex; align-items: center; gap: 10px; height: 48px; margin-bottom: 14px; }
.portal-bar .spacer { flex: 1; }
.greet { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.greet small { display: block; font-size: 12px; font-weight: 400; color: var(--text-3); letter-spacing: 0; }
.budget-big { display: flex; align-items: baseline; gap: 6px; }
.budget-big .value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; z-index: 20; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 0.5px solid var(--sep); }
  .brand { padding: 0 8px 0 0; }
  .brand small, .nav-label, .nav-gap, .me-chip .who { display: none; }
  .nav-item { width: auto; flex: none; padding: 6px 10px; }
  .nav-item span { display: none; }
  .me-chip { width: auto; margin-left: auto; }
  .main { padding: 16px 16px 40px; }
  .g3, .g2 { grid-template-columns: minmax(0, 1fr); }
  .row-fields { grid-template-columns: 1fr; }
  .portal { padding: 10px 16px 40px; }
}
@media (max-width: 420px) {
  .g4 { grid-template-columns: minmax(0, 1fr); }
}

/* =====================================================================
   Premium layer — ambient light, glass cards, refined depth & motion.
   Overrides the base rules above; type sizes stay the same.
   ===================================================================== */
:root {
  --bg: #f3f3f6;
  --ambient: radial-gradient(900px 520px at 12% -8%, rgba(120, 160, 255, 0.20), transparent 62%),
             radial-gradient(760px 460px at 92% -6%, rgba(186, 140, 255, 0.16), transparent 60%),
             radial-gradient(900px 600px at 60% 110%, rgba(110, 200, 255, 0.10), transparent 60%);
  --card: rgba(255, 255, 255, 0.78);
  --card-solid: #ffffff;
  --card-edge: rgba(0, 0, 0, 0.06);
  --card-hi: rgba(255, 255, 255, 0.9);
  --shadow: 0 0 0 0.5px var(--card-edge), 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px -12px rgba(15, 23, 42, 0.12);
  --shadow-hover: 0 0 0 0.5px var(--card-edge), 0 2px 4px rgba(15, 23, 42, 0.05), 0 18px 40px -14px rgba(15, 23, 42, 0.18);
  --accent-grad: linear-gradient(180deg, #2b8cff 0%, #0068e0 100%);
  --series-top: #4a90f0;
  --series-bot: #2a6fd0;
  --spark: #2a78d6;
  --radius: 18px;
  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI Variable Display", "Segoe UI", Inter, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0d;
    --ambient: radial-gradient(900px 520px at 12% -8%, rgba(70, 110, 255, 0.20), transparent 62%),
               radial-gradient(760px 460px at 92% -6%, rgba(150, 90, 255, 0.14), transparent 60%),
               radial-gradient(900px 600px at 60% 110%, rgba(40, 140, 255, 0.08), transparent 60%);
    --card: rgba(30, 30, 34, 0.72);
    --card-solid: #1f1f23;
    --card-edge: rgba(255, 255, 255, 0.08);
    --card-hi: rgba(255, 255, 255, 0.06);
    --shadow: 0 0 0 0.5px var(--card-edge), 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-hover: 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 18px 40px -14px rgba(0, 0, 0, 0.7);
    --accent-grad: linear-gradient(180deg, #3a9bff 0%, #0a74f0 100%);
    --series-top: #5aa0ff;
    --series-bot: #2f78e0;
    --spark: #4b95f0;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0d;
  --ambient: radial-gradient(900px 520px at 12% -8%, rgba(70, 110, 255, 0.20), transparent 62%),
             radial-gradient(760px 460px at 92% -6%, rgba(150, 90, 255, 0.14), transparent 60%),
             radial-gradient(900px 600px at 60% 110%, rgba(40, 140, 255, 0.08), transparent 60%);
  --card: rgba(30, 30, 34, 0.72);
  --card-solid: #1f1f23;
  --card-edge: rgba(255, 255, 255, 0.08);
  --card-hi: rgba(255, 255, 255, 0.06);
  --shadow: 0 0 0 0.5px var(--card-edge), 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-hover: 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 18px 40px -14px rgba(0, 0, 0, 0.7);
  --accent-grad: linear-gradient(180deg, #3a9bff 0%, #0a74f0 100%);
  --series-top: #5aa0ff;
  --series-bot: #2f78e0;
  --spark: #4b95f0;
}

body { background: var(--ambient), var(--bg); background-attachment: fixed; }

/* glass cards */
.card {
  background: var(--card);
  backdrop-filter: saturate(160%) blur(24px);
  -webkit-backdrop-filter: saturate(160%) blur(24px);
  box-shadow: inset 0 1px 0 var(--card-hi), var(--shadow);
  transition: box-shadow .25s ease, transform .25s ease;
}
.card.lift:hover { box-shadow: inset 0 1px 0 var(--card-hi), var(--shadow-hover); transform: translateY(-1px); }
.sheet, .menu, .chart-tip { background: var(--card-solid); }

/* sidebar: floating white pill for the active item, like System Settings */
.sidebar { background: color-mix(in srgb, var(--card-solid) 55%, transparent); }
/* No fades on the sidebar items: the highlight, its shadow and the text all
   switch in the same frame, so moving between pages never shows a half state. */
.nav-item { transition: none; }
.nav-item.active {
  background: var(--card-solid); color: var(--text);
  box-shadow: 0 0 0 0.5px var(--card-edge), 0 1px 3px rgba(15, 23, 42, 0.08);
}
.nav-item.active svg { color: var(--accent); }
.brand { letter-spacing: -0.01em; }
.mark { box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 0 0 0.5px rgba(0,0,0,.1), 0 4px 12px -4px rgba(42, 91, 215, .6); }

/* numbers */
.stat .value, .budget-big .value { font-family: var(--display); font-weight: 600; letter-spacing: -0.025em; font-feature-settings: "tnum"; }
.stat { position: relative; overflow: hidden; }
.stat .label { font-weight: 500; }
.stat .spark { position: absolute; right: 18px; top: 20px; width: 84px; height: 28px; }
.stat .spark path.line { fill: none; stroke: var(--spark); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.stat .spark circle { fill: var(--spark); stroke: var(--card-solid); stroke-width: 2; }
.topbar h1 { letter-spacing: -0.02em; }

/* buttons & meters */
.btn.primary { background: var(--accent-grad); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 1px 2px rgba(0, 80, 200, .25), 0 4px 12px -4px rgba(0, 104, 224, .45); }
.btn.primary:hover { filter: brightness(1.06); }
.btn { transition: background .15s, transform .08s, box-shadow .15s, filter .15s; }
.meter i { background: linear-gradient(90deg, #5aa2ff, #1a73e8); }
.meter.warn i { background: linear-gradient(90deg, #ffc15e, #ff9500); }
.meter.over i { background: linear-gradient(90deg, #ff7a70, #ff3b30); }
.hbar .track i { background: linear-gradient(90deg, var(--series-top), var(--series-bot)); }
.seg { background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); }
.seg button.on { background: var(--card-solid); }

/* status pill in the top bar (replaces the big banner) */
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 4px 0 11px; border-radius: 999px;
  background: var(--orange-tint); color: var(--text); font-size: 12px;
}
.pill .btn { height: 20px; padding: 0 9px; font-size: 11.5px; background: var(--card-solid); box-shadow: 0 0 0 0.5px var(--card-edge); }

/* chart refinements */
.chart .bar { fill: url(#barGrad); }
.chart .bar.latest { fill: url(#barGradHot); }
.chart .avg { stroke: var(--text-3); stroke-width: 1; opacity: .55; shape-rendering: crispEdges; }
.chart .avg-label { fill: var(--text-2); font-size: 10.5px; font-family: var(--font); }
.chart .avg-chip { fill: var(--card-solid); stroke: var(--card-edge); }

/* tables & rows feel lighter on glass */
.t th { font-weight: 500; letter-spacing: .01em; }
.t tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.row.clickable:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.avatar { box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 0 0 0.5px rgba(0,0,0,.06), 0 2px 6px -2px rgba(0,0,0,.25); }
.code { background: color-mix(in srgb, var(--fill-2) 70%, transparent); }

/* entrance motion */
@keyframes enter { from { opacity: 0; transform: translateY(6px) scale(.995); } }
/* only when arriving on a page — a page redrawing itself (save, filter) stays put */
#page.entering > *, .portal > * { animation: enter .5s cubic-bezier(.2, .8, .2, 1) both; }
#page.entering .grid > .card { animation: enter .55s cubic-bezier(.2, .8, .2, 1) both; }
#page.entering .grid > .card:nth-child(2) { animation-delay: 40ms; }
#page.entering .grid > .card:nth-child(3) { animation-delay: 80ms; }
#page.entering .grid > .card:nth-child(4) { animation-delay: 120ms; }
@media (prefers-reduced-motion: reduce) {
  #page > *, .portal > *, .grid > .card, .sheet, .scrim, .menu, .toast { animation: none !important; }
  .card, .btn, .nav-item { transition: none !important; }
}

/* ---------- full-height app shell: sidebar fixed, content scrolls ---------- */
body.app { height: 100vh; overflow: hidden; }
body.app .shell { height: 100vh; min-height: 0; }
body.app .sidebar { position: relative; height: 100vh; overflow-y: auto; }
body.app .main { height: 100vh; overflow-y: auto; overscroll-behavior: contain; }
body.app .main::-webkit-scrollbar { width: 10px; }
body.app .main::-webkit-scrollbar-thumb { background: transparent; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
body.app .main:hover::-webkit-scrollbar-thumb { background-color: var(--fill-hover); }
@media (max-width: 760px) {
  body.app { height: auto; overflow: auto; }
  body.app .shell, body.app .sidebar, body.app .main { height: auto; overflow: visible; }
  body.app .sidebar { position: sticky; top: 0; }
}

/* ---------- login ---------- */
body.auth { min-height: 100vh; margin: 0; }
.auth-split { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); min-height: 100vh; }

.auth-art {
  position: relative; overflow: hidden; isolation: isolate; color: #fff;
  background: linear-gradient(150deg, #070b1a 0%, #0e1a46 46%, #24135a 100%);
  display: flex; flex-direction: column; padding: 34px 44px 30px;
}
.auth-art .orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .75; z-index: -1; will-change: transform; }
.auth-art .o1 { width: 460px; height: 460px; left: -120px; top: -100px; background: radial-gradient(circle, #3d7bff 0%, transparent 70%); animation: drift1 18s ease-in-out infinite alternate; }
.auth-art .o2 { width: 420px; height: 420px; right: -140px; top: 22%; background: radial-gradient(circle, #8a5cff 0%, transparent 70%); animation: drift2 22s ease-in-out infinite alternate; }
.auth-art .o3 { width: 380px; height: 380px; left: 24%; bottom: -170px; background: radial-gradient(circle, #19b5ff 0%, transparent 70%); opacity: .55; animation: drift3 26s ease-in-out infinite alternate; }
.auth-art .grain {
  position: absolute; inset: 0; z-index: -1; opacity: .5; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px); background-size: 22px 22px;
  mask-image: radial-gradient(ellipse at 40% 40%, #000 30%, transparent 75%);
}
@keyframes drift1 { to { transform: translate(90px, 60px) scale(1.08); } }
@keyframes drift2 { to { transform: translate(-80px, 70px) scale(.94); } }
@keyframes drift3 { to { transform: translate(60px, -50px) scale(1.1); } }

.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.auth-brand .mark { width: 28px; height: 28px; border-radius: 8px; }
.auth-brand small { font-weight: 400; color: rgba(255,255,255,.55); font-size: 12px; }
.auth-copy { margin-top: auto; max-width: 420px; }
.auth-copy h2 { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.45; letter-spacing: -0.015em; }
.auth-copy h2 span { background: linear-gradient(90deg, #9cc2ff, #c9a8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-copy p { margin: 10px 0 0; font-size: 13px; color: rgba(255,255,255,.62); line-height: 1.7; }
.auth-points { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.auth-points span {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: 999px; font-size: 12px;
  color: rgba(255,255,255,.82); background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 0.5px rgba(255,255,255,.14);
}
.auth-points svg { width: 13px; height: 13px; color: #9cc2ff; }
.auth-foot { margin-top: 28px; font-size: 11.5px; color: rgba(255,255,255,.4); }

/* floating glass previews (decorative, no real data) */
.auth-stage { position: relative; height: 270px; margin: 26px 0 8px; max-width: 460px; }
.glass {
  position: absolute; border-radius: 16px; padding: 14px 16px;
  background: rgba(255,255,255,.08); backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), inset 0 0 0 0.5px rgba(255,255,255,.14), 0 24px 50px -20px rgba(0,0,0,.6);
}
.glass .g-label { font-size: 11.5px; color: rgba(255,255,255,.6); }
.glass .g-row { display: flex; align-items: center; gap: 9px; }
.glass.g1 { left: 0; top: 18px; width: 300px; animation: float 7s ease-in-out infinite; }
.glass.g2 { right: 0; top: 120px; width: 230px; animation: float 8s ease-in-out -2s infinite; }
.glass.g3 { left: 54px; bottom: 0; width: 210px; animation: float 9s ease-in-out -4s infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
.g-bars { display: flex; align-items: flex-end; gap: 5px; height: 64px; margin-top: 12px; }
.g-bars i { flex: 1; border-radius: 3px 3px 1px 1px; background: linear-gradient(180deg, rgba(156,194,255,.95), rgba(90,140,255,.35)); }
.g-bars i:last-child { background: linear-gradient(180deg, #c9a8ff, #7b5cff); }
.g-chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 11.5px; background: rgba(255,255,255,.1); box-shadow: inset 0 0 0 0.5px rgba(255,255,255,.16); }
.g-dot { width: 7px; height: 7px; border-radius: 50%; background: #34c759; box-shadow: 0 0 0 3px rgba(52,199,89,.2); }
.g-key { font-family: var(--mono); font-size: 11.5px; color: rgba(255,255,255,.85); letter-spacing: .02em; }
.g-meter { height: 5px; border-radius: 999px; background: rgba(255,255,255,.12); margin-top: 10px; overflow: hidden; }
.g-meter i { display: block; height: 100%; width: 38%; border-radius: 999px; background: linear-gradient(90deg, #9cc2ff, #c9a8ff); }

/* form side */
.auth-side { position: relative; display: grid; place-items: center; padding: 32px 24px; background: var(--ambient), var(--bg); }
.auth-form { width: min(340px, 100%); }
.auth-form .hello { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.auth-form .hello-sub { margin: 4px 0 26px; color: var(--text-3); font-size: 12.5px; }
.auth-form .field + .field { margin-top: 14px; }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; transition: color .15s; }
.input-wrap .input { height: 42px; padding-left: 38px; border-radius: 12px; background: var(--card); box-shadow: inset 0 0 0 0.5px var(--card-edge), 0 1px 2px rgba(15,23,42,.04); }
.input-wrap .input:focus { background: var(--card-solid); box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-tint); }
.input-wrap:focus-within > svg { color: var(--accent); }
.input-wrap .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; background: none; border-radius: 8px; color: var(--text-3); cursor: pointer; display: grid; place-items: center; }
.input-wrap .eye:hover { background: var(--fill-2); color: var(--text-2); }
.input-wrap .eye svg { width: 16px; height: 16px; }
.input-wrap .input.with-eye { padding-right: 40px; }
.caps { font-size: 11.5px; color: var(--orange); margin-top: 6px; }
.auth-form .submit { width: 100%; height: 42px; margin-top: 22px; border-radius: 12px; font-size: 13.5px; }
.auth-form .submit .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-form .err { min-height: 18px; margin-top: 12px; color: var(--red); font-size: 12px; text-align: center; }
.auth-form .err.shake { animation: shake .35s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.auth-note { position: absolute; bottom: 22px; left: 0; right: 0; text-align: center; font-size: 11.5px; color: var(--text-3); }

@media (max-width: 900px) {
  .auth-split { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .auth-side { min-height: 100vh; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-art .orb, .glass { animation: none !important; }
}
/* login balance: stage centered in the art panel; brand above the form on phones */
.auth-stage { margin: auto; width: min(460px, 100%); transform: translateY(-10px); }
.auth-copy { margin-top: 0; }
.auth-mobile-brand { display: none; }
@media (max-width: 900px) {
  .auth-mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-weight: 600; font-size: 14px; }
  .auth-mobile-brand .mark { width: 30px; height: 30px; border-radius: 9px; }
}

/* ---------- spacing: cards hug their content, less bottom air ---------- */
.main { padding-bottom: 28px; }
.grid { align-items: start; }
.grid.g-main { align-items: stretch; }

/* ---------- member portal pieces ---------- */
.g-connect { grid-template-columns: minmax(0, .8fr) minmax(0, 1.4fr); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 13px; line-height: 1.55; }
.steps .n { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 600;
  color: var(--accent-text); background: var(--accent-tint); box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--accent) 30%, transparent); }
.kv { display: grid; gap: 8px; margin-top: 14px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.kv .mono { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-glyph { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 16%, transparent), color-mix(in srgb, var(--accent) 6%, transparent));
  color: var(--accent); box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--accent) 25%, transparent); }
.key-glyph svg { width: 16px; height: 16px; }
.key-glyph.off { background: var(--fill-2); color: var(--text-3); box-shadow: none; }
@media (max-width: 1080px) { .g-connect { grid-template-columns: minmax(0, 1fr); } }

/* ---------- login card ---------- */
.auth-side { overflow: hidden; isolation: isolate; }
.auth-side::before, .auth-side::after { content: ""; position: absolute; border-radius: 50%; filter: blur(70px); z-index: -1; pointer-events: none; }
.auth-side::before { width: 420px; height: 420px; right: -120px; top: -120px; background: radial-gradient(circle, rgba(120, 150, 255, .35), transparent 70%); }
.auth-side::after { width: 380px; height: 380px; left: -140px; bottom: -140px; background: radial-gradient(circle, rgba(190, 140, 255, .25), transparent 70%); }
.auth-card {
  width: min(380px, 100%); padding: 32px 30px 22px; border-radius: 24px;
  background: color-mix(in srgb, var(--card-solid) 72%, transparent);
  backdrop-filter: blur(28px) saturate(170%); -webkit-backdrop-filter: blur(28px) saturate(170%);
  box-shadow: inset 0 1px 0 var(--card-hi), 0 0 0 0.5px var(--card-edge), 0 30px 60px -24px rgba(15, 23, 42, .28), 0 12px 24px -12px rgba(15, 23, 42, .12);
  animation: enter .6s cubic-bezier(.2, .8, .2, 1) both;
}
.auth-card .auth-form { width: 100%; }
.auth-card .crest { display: grid; justify-items: center; gap: 12px; margin-bottom: 24px; text-align: center; }
.auth-card .crest .mark { width: 46px; height: 46px; border-radius: 13px; box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 0 0 0.5px rgba(0,0,0,.1), 0 10px 26px -8px rgba(60, 100, 255, .65); }
.auth-card .crest .mark svg { width: 23px; height: 23px; }
.auth-card .hello { text-align: center; }
.auth-card .hello-sub { text-align: center; margin: 3px 0 0; }
.auth-card .card-foot { margin-top: 18px; padding-top: 14px; border-top: 0.5px solid var(--sep); text-align: center; font-size: 11.5px; color: var(--text-3); }
.auth-card .input-wrap .input { background: color-mix(in srgb, var(--card-solid) 80%, transparent); }
.auth-mobile-brand, .auth-note { display: none !important; }
.grid:has(> .stat), .grid.g-connect { align-items: stretch; }
.auth-form .err:empty { display: none; }

/* ---------- dashboard pages fill the window height ---------- */
.page.dash { display: flex; flex-direction: column; min-height: calc(100vh - 22px - 28px); }
.page.dash > .grid.g-main { flex: 1.5 1 auto; min-height: 380px; }
.page.dash > .grid.g3:last-child { flex: 1 1 auto; min-height: 260px; align-items: stretch; }
.page.dash > .grid > .card { display: flex; flex-direction: column; min-height: 0; }
.page.dash > .grid > .card > .rows, .page.dash > .grid > .card > .scroll-y { flex: 1 1 0; min-height: 0; overflow-y: auto; }
.page.dash > .card.fill { flex: 1 1 auto; min-height: 300px; }
.page.dash .rows::-webkit-scrollbar, .page.dash .scroll-y::-webkit-scrollbar { width: 8px; }
.page.dash .rows::-webkit-scrollbar-thumb, .page.dash .scroll-y::-webkit-scrollbar-thumb { background: transparent; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
.page.dash .rows:hover::-webkit-scrollbar-thumb, .page.dash .scroll-y:hover::-webkit-scrollbar-thumb { background-color: var(--fill-hover); }
@media (max-width: 760px) { .page.dash { min-height: 0; } }
.chart > svg { position: absolute; inset: 0; }

/* cache page */
.advice { margin-top: 16px; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); }
.advice.green { background: var(--green-tint); color: var(--text); }
.page.dash > .grid.g-main:last-child, .page.dash > .card.flush:last-child { flex: 1 1 auto; }

/* ---------- usage log ---------- */
:root {
  --tk-read: #2a78d6; --tk-fresh: #eb6834; --tk-write: #1baf7a; --tk-out: #eda100;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --tk-read: #3987e5; --tk-fresh: #d95926; --tk-write: #199e70; --tk-out: #c98500; }
}
:root[data-theme="dark"] { --tk-read: #3987e5; --tk-fresh: #d95926; --tk-write: #199e70; --tk-out: #c98500; }
.tk-read { background: var(--tk-read); } .tk-fresh { background: var(--tk-fresh); }
.tk-write { background: var(--tk-write); } .tk-out { background: var(--tk-out); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; }
.toolbar .spacer { flex: 1; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 0; }
.strip .cell { padding: 14px 18px; position: relative; min-width: 0; }
.strip .cell + .cell::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 0.5px; background: var(--sep); }
.strip .v { font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: -0.02em; margin: 3px 0 1px; }
.sub { font-size: 11.5px; color: var(--text-3); }
.strong { font-weight: 500; }

.t.usage td { vertical-align: middle; padding-top: 9px; padding-bottom: 9px; }
.t.usage .t-time { color: var(--text-2); width: 64px; }
.t.usage .t-tok { width: 190px; }
.log .u-row { cursor: pointer; }
.who { display: flex; align-items: center; gap: 9px; }
.tok { display: flex; align-items: center; gap: 10px; }
.tok .num { font-size: 12px; color: var(--text-2); min-width: 44px; }
.tokbar { display: flex; gap: 2px; width: 120px; height: 6px; border-radius: 999px; overflow: hidden; background: var(--fill-2); }
.tokbar i { display: block; height: 100%; min-width: 2px; }
.tokbar i:first-child { border-radius: 999px 0 0 999px; } .tokbar i:last-child { border-radius: 0 999px 999px 0; }
.tokbar i:only-child { border-radius: 999px; }
.tokbar.big { width: 100%; height: 10px; margin: 10px 0 4px; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.t.usage tr.day td { background: none !important; padding: 16px 20px 6px; border-top: 0; }
.t.usage tr.day div { display: flex; align-items: baseline; gap: 10px; font-size: 12px; }
.t.usage tr.day + tr td { border-top: 0.5px solid var(--sep); }
.t.usage tbody tr.day:first-child td { padding-top: 8px; }
.end { padding: 16px; text-align: center; font-size: 11.5px; min-height: 1px; }
.sk-rows { padding: 6px 20px 14px; }
.sk-row { display: grid; grid-template-columns: 60px 1.2fr 1fr 1fr; gap: 24px; padding: 12px 0; }
.sk-row .skeleton { height: 12px; }

/* drawer */
.drawer-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .18); animation: fade .18s ease; }
.drawer {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(400px, calc(100vw - 24px)); overflow-y: auto;
  border-radius: 20px; padding: 18px 20px 16px;
  background: color-mix(in srgb, var(--card-solid) 88%, transparent);
  backdrop-filter: blur(30px) saturate(170%); -webkit-backdrop-filter: blur(30px) saturate(170%);
  box-shadow: inset 0 1px 0 var(--card-hi), var(--shadow-pop);
  animation: slidein .26s cubic-bezier(.2, .9, .3, 1);
}
.drawer.leaving { animation: slideout .18s ease forwards; }
.drawer-scrim.leaving { animation: fadeout .18s ease forwards; }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }
@keyframes slideout { to { transform: translateX(24px); opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }
.dr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dr-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.dr-hero { display: flex; align-items: flex-end; justify-content: space-between; margin: 18px 0 4px; padding: 14px 16px; border-radius: 14px;
  background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); }
.dr-cost { font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.dr-sec { padding: 14px 0; border-bottom: 0.5px solid var(--sep); }
.dr-sec:last-of-type { border-bottom: 0; }
.dr-row { display: flex; justify-content: space-between; align-items: baseline; }
.dr-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 9px; }
.dr-list li { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.dr-list .key { color: var(--text-2); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.dr-list .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.note { font-size: 11.5px; color: var(--text-3); margin-top: 8px; }
.dr-foot { font-size: 11px; text-align: center; margin: 10px 0 0; }
.drawer .secret { font-size: 11.5px; }

@media (max-width: 1080px) { .strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } .strip .cell:nth-child(4)::before { display: none; } }
@media (max-width: 760px) { .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } .legend { display: none; } }
.btn:focus { outline: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-tint), 0 0 0 1px var(--accent); }
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar .seg { order: 3; width: 100%; }
  .topbar .seg button { flex: 1; }
  .toolbar .seg { flex: 1 1 auto; }
  .t.usage .t-tok { width: auto; }
  .tokbar { width: 72px; }
}
@media (max-width: 760px) {
  .t.usage th:nth-child(4), .t.usage td:nth-child(4), .t.usage th:nth-child(6), .t.usage td:nth-child(6) { display: none; }
  .t.usage th, .t.usage td { padding-left: 10px; padding-right: 10px; }
  .t.usage .t-time { width: auto; }
  .who .avatar { display: none; }
}
@media (max-width: 1080px) { .strip .cell::before { display: none; } .strip .cell { border-top: 0.5px solid var(--sep); } .strip .cell:nth-child(-n+3) { border-top: 0; } }
@media (max-width: 760px) { .strip .cell:nth-child(3) { border-top: 0.5px solid var(--sep); } }

/* ---------- phone navigation: top bar + slide-in sidebar ---------- */
.mbar, .nav-scrim { display: none; }
@media (max-width: 760px) {
  body.app { overflow-x: hidden; }
  body.app .shell { display: block; }
  .mbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
    height: 52px; padding: 0 12px 0 6px;
    background: color-mix(in srgb, var(--card-solid) 70%, transparent);
    backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid var(--sep);
  }
  .mbar .mark { width: 24px; height: 24px; border-radius: 7px; }
  .mbar .mark svg { width: 14px; height: 14px; }
  .mbar-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
  .mbar-menu { width: 40px; height: 40px; border: 0; background: none; border-radius: 10px; display: grid; place-items: center; color: var(--text); cursor: pointer; }
  .mbar-menu:active { background: var(--fill-2); }
  .mbar-menu svg { width: 21px; height: 21px; }

  /* the sidebar becomes a panel that slides in from the left */
  body.app .sidebar {
    position: fixed; z-index: 60; top: 0; left: 0; bottom: 0; width: min(290px, 84vw); height: 100dvh;
    display: flex; flex-direction: column; align-items: stretch; gap: 2px; overflow-x: hidden; overflow-y: auto;
    padding: max(18px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
    border-right: 0; border-bottom: 0;
    background: color-mix(in srgb, var(--card-solid) 92%, transparent);
    backdrop-filter: blur(30px) saturate(170%); -webkit-backdrop-filter: blur(30px) saturate(170%);
    box-shadow: var(--shadow-pop);
    transform: translateX(-105%); transition: transform .28s cubic-bezier(.2, .9, .3, 1);
  }
  body.nav-open .sidebar { transform: none; }
  body.app .sidebar .brand { padding: 4px 10px 18px; }
  body.app .sidebar .brand small, body.app .sidebar .nav-gap, body.app .sidebar .me-chip .who { display: revert; }
  body.app .sidebar .nav-gap { display: block; flex: 1; }
  body.app .sidebar .nav-item { width: 100%; flex: none; padding: 10px 12px; font-size: 14px; }
  body.app .sidebar .nav-item span { display: inline; }
  body.app .sidebar .me-chip { width: 100%; margin-left: 0; }
  body.app .sidebar .me-chip .who { display: block; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .3); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }

  body.app .main { padding: 14px 16px 32px; max-width: 100vw; overflow-x: clip; }
  .topbar h1 { font-size: 17px; }
}
@media (max-width: 760px) and (prefers-reduced-motion: reduce) { body.app .sidebar { transition: none; } }
@media (max-width: 760px) { .strip .cell:nth-child(5) { grid-column: 1 / -1; } }
@media (max-width: 760px) {
  /* members: name row on top, budget bar full width beneath */
  .m-row { flex-wrap: wrap; row-gap: 8px; }
  .m-row .m-name { flex: 1 1 0 !important; min-width: 0; }
  .m-row .m-keys { display: none; }
  .m-row .m-budget { order: 3; flex: 1 0 100% !important; max-width: none !important; padding-left: 44px; }
  .m-row .m-budget .meta { white-space: normal; }
  .row.inset.m-row + .row.inset.m-row::before { left: 64px; }
  /* overview: two stat cards per row, no sparklines */
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .spark { display: none; }
  .stat .value { font-size: 20px; }
}
@media (max-width: 340px) { .g4 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  /* no fixed height to share on phones: lists grow with their content */
  .page.dash > .grid.g-main, .page.dash > .grid.g3:last-child { min-height: 0; }
  .page.dash > .grid > .card > .rows, .page.dash > .grid > .card > .scroll-y { flex: none; overflow: visible; }
  .page.dash > .card.fill { min-height: 0; }
}

/* ---------- phone bar v2 (iOS-style) & narrower panel ---------- */
.m-dot { display: none; }
.field .tip { position: static; transform: none; padding: 0; background: none; box-shadow: none; font-size: 11.5px; color: var(--text-3); line-height: 1.45; }
@media (max-width: 760px) {
  .mbar {
    display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px;
    height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
    background: transparent; border-bottom: 0.5px solid transparent;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    transition: background .25s, border-color .25s, backdrop-filter .25s;
  }
  .mbar.scrolled {
    background: color-mix(in srgb, var(--card-solid) 72%, transparent);
    backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px);
    border-bottom-color: var(--sep);
  }
  .mbar-btn, .mbar-acct {
    width: 38px; height: 38px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; display: grid; place-items: center;
    color: var(--text);
    background: color-mix(in srgb, var(--card-solid) 70%, transparent);
    backdrop-filter: blur(18px) saturate(170%); -webkit-backdrop-filter: blur(18px) saturate(170%);
    box-shadow: inset 0 1px 0 var(--card-hi), 0 0 0 0.5px var(--card-edge), 0 4px 14px -6px rgba(15, 23, 42, .25);
    transition: transform .12s;
  }
  .mbar-btn:active, .mbar-acct:active { transform: scale(.94); }
  .mbar-btn svg { width: 19px; height: 19px; }
  .mbar-acct { justify-self: end; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .mbar-acct .avatar { width: 34px; height: 34px; font-size: 13px; box-shadow: 0 0 0 2px var(--card-solid), 0 4px 12px -4px rgba(0,0,0,.35); }
  .mbar-title {
    text-align: center; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s;
  }
  .mbar.scrolled .mbar-title { opacity: 1; transform: none; }
  .mbar .mark, .mbar-menu .mark { display: none; }

  body.app .main { padding-top: 4px; }
  .topbar { margin-bottom: 14px; }
  .topbar h1 { font-size: 22px; letter-spacing: -0.02em; }

  body.app .sidebar { width: min(248px, 72vw); padding-left: 10px; padding-right: 10px; }
  body.app .sidebar .nav-item { padding: 9px 11px; font-size: 13.5px; }

  /* usage rows: status dot before the time instead of a result column */
  .t.usage th:nth-child(7), .t.usage td:nth-child(7) { display: none; }
  .m-dot { display: inline-block; width: 6px; height: 6px; margin-right: 7px; vertical-align: middle; }
  .t.usage .t-time { white-space: nowrap; }
}
@media (max-width: 760px) { .t.usage th:nth-child(5), .t.usage td:nth-child(5) { padding-right: 18px; } }

/* ---------- calmer page titles; day bands in the usage log ---------- */
.topbar h1 { color: color-mix(in srgb, var(--text) 86%, transparent); }
@media (max-width: 760px) {
  .topbar h1 { font-size: 17px; letter-spacing: -0.01em; }
}
.t.usage tr.day td {
  padding: 7px 20px !important; border-top: 0.5px solid var(--sep) !important;
  background: color-mix(in srgb, var(--fill-2) 55%, transparent) !important;
}
.t.usage tbody tr.day:first-child td { border-top: 0 !important; }
.t.usage tr.day div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 11.5px; }
.t.usage tr.day .strong { font-weight: 600; color: var(--text-2); letter-spacing: .02em; }
.t.usage tr.day .faint { color: var(--text-3); }
.t.usage tr.day + tr td { border-top: 0 !important; }
@media (max-width: 760px) {
  .t.usage tr.day td { padding: 7px 18px 7px 10px !important; }
}

/* ---------- forms: fields align to the top; upstream test panel ---------- */
.field { align-content: start; }
.row-fields { margin-top: 14px; align-items: start; }
.form-tip { display: block; margin-top: 6px; }
.sheet.wide { width: min(520px, 100%); }
.probe-field { margin-top: 18px; padding-top: 16px; border-top: 0.5px solid var(--sep); }
.probe-bar { display: flex; gap: 8px; }
.probe-bar .input { flex: 1; min-width: 0; }
.probe-out { margin-top: 10px; }
.probe-note { font-size: 11.5px; margin: 2px 2px 0; }
.probe-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.probe-steps li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); }
.probe-ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; margin-top: 1px; color: #fff; background: var(--text-3); }
.probe-ic svg { width: 12px; height: 12px; stroke-width: 2.4; }
.probe-steps li.ok .probe-ic { background: #34c759; }
.probe-steps li.bad .probe-ic { background: #ff3b30; }
.probe-name { font-weight: 500; font-size: 12.5px; }
.probe-detail { font-size: 12px; color: var(--text-2); margin-top: 2px; word-break: break-word; }
.probe-reply { margin-top: 6px; display: inline-block; padding: 4px 10px; border-radius: 10px 10px 10px 3px; background: var(--card-solid); font-size: 12px; box-shadow: 0 0 0 0.5px var(--card-edge); }
.probe-hint { margin-top: 10px; padding: 9px 12px; border-radius: 12px; font-size: 12px; background: var(--orange-tint); }
.probe-hint.bad { background: var(--red-tint); }
.probe-models { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11.5px; max-height: 120px; overflow-y: auto; }
.chip { height: 24px; padding: 0 10px; border-radius: 999px; border: 0; cursor: pointer; font-size: 11.5px; font-family: var(--mono);
  background: var(--fill-2); color: var(--text-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); }
.chip:hover { background: var(--fill); color: var(--text); }
.chip.on { background: var(--accent-tint); color: var(--accent-text); }
.spin.dark { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--fill-hover); border-top-color: var(--text-2); animation: spin .7s linear infinite; }
@media (max-width: 760px) { .row-fields { grid-template-columns: 1fr 96px; } }
.form-tip, .tip { font-size: 11.5px; color: var(--text-3); line-height: 1.45; font-weight: 400; }

/* ---------- context menu v2: frosted, label left / glyph right (iOS) ---------- */
.menu {
  min-width: 184px; padding: 5px; border-radius: 14px;
  background: color-mix(in srgb, var(--card-solid) 92%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.06), 0 0 0 0.5px var(--sep);
  animation: menu-in .16s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes menu-in { from { opacity: 0; transform: scale(.94); } }
.menu button {
  justify-content: space-between; gap: 18px; padding: 8px 10px 8px 12px; border-radius: 9px;
  font-size: 13.5px; color: var(--text); letter-spacing: -0.005em;
}
.menu button svg { width: 16px; height: 16px; flex: none; color: var(--text-2); stroke-width: 1.7; }
.menu button:hover, .menu button:focus-visible { background: var(--fill); color: var(--text); outline: none; }
.menu button.danger, .menu button.danger svg { color: var(--red); }
.menu button.danger:hover, .menu button.danger:focus-visible { background: color-mix(in srgb, var(--red) 11%, transparent); color: var(--red); }
.menu hr { height: 0; border: 0; border-top: 0.5px solid var(--sep); margin: 5px 10px; }
@media (max-width: 720px) {
  .menu { min-width: 208px; }
  .menu button { padding: 11px 12px 11px 14px; font-size: 15px; }
  .menu button svg { width: 18px; height: 18px; }
  .row [data-test] { display: none; } /* 测试 lives in the ··· menu on phones */
}

/* ---------- scrollbars: thin, light, inset — everywhere ---------- */
:root { --sb: rgba(0, 0, 0, 0.16); --sb-hover: rgba(0, 0, 0, 0.32); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sb: rgba(255, 255, 255, 0.16); --sb-hover: rgba(255, 255, 255, 0.32); } }
:root[data-theme="dark"] { --sb: rgba(255, 255, 255, 0.16); --sb-hover: rgba(255, 255, 255, 0.32); }
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background-color: var(--sb); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; min-height: 32px; }
::-webkit-scrollbar-thumb:hover { background-color: var(--sb-hover); }
/* the page scroller stays out of the way until you're over it */
body.app .main::-webkit-scrollbar-thumb, .page.dash .rows::-webkit-scrollbar-thumb, .page.dash .scroll-y::-webkit-scrollbar-thumb { background-color: transparent; }
body.app .main:hover::-webkit-scrollbar-thumb, .page.dash .rows:hover::-webkit-scrollbar-thumb, .page.dash .scroll-y:hover::-webkit-scrollbar-thumb { background-color: var(--sb); }
body.app .main::-webkit-scrollbar-thumb:hover, .page.dash .rows::-webkit-scrollbar-thumb:hover, .page.dash .scroll-y::-webkit-scrollbar-thumb:hover { background-color: var(--sb-hover); }
@supports (-moz-appearance: none) { * { scrollbar-width: thin; scrollbar-color: var(--sb) transparent; } }

/* ---------- model picker ---------- */
.combo { position: relative; flex: 1; min-width: 0; display: flex; }
.combo .input { flex: 1; min-width: 0; padding-right: 34px; }
.combo-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.combo-btn:hover { background: var(--fill); color: var(--text); }
.combo-btn svg { width: 16px; height: 16px; }
.combo .input[aria-expanded="true"] + .combo-btn svg { transform: rotate(180deg); }

.picker {
  position: fixed; z-index: 80; padding: 5px; border-radius: 14px;
  background: color-mix(in srgb, var(--card-solid) 94%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.06), 0 0 0 0.5px var(--sep);
  animation: menu-in .14s cubic-bezier(.2, .9, .3, 1.15); transform-origin: top center;
}
.picker.up { transform-origin: bottom center; }
.pick-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px 7px; font-size: 11.5px; color: var(--text-2); border-bottom: 0.5px solid var(--sep); margin-bottom: 4px; }
.pick-count { font-weight: 500; color: var(--text); }
.pick-list { overflow-y: auto; overscroll-behavior: contain; }
.pick-sec { padding: 8px 10px 4px; font-size: 11px; color: var(--text-3); }
.pick-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left; font-size: 12.5px; color: var(--text); }
.pick-row .pick-id { overflow: hidden; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.pick-row svg { width: 15px; height: 15px; flex: none; color: var(--accent); stroke-width: 2.2; }
.pick-row:hover, .pick-row.active { background: var(--fill); }
.pick-row.dim { color: var(--text-3); }
.pick-row[aria-selected="true"] { font-weight: 500; }
.pick-empty { padding: 12px 10px; font-size: 12px; color: var(--text-2); }

.probe-steps li { align-items: center; }
.probe-steps li .probe-ic { align-self: flex-start; margin-top: 1px; }
.probe-link { flex: none; display: inline-flex; align-items: center; gap: 2px; height: 26px; padding: 0 6px 0 10px; border: 0; border-radius: 999px; background: var(--card-solid); box-shadow: 0 0 0 0.5px var(--card-edge); color: var(--accent-text, var(--accent)); font-size: 12px; cursor: pointer; }
.probe-link:hover { background: var(--fill); }
.probe-link svg { width: 14px; height: 14px; transform: rotate(-90deg); }
@media (max-width: 720px) {
  .pick-row { padding: 10px 12px; font-size: 14px; }
}
/* keep the thumb clear of rounded corners */
.sheet::-webkit-scrollbar-track, .picker .pick-list::-webkit-scrollbar-track, .drawer ::-webkit-scrollbar-track { margin-block: 14px; }
.pick-list::-webkit-scrollbar-track { margin-block: 4px; }
.probe-steps li > .grow { flex: 1; min-width: 0; } /* pushes 选择 to the right edge */

/* ---------- sidebar v3: one glyph column, labels on one line ---------- */
/* Every leading glyph (logo, nav icons, avatar) sits in the same 26px column,
   so their centres and the labels after them line up top to bottom. */
.brand { gap: 10px; padding: 4px 8px 20px; font-size: 15px; }
.brand small { font-size: 12px; }
.nav-item { gap: 10px; min-height: 36px; padding: 0 8px; border-radius: 10px; font-size: 13.5px; }
.nav-item svg { width: 18px; height: 18px; margin: 0 4px; }
.me-chip { gap: 10px; padding: 7px 8px; border-radius: 12px; }
.nav-gap { flex: 1; min-height: 16px; margin: 0 8px 8px; border-bottom: 0.5px solid var(--sep); }

@media (min-width: 761px) {
  /* a floating panel inset from the window edge, like the macOS sidebar */
  body.app .shell { grid-template-columns: 236px minmax(0, 1fr); }
  body.app .sidebar {
    margin: 10px 0 10px 10px; height: calc(100vh - 20px); padding: 16px 10px 10px;
    border-right: 0; border-radius: 18px;
    background: color-mix(in srgb, var(--card-solid) 58%, transparent);
    box-shadow: 0 0 0 0.5px var(--card-edge), 0 8px 30px -12px rgba(15, 23, 42, 0.12);
  }
  body.app .main { padding-left: 28px; }
}
@media (max-width: 760px) {
  body.app .sidebar { border-radius: 0 20px 20px 0; padding-left: 10px; padding-right: 10px; }
  body.app .sidebar .brand { padding: 4px 8px 20px; }
  body.app .sidebar .nav-item { padding: 0 8px; min-height: 42px; font-size: 14px; }
  body.app .sidebar .me-chip { padding: 8px; }
}

/* ======================= billing ======================= */
/* balance figure */
.bal { font-weight: 600; font-size: 13px; color: var(--text); }
.bal.low { color: var(--orange); }
.bal.neg { color: var(--red); }
.bal.unl { font-weight: 500; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--fill-2); color: var(--text-2); }
.stat .value.neg, .wh-bal.neg { color: var(--red); }

/* members: balance column */
.m-budget { width: 190px; flex: none; text-align: right; }
.m-bal { margin-bottom: 3px; }
@media (max-width: 760px) { .m-row .m-budget { text-align: left; width: auto; } }

/* small switch rows inside forms */
.switch-row { display: flex !important; align-items: center; justify-content: space-between; gap: 16px; margin-top: 14px; }
.switch-row label { margin: 0; }
.switch-row .tip { display: block; margin-top: 2px; }
.form-err { margin: 8px 2px 0; font-size: 12px; color: var(--red); }
.row-fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .row-fields.three { grid-template-columns: 1fr 1fr 1fr; } }
.sheet-scroll { max-height: min(56vh, 520px); overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.sheet .actions.center { justify-content: center; }

/* redeem sheet */
.sheet.redeem { text-align: center; }
.sheet.redeem .lead { max-width: 300px; margin-left: auto; margin-right: auto; }
.sheet.redeem .actions { justify-content: center; }
.redeem-ic { width: 52px; height: 52px; margin: 2px auto 12px; border-radius: 16px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, #ffb340, #ff7a1a); box-shadow: 0 8px 20px -8px rgba(255, 122, 26, .7), inset 0 1px 0 rgba(255,255,255,.35); }
.redeem-ic svg { width: 26px; height: 26px; }
.code-input { text-align: center; font-size: 17px !important; letter-spacing: 0.06em; height: 50px; }
.redeem-done { padding: 8px 0 0; }
.redeem-check { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: #34c759; box-shadow: 0 10px 24px -10px rgba(52, 199, 89, .9); animation: pop .3s cubic-bezier(.2, .9, .3, 1.4); }
.redeem-check svg { width: 28px; height: 28px; stroke-width: 2.4; }
.redeem-amt { font-family: var(--display); font-size: 34px; font-weight: 600; letter-spacing: -0.03em; color: var(--green); margin-bottom: 4px; }

/* member home: balance card */
.bal-card { position: relative; }
.bal-redeem { position: absolute; top: 14px; right: 14px; }
.bal-card .foot a { color: var(--accent-text); }

/* member 余额 page */
.wallet-hero { display: flex; align-items: stretch; gap: 24px; padding: 22px 24px; overflow: hidden; position: relative; }
.wallet-hero::before { content: ""; position: absolute; inset: -40% -10% auto auto; width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%); pointer-events: none; }
.wh-main { flex: 1; min-width: 0; position: relative; }
.wh-main .label { font-size: 12px; color: var(--text-2); }
.wh-bal { font-family: var(--display); font-size: 40px; font-weight: 600; letter-spacing: -0.035em; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.wh-sub { font-size: 12.5px; color: var(--text-2); }
.wh-sub b { color: var(--text); font-weight: 600; }
.wh-side { display: flex; flex-direction: column; justify-content: center; gap: 8px; min-width: 190px; position: relative; padding-left: 24px; border-left: 0.5px solid var(--sep); }
.wh-kv { display: flex; justify-content: space-between; gap: 16px; font-size: 12.5px; color: var(--text-2); }
.wh-kv b { color: var(--text); font-weight: 600; }
.wh-side .btn { margin-top: 6px; justify-content: center; }
@media (max-width: 760px) {
  .wallet-hero { flex-direction: column; gap: 16px; padding: 18px; }
  .wh-bal { font-size: 34px; }
  .wh-side { padding-left: 0; border-left: 0; padding-top: 14px; border-top: 0.5px solid var(--sep); }
}

/* statement: the date in a rail on the left, that day's items beside it */
.stmt-day { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 10px 20px; }
.stmt-day + .stmt-day { border-top: 0.5px solid var(--sep); }
.stmt-date { padding-top: 7px; display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
.stmt-date b { font-size: 12.5px; font-weight: 600; color: var(--text); }
.stmt-date span { font-size: 11px; color: var(--text-3); }
.stmt-items { list-style: none; margin: 0; padding: 0; }
.stmt-item { display: flex; align-items: center; gap: 10px; padding: 5px 0; min-width: 0; }
.stmt-item + .stmt-item { border-top: 0.5px solid color-mix(in srgb, var(--sep) 60%, transparent); }
.stmt-item .grow { flex: 1; min-width: 0; }
.stmt-item .title { font-size: 13px; font-weight: 500; }
.stmt-item .meta { color: var(--text-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stmt-ic { width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--fill-2); color: var(--text-2); }
.stmt-ic svg { width: 14px; height: 14px; }
.stmt-ic.grant { background: var(--accent-tint); color: var(--accent-text); }
.stmt-ic.redeem { background: var(--orange-tint); color: var(--orange); }
.stmt-ic.adjust { background: var(--fill); color: var(--text); }
.stmt-amt { font-weight: 600; font-size: 13.5px; }
.stmt-amt.pos { color: var(--green); }
.stmt-amt.muted { color: var(--text-2); font-weight: 500; }
.stmt-item .right { text-align: right; flex: none; }
.sheet .stmt-day { padding-left: 0; padding-right: 0; }
@media (max-width: 520px) { .stmt-day { grid-template-columns: 58px minmax(0, 1fr); gap: 10px; } }

/* admin › member statement: name, summary, daily strip */
.ledger-who { display: inline-flex; align-items: center; gap: 9px; }
.sheet.ledger .sheet-head .lead { margin-bottom: 12px; }
.lsum { border-radius: 14px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--sep); padding: 14px 16px 12px; margin-bottom: 6px; }
.lsum-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lsum-stats > div { padding: 0 14px; min-width: 0; }
.lsum-stats > div:first-child { padding-left: 0; }
.lsum-stats > div + div { border-left: 0.5px solid var(--sep); }
.lsum .k { font-size: 11.5px; color: var(--text-3); }
.lsum .v { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lsum .s { font-size: 11px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lsum-chart { margin-top: 14px; padding-top: 12px; border-top: 0.5px solid var(--sep); }
.lsum-cap { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--text-3); margin-bottom: 8px; }
.lsum-tip.live { color: var(--text); font-weight: 500; }
.lsum-bars { display: flex; align-items: flex-end; gap: 2px; height: 44px; }
.lsum-bars > span { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; position: relative; }
.lsum-bars > span::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 1px; background: var(--fill); }
.lsum-bars > span i { display: block; width: 100%; border-radius: 3px 3px 1px 1px; background: var(--accent); opacity: .85; position: relative; z-index: 1; transition: opacity .12s; }
.lsum-bars:hover > span i { opacity: .35; }
.lsum-bars > span.hover i { opacity: 1; }
.lsum-bars > span.hover::after { background: var(--text-3); }
.lsum-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-3); margin-top: 5px; }
@media (max-width: 520px) {
  .lsum-stats > div { padding: 0 10px; }
  .lsum .v { font-size: 16px; }
}

/* 价格 groups */
.pg-grid { align-items: stretch; }
.pg-card { display: flex; flex-direction: column; gap: 10px; }
.pg-head { display: flex; align-items: center; gap: 8px; margin: -4px -6px -2px 0; }
.pg-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.pg-price { display: flex; gap: 22px; }
.pg-price span { display: flex; flex-direction: column; font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.pg-price small { font-family: var(--font); font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-bottom: 2px; }
.pg-cache { font-size: 11.5px; color: var(--text-3); }
.pg-models { display: flex; flex-wrap: wrap; gap: 6px; }
.pg-foot { font-size: 11.5px; margin-top: auto; padding-top: 2px; }
.chip-s { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 7px; font-size: 12px;
  background: var(--fill-2); color: var(--text); border: 0; font-family: inherit; }
.chip-s.glob { background: var(--accent-tint); color: var(--accent-text); }
button.chip-s { cursor: pointer; }
button.chip-s:hover { background: var(--fill); }
.chip-s b { font-weight: 500; font-size: 10.5px; color: var(--orange); }
.unpriced { box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--orange) 35%, transparent), var(--shadow); }
.unpriced .card-head h2 { display: flex; align-items: center; gap: 8px; }
.up-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips-edit { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips-edit:empty { display: none; }
.chip-x { display: inline-flex; align-items: center; gap: 2px; height: 26px; padding: 0 3px 0 10px; border-radius: 8px; font-size: 12px; background: var(--fill-2); }
.chip-x.glob { background: var(--accent-tint); color: var(--accent-text); }
.chip-x button { width: 20px; height: 20px; border: 0; border-radius: 6px; background: none; color: inherit; opacity: .55; display: grid; place-items: center; cursor: pointer; }
.chip-x button:hover { opacity: 1; background: var(--fill); }
.chip-x svg { width: 12px; height: 12px; stroke-width: 2.2; }

/* 兑换码 */
.rb-row { cursor: pointer; gap: 14px; }
.rb-row:hover { background: var(--fill-2); }
.rb-ic { width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--orange-tint); color: var(--orange); }
.rb-ic svg { width: 18px; height: 18px; }
.rb-prog { width: 150px; flex: none; }
.rb-prog .meta { margin-bottom: 5px; }
.codes-box { max-height: 300px; overflow-y: auto; padding: 12px 14px; border-radius: 12px; background: var(--fill-2); font-size: 13px; line-height: 1.9;
  column-width: 200px; column-gap: 24px; user-select: all; }
.code-tail { font-size: 12.5px; color: var(--text-2); }
@media (max-width: 760px) {
  .rb-row { flex-wrap: wrap; }
  .rb-prog { order: 5; width: auto; flex: 1 0 100%; padding-left: 48px; }
}
.pg-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pg-head .btn { margin-left: auto; }
.code-wrap { display: flex; align-items: center; height: 50px; padding: 0 14px; border-radius: 12px; background: var(--fill-2);
  box-shadow: inset 0 0 0 0.5px var(--card-edge); cursor: text; justify-content: center; }
.code-wrap:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-tint); background: var(--card-solid); }
.code-pre { font-size: 17px; letter-spacing: 0.06em; color: var(--text-3); flex: none; }
.code-wrap .code-input { border: 0; outline: 0; background: none; height: 100%; width: 13.5ch; padding: 0; text-align: left; color: var(--text); }
.stmt-more { display: block; width: 100%; padding: 14px; border: 0; border-top: 0.5px solid var(--sep); background: none; color: var(--accent-text); font-size: 12.5px; cursor: pointer; }
.stmt-more:hover { background: var(--fill-2); }
/* 价格: per-model tables inside outer groups */
.pg-card .card-head .btn.sm { margin-left: 6px; }
.pg-table td { padding-top: 11px; padding-bottom: 11px; }
.pg-model { font-size: 13px; font-weight: 500; }
.pg-model.glob { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--accent-tint); color: var(--accent-text); font-weight: 500; }
.pg-cover { margin-left: 8px; font-size: 11px; color: var(--text-3); }
.pg-table .r { text-align: right; }
.pg-table td.muted { color: var(--text-3); }
.pg-table td.strong { font-weight: 600; }
.seg.wrap { flex-wrap: wrap; height: auto; }
/* every group's table shares one grid so columns line up card to card */
.pg-table { table-layout: fixed; min-width: 760px; }
.pg-table col.pg-num { width: 112px; }
.pg-table col.pg-act { width: 60px; }
.pg-table td:first-child { overflow: hidden; text-overflow: ellipsis; }
/* 开放的模型 */
.mp { margin-top: 10px; border-radius: 12px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); overflow: hidden; }
.mp-bar { display: flex; gap: 6px; align-items: center; padding: 8px; border-bottom: 0.5px solid var(--sep); }
.mp-bar .input { flex: 1; min-width: 0; height: 32px; background: var(--card-solid); }
.mp-list { max-height: 240px; overflow-y: auto; padding: 4px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 4px; }
.mp-row { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px; font-size: 12.5px; cursor: pointer; min-width: 0; }
.mp-row:hover { background: var(--fill); }
.mp-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; }
.mp-empty { grid-column: 1 / -1; padding: 18px 10px; text-align: center; font-size: 12px; color: var(--text-3); }
.mp + .tip, .seg + .mp + .tip { display: block; margin-top: 6px; }
/* drawer scrolls itself: keep its scrollbar off the rounded corners and out of sight until hovered */
.drawer { scrollbar-gutter: stable; padding-right: 14px; }
.drawer::-webkit-scrollbar-track { margin-block: 22px; }
.drawer::-webkit-scrollbar-thumb { background-color: transparent; }
.drawer:hover::-webkit-scrollbar-thumb { background-color: var(--sb); }
.drawer::-webkit-scrollbar-thumb:hover { background-color: var(--sb-hover); }
.dr-list li > span:last-child { text-align: right; min-width: 0; }
.dr-list li { align-items: center; min-height: 20px; }
.price-tag { display: inline-flex; align-items: center; gap: 6px; }
.price-tag i { font-style: normal; font-size: 10.5px; font-weight: 500; line-height: 1; padding: 3px 6px; border-radius: 5px; background: var(--fill); color: var(--text-2); }

/* ---------- calm switching: the old view stays until the new one is ready ---------- */
#page { transition: opacity .2s ease; }
#page.leaving { opacity: .55; }
.log, .strip { transition: opacity .15s ease; }
.log.stale, .strip.stale { opacity: .5; transition: opacity .2s ease .15s; } /* dims only if it takes a moment */

/* ---------- dropdown (replaces native <select>) ---------- */
.dd {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; max-width: 220px; padding: 0 8px 0 11px;
  border: 0; border-radius: 8px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--sep);
  color: var(--text); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.dd:hover { background: var(--fill); }
.dd:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-tint); }
.dd[aria-expanded="true"] { background: var(--card-solid); box-shadow: inset 0 0 0 0.5px var(--card-edge), 0 1px 2px rgba(0,0,0,.06); }
.dd-v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd svg { width: 14px; height: 14px; flex: none; color: var(--text-3); stroke-width: 2; transition: transform .18s ease; }
.dd[aria-expanded="true"] svg { transform: rotate(180deg); }
.dd-pop { max-width: 300px; }
.dd-pop .dd-q { height: 30px; font-size: 12.5px; margin-bottom: 4px; }
.dd-pop .pick-row { padding: 6px 10px 6px 8px; font-size: 13px; }
.dd-face { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.dd-face > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar.xs { width: 20px; height: 20px; font-size: 9.5px; }
@media (max-width: 720px) {
  .dd { height: 34px; font-size: 14px; }
  .dd-pop .pick-row { padding: 10px 12px 10px 10px; font-size: 15px; }
}

/* ---------- unlimited balance: a quiet label, not a big number ---------- */
.stat .value.unl { font-family: var(--font); font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--text-2); margin-top: 10px; }
.wh-bal.unl { font-family: var(--font); font-size: 20px; font-weight: 500; letter-spacing: 0; color: var(--text-2); margin: 8px 0 10px; }

/* ---------- copy feedback ---------- */
.btn.copied, .btn.copied svg { color: var(--green); }

/* ---------- member keys: addresses, model choice, created sheet ---------- */
.addr { display: grid; gap: 6px; }
.addr-row { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 6px 6px 6px 12px; border-radius: 10px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); }
.addr-k { flex: none; width: 88px; font-size: 12px; color: var(--text-2); }
.addr-v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; color: var(--text); user-select: all; }
.addr-row .btn { flex: none; }
.addr-tip { margin-top: 8px; }
.sheet .addr { margin-top: 12px; }
.mp-sec { grid-column: 1 / -1; padding: 8px 8px 3px; font-size: 11px; color: var(--text-3); }
.km-list { grid-template-columns: 1fr; max-height: 260px; }
.km-row .km-id { flex: 1; min-width: 0; }
.km-row .km-price { flex: none; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.made-head { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.made-head .spacer { flex: 1; }
.made-code { margin-top: 8px; font-size: 11.5px; }
@media (max-width: 720px) {
  .addr-row { flex-wrap: wrap; gap: 4px 10px; }
  .addr-k { width: auto; }
  .addr-v { flex-basis: 100%; order: 3; }
  .addr-row .btn { margin-left: auto; }
}
.key-models { font-size: 11.5px; margin-top: 2px; }
.made-code { white-space: pre; overflow-x: auto; }

/* ---------- tables: breathing room after number columns, calmer header ---------- */
/* a right-aligned figure never sits flush against the next column's text */
.t:not(.pg-table) th.r + th:not(.r), .t:not(.pg-table) td.r + td:not(.r) { padding-left: 36px; } /* the price table has its own fixed columns */
.t .act { width: 1%; padding-left: 24px; } /* action buttons take only what they need */
.t thead th { padding-top: 12px; padding-bottom: 10px; border-bottom: 0.5px solid var(--sep); }
.t thead + tbody tr:first-child td { border-top: 0; }
.t.usage tr.day td { background: color-mix(in srgb, var(--fill-2) 32%, transparent) !important; padding-top: 8px !important; padding-bottom: 8px !important; }

/* ---------- usage day rows: total under 花费, count beside the date ---------- */
.t.usage tr.day td { padding: 8px 12px !important; }
.t.usage tr.day td:first-child { padding-left: 20px !important; }
.t.usage tr.day td:last-child { padding-right: 20px !important; }
.t.usage tr.day .day-l { display: flex; justify-content: flex-start; gap: 10px; width: 0; white-space: nowrap; overflow: visible; } /* spills over the empty cells without widening the time column */
.t.usage tr.day .day-cost { font-size: 12px; font-weight: 500; color: var(--text-2); }
@media (max-width: 760px) {
  .t.usage tr.day td, .t.usage tr.day td:first-child, .t.usage tr.day td:last-child { padding-left: 10px !important; padding-right: 10px !important; }
  .t.usage tr.day td:nth-child(5) { padding-right: 18px !important; }
}
/* phones: long device / model names end in "…" so 花费 stays on screen */
@media (max-width: 760px) {
  .t.usage td:nth-child(2) .strong, .t.usage td:nth-child(2) .sub { max-width: 22vw; overflow: hidden; text-overflow: ellipsis; }
  .t.usage td:nth-child(3) .strong, .t.usage td:nth-child(3) .sub { max-width: 26vw; overflow: hidden; text-overflow: ellipsis; }
}

/* Always reserve the scrollbar's room, so switching between a short page and a
   long one doesn't shift or resize the content sideways. */
body.app .main { scrollbar-gutter: stable; }

/* Switching pages: the content slides up into place. It starts half visible
   (never from zero, which would blank the screen for a moment). */
@keyframes slide-up { from { opacity: .5; transform: translateY(14px); } }
#page.switching > * { animation: slide-up .38s cubic-bezier(.2, .8, .2, 1) both; }
#page.switching > * + * { animation-delay: 30ms; }
#page.switching .grid > .card:nth-child(2) { animation: slide-up .38s cubic-bezier(.2, .8, .2, 1) 50ms both; }
#page.switching .grid > .card:nth-child(3) { animation: slide-up .38s cubic-bezier(.2, .8, .2, 1) 80ms both; }
#page.switching .grid > .card:nth-child(4) { animation: slide-up .38s cubic-bezier(.2, .8, .2, 1) 110ms both; }
@media (prefers-reduced-motion: reduce) { #page.switching > *, #page.switching .grid > .card { animation: none !important; } }

/* ---------- sheets: fixed title and buttons, the middle scrolls ---------- */
.sheet { display: flex; flex-direction: column; padding: 0; overflow: hidden; max-height: min(calc(100vh - 32px), 820px); }
/* On phones 100vh is the height with the browser bars hidden, taller than what
   is visible, so a full sheet ran off both ends. dvh follows the real height. */
@supports (height: 100dvh) {
  .sheet { max-height: min(calc(100dvh - 32px), 820px); }
  .scrim { height: 100dvh; }
}
.sheet-head { flex: none; padding: 22px 22px 0; transition: box-shadow .15s; position: relative; z-index: 1; }
.sheet-head .lead { margin-bottom: 14px; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 22px 18px; }
.sheet:not(.has-head) .sheet-body { padding-top: 22px; }
.sheet.has-foot .sheet-body { padding-bottom: 6px; }
.sheet-foot { flex: none; padding: 14px 22px 18px; transition: box-shadow .15s; position: relative; z-index: 1; }
.sheet-foot .actions { margin-top: 0 !important; }
.sheet.body-top .sheet-head { box-shadow: 0 0.5px 0 var(--sep); }
.sheet.body-more .sheet-foot { box-shadow: 0 -0.5px 0 var(--sep); }
.sheet-body::-webkit-scrollbar-track { margin-block: 6px; }
.sheet-body .sheet-scroll { max-height: none; overflow: visible; } /* the body scrolls now; no scroller inside a scroller */
.sheet.zoom { animation: none; }

/* ---------- sign-up page ---------- */
.input-wrap .input.with-code { padding-right: 104px; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.input-wrap .input.with-code::placeholder { letter-spacing: 0; }
.input-wrap .code-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); height: 30px; min-width: 88px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--accent-tint); color: var(--accent-text, var(--accent)); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.input-wrap .code-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.input-wrap .code-btn:disabled { background: var(--fill-2); color: var(--text-3); cursor: default; }
.code-tip { margin-top: 6px; font-size: 11.5px; color: var(--text-3); }
.auth-card .card-foot a { color: var(--accent-text, var(--accent)); font-weight: 500; }
.reg-card { display: flex; align-items: center; gap: 16px; padding: 14px 20px; }
.reg-card .title { font-size: 13.5px; font-weight: 500; }
.reg-card .meta { margin-top: 2px; font-size: 12px; color: var(--text-3); line-height: 1.5; }
.reg-card .grow { flex: 1; min-width: 0; }

/* ---------- member › 模型 ---------- */
.mdl-table .mdl-id { font-weight: 500; }
.mdl-table tr.mdl-group td { padding-top: 14px; padding-bottom: 6px; border-top: 0; font-size: 11.5px; font-weight: 600; color: var(--text-3); letter-spacing: .02em; background: none !important; }
.mdl-table tr.mdl-group + tr td { border-top: 0.5px solid var(--sep); }
.mdl-table td .btn.icon { opacity: .55; transition: opacity .15s; }
.mdl-table tr:hover td .btn.icon, .mdl-table td .btn.icon:focus-visible, .mdl-table td .btn.copied { opacity: 1; }
.pg-card .hint code { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 5px; background: var(--fill-2); color: var(--text-2); }
#q { max-width: 360px; }
.models-foot { margin: 4px 4px 0; }
@media (max-width: 760px) {
  .mdl-table { min-width: 0; table-layout: auto; }
  .mdl-table col { width: auto !important; }
  .mdl-table th:nth-child(4), .mdl-table td:nth-child(4) { display: none; }
  .mdl-table td .btn.icon { opacity: 1; }
  .pg-card .card-head { flex-wrap: wrap; }
}

/* small icon buttons: .btn.sm's padding must not squeeze the glyph */
.btn.icon.sm { padding: 0; }
.btn svg { flex: none; }

/* ---------- member › 模型 v2: a gallery of model cards ---------- */
.mdl-search { display: inline-flex; align-items: center; gap: 7px; width: 200px; height: 30px; padding: 0 10px; border-radius: 9px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--sep); color: var(--text-3); cursor: text; transition: width .2s ease, background .15s, box-shadow .15s; }
.mdl-search:focus-within { width: 240px; background: var(--card-solid); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-tint); }
.mdl-search svg { width: 15px; height: 15px; flex: none; }
.mdl-search input { flex: 1; min-width: 0; max-width: none; border: 0; outline: 0; padding: 0; background: none; font: inherit; font-size: 12.5px; color: var(--text); }
.mdl-search input::placeholder { color: var(--text-3); }

.mdl-sec + .mdl-sec { margin-top: 28px; }
.mdl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 4px 12px; }
.mdl-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.mdl-count { padding: 1px 7px; border-radius: 999px; background: var(--fill-2); color: var(--text-3); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mdl-how { margin-left: auto; font-size: 12px; color: var(--text-3); }
.mdl-how code { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 5px; background: var(--fill-2); color: var(--text-2); }

.mdl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 12px; }
.mdl-card {
  position: relative; padding: 14px 14px 12px; border-radius: 16px; cursor: pointer; outline: none;
  background: var(--card); box-shadow: inset 0 1px 0 var(--card-hi), var(--shadow);
  transition: transform .22s cubic-bezier(.2, .8, .2, 1), box-shadow .22s;
}
.mdl-card:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 var(--card-hi), var(--shadow-hover, var(--shadow)); }
.mdl-card:active { transform: translateY(0) scale(.99); }
.mdl-card:focus-visible { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.mdl-top { display: flex; align-items: center; gap: 10px; }
.mdl-mono { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; color: #fff; font-size: 15px; font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 6px 14px -6px rgba(0, 0, 0, .45); }
.mdl-mono.p-openai { background: linear-gradient(145deg, #4a505c, #15171c); }
.mdl-mono.p-anthropic { background: linear-gradient(145deg, #e8a07a, #b8562f); }
.mdl-name { flex: 1; min-width: 0; }
.mdl-id { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mdl-sub { margin-top: 1px; font-size: 11.5px; color: var(--text-3); }
.mdl-copy { opacity: 0; transition: opacity .15s; }
.mdl-card:hover .mdl-copy, .mdl-card:focus-visible .mdl-copy, .mdl-copy.copied { opacity: 1; }
@media (hover: none) { .mdl-copy { opacity: 1; } }

.mdl-level { display: flex; align-items: center; gap: 7px; margin: 12px 0 11px; font-size: 11.5px; font-weight: 600; }
.mdl-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.mdl-bars i { width: 4px; border-radius: 2px; background: var(--fill-hover); }
.mdl-bars i:nth-child(1) { height: 5px; } .mdl-bars i:nth-child(2) { height: 7px; } .mdl-bars i:nth-child(3) { height: 9.5px; } .mdl-bars i:nth-child(4) { height: 12px; }
.mdl-level.l1 { color: #1f9d55; } .mdl-level.l2 { color: var(--accent); } .mdl-level.l3 { color: #e07b00; } .mdl-level.l4 { color: #8a5cff; }
.mdl-level.l1 .mdl-bars i:nth-child(-n+1), .mdl-level.l2 .mdl-bars i:nth-child(-n+2),
.mdl-level.l3 .mdl-bars i:nth-child(-n+3), .mdl-level.l4 .mdl-bars i { background: currentColor; }

.mdl-prices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding-top: 10px; border-top: 0.5px solid var(--sep); }
.mdl-prices div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mdl-prices div + div { padding-left: 11px; border-left: 0.5px solid var(--sep); }
.mdl-prices span { font-size: 10.5px; color: var(--text-3); }
.mdl-prices b { font-family: var(--display); font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.mdl-prices b.soft { color: var(--text-2); font-weight: 500; }

@media (max-width: 760px) {
  .topbar .mdl-search { order: 3; width: 100%; }
  .topbar .mdl-search:focus-within { width: 100%; }
  .mdl-how { margin-left: 0; width: 100%; }
  .mdl-grid { grid-template-columns: 1fr; gap: 10px; }
}

/* Motion goes on the leaves only: a card row (.grid) stays put and its cards
   move, otherwise a card would ride its row's slide and then do its own —
   twice the distance in two steps, which reads as a double bounce. */
#page.switching > .grid, #page.entering > .grid { animation: none; }
#page.switching > .grid > * { animation: slide-up .38s cubic-bezier(.2, .8, .2, 1) both; }
#page.entering > .grid > * { animation: enter .5s cubic-bezier(.2, .8, .2, 1) both; }
#page.switching > .grid > :nth-child(2), #page.entering > .grid > :nth-child(2) { animation-delay: 40ms; }
#page.switching > .grid > :nth-child(3), #page.entering > .grid > :nth-child(3) { animation-delay: 80ms; }
#page.switching > .grid > :nth-child(4), #page.entering > .grid > :nth-child(4) { animation-delay: 120ms; }
#page.switching .grid .grid > *, #page.entering .grid .grid > * { animation: none; } /* nested rows: once is enough */
@media (prefers-reduced-motion: reduce) { #page.switching > .grid > *, #page.entering > .grid > * { animation: none !important; } }

/* ---------- upstream cost ---------- */
textarea.input { height: auto; min-height: 64px; padding: 8px 12px; line-height: 1.55; resize: vertical; }
.rate-row { display: flex; align-items: center; gap: 10px; }
.rate-row .input { width: 110px; flex: none; }
.rate-x { font-size: 12.5px; color: var(--text-2); }
.rate-hint { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--accent-text, var(--accent)); }
details.rules { margin-top: 8px; }
details.rules summary { cursor: pointer; font-size: 12px; color: var(--text-2); list-style: none; display: inline-flex; align-items: center; gap: 4px; }
details.rules summary::-webkit-details-marker { display: none; }
details.rules summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 14px; line-height: 1; }
details.rules[open] summary::before { transform: rotate(90deg); }
details.rules textarea { margin-top: 8px; font-size: 12px; }
details.rules .tip { display: block; margin-top: 4px; }

/* ---------- price rows: list price and loss warning ---------- */
.pg-sub { display: flex; align-items: center; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.pg-official { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.pg-loss { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px 1px 5px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--red); background: color-mix(in srgb, var(--red) 11%, transparent); cursor: help; }
.pg-loss svg { width: 11px; height: 11px; }
.row-fields.official { margin-top: 14px; }
.margin-line { margin-top: 2px; }
.margin-line .pos { color: var(--green); }
.margin-line .neg { color: var(--red); }
.t.usage td.r .sub { font-weight: 400; }

/* ---------- upstreams: one card per channel, keys inside ---------- */
.ch-head { flex-wrap: wrap; row-gap: 6px; }
.ch-title { display: flex; align-items: center; gap: 6px; }
.ch-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 360px; }
.ch-head .btn.sm { margin-left: 2px; }
.ch-note { padding: 0 20px 8px; font-size: 12px; color: var(--text-2); }
.proto { flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; font-size: 10.5px; font-weight: 700; line-height: 1; color: #fff; letter-spacing: 0; }
.proto.p-anthropic { background: linear-gradient(145deg, #e8a07a, #c0603a); }
.proto.p-openai { background: linear-gradient(145deg, #5a606c, #1d2026); }
.ch-card .row .proto { margin-right: -2px; }
.ch-card + .ch-card { margin-top: 14px; }
@media (max-width: 760px) {
  .ch-url { order: 5; width: 100%; max-width: none; }
  .ch-head .hint:not(.ch-url) { display: none; }
}
.row-fields + .field { margin-top: 14px; }
@media (max-width: 760px) {
  .ch-head [data-addkey] { display: none; } /* also in the ··· menu */
  .ch-title { flex: 1; min-width: 0; }
  .ch-title h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .ch-head .spacer { display: none; }
}

/* ---------- 价格 v3: sale groups + list prices ---------- */
.sec-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 22px 4px 10px; font-size: 14px; font-weight: 600; }
#page > .sec-title:first-of-type { margin-top: 2px; }
.sec-title span { font-size: 12px; font-weight: 400; color: var(--text-3); }
.sg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
#page > .sg-grid { margin-top: 0; }
.sg-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.sg-top { display: flex; align-items: center; gap: 8px; }
.sg-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.sg-name .badge { font-size: 10.5px; }
.sg-rate { font-family: var(--display); font-size: 28px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.sg-rate small { margin-left: 4px; font-family: var(--font); font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--text-3); }
.sg-keys { display: flex; flex-wrap: wrap; gap: 5px; }
.sg-loss { display: flex; align-items: flex-start; gap: 5px; font-size: 11.5px; line-height: 1.45; color: var(--red); }
.sg-loss svg { width: 12px; height: 12px; flex: none; margin-top: 2px; }
.sg-foot { margin-top: auto; font-size: 11.5px; color: var(--text-3); }
.op-table { min-width: 860px; }
.op-table col.op-model { width: 26%; }
.op-table col.op-src { width: 120px; }
.op-table td { vertical-align: middle; }
.src { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 500; background: var(--fill-2); color: var(--text-2); white-space: nowrap; }
.src.src-auto { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--green); }
.src.src-manual { background: var(--accent-tint); color: var(--accent-text, var(--accent)); }
.src.src-glob, .src.src-legacy { background: color-mix(in srgb, var(--orange) 12%, transparent); color: var(--orange); }
.pg-keys-cell { white-space: normal !important; }
.kchip { display: inline-flex; align-items: center; gap: 5px; margin: 2px 6px 2px 0; padding: 1px 3px 1px 7px; border-radius: 6px; font-size: 11.5px; background: var(--fill-2); color: var(--text-2); white-space: nowrap; }
.kchip b { padding: 0 5px; border-radius: 4px; font-weight: 600; font-size: 10.5px; background: var(--card-solid); color: var(--text); }
.kchip.off { opacity: .5; text-decoration: line-through; }
.g-keys { margin-top: 8px; max-height: 260px; overflow-y: auto; padding: 4px; border-radius: 12px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); }
.g-ch { padding: 8px 8px 3px; font-size: 11px; font-weight: 600; color: var(--text-3); }
.g-key { gap: 9px; }
.g-key .g-key-name { flex: 1; }
.g-key-rate { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.g-key-rate.off { color: var(--orange); }
#g-tip { display: block; margin-top: 6px; }
#g-tip .neg { color: var(--red); }
details.retired { padding: 0; }
details.retired summary { padding: 14px 20px; cursor: pointer; font-size: 13px; font-weight: 500; list-style: none; }
details.retired summary::-webkit-details-marker { display: none; }
details.retired summary .faint { margin-left: 6px; font-weight: 400; font-size: 12px; }
details.retired[open] summary { border-bottom: 0.5px solid var(--sep); }

/* ---------- groups on the member side ---------- */
.mdl-rate { padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--accent-tint); color: var(--accent-text, var(--accent)); font-variant-numeric: tabular-nums; }
.gtag { display: inline-block; padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 500; background: var(--accent-tint); color: var(--accent-text, var(--accent)); }
.gtag.gone { background: var(--orange-tint); color: var(--orange); }
.gpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.gpick-item { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 0; border-radius: 12px; text-align: left; cursor: pointer; font: inherit;
  background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); color: var(--text); transition: box-shadow .15s, background .15s; }
.gpick-item:hover { background: var(--fill); }
.gpick-item.on { background: var(--card-solid); box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-tint); }
.gpick-top { display: flex; align-items: center; gap: 8px; }
.gpick-top b { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gpick-rate { font-family: var(--display); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gpick-item.on .gpick-rate { color: var(--accent-text, var(--accent)); }
.gpick-sub { font-size: 11.5px; color: var(--text-3); }
/* card tile colour follows the model family, not the protocol it travels over */
.mdl-mono.f-claude { background: linear-gradient(145deg, #e8a07a, #b8562f); }
.mdl-mono.f-gpt { background: linear-gradient(145deg, #4a505c, #15171c); }
.mdl-mono.f-grok { background: linear-gradient(145deg, #7b8794, #2e3640); }
.mdl-mono.f-gemini { background: linear-gradient(145deg, #6ea8ff, #3b62d8); }
.mdl-mono.f-deepseek { background: linear-gradient(145deg, #6c8cff, #3346c8); }
.mdl-mono.f-其他, .mdl-mono.f-kimi, .mdl-mono.f-glm, .mdl-mono.f-qwen { background: linear-gradient(145deg, #a593ff, #5f48d6); }

/* member › 模型: family sub-sections inside each group */
.mdl-fam + .mdl-fam { margin-top: 18px; }
.mdl-fam-head { display: flex; align-items: center; gap: 7px; margin: 0 4px 10px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.mdl-dot { width: 10px; height: 10px; border-radius: 3px; background: linear-gradient(145deg, #a593ff, #5f48d6); }
.mdl-dot.f-claude { background: linear-gradient(145deg, #e8a07a, #b8562f); }
.mdl-dot.f-gpt { background: linear-gradient(145deg, #4a505c, #15171c); }
.mdl-dot.f-grok { background: linear-gradient(145deg, #7b8794, #2e3640); }
.mdl-dot.f-gemini { background: linear-gradient(145deg, #6ea8ff, #3b62d8); }
.mdl-dot.f-deepseek { background: linear-gradient(145deg, #6c8cff, #3346c8); }
.mdl-fam-n { font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
/* discounts members can see */
.mdl-prices s.mdl-list { font-size: 11px; color: var(--text-3); text-decoration-thickness: 1px; font-variant-numeric: tabular-nums; }
.mdl-rate.deal, .gpick-rate.deal { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.gpick-rate.deal { padding: 1px 7px; border-radius: 999px; font-size: 12.5px; }
.gpick-item.on .gpick-rate.deal { color: var(--green); }

/* ---------- 接入: step-by-step guide ---------- */
.cx-pick { display: flex; flex-wrap: wrap; gap: 12px 24px; padding: 14px 18px; }
.cx-pick > div { display: flex; align-items: center; gap: 10px; }
.cx-label { font-size: 12px; color: var(--text-3); }
.cx-step { display: flex; gap: 16px; padding: 18px 20px; }
.cx-num { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(145deg, #5e9cff, #2a5bd7); box-shadow: 0 4px 10px -4px rgba(42, 91, 215, .6); }
.cx-body { flex: 1; min-width: 0; }
.cx-body h2 { margin: 3px 0 10px; font-size: 15px; font-weight: 600; }
.cx-body p { margin: 8px 0; font-size: 13px; line-height: 1.65; color: var(--text); }
.cx-body p.tip, .cx-body .tip { font-size: 12px; color: var(--text-3); }
.cx-body code, .cx-faq code { font-family: var(--mono); font-size: 11.5px; padding: 1px 5px; border-radius: 5px; background: var(--fill-2); color: var(--text); }
.cx-body a:not(.btn) { color: var(--accent-text, var(--accent)); }
.cx-body p .btn { margin-left: 6px; vertical-align: middle; }
.cx-code { position: relative; margin: 8px 0; border-radius: 12px; background: color-mix(in srgb, var(--fill-2) 80%, transparent); box-shadow: inset 0 0 0 0.5px var(--card-edge); }
.cx-code pre { margin: 0; padding: 12px 92px 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 12px; line-height: 1.6; white-space: pre; }
.cx-code .cx-copy { position: absolute; top: 8px; right: 8px; }
.cx-vals { display: grid; gap: 6px; margin: 8px 0; }
.cx-val { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 12px; border-radius: 10px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); min-width: 0; }
.cx-k { flex: none; width: 128px; font-size: 12px; color: var(--text-2); }
.cx-v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none !important; padding: 0 !important; font-size: 12.5px !important; }
.cx-val .btn { flex: none; }
.cx-list { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 10px; font-size: 13px; line-height: 1.65; }
.cx-list li::marker { color: var(--text-3); font-weight: 600; }
.cx-paste { display: grid; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.cx-paste .input { max-width: 520px; }
.cx-warn { color: var(--orange) !important; font-size: 12px !important; }
.cx-faq { padding: 18px 20px; }
.cx-faq h2 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.cx-faq details { border-top: 0.5px solid var(--sep); }
.cx-faq summary { padding: 11px 0; cursor: pointer; font-size: 13px; font-weight: 500; list-style: none; display: flex; align-items: center; gap: 6px; }
.cx-faq summary::-webkit-details-marker { display: none; }
.cx-faq summary::before { content: "›"; display: inline-block; width: 10px; color: var(--text-3); transition: transform .15s; }
.cx-faq details[open] summary::before { transform: rotate(90deg); }
.cx-faq details p { margin: 0 0 12px 16px; font-size: 12.5px; line-height: 1.65; color: var(--text-2); }
@media (max-width: 760px) {
  .cx-step { gap: 12px; padding: 16px 14px; }
  .cx-val { flex-wrap: wrap; gap: 4px 10px; }
  .cx-k { width: auto; }
  .cx-v { flex-basis: 100%; order: 3; }
  .cx-val .btn { margin-left: auto; }
  .cx-pick > div { width: 100%; flex-wrap: wrap; }
}

/* ---- admin › 设置 ---- */
/* Admin › 设置: grouped rows like a system settings pane */
.prefs { display: grid; gap: 22px; padding-bottom: 8px; }
@media (min-width: 1100px) {
  .prefs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; column-gap: 24px; }
  .p-notify { grid-column: 1; grid-row: 1; }
  .p-cache { grid-column: 1; grid-row: 2; }
  .p-quality { grid-column: 1; grid-row: 3; }
  /* the member texts fill the right column, 充值说明 takes the spare height */
  .p-member { grid-column: 2; grid-row: 1 / 4; align-self: stretch; display: flex; flex-direction: column; }
  .p-member .pref-card { flex: 1; display: flex; flex-direction: column; }
  .p-member .pref-row.grow { flex: 1; }
  .p-member .pref-row.grow textarea { flex: 1; }
  .prefs > .savebar { grid-column: 1 / -1; }
}
.pref-head { display: flex; align-items: center; gap: 9px; margin: 0 4px 8px; }
.pref-head h2 { font-size: 13px; font-weight: 600; margin: 0; }
.pref-head .nav-tile { width: 22px; height: 22px; border-radius: 6px; }
.pref-head .nav-tile svg { width: 13px; height: 13px; color: #fff; stroke-width: 2; }
.pref-head .pill { margin-left: auto; }
.pill.warn { background: var(--orange-tint); color: var(--orange); }
.pill.ok { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--green); }
.pref-card { padding: 0; }
.pref-row { display: flex; align-items: center; gap: 24px; padding: 14px 18px; position: relative; }
.pref-row + .pref-row::before { content: ""; position: absolute; top: 0; left: 18px; right: 0; height: 0.5px; background: var(--sep); }
.pref-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pref-label label { font-size: 13px; font-weight: 500; color: var(--text); }
.pref-label .tip { font-size: 11.5px; color: var(--text-3); line-height: 1.5; margin: 0; }
.pref-ctl { flex: none; display: flex; justify-content: flex-end; }
.pref-ctl > .input { width: 260px; height: 32px; }
.pref-row.stack { flex-direction: column; align-items: stretch; gap: 8px; }
.pref-row.stack .pref-label { flex: none; flex-direction: row; align-items: baseline; justify-content: space-between; }
.pref-row.stack textarea { resize: vertical; min-height: 0; line-height: 1.55; }
.pref-row.stack > .tip { font-size: 11.5px; color: var(--text-3); margin: 0; }
.pref-count { font-size: 11px; color: var(--text-3); }
.pref-count.near { color: var(--orange); }
.unit-input { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 9px; background: var(--fill-2);
  box-shadow: inset 0 0 0 0.5px var(--sep); font-size: 12.5px; color: var(--text-2); cursor: text; transition: box-shadow .15s, background .15s; }
.unit-input:focus-within { background: var(--card); box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-tint); }
.unit-input input { width: 5ch; border: 0; outline: 0; background: none; padding: 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--text); text-align: center; -moz-appearance: textfield; }
.unit-input input::-webkit-inner-spin-button, .unit-input input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.savebar { position: sticky; bottom: 14px; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 18px; border-radius: 14px;
  background: color-mix(in srgb, var(--card-solid) 82%, transparent); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 0 0 0.5px var(--sep), 0 8px 24px -10px rgba(0, 0, 0, .18);
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .25s cubic-bezier(.2, .9, .25, 1), box-shadow .2s; }
.savebar.dirty, .savebar.busy { opacity: 1; transform: none; pointer-events: auto; }
.savebar-msg { flex: 1; font-size: 12.5px; color: var(--text-3); }
.savebar.dirty .savebar-msg { color: var(--text); font-weight: 500; }
.savebar.dirty .savebar-msg::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); margin-right: 8px; vertical-align: 1px; }
.savebar.dirty { box-shadow: 0 0 0 0.5px color-mix(in srgb, var(--accent) 35%, transparent), 0 10px 28px -10px rgba(0, 0, 0, .25); }
@media (max-width: 760px) {
  .pref-row:not(.stack) { flex-direction: column; align-items: stretch; gap: 10px; }
  .pref-ctl { justify-content: flex-start; }
  .pref-ctl > .input { width: 100%; }
  .pref-row:has(.switch) { flex-direction: row; align-items: center; }
  .savebar { bottom: calc(10px + env(safe-area-inset-bottom)); }
}

/* ---- member: announcement bar, top-up note ---- */
.notice-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; padding: 8px 8px 8px 16px; border-radius: 14px;
  background: var(--accent-tint); color: var(--text); font-size: 13px; line-height: 1.5; }
.notice-bar > svg { width: 16px; height: 16px; flex: none; color: var(--accent); }
.notice-bar .notice-text { flex: 1; min-width: 0; white-space: pre-line; }
.notice-bar .btn.icon.sm { flex: none; }
.pay-text { font-size: 13.5px; line-height: 1.7; white-space: pre-line; color: var(--text-2); }

/* ---- admin › 上游 › 余额与核对 ---- */
.bill-hero { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin: 4px 0 16px; padding: 16px 18px; border-radius: 16px;
  background: linear-gradient(135deg, var(--green-tint), color-mix(in srgb, var(--green-tint) 35%, transparent)); box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--green) 18%, transparent); }
.bill-hero.low { background: linear-gradient(135deg, var(--orange-tint), color-mix(in srgb, var(--orange-tint) 35%, transparent)); box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--orange) 20%, transparent); }
.bill-hero.none { background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--sep); }
.bill-main { display: flex; align-items: center; gap: 14px; flex: 1 1 260px; min-width: 0; }
.bill-icon { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, #4fd1a5, #139a6c); box-shadow: 0 2px 6px rgba(19, 154, 108, .28); }
.bill-hero.low .bill-icon { background: linear-gradient(145deg, #ffc15e, #e08600); box-shadow: 0 2px 6px rgba(224, 134, 0, .28); }
.bill-hero.none .bill-icon { background: linear-gradient(145deg, #b0b0b6, #8e8e93); box-shadow: none; }
.bill-icon svg { width: 22px; height: 22px; }
.bill-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.bill-label .pill { height: 18px; font-size: 11px; background: color-mix(in srgb, var(--card) 70%, transparent); }
.bill-bal { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; }
.bill-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.bill-hero.none .bill-sub { color: var(--orange); }
.bill-stats { display: flex; }
.bill-stats > div { padding: 0 18px; }
.bill-stats > div + div { border-left: 0.5px solid color-mix(in srgb, var(--text) 12%, transparent); }
.bill-note { font-size: 11px; color: var(--orange); margin-top: 1px; white-space: nowrap; }
.bill-stats .v { font-size: 17px; font-weight: 600; margin-top: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .bill-hero { padding: 14px; gap: 14px; }
  .bill-stats { width: 100%; padding-top: 12px; border-top: 0.5px solid color-mix(in srgb, var(--text) 10%, transparent); }
  .bill-stats > div { flex: 1; padding: 0 10px; }
  .bill-stats > div:first-child { padding-left: 0; }
  .bill-bal { font-size: 26px; }
}
.bill-t td, .bill-t th { white-space: nowrap; }
.spin-wrap { display: grid; place-items: center; padding: 24px; }

/* ---- sidebar: grouped like System Settings — small headings, colour icon tiles ---- */
.sidebar { overflow-y: auto; scrollbar-width: none; }
.sidebar::-webkit-scrollbar { display: none; }
.nav-groups { display: flex; flex-direction: column; gap: 16px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-label { padding: 0 10px 6px; font-size: 11px; font-weight: 600; color: var(--text-3); letter-spacing: 0.04em; line-height: 1; }
.sidebar .nav-item { gap: 10px; padding: 5px 10px 5px 7px; border-radius: 10px; font-size: 13px; }
.nav-tile {
  width: 24px; height: 24px; border-radius: 7px; flex: none; display: grid; place-items: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tile) 78%, #fff), var(--tile));
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 1px 1.5px rgba(0, 0, 0, 0.1);
}
.sidebar .nav-item .nav-tile svg, .sidebar .nav-item.active .nav-tile svg { display: block; width: 15px; height: 15px; margin: 0; color: #fff; stroke-width: 1.9; }
.sidebar .nav-item:hover:not(.active) { background: var(--fill-2); }
.sidebar .nav-item > svg { width: 20px; height: 20px; margin: 0 2px; }
@media (min-width: 761px) and (max-height: 760px) {
  .nav-groups { gap: 10px; }
  .brand { padding-bottom: 12px; }
  .sidebar .nav-item { padding-top: 4px; padding-bottom: 4px; }
}
@media (max-width: 760px) {
  body.app .sidebar .nav-groups { gap: 18px; }
  body.app .sidebar .nav-label { display: block; padding: 0 12px 7px; font-size: 12px; }
  body.app .sidebar .nav-item { padding: 7px 12px 7px 9px; font-size: 14px; }
  body.app .sidebar .nav-item .nav-tile { display: grid; width: 28px; height: 28px; border-radius: 8px; }
  .sidebar .nav-item .nav-tile svg, .sidebar .nav-item.active .nav-tile svg { width: 17px; height: 17px; }
}


/* brand row lines up with the menu: same tile size, same left edge, text over the item text */
.sidebar .brand { gap: 10px; padding-left: 7px; }
.sidebar .brand .mark { width: 24px; height: 24px; border-radius: 7px; }
.sidebar .brand .mark svg { width: 14px; height: 14px; }
.sidebar .nav-label { padding-left: 7px; }
@media (max-width: 760px) {
  body.app .sidebar .brand { padding-left: 9px; }
  body.app .sidebar .brand .mark { width: 28px; height: 28px; border-radius: 8px; }
  body.app .sidebar .brand .mark svg { width: 16px; height: 16px; }
  body.app .sidebar .nav-label { padding-left: 9px; }
}
.sidebar .me-chip { gap: 10px; padding-left: 6px; }
.sidebar .me-chip .avatar.sm { width: 26px; height: 26px; }
@media (max-width: 760px) {
  body.app .sidebar .me-chip { padding-left: 8px; }
  body.app .sidebar .me-chip .avatar.sm { width: 30px; height: 30px; }
}

/* ---- wide screens: let the content use the room ---- */
.page { max-width: 1920px; }

/* overview fills the window by sharing the leftover height between the chart
   row and the bottom row (grid rows, which every browser sizes the same),
   each with a floor so neither gets squashed */
.page.dash.ov { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(290px, 1.6fr) minmax(210px, 1fr); }
.page.dash.ov > .grid.g-main, .page.dash.ov > .grid.g3:last-child { min-height: 0; }
@media (max-width: 760px) { .page.dash.ov { display: block; } }

/* auth forms: the button turns on once the page script runs; if it never does, say so */
.auth-form .load-hint { display: none; margin-top: 10px; font-size: 12.5px; color: var(--text-3); text-align: center; }
.auth-form:not(.ready) .load-hint { display: block; opacity: 0; animation: load-hint 0.2s 5s forwards; }
@keyframes load-hint { to { opacity: 1; } }

/* ---- 质量: answer tests per upstream ---- */
.qa-sum { margin-bottom: 14px; }
.qa-sum-row { display: flex; flex-wrap: wrap; gap: 14px 40px; }
.qa-sum-model { font-size: 12.5px; color: var(--text-2); }
.qa-sum-val { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.qa-empty { margin: 4px 0 0; font-size: 12.5px; }
/* masonry: each card as tall as its content, the next one moves up under it */
.qa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr)); grid-auto-rows: 2px; grid-auto-flow: row dense; column-gap: 14px; align-items: start; }
.qa-card { padding: 18px 20px; margin: 0 0 14px; }
.qa-card.off { opacity: .6; }
.qa-head { display: flex; align-items: center; gap: 12px; }
.qa-head .grow { flex: 1; min-width: 0; }
.qa-code { margin: 6px 0; padding: 8px 10px; border-radius: 8px; background: var(--fill-2); font-family: var(--mono); font-size: 11.5px; line-height: 1.5; color: var(--text); white-space: pre; overflow-x: auto; }
.qa-name { font-weight: 600; font-size: 14px; }
.qa-prov { font-size: 12px; margin-top: 2px; }
.qa-running { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.qa-running .spin { width: 13px; height: 13px; border-width: 2px; border-color: var(--fill); border-top-color: var(--accent); }
.qa-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 16px 0 4px; padding: 12px 0; border-top: 0.5px solid var(--sep); border-bottom: 0.5px solid var(--sep); }
.qa-stats > div { padding: 0 12px; }
.qa-stats > div:first-child { padding-left: 0; }
.qa-stats > div + div { border-left: 0.5px solid var(--sep); }
.qa-stats .label { font-size: 11.5px; color: var(--text-2); }
.qa-stats .v { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin: 3px 0 1px; font-variant-numeric: tabular-nums; }
.qa-stats .faint { font-size: 11.5px; }
.good { color: var(--green); }
.warn { color: var(--orange); }
.bad { color: var(--red); }
.qa-model { padding: 14px 0 2px; }
.qa-model + .qa-model { border-top: 0.5px solid var(--sep); }
.qa-mhead { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.qa-mname { font-size: 13px; font-weight: 600; }
.qa-acc { font-size: 12.5px; }
.qa-acc b { font-size: 16px; font-variant-numeric: tabular-nums; }
.qa-next { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-variant-numeric: tabular-nums; }
.qa-next svg { width: 13px; height: 13px; }
.qa-strip { display: flex; gap: 2px; height: 26px; margin: 10px 0 6px; }
.qa-strip > * { flex: 1 1 0; min-width: 0; border-radius: 3px; }
.qa-pad { background: var(--fill-2); }
.qa-bar { border: 0; padding: 0; cursor: pointer; transition: transform .12s, filter .12s; }
.qa-bar:hover, .qa-bar:focus-visible { transform: scaleY(1.12); filter: brightness(1.08); }
.qa-bar.pass, .qa-legend i.pass { background: #34c759; }
.qa-bar.fail, .qa-legend i.fail { background: #ff3b30; }
.qa-bar.error, .qa-legend i.error { background: #ffcc00; }
.qa-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.qa-legend { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; }
.qa-legend i { width: 8px; height: 8px; border-radius: 2px; margin-left: 8px; }
.qa-legend i:first-child { margin-left: 0; }
.advice.orange { background: var(--orange-tint); color: var(--text); }
.qa-sheet { width: min(680px, calc(100vw - 32px)); }
.qa-q { padding: 12px 0; border-top: 0.5px solid var(--sep); }
.qa-qhead { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.qa-qtext { margin: 6px 0; font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; line-height: 1.55; }
.qa-qans { font-size: 12.5px; margin-top: 3px; }
.qa-qans .mono { font-size: 12px; }
.qa-reply { margin-top: 12px; font-size: 12.5px; }
.qa-reply pre { white-space: pre-wrap; font-family: var(--mono); font-size: 11.5px; line-height: 1.5; background: var(--fill-2); border-radius: 10px; padding: 10px 12px; max-height: 320px; overflow: auto; }
@media (max-width: 760px) {
  .qa-card { padding: 16px; }
  .qa-stats .v { font-size: 17px; }
  .qa-stats > div { padding: 0 8px; }
  .qa-strip { height: 22px; gap: 1.5px; }
  .qa-legend { display: none; }
  .qa-sum-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
  .qa-sum-val { font-size: 22px; }
  .qa-sum-model { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---- 上游: channel cards ---- */
.uc-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 14px; }
.uc-tile { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.12); }
.uc-id { flex: 1; min-width: 0; }
.uc-id h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-sub { margin-top: 2px; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-sub .mono { font-size: 11.5px; }
.uc-sep { margin: 0 6px; }
.uc-count { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.uc-keys { list-style: none; margin: 0; padding: 0 8px 8px; }
.uc-key { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; transition: background .15s; }
.uc-key:hover { background: var(--fill-2); }
.uc-key + .uc-key { margin-top: 2px; }
.uc-key.off .uc-logo, .uc-key.off .uc-main { opacity: .5; }
.uc-logo { position: relative; flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; }
.uc-logo.p-anthropic { background: linear-gradient(145deg, #e8a07a, #c0603a); }
.uc-logo.p-openai { background: linear-gradient(145deg, #5a606c, #1d2026); }
.uc-state { position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%; background: var(--text-3); box-shadow: 0 0 0 2px var(--card); }
.uc-state.ok { background: #34c759; }
.uc-state.warn { background: #ff9f0a; }
.uc-main { flex: 1; min-width: 0; }
.uc-name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-tail { margin-left: 8px; font-size: 11.5px; font-weight: 400; color: var(--text-3); }
.uc-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; background: var(--fill-2); color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill.accent { background: var(--accent-tint); color: var(--accent-text); }
.uc-faint { font-size: 11.5px; color: var(--text-3); margin-left: 2px; white-space: nowrap; }
.uc-err { margin-top: 5px; font-size: 12px; color: var(--orange); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .uc-head { padding: 14px 14px 12px; gap: 10px; }
  .uc-count, .uc-head [data-addkey] { display: none; } /* also in the ··· menu */
  .uc-keys { padding: 0 4px 6px; }
  .uc-key { gap: 10px; padding: 10px; }
  .uc-key [data-test] { display: none; } /* also in the ··· menu */
  .uc-faint { display: none; }
}

/* ---- a deleted sale group: where its keys go (admin), choosing again (member) ---- */
.mv-list { display: flex; flex-direction: column; border-radius: 14px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); overflow: hidden; }
.mv-opt { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; cursor: pointer; transition: background .15s; }
.mv-opt + .mv-opt::before { content: ""; position: absolute; top: 0; left: 44px; right: 0; height: 0.5px; background: var(--sep); }
.mv-opt:hover { background: var(--fill); }
.mv-opt input { appearance: none; flex: none; width: 18px; height: 18px; margin: 0; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--text-3); transition: box-shadow .15s; cursor: pointer; }
.mv-opt input:checked { box-shadow: inset 0 0 0 5.5px var(--accent); }
.mv-opt input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.mv-main b { font-size: 13.5px; font-weight: 600; }
.mv-main span { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mv-flag { flex: none; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--orange-tint); color: var(--orange); }
.mv-note { display: flex; gap: 8px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.6; background: var(--accent-tint); color: var(--text-2); }
.mv-note > svg { width: 15px; height: 15px; flex: none; margin-top: 2px; color: var(--accent); }
.mv-note.warn { background: var(--orange-tint); }
.mv-note.warn > svg { color: var(--orange); }
.mv-note b { color: var(--text); font-weight: 600; }

.regroup-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; box-shadow: inset 0 0 0 1px var(--orange-tint), var(--shadow); }
.regroup-card .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.regroup-card b { font-size: 14px; font-weight: 600; }
.regroup-card .grow span { font-size: 12.5px; color: var(--text-2); }
.regroup-ic { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--orange-tint); color: var(--orange); }
.regroup-ic svg { width: 17px; height: 17px; }
.notice-bar.regroup-bar { background: var(--orange-tint); padding-right: 14px; text-decoration: none; }
.notice-bar.regroup-bar > svg { color: var(--orange); }
.regroup-go { flex: none; display: inline-flex; align-items: center; gap: 2px; font-weight: 600; color: var(--orange); }
.regroup-go svg { width: 14px; height: 14px; transform: rotate(-90deg); }
@media (max-width: 520px) {
  .regroup-card { flex-wrap: wrap; }
  .regroup-card .btn { width: 100%; }
}

/* ---- deleting upstream keys: which sale groups lose what ---- */
.imp-list { display: flex; flex-direction: column; border-radius: 14px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); overflow: hidden; }
.imp-row { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 11px 14px; }
.imp-row + .imp-row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 0.5px; background: var(--sep); }
.imp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.imp-main b { font-size: 13.5px; font-weight: 600; }
.imp-main span { font-size: 12px; color: var(--text-3); }
.imp-main .imp-models { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); }
.imp-models i { font-style: normal; white-space: nowrap; }
.imp-flag { flex: none; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--orange-tint); color: var(--orange); }
.imp-flag.bad { background: var(--red-tint); color: var(--red); }

/* ---------- account settings: wide sections + selectable model grid ---------- */
.sheet.account-sheet { width: min(900px, calc(100vw - 32px)); }
.acc-sec { border-top: 0.5px solid var(--sep); padding: 16px 0 4px; }
.acc-sec:first-of-type { border-top: 0; padding-top: 2px; }
.acc-sec-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .02em; }
.acc-sec-note { font-size: 11.5px; font-weight: 400; color: var(--text-3); }
.acc-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; align-items: start; }
.acc-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; align-items: start; }
.acc-legacy { margin-top: 14px; max-width: 320px; }
.acc-all-models { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; font-size: 12.5px; color: var(--text-2); }
.acc-all-models input { margin: 0; }
.model-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; max-height: 230px; overflow: auto; padding: 8px; border-radius: 12px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--card-edge); }
.model-pick { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 7px 9px; border-radius: 8px; font-size: 12px; color: var(--text-2); }
.model-pick:hover { background: var(--card-solid); }
.model-pick input { flex: none; margin: 0; }
.model-pick .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.acc-model-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.acc-model-actions .tip { flex: 1 1 180px; margin: 0; }
.acc-grid2 > .field + .field, .acc-grid3 > .field + .field { margin-top: 0; }
.acc-actions { align-items: center; }
.acc-actions .acc-enable-label { margin-right: auto; }
.acc-enable-label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.topbar h1.sec-title, .topbar h2.sec-title { font-size: 14px; font-weight: 500; color: var(--text-2); letter-spacing: .01em; }
.acc-enable-label input { flex: none; margin: 2px 0 0; }
.acc-enable-label b { display: block; font-weight: 500; color: var(--text); }
.acc-enable-note { display: block; margin-top: 2px; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
@media (max-width: 760px) {
  .acc-grid3, .model-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet.account-sheet { width: 100%; }
  .scrim:has(> .account-sheet) { padding: 10px; }
}
@media (max-width: 520px) {
  .acc-grid2, .acc-grid3, .model-grid { grid-template-columns: 1fr; }
  .sheet.account-sheet { width: 100%; }
}

/* ---------- accounts page: tabs, filtering, pagination, row switches ---------- */
.accounts-page, .fit-page { display: flex; flex-direction: column; height: calc(100vh - 50px); min-height: 480px; } /* the list scrolls inside its card */
.accounts-top { margin-bottom: 10px; }
.acc-tabs { flex: none; }
.page-filter { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.acc-search { display: flex; align-items: center; gap: 7px; width: min(320px, 46vw); height: 32px; padding: 0 6px 0 10px; border-radius: 10px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--sep); color: var(--text-3); cursor: text; transition: background .15s, box-shadow .15s, color .15s; }
.acc-search:focus-within { background: var(--card-solid); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-tint); }
.acc-search > svg { width: 15px; height: 15px; flex: none; }
.acc-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; padding: 0; background: none; font: inherit; font-size: 13px; color: var(--text); -webkit-appearance: none; appearance: none; }
.acc-search input::placeholder { color: var(--text-3); }
.acc-search input::-webkit-search-cancel-button { display: none; }
.acc-search-x { flex: none; display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: var(--fill-hover); color: var(--text-2); cursor: pointer; }
.acc-search-x[hidden] { display: none; }
.acc-search-x svg { width: 11px; height: 11px; stroke-width: 2.4; }
.acc-search-x:hover { color: var(--text); }
.page-filter .sub { margin-left: auto; }
.page-card { flex: 1 1 auto; min-height: 320px; display: flex; flex-direction: column; overflow: hidden; }
.page-card .table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; }
.page-card .t thead th { position: sticky; top: 0; z-index: 1; background: var(--card-solid); }
.page-foot { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 0.5px solid var(--sep); }
.page-foot .sub { color: var(--text-3); }
.page-foot .spacer { flex: 1; }
.acc-name { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.acc-name-text { min-width: 0; }
.acc-off .acc-name-text { opacity: .55; }
.acc-name .switch { margin-top: -1px; }
@media (max-width: 760px) {
  .page-filter { flex-wrap: nowrap; }
  .acc-search { width: auto; flex: 1 1 auto; min-width: 0; height: 34px; }
  .acc-search input { font-size: 14px; }
  .page-filter .sub { display: none; }
  .accounts-page, .fit-page { height: calc(100dvh - 92px); min-height: 0; overflow: hidden; }
  .page-card { flex: 1 1 auto; min-height: 0; overflow: hidden; }
  .page-card .table-wrap { flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; }
}

/* Rows: desktop table and phone cards share these pieces. */
.accounts-page > *, .fit-page > * { flex-shrink: 0; }
.accounts-page > .page-card, .fit-page > .page-card { flex-shrink: 1; }
.acc-top-acts { display: flex; gap: 8px; flex: none; }
.acc-table td { vertical-align: top; padding-top: 13px; padding-bottom: 13px; white-space: normal; word-break: keep-all; }
.acc-table .acc-note { word-break: normal; }
.acc-table th:nth-child(1) { width: 23%; }
.acc-table th:nth-child(2) { width: 20%; }
.acc-table th:nth-child(3) { width: 23%; }
.acc-acts .btn.icon, .acc-card-foot .btn.icon { width: 26px; }
.acc-acts .btn.icon svg, .acc-card-foot .btn.icon svg { width: 16px; height: 16px; stroke-width: 2.6; }
.acc-table td.r { white-space: nowrap; width: 1%; }
.acc-title { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-name-text .sub { margin-top: 2px; line-height: 1.45; }
.acc-node { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; min-width: 0; }
.acc-node .badge { align-self: center; height: 18px; padding: 0 6px; font-size: 10.5px; }
.acc-ip { font: 11.5px/1.4 var(--mono); color: var(--text-3); }
.acc-k { flex: none; min-width: 34px; color: var(--text-3); font-size: 11px; }
.acc-table .badge + .sub, .acc-note + .sub { margin-top: 5px; }
.acc-note { margin-top: 5px; max-width: 280px; color: var(--red); font-size: 11.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.acc-acts { display: inline-flex; gap: 6px; }
.acc-off .acc-title, .acc-off .acc-node { opacity: .55; }
.acc-up { color: var(--green); }
.acc-down { color: var(--red); }
.acc-check-all.busy svg { animation: spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .acc-check-all.busy svg { animation: none; } }
.acc-enable-label .switch { margin-top: 1px; }
.acc-enable-label .switch input { margin: 0; }

/* Switching an account on or off: a small centred confirm. */
.sheet.toggle-sheet { width: min(320px, 100%); }
.toggle-sheet .sheet-body { padding: 24px 22px 4px; }
.tg-top { display: flex; flex-direction: column; align-items: center; text-align: center; }
.tg-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 12px; }
.tg-icon svg { width: 24px; height: 24px; }
.tg-icon.on { background: var(--green-tint); color: var(--green); }
.tg-icon.off { background: var(--orange-tint); color: var(--orange); }
.tg-title { font-size: 15px; font-weight: 600; color: var(--text); }
.tg-name { max-width: 100%; margin-top: 8px; padding: 3px 10px; border-radius: 999px; background: var(--fill-2); font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-text { margin: 10px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--text-3); }
.toggle-sheet .sheet-foot { padding-top: 18px; }
.toggle-sheet .actions .btn { flex: 1; height: 36px; }
/* Account row details */
.acc-ip { display: block; margin-top: 2px; }
.acc-bk { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 240px; margin-top: 3px; font-size: 12px; color: var(--text-3); }
.acc-bk-v { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-bk .badge { flex: none; height: 18px; padding: 0 6px; font-size: 10.5px; }
.acc-facts { margin-top: 6px; font-size: 12px; line-height: 1.6; color: var(--text-3); }
.acc-facts > span { display: block; white-space: nowrap; }
.acc-card .acc-facts > span { display: inline; }
.acc-card .acc-facts > span + span::before { content: " · "; }
.acc-u { width: 11%; }
.acc-table th, .acc-table td { padding-left: 10px; padding-right: 10px; }
.acc-table th:first-child, .acc-table td:first-child { padding-left: 20px; }
.acc-table th:last-child, .acc-table td:last-child { padding-right: 16px; }
.uq + .uq { margin-top: 5px; }
.uq-v { display: block; line-height: 20px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.uq-v b { font-size: 13px; font-weight: 500; color: var(--text); }
.uq-v small { font-size: 11px; color: var(--text-3); }
.uq-v .uq-u { margin-left: 3px; }
.um-bar { display: block; width: 84px; max-width: 100%; height: 3px; margin-top: 2px; border-radius: 2px; background: var(--fill-hover); overflow: hidden; }
.um-bar > i { display: block; height: 100%; border-radius: 2px; background: var(--green); }
.um-bar.orange > i { background: #ff9f0a; }
.um-bar.red > i { background: #ff3b30; }
.acc-off .acc-u, .acc-off .acc-ip, .acc-off .acc-stats { opacity: .55; }
.acc-empty { margin: 0; padding: 28px 16px; text-align: center; color: var(--text-3); font-size: 13px; }

/* Phone: one card per account / node instead of a squeezed table. */
.acc-cards { display: flex; flex-direction: column; }
.acc-card { padding: 14px 0 12px; }
.acc-card:first-child { padding-top: 2px; }
.acc-card + .acc-card { border-top: 0.5px solid var(--sep); }
.acc-card-head { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
.acc-card-head .acc-name-text { flex: 1; }
.acc-card-head .switch { margin-top: -1px; }
.acc-card-state { flex: none; }
.acc-card-head + .acc-note { margin: 6px 0 0; }
.acc-kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 14px; margin: 12px 0 0; padding: 11px 12px; border-radius: 12px; background: var(--fill-2); font-size: 12.5px; line-height: 1.45; }
.acc-kv dt { color: var(--text-3); font-size: 11.5px; line-height: 1.6; }
.acc-kv dd { margin: 0; min-width: 0; color: var(--text); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.acc-kv dd.mono { font-size: 12px; }
.acc-kv dd .sub { margin-top: 4px; font-size: 11.5px; }
.acc-kv .acc-note { max-width: none; }
.acc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--fill-2); }
.as-h { margin-bottom: 4px; font-size: 11.5px; color: var(--text-3); }
.acc-stats .um-bar { width: 100%; }
.acc-card-foot { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
@media (min-width: 761px) and (max-width: 1260px) {
  .acc-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
  .acc-card, .acc-card:first-child { padding: 14px 14px 12px; border-radius: 14px; box-shadow: inset 0 0 0 0.5px var(--sep); }
  .acc-card + .acc-card { border-top: 0; }
}
@media (max-width: 760px) {
  .accounts-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 12px; }
  .accounts-top .acc-head { display: contents; }
  .accounts-top h1 { grid-column: 1; grid-row: 1; }
  .accounts-top .acc-top-acts { grid-column: 2; grid-row: 1; }
  .accounts-top .acc-head .sub { grid-column: 1 / -1; grid-row: 2; margin-top: -6px; }
  .accounts-top .spacer { display: none; }
  .accounts-top .seg { grid-column: 1 / -1; grid-row: 3; width: 100%; }
  .acc-top-acts .btn { height: 32px; padding: 0 13px; }
  .accounts-page .page-foot { flex-wrap: wrap; }
}

/* Usage failure details: a short reason in the row, full text only in the drawer. */
.err-reason { margin-top: 3px; color: var(--text-3); font-size: 11px; }
.err-detail span:last-child, .dr-list .err-detail span:last-child { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- account import: dropzone, steps, preview cards ---------- */
.sheet.import-sheet { width: min(760px, calc(100vw - 32px)); }
.imp-drop {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  min-height: 92px; padding: 16px 16px; border-radius: 16px; cursor: pointer;
  border: 1px dashed color-mix(in srgb, var(--accent) 34%, var(--sep));
  background: color-mix(in srgb, var(--accent) 4%, var(--card-solid));
  transition: border-color .15s, background .15s, transform .1s;
}
.imp-drop:hover, .imp-drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card-solid)); }
.imp-drop.over { transform: scale(1.005); }
.imp-drop-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-tint); color: var(--accent); }
.imp-drop-icon svg { width: 20px; height: 20px; }
.imp-drop-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.imp-drop-copy b { font-size: 13px; font-weight: 600; }
.imp-file { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); font-size: 11.5px; }
.imp-drop.has-file .imp-file { color: var(--accent); }
.imp-formats { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 10px 2px 2px; }
.imp-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--fill-2); color: var(--text-2); font-size: 10.5px; white-space: nowrap; }
.imp-preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 20px 2px 8px; }
.imp-preview-head b { font-size: 12.5px; }
.imp-preview-head .sub { margin-left: 8px; }
.imp-cards { display: flex; flex-direction: column; gap: 8px; }
.imp-card { padding: 12px 14px; border-radius: 14px; background: var(--card-solid); box-shadow: inset 0 0 0 0.5px var(--card-edge); }
.imp-card.error { background: color-mix(in srgb, var(--red) 4%, var(--card-solid)); }
.imp-card-head { display: flex; align-items: center; gap: 10px; }
.imp-avatar { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--accent-tint); color: var(--accent); font-size: 12px; font-weight: 600; }
.imp-card-title { min-width: 0; flex: 1; }
.imp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
.imp-card-title .sub { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-card-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.imp-node { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 9px; }
.imp-node-label { color: var(--text-3); font-size: 11px; }
.imp-node .input { height: 32px; font-size: 12px; }
.imp-detail { margin-top: 8px; font-size: 11.5px; color: var(--text-3); }
.imp-detail.error { color: var(--red); }
.imp-actions { align-items: center; }
.imp-actions .imp-count { margin-right: auto; color: var(--text-3); font-size: 11.5px; }
.account-import-error { margin: 12px 2px 0; color: var(--red); font-size: 12px; }
@media (max-width: 620px) {
  .sheet.import-sheet { width: calc(100vw - 20px); }
  .imp-drop { grid-template-columns: auto minmax(0, 1fr); }
  .imp-file { grid-column: 1 / -1; max-width: none; }
  .imp-drop .btn { grid-column: 1 / -1; justify-self: start; }
  .imp-actions { flex-wrap: wrap; }
  .imp-actions .imp-count { width: 100%; }
}

/* ---------- safety page + settings section ---------- */
.safety-toolbar { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.safety-toolbar .input { width: 168px; }
.safety-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 12px; }
.safety-stats .stat { padding: 14px 18px; }
.safety-stats .stat-v { margin-top: 4px; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.safety-stats .stat-v.orange { color: var(--orange); }
.safety-stats .stat-v.red { color: var(--red); }
@media (max-width: 760px) {
  .safety-toolbar .input { flex: 1 1 42%; width: auto; }
  .safety-stats { grid-template-columns: 1fr 1fr; }
}
.safety-toolbar .dd { min-width: 150px; }
.safety-toolbar .dd { height: 30px; min-width: 150px; justify-content: space-between; padding-right: 9px; }

/* ---------- admin keys: filters over a one-screen list ---------- */
.fit-page > .topbar { margin-bottom: 12px; }
.keys-filter { flex-wrap: wrap; gap: 8px 10px; }
.keys-filter .seg button { display: inline-flex; align-items: center; gap: 5px; }
.seg-n { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.seg button.on .seg-n { color: var(--text-2); }
.k-name { font-weight: 500; }
.k-who { display: inline-flex; align-items: center; gap: 8px; }
.k-off td > * { opacity: .55; }
.k-off td.act > * { opacity: 1; }
.k-none { padding: 28px 20px !important; text-align: center; }
@media (max-width: 760px) {
  .keys-filter { flex-wrap: wrap; }
  .keys-filter .acc-search { flex: 1 1 100%; }
  .keys-filter .seg { flex: 1 1 100%; }
  .keys-filter .seg button { flex: 1 1 auto; justify-content: center; padding: 0 7px; white-space: nowrap; }
  .keys-filter .dd { flex: 1 1 0; min-width: 0; max-width: none; height: 32px; justify-content: space-between; padding-right: 10px; }
  /* rows become two compact lines: name / member on the left, spend / last use on the right */
  .fit-page .t thead { display: none; }
  .fit-page .t, .fit-page .t tbody { display: block; width: 100%; }
  .fit-page .t tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "name cost act" "who used act"; column-gap: 12px; row-gap: 6px; align-items: center; padding: 12px 4px; border-top: 0.5px solid var(--sep); }
  .fit-page .t tbody tr:first-child { border-top: 0; }
  .fit-page .t td { display: block; padding: 0 !important; border: 0; white-space: nowrap; background: none !important; }
  .fit-page .t td:nth-child(1) { grid-area: name; min-width: 0; overflow: hidden; }
  .fit-page .t td:nth-child(1) .key-models { overflow: hidden; text-overflow: ellipsis; }
  .fit-page .t td:nth-child(2) { grid-area: who; font-size: 12px; color: var(--text-2); }
  .fit-page .t td:nth-child(2) .k-who { gap: 6px; }
  .fit-page .t td:nth-child(2) .avatar { width: 18px; height: 18px; font-size: 9px; }
  .fit-page .t td:nth-child(3), .fit-page .t td:nth-child(6) { display: none; }
  .fit-page .t td:nth-child(4) { grid-area: cost; text-align: right; font-weight: 500; }
  .fit-page .t td:nth-child(5) { grid-area: used; text-align: right; font-size: 12px; }
  .fit-page .t td.act { grid-area: act; }
  .fit-page .t td.k-none { grid-column: 1 / -1; }
  .fit-page .t tbody tr:has(.k-none) { display: block; }
}

/* ---------- a redeem batch: summary + code list ---------- */
.rd-sheet h3 { display: flex; align-items: center; gap: 10px; }
.rd-ic { width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--orange-tint); color: var(--orange); }
.rd-ic svg { width: 16px; height: 16px; }
.rd-sheet .sheet-head .lead { margin: 4px 0 14px 38px; }
.rd-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.rd-stats > div { padding: 10px 12px; border-radius: 12px; background: var(--fill-2); min-width: 0; }
.rd-k { display: block; font-size: 11px; color: var(--text-3); margin-bottom: 3px; }
.rd-v { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.rd-v b { font-size: 14px; font-weight: 600; color: var(--text); }
.rd-v small, .rd-stats small { font-size: 11.5px; color: var(--text-3); }
.rd-stats > div > small { display: block; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-stats .meter { height: 4px; margin-top: 7px; }
.rd-stats .rd-warn { color: var(--orange); }
.rd-list { list-style: none; margin: 0; padding: 4px 0; border-radius: 12px; box-shadow: inset 0 0 0 0.5px var(--sep); }
.rd-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr) 150px 76px; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px 0 12px; }
.rd-list li + li { box-shadow: 0 -0.5px 0 var(--sep); }
.rd-i { font-size: 11px; color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.rd-code { font-family: var(--mono); font-size: 12.5px; color: var(--text); letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-mask { color: var(--text-3); }
.rd-st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.rd-st small { margin-left: 2px; color: var(--text-3); font-size: 11px; }
.rd-st.ok { color: var(--text); }
.dot.blue { background: var(--accent); }
.rd-act { display: flex; justify-content: flex-end; }
.rd-act .btn.sure { background: var(--red); color: #fff; }
.rd-list li.dead .rd-code { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-3); }
.rd-sheet .actions .rd-all { margin-right: auto; }
@media (max-width: 520px) {
  .rd-stats { gap: 6px; }
  .rd-stats > div { padding: 9px 10px; }
  .rd-v b { font-size: 13px; }
  .rd-list li { grid-template-columns: 16px minmax(0, 1fr) 70px 40px; gap: 8px; min-height: 40px; padding: 0 6px 0 8px; }
  .rd-code { font-size: 12px; letter-spacing: 0; }
  .rd-st { font-size: 11.5px; gap: 5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .rd-st small { display: none; }
  .rd-act .btn { padding: 0 6px; }
  .rd-sheet .sheet-head .lead { margin-left: 0; }
}
.rd-act .btn.ghost { color: var(--red); }
.rd-act .btn.ghost:hover { background: var(--red-tint); }
.rd-act .btn.ghost.sure { background: var(--red); color: #fff; }

/* ---------- add / edit member ---------- */
.sheet.member-sheet { width: min(480px, 100%); }
.member-sheet h3 { margin-bottom: 2px; }
.mf-head { display: flex; align-items: center; gap: 12px; }
.mf-head small { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--text-3); }
.mf-av .avatar { width: 40px; height: 40px; font-size: 16px; }
.mf-av .avatar.mf-blank { background: var(--fill-hover); color: var(--text-3); box-shadow: none; }
.mf-blank svg { width: 20px; height: 20px; }
.member-sheet .sheet-head { padding-bottom: 14px; }
.mf-names { margin-top: 0 !important; }
.mf-sec { margin: 20px 0 8px; font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .02em; }
.mf-group { border-radius: 12px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--sep); }
.mf-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 52px; padding: 8px 12px 8px 14px; cursor: pointer; }
.mf-row + .mf-row { box-shadow: 0 -0.5px 0 var(--sep); }
.mf-l { display: block; min-width: 0; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer; }
.mf-l small { display: block; margin-top: 2px; font-size: 11.5px; font-weight: 400; color: var(--text-3); line-height: 1.4; }
.mf-row .input { flex: none; height: 32px; background: var(--card-solid); text-align: right; font-variant-numeric: tabular-nums; }
.mf-num { width: 72px; }
.mf-money { position: relative; flex: none; }
.mf-money i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12.5px; color: var(--text-3); pointer-events: none; }
.mf-money .input { width: 104px; padding-left: 22px; }
.mf-money .input:disabled { opacity: .45; }
.mf-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mf-role { display: flex; flex-direction: column; gap: 3px; padding: 11px 13px; border: 0; border-radius: 12px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--sep); text-align: left; font: inherit; color: var(--text); cursor: pointer; transition: box-shadow .15s, background .15s; }
.mf-role:hover { background: var(--fill-hover); }
.mf-role.on { background: var(--accent-tint); box-shadow: inset 0 0 0 1.5px var(--accent); }
.mf-role-t { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; }
.mf-role-t svg { width: 15px; height: 15px; color: var(--accent); stroke-width: 2.4; opacity: 0; transition: opacity .15s; }
.mf-role.on .mf-role-t svg { opacity: 1; }
.mf-role-d { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }
.mf-role:focus-visible { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-tint); }
@media (max-width: 520px) {
  .mf-names { grid-template-columns: 1fr; }
}
.protocol-report { margin: 8px 0 0; padding: 12px; max-height: 420px; overflow: auto; border-radius: 10px; background: var(--fill-2); color: var(--text-2); font-size: 11.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.protocol-detail summary { cursor: pointer; color: var(--accent); font-size: 12px; }
.protocol-sheet { max-width: 760px; width: min(760px, calc(100vw - 32px)); }
.protocol-sheet .protocol-report { max-height: min(56vh, 520px); margin-top: 12px; }
.canary-card { margin-top: 14px; padding: 16px; }
.canary-head { display:flex; align-items:baseline; gap:10px; margin-bottom:12px; }
.canary-head h3 { margin:0; }
.canary-controls { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.canary-list { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.canary-item { display:inline-flex; align-items:center; gap:6px; padding:4px 4px 4px 10px; border-radius:10px; background:var(--fill-2); font-size:12px; }
.canary-item code { color:var(--text-2); }

/* No double-tap zoom on buttons and links; pinch zoom still works. */
html { touch-action: manipulation; }

/* Overview stats on a phone: this month's spend gets its own row (with its
   sparkline), the other three sit side by side as small tiles. */
.ov-short { display: none; }
@media (max-width: 760px) {
  .ov .grid.g4 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .ov .g4 > .ov-hero { grid-column: 1 / -1; padding: 16px 18px; }
  .ov .g4 > .ov-hero .spark { display: block; top: 18px; right: 18px; width: 96px; height: 32px; }
  .ov .g4 > .ov-hero .value { font-size: 26px; }
  .ov .g4 > .stat:not(.ov-hero) { padding: 12px 12px 11px; }
  .ov .g4 > .stat:not(.ov-hero) .label { font-size: 11.5px; }
  .ov .g4 > .stat:not(.ov-hero) .value { font-size: 18px; margin-top: 4px; }
  .ov .g4 > .stat:not(.ov-hero) .value small { font-size: 11px; margin-left: 2px; }
  .ov .g4 > .stat:not(.ov-hero) .foot { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ov .ov-long { display: none; }
  .ov .ov-short { display: inline; }
}
@media (max-width: 340px) { .ov .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Sidebar: the brand on top and the account rows at the bottom stay put; only
   the page links scroll, fading out under either edge. The side padding keeps
   the active pill's shadow from being clipped by the scroller. */
body.app .sidebar { overflow: hidden; }
body.app .sidebar .nav-groups {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  margin: -8px -6px 0; padding: 8px 6px 14px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 8px, #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 8px, #000 calc(100% - 14px), transparent 100%);
}
body.app .sidebar .nav-groups::-webkit-scrollbar { display: none; }
body.app .sidebar .nav-gap { flex: none; min-height: 0; height: 0; margin: 0 8px 8px; }
body.app .sidebar .nav-groups .nav-item { scroll-margin-block: 10px 18px; }

/* channel form: unit inside the number box, official-address shortcuts */
.ch-nums { margin-top: 14px; }
.in-unit { position: relative; display: block; }
.in-unit .input { width: 100%; padding-right: 34px; }
.in-unit i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12.5px; color: var(--text-3); pointer-events: none; }
.url-presets { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.chip-btn { height: 22px; padding: 0 9px; border: 0; border-radius: 999px; background: var(--fill-2); box-shadow: inset 0 0 0 0.5px var(--sep); color: var(--accent-text); font: inherit; font-size: 11.5px; font-weight: 500; cursor: pointer; }
.chip-btn:hover { background: var(--accent-tint); }
@media (max-width: 520px) {
  .ch-nums { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}

/* sale-group form: name wide, rate narrow with its unit inside */
.g-top { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.in-unit.wide .input { padding-right: 68px; }
@media (max-width: 520px) { .g-top { grid-template-columns: minmax(0, 1fr); gap: 14px; } }

/* Usage filters: the member dropdown matches the segmented controls beside it. */
.toolbar .dd { height: 30px; font-size: 12.5px; }
@media (max-width: 760px) {
  .toolbar .dd { height: 32px; }
  .toolbar .seg button { height: 28px; }
}

/* Usage log on a phone: each request is two short lines instead of a table
   that runs off the right edge.
     ● 18:01  管理员 · ccmax                 $0.59
              claude-opus-4-1 · 流式      成本 $0.00   */
@media (max-width: 760px) {
  .t.usage thead { display: none; }
  .t.usage, .t.usage tbody { display: block; width: 100%; }
  .t.usage tr.u-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "time who cost" ". model cost"; column-gap: 10px; row-gap: 3px; align-items: baseline; padding: 10px 16px 10px 14px; border-top: 0.5px solid var(--sep); }
  .t.usage tr.u-row td { display: block; padding: 0 !important; border: 0 !important; background: none !important; min-width: 0; }
  .t.usage tr.u-row td:nth-child(1) { grid-area: time; font-size: 12.5px; }
  .t.usage tr.u-row td:nth-child(2) { grid-area: who; }
  .t.usage tr.u-row td:nth-child(3) { grid-area: model; }
  .t.usage tr.u-row td:nth-child(4), .t.usage tr.u-row td:nth-child(6), .t.usage tr.u-row td:nth-child(7) { display: none; }
  .t.usage tr.u-row td:nth-child(5) { grid-area: cost; align-self: start; text-align: right; }
  .t.usage tr.u-row td:nth-child(2) .who .avatar { display: none; }
  .t.usage tr.u-row td:nth-child(2) .who, .t.usage tr.u-row td:nth-child(2) .who > div { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
  .t.usage tr.u-row td:nth-child(2) .strong, .t.usage tr.u-row td:nth-child(2) .sub,
  .t.usage tr.u-row td:nth-child(3) .strong, .t.usage tr.u-row td:nth-child(3) .sub { max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .t.usage tr.u-row td:nth-child(2) .strong { font-size: 13.5px; flex: 0 1 auto; }
  .t.usage tr.u-row td:nth-child(2) .sub { flex: 0 1 auto; }
  .t.usage tr.u-row td:nth-child(2) .sub::before { content: "· "; }
  .t.usage tr.u-row td:nth-child(3) { display: flex; align-items: baseline; gap: 6px; }
  .t.usage tr.u-row td:nth-child(3) .strong { font-size: 12px; font-weight: 400; color: var(--text-2); flex: 0 1 auto; }
  .t.usage tr.u-row td:nth-child(3) .sub { flex: 0 1 auto; }
  .t.usage tr.u-row td:nth-child(3) .sub::before { content: "· "; }
  .t.usage tr.u-row td:nth-child(5) .strong { font-size: 13.5px; }
  .t.usage tr.u-row td:nth-child(5) .sub { margin-top: 3px; }
  /* day bands: label on the left, the day's total on the right */
  .t.usage tr.day { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 16px 7px 14px; border-top: 0.5px solid var(--sep); background: color-mix(in srgb, var(--fill-2) 55%, transparent); }
  .t.usage tbody tr.day:first-child { border-top: 0; }
  .t.usage tr.day td { display: none; padding: 0 !important; border: 0 !important; background: none !important; }
  .t.usage tr.day td:nth-child(1), .t.usage tr.day td:nth-child(5) { display: block; padding: 0 !important; }
  .t.usage tr.day .day-l { width: auto; }
  .t.usage tr.day + tr.u-row { border-top: 0; }
}

/* Dropdowns inside filter bars read like the segmented buttons next to them:
   same size, weight and grey, instead of the bigger black general one. */
.toolbar .dd, .safety-toolbar .dd, .keys-filter .dd { font-size: 12px; font-weight: 500; color: var(--text-2); }
.toolbar .dd[aria-expanded="true"], .safety-toolbar .dd[aria-expanded="true"], .keys-filter .dd[aria-expanded="true"] { color: var(--text); }
@media (max-width: 720px) {
  .toolbar .dd, .safety-toolbar .dd, .keys-filter .dd { font-size: 12.5px; }
  .toolbar .seg button, .safety-toolbar .seg button, .keys-filter .seg button { font-size: 12.5px; }
}
/* Safety filters on a phone: the date range on its own row, the two dropdowns side by side. */
@media (max-width: 760px) {
  .safety-toolbar .seg { flex: 1 1 100%; }
  .safety-toolbar .seg button { flex: 1; }
  .safety-toolbar .dd { flex: 1 1 0; min-width: 0; max-width: none; height: 32px; }
  .safety-toolbar .seg button { height: 28px; }
}
.keys-filter .dd { height: 30px; }
@media (max-width: 760px) { .keys-filter .dd { height: 32px; } .keys-filter .seg button { height: 28px; } }

/* Card titles never break into a vertical column of characters; a long hint
   beside them wraps instead, starting level with the title. */
.card-head h2 { flex: none; white-space: nowrap; }
.card-head .hint { min-width: 0; line-height: 1.45; }
.card-head:has(> .hint) { align-items: baseline; }
.card-head:has(> .hint):has(> .btn, > .seg, > .dd, > a.btn) { align-items: center; }

/* Cache tables on a phone: each row becomes
     name                              [badge]
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  78%
     请求 2,211  缓存读 62M  缓存写 7.5M  省下 $3.10   */
@media (max-width: 760px) {
  .cache-t thead { display: none; }
  .cache-t, .cache-t tbody { display: block; width: 100%; }
  .cache-t tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 18px; border-top: 0.5px solid var(--sep); }
  .cache-t tbody tr:first-child { border-top: 0; }
  .cache-t td { display: block; padding: 0 !important; border: 0 !important; background: none !important; white-space: nowrap; }
  .cache-t td:nth-child(1) { order: 1; flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
  .cache-t td:nth-child(7) { order: 2; flex: none; }
  .cache-t td:nth-child(7):empty { display: none; }
  .cache-t td:nth-child(3) { order: 3; flex: 1 1 100%; }
  .cache-t td[data-l] { order: 4; flex: none; text-align: left; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
  .cache-t td[data-l]::before { content: attr(data-l) " "; color: var(--text-3); }
}

/* Sign-in pages on phones. The page itself paints the background, not the
   form panel, so whatever the phone lets you scroll to (below the panel while
   the keyboard is up, or the extra height when Safari hides its bars) looks
   the same instead of showing a flat band. Height is the visible height (svh),
   not the taller 100vh, and while the keyboard is up the card sits at the top. */
@media (max-width: 900px) {
  html:has(body.auth), body.auth { background: var(--ambient), var(--bg); background-attachment: scroll; }
  body.auth, .auth-split, .auth-side { min-height: 100vh; min-height: 100svh; }
  .auth-side { background: none; }
  body.auth.kb .auth-side { place-items: start center; padding-top: 16px; padding-bottom: 16px; }
}

/* No grey/blue flash from the phone browser on tap; each control shows its
   own pressed state instead, so taps still feel answered. */
html { -webkit-tap-highlight-color: transparent; }
@media (hover: none) {
  .nav-item:active:not(.active), .menu button:active, .pick-row:active, .rb-row:active, .chip-btn:active,
  .mf-role:active, .acc-search-x:active, .input-wrap .eye:active, .dd:active { background: var(--fill-hover); }
  .seg button:active:not(.on) { background: var(--fill-2); }
  .switch:active span::after { width: 24px; }
  .switch input:checked:active + span::after { transform: translateX(10px); }
  .menu button, .pick-row, .seg button, .dd, .chip-btn, .mf-role { transition: background .12s; } /* not .nav-item: its highlight must switch in one frame */
}
