:root {
  --bg: #f2f0ea;
  --bg-accent: #e8e4d9;
  --surface: #ffffff;
  --surface-subtle: #f8f6f1;
  --line: #dfdbcf;
  --line-strong: #cbc5b8;
  --text: #14110f;
  --muted: #5e5850;
  --faint: #928b82;
  --accent: #221f1b;
  --accent-hover: #3d3831;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --danger: #b91c1c;
  --reserved: #57534e;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-soft: 0 8px 24px rgba(20, 17, 15, 0.06);
  --shadow-card: 0 14px 34px rgba(20, 17, 15, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI Variable", "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 480px at 10% -10%, var(--bg-accent), transparent 72%),
    linear-gradient(180deg, #f6f4ee 0%, var(--bg) 65%);
  -webkit-font-smoothing: antialiased;
}

.layout {
  width: min(1080px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 60px 0 84px;
}

.auth-panel,
.provider-card,
.limit-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Noto Serif SC", serif;
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: end;
  padding: 8px 0 28px;
  border-bottom: 1px solid rgba(94, 88, 80, 0.18);
}

.eyebrow,
.provider-kicker,
.limit-label {
  margin: 0 0 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
}

.hero-badge {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line-strong);
}

.subtitle {
  margin-top: 10px;
  max-width: 56ch;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

.limit-card {
  padding: 18px 22px;
  display: grid;
  gap: 2px;
  min-width: 180px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(248, 246, 241, 0.9));
}

.limit-card .limit-label {
  margin-bottom: 4px;
}

.limit-card strong {
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.limit-card small,
.status-line,
.snapshot-meta,
.provider-description {
  color: var(--muted);
}

.limit-card small {
  font-size: 12px;
}

.auth-panel {
  margin-top: 28px;
  padding: 22px 24px;
}

.auth-panel > div > p {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.login-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.login-form label {
  width: 100%;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

input,
button {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  font: inherit;
}

input {
  flex: 1 1 280px;
  min-width: 0;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

input::placeholder {
  color: var(--faint);
}

input:focus-visible {
  outline: none;
  border-color: var(--text);
  background: #fffdf8;
  box-shadow: 0 0 0 3px rgba(34, 31, 27, 0.1);
}

button {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  background: linear-gradient(180deg, #2b2722, var(--accent));
  color: #fafaf9;
  border-color: var(--accent);
  cursor: pointer;
  transition: transform 140ms ease, background 120ms ease, opacity 120ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(28, 25, 23, 0.15);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status-line {
  margin-top: 12px;
  font-size: 13px;
}

.providers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.provider-card {
  padding: 22px;
  display: grid;
  gap: 14px;
  align-content: start;
  transition: transform 180ms ease, border-color 120ms ease, box-shadow 180ms ease;
}

.provider-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}

.provider-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.provider-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.provider-name {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.status-badge {
  flex: none;
  align-self: start;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: #fbfaf7;
  border: 1px solid var(--line);
}

.status-badge.ready,
.status-badge.configured {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: #bbf7d0;
}

.status-badge.not-configured {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: #fde68a;
}

.status-badge.reserved {
  color: var(--reserved);
  background: var(--surface-subtle);
}

.quota-list {
  display: grid;
  gap: 13px;
  min-height: 210px;
  align-content: start;
}

.quota-row {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(223, 219, 207, 0.7);
  background: linear-gradient(180deg, #fffefc, #faf8f3);
}

.quota-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.quota-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.quota-value {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ok);
  white-space: nowrap;
}

.quota-bar {
  height: 5px;
  border-radius: 999px;
  background: #ebe6da;
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--ok);
  transition: width 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

.quota-fill.low {
  background: var(--warn);
}

.quota-fill.high {
  background: var(--danger);
}

.quota-row-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.quota-extra {
  white-space: nowrap;
}

.provider-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid rgba(94, 88, 80, 0.16);
}

.snapshot-meta {
  font-size: 12px;
  line-height: 1.5;
  flex: 1;
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  background: #fffdf9;
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.refresh-button:hover:not(:disabled) {
  background: #f4f0e7;
}

.refresh-icon {
  transition: transform 300ms ease;
}

.refresh-button.spinning .refresh-icon {
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.empty-quota {
  padding: 20px 12px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
  background: #faf8f2;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}

.balance-row,
.cliproxy-summary {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #fdfcf8, #f8f5ee);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.peak-badge {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.peak-phase {
  font-weight: 600;
  white-space: nowrap;
}

.peak-phase.peak {
  color: var(--warn);
}

.peak-phase.off-peak {
  color: var(--ok);
}

.peak-extra {
  color: var(--faint);
  font-size: 12px;
}

.balance-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.balance-currency {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.balance-total {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.balance-row.unavailable .balance-total {
  color: var(--warn);
}

.balance-breakdown {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}

.cliproxy-summary {
  gap: 10px;
}

.cliproxy-accounts-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cliproxy-ready {
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--ok);
}

.cliproxy-summary.unhealthy .cliproxy-ready {
  color: var(--warn);
}

.cliproxy-summary.empty .cliproxy-ready {
  color: var(--faint);
}

.cliproxy-total {
  font-size: 13px;
  color: var(--muted);
}

.cliproxy-breakdown {
  font-size: 13px;
  color: var(--text);
}

.cliproxy-requests {
  font-size: 12px;
  color: var(--muted);
}

.cliproxy-plan {
  font-size: 12px;
  color: var(--muted);
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.cliproxy-plan.hidden {
  display: none;
}

.codex-summary {
  display: grid;
  gap: 14px;
}

.codex-account {
  display: grid;
  gap: 8px;
}

.codex-account-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.codex-account-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.codex-plan-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: #eff8f2;
  color: var(--ok);
  border: 1px solid #bbf7d0;
}

.codex-weekly-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--muted);
  border: 1px solid var(--line);
}

.codex-weekly-badge.low {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: #fde68a;
}

.codex-weekly-badge.critical {
  color: var(--danger);
  background: #fef2f2;
  border-color: #fecaca;
}

.codex-error {
  font-size: 13px;
  color: var(--warn);
}

.hero,
.auth-panel,
.provider-card {
  animation: riseIn 460ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-panel {
  animation-delay: 70ms;
}

.provider-card {
  animation-delay: 120ms;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.hidden {
  display: none;
}

@media (max-width: 780px) {
  .layout {
    width: calc(100vw - 32px);
    padding-top: 32px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 20px;
    align-items: start;
  }

  .limit-card {
    min-width: 0;
  }

  h1 {
    font-size: 1.65rem;
  }

  .providers {
    grid-template-columns: 1fr;
  }

  .provider-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .refresh-button {
    justify-content: center;
  }
}
