/* Nova AI · 用量看板 — dashboard-only components.
   Tokens, reset, brand, buttons, tags and the card base live in base.css. */

html, body { height: 100%; }

/* ── sign in ───────────────────────────────────────────────────────── */

.signin {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: var(--sp-5) var(--sp-4);
  padding-bottom: max(var(--sp-5), env(safe-area-inset-bottom));
}

.signin__card {
  width: 100%; max-width: 420px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
  box-shadow: var(--shadow);
}

.signin__title { font-size: 22px; font-weight: 650; letter-spacing: -.02em; text-align: center; }
.signin__sub {
  margin: var(--sp-2) 0 var(--sp-5);
  color: var(--text-secondary); font-size: 14px; text-align: center;
}
.signin__note {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  margin-top: var(--sp-4);
  color: var(--text-muted); font-size: 12.5px; line-height: 1.45;
}
.signin__note .icon { margin-top: 2px; font-size: 14px; }
.signin__back {
  display: block; margin-top: var(--sp-4);
  color: var(--text-muted); font-size: 12.5px; text-align: center;
  text-decoration: none;
}
.signin__back:hover { color: var(--text-secondary); text-decoration: underline; }

/* ── form controls ─────────────────────────────────────────────────── */

.field { display: block; }
.field__label { display: block; margin-bottom: var(--sp-2); font-size: 13px; font-weight: 550; color: var(--text-secondary); }
.field__wrap { position: relative; display: block; }

