:root {
  color-scheme: light;
  --paper: #f5f0e3;
  --paper-2: #ede5d0;
  --ink: #24303a;
  --muted: #7b8288;
  --faint: #a7adb3;
  --line: rgba(36, 48, 58, 0.12);
  --line-strong: rgba(36, 48, 58, 0.22);
  --card: rgba(253, 250, 240, 0.82);
  --shadow: 0 24px 60px rgba(90, 74, 44, 0.16);
  --soft-shadow: 0 14px 40px rgba(90, 74, 44, 0.12);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --accent: #0e7490;
  --accent-ink: #0b5d73;
  --good: #12916e;
  --medium: #d97706;
  --high: #dc2626;
  --c1: #1d4ed8;
  --font-display: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 12% 6%, rgba(255, 253, 245, 0.9) 0, transparent 30rem),
    radial-gradient(circle at 92% 16%, rgba(186, 210, 228, 0.55) 0, transparent 26rem),
    radial-gradient(circle at 50% 100%, rgba(196, 181, 253, 0.14) 0, transparent 34rem),
    linear-gradient(158deg, var(--paper) 0%, var(--paper-2) 100%);
  overflow-x: hidden;
}

/* 制图网格层 */
.blueprint-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(36, 48, 58, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 48, 58, 0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, black 20%, transparent 82%);
}

.blueprint-layer::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(rgba(36, 48, 58, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 48, 58, 0.028) 1px, transparent 1px);
  background-size: 4px 4px;
  opacity: 0.7;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 64px;
}

/* ---------- 登录 ---------- */
.auth-view {
  display: grid;
  min-height: calc(100vh - 104px);
  place-items: center;
}

.auth-card {
  width: min(430px, 100%);
  padding: 38px 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: 0.02em;
}

.auth-sub {
  margin: 8px 0 26px;
  color: var(--muted);
  font-size: 14px;
}

.password-field,
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.password-field > span,
.field > span {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.password-field input,
.field input,
.field textarea {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.password-field input:focus,
.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.14);
}

.primary-button {
  width: 100%;
  margin-top: 18px;
  padding: 12px 20px;
  border: 1px solid var(--accent-ink);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 10px 24px rgba(14, 116, 144, 0.28);
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}

.primary-button:hover {
  background: var(--accent-ink);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(0);
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.primary-button--compact {
  width: auto;
  margin-top: 0;
  padding: 9px 15px;
  font-size: 13px;
}

.ghost-button {
  padding: 9px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}

.ghost-button:hover {
  border-color: var(--accent);
}

.form-error {
  margin: 12px 0 0;
  color: var(--high);
  font-size: 13px;
}

/* ---------- 顶栏 ---------- */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.title-group .eyebrow {
  margin-bottom: 6px;
}

.title-group h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: 0.02em;
}

/* 胶囊切换 */
.switch {
  position: relative;
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 1px 3px rgba(90, 74, 44, 0.08);
}

.switch__glide {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  border-radius: 999px;
  background: var(--ink);
  box-shadow: 0 4px 12px rgba(36, 48, 58, 0.28);
  transition: transform 0.24s cubic-bezier(0.33, 1, 0.68, 1);
}

.switch__opt {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  transition: color 0.2s;
}

.switch__opt--active {
  color: #fff;
}

.switch__icon {
  font-size: 14px;
  line-height: 1;
}

/* ---------- 面板 ---------- */
.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
}

.panel-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-note code,
.import-box code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.6);
  font-family: var(--font-mono);
  font-size: 12px;
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- 总用量 ---------- */
.summary-card {
  position: relative;
  margin-bottom: 24px;
  padding: 22px 24px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
}

.summary-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat__label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.stat__value {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.stat__value .unit {
  margin-left: 4px;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font-body);
}

.supplier {
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.summary-bar {
  position: relative;
  height: 16px;
  margin-top: 18px;
  border-radius: 999px;
  background: rgba(36, 48, 58, 0.08);
  box-shadow: inset 0 1px 3px rgba(36, 48, 58, 0.16);
  overflow: hidden;
}

.summary-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.33, 1, 0.68, 1), background 0.4s;
}

.summary-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.hint {
  margin: 18px 2px 0;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

/* ---------- 账号卡片（总览） ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.acc-card {
  padding: 20px 20px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
  animation: rise 0.5s both;
}

.acc-card--error {
  border-color: rgba(220, 38, 38, 0.3);
}

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

.acc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.acc-nick {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.01em;
}

.acc-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.acc-badge--low {
  background: rgba(18, 145, 110, 0.12);
  color: var(--good);
}

.acc-badge--medium {
  background: rgba(217, 119, 6, 0.13);
  color: var(--medium);
}

.acc-badge--high {
  background: rgba(220, 38, 38, 0.12);
  color: var(--high);
}

.acc-badge--error {
  background: rgba(120, 120, 120, 0.14);
  color: var(--muted);
}

.acc-bar {
  position: relative;
  height: 11px;
  margin-top: 16px;
  border-radius: 999px;
  background: rgba(36, 48, 58, 0.08);
  box-shadow: inset 0 1px 2px rgba(36, 48, 58, 0.12);
  overflow: hidden;
}

.acc-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  transition: width 0.55s cubic-bezier(0.33, 1, 0.68, 1), background 0.4s;
}

.acc-fill--low,
.summary-fill--low {
  background: var(--good);
}

.acc-fill--medium,
.summary-fill--medium {
  background: var(--medium);
}

.acc-fill--high,
.summary-fill--high {
  background: var(--high);
}

.acc-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px dashed var(--line-strong);
}

.acc-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.acc-stat span {
  color: var(--muted);
  font-size: 11px;
}

.acc-stat strong {
  font-family: var(--font-mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.acc-foot {
  margin-top: 11px;
  color: var(--faint);
  font-size: 11px;
}

.acc-foot--error {
  color: var(--high);
}

.empty-state {
  margin: 0;
  padding: 44px 0;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}

/* ---------- 管理页 ---------- */
.import-box {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.4);
}

.import-box__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.import-box__head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.import-area {
  width: 100%;
  min-height: 160px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.import-area:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.14);
}

.import-box__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.import-box__foot .form-error {
  margin: 0;
}

.small-button,
.danger-button {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
}

.small-button {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
}

.small-button:hover {
  border-color: var(--accent);
}

.danger-button {
  border: 1px solid rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.06);
  color: var(--high);
}

.danger-button:hover {
  background: rgba(220, 38, 38, 0.12);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.item-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
}

.item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.item-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
}

.item-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.field--wide {
  grid-column: 1 / -1;
}

.field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.field-row input {
  flex: 1;
}

/* 浏览器指纹粘贴框 */
.curl-area {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.curl-area:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.14);
}

.cookie-status {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--good);
  font-family: var(--font-mono);
  font-size: 11px;
}

.cookie-status--missing {
  color: var(--medium);
}

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 12px 30px rgba(36, 48, 58, 0.3);
  animation: toast-in 0.28s ease-out both;
}

.toast--error {
  background: var(--high);
}

.toast--leaving {
  animation: toast-out 0.28s ease-in both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 640px) {
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

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