.field__input {
  width: 100%;
  padding: 11px 48px 11px 12px;
  background: var(--page);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field__input::placeholder { color: var(--text-muted); }
.field__input:hover { border-color: rgba(255, 255, 255, .26); }
.field__input:focus { outline: none; border-color: var(--series-1); box-shadow: 0 0 0 3px rgba(57, 135, 229, .22); }

.field__reveal {
  position: absolute; inset-inline-end: 1px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--text-muted); font-size: 17px; cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.field__reveal:hover { color: var(--text-primary); background: var(--surface-3); }

.field__help { display: block; margin-top: var(--sp-2); color: var(--text-muted); font-size: 12.5px; }

.check {
  display: flex; align-items: center; gap: var(--sp-2);
  margin: var(--sp-4) 0 var(--sp-3);
  min-height: 44px; cursor: pointer; user-select: none;
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check__box {
  width: 18px; height: 18px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--border-strong); border-radius: 5px;
  background: var(--page); color: transparent; font-size: 13px;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.check input:checked + .check__box { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.check input:focus-visible + .check__box { box-shadow: var(--ring); }
.check__text { font-size: 13.5px; color: var(--text-secondary); }

/* ── top bar ───────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(10, 14, 23, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1240px; margin: 0 auto;
  padding: var(--sp-3) var(--sp-4);
  padding-inline: max(var(--sp-4), env(safe-area-inset-left)) max(var(--sp-4), env(safe-area-inset-right));
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
}
.topbar__actions { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }

/* Below 760px the controls move to their own row so the brand and the key
   chip never compete for the same line. */
@media (max-width: 760px) {
  .topbar__inner { flex-wrap: wrap; row-gap: var(--sp-2); }
  .brand__divider, .brand__page { display: none; }
  .keychip { max-width: none; }
  .topbar__actions { flex: 1 0 100%; }
  .select { flex: 1; min-width: 0; }
  .select select { width: 100%; }
}

.keychip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  margin-inline-start: auto;   /* brand left, chip + controls right */
  max-width: 46vw; padding: 5px 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; font-size: 12.5px;
}
.keychip__alias { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.keychip__mask { color: var(--text-muted); font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; }

.select { position: relative; display: inline-flex; align-items: center; }
.select__icon {
  position: absolute; inset-inline-start: 11px; font-size: 15px;
  color: var(--text-muted); pointer-events: none;
}
.select select {
  appearance: none;
  min-height: 44px; padding: 0 var(--sp-4) 0 34px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  color: var(--text-primary); font: inherit; font-size: 13.5px; cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.select select:hover { background: var(--surface-3); border-color: var(--border-strong); }

/* ── page grid ─────────────────────────────────────────────────────── */

.page {
  max-width: 1240px; margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-6);
  padding-inline: max(var(--sp-4), env(safe-area-inset-left)) max(var(--sp-4), env(safe-area-inset-right));
  padding-bottom: max(var(--sp-6), env(safe-area-inset-bottom));
  display: grid; gap: var(--sp-4);
}

.grid { display: grid; gap: var(--sp-4); }
.grid--hero  { grid-template-columns: 1fr; }

@media (min-width: 720px) {
  .grid--hero  { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
}

/* ── card internals ────────────────────────────────────────────────── */

.card__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4);
}
.card__title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.card__hint  { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.card__label {
  display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap;
  color: var(--text-secondary); font-size: 13px; font-weight: 550;
}
.card__range { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.card__tools { display: flex; align-items: center; gap: var(--sp-2); }

/* ── hero figure ───────────────────────────────────────────────────── */

/* Centred so the card reads as deliberate when the budget card beside it
   stretches the row taller — more so now that it carries the token figure too. */
.card--hero { display: flex; flex-direction: column; justify-content: center; }

.hero {
  margin-top: var(--sp-2);
  font-size: clamp(38px, 8vw, 54px);
  font-weight: 650; line-height: 1.05; letter-spacing: -.035em;
}

/* ── budget meter ──────────────────────────────────────────────────── */

.card--budget { display: flex; flex-direction: column; gap: var(--sp-3); }

.meter__top { display: flex; align-items: baseline; gap: var(--sp-2); margin-top: var(--sp-3); }
.meter__value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.meter__limit { color: var(--text-muted); font-size: 13.5px; }

.meter__track {
  height: 10px; border-radius: 999px; overflow: hidden;
  background: rgba(57, 135, 229, .18);   /* lighter step of the fill's own ramp */
}
.meter__fill {
  height: 100%; border-radius: 999px; background: var(--series-1);
  transition: width 420ms var(--ease), background var(--dur) var(--ease);
}
.meter.is-warning .meter__fill  { background: var(--warning); }
.meter.is-warning .meter__track { background: rgba(250, 178, 25, .18); }
.meter.is-critical .meter__fill  { background: var(--critical); }
.meter.is-critical .meter__track { background: rgba(208, 59, 59, .2); }

.meter__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3);
}
.meter__reset { color: var(--text-muted); font-size: 12.5px; }

/* Concurrent budget windows stack inside the one card. A rule divides them so
   two meters never read as a single split bar; the duration heading carries the
   identity, so the meters themselves stay identical to the single-budget one. */
.budget-win + .budget-win {
  margin-top: var(--sp-4); padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}
.budget-win__label { color: var(--text-muted); font-size: 12.5px; font-weight: 550; }
.budget-win .meter__top { margin-top: var(--sp-2); }

/* ── secondary metric ──────────────────────────────────────────────── */

.stat { display: flex; flex-direction: column; gap: var(--sp-1); }

/* Rides under the hero figure, divided from it so the headline spend stays the
   one thing the card leads with. */
.hero__meta {
  margin-top: var(--sp-4); padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}
.stat__label {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-secondary); font-size: 12.5px; font-weight: 550;
}
.stat__label .icon { font-size: 15px; color: var(--text-muted); }
.stat__value { font-size: clamp(21px, 3.4vw, 26px); font-weight: 650; letter-spacing: -.02em; }
.stat__sub   { color: var(--text-muted); font-size: 12px; }

/* ── chart ─────────────────────────────────────────────────────────── */

.card--chart { padding-bottom: var(--sp-3); }
.chart { position: relative; height: 300px; }
@media (max-width: 640px) { .chart { height: 240px; } }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
}
.segmented__btn {
  min-height: 36px; padding: 0 var(--sp-3);
  background: none; border: 0; border-radius: 7px;
  color: var(--text-secondary); font: inherit; font-size: 13px; font-weight: 550;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.segmented__btn:hover { color: var(--text-primary); }
.segmented__btn.is-active { background: var(--surface-3); color: var(--text-primary); }

/* ── tables ────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; margin-top: var(--sp-4); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
  padding: 9px var(--sp-3);
  text-align: start; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table th {
  color: var(--text-muted); font-weight: 550; font-size: 12px;
  position: sticky; top: 0; background: var(--surface-1);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }
.table .bar-col { width: 130px; }
@media (max-width: 640px) { .table .bar-col { display: none; } }
.table .model { font-family: var(--font-mono); font-size: 12.5px; }

.share { display: flex; align-items: center; gap: var(--sp-2); }
.share__track { flex: 1; min-width: 56px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.share__fill  { display: block; height: 100%; border-radius: 999px; }
.share__pct   { color: var(--text-muted); font-size: 11.5px; font-variant-numeric: tabular-nums; min-width: 34px; text-align: end; }

.empty { color: var(--text-muted); font-size: 13px; padding: var(--sp-5) 0; text-align: center; }

/* ── alerts, footer, loading ───────────────────────────────────────── */

.alert {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: 10px var(--sp-3); border-radius: var(--r-md);
  font-size: 13.5px;
}
.alert .icon { margin-top: 2px; font-size: 16px; flex: none; }
.alert--error { margin-top: var(--sp-3); background: rgba(208, 59, 59, .12); border: 1px solid rgba(208, 59, 59, .38); color: #f0a1a1; }

.foot {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  color: var(--text-muted); font-size: 12px;
}
.foot a { color: var(--text-secondary); text-decoration: none; }
.foot a:hover { color: var(--text-primary); }
.foot__sep { opacity: .5; }

.loading {
  position: fixed; inset-block-end: var(--sp-5); inset-inline-start: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px var(--sp-4);
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: 999px; box-shadow: var(--shadow);
  font-size: 13px; color: var(--text-secondary);
}
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--series-1);
  animation: spin 720ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page.is-stale { opacity: .55; transition: opacity var(--dur) var(--ease); }
