:root {
  --bg: #f4f7fb;
  --panel: #fff;
  --text: #14211f;
  --muted: #60716d;
  --line: #d9e2df;
  --blue: #155eef;
  --teal: #0f766e;
  --green: #15803d;
  --red: #b42318;
  --warn: #9a6700;
  --soft: #eef6f5;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
.wrap { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.top { border-bottom: 1px solid var(--line); background: #fff; }
.bar { display: flex; min-height: 70px; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 44px; height: 44px; border: 0; border-radius: 8px; object-fit: contain; }
.nav { display: flex; flex-wrap: wrap; gap: 10px; }
.nav a { padding: 9px 11px; border-radius: 6px; color: var(--text); font-weight: 800; text-decoration: none; }
.nav a:hover, .nav a[aria-current="page"] { background: #eef4f6; }
main { min-height: calc(100vh - 70px); padding: 28px 0 56px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(28px, 5vw, 36px); }
h2 { margin-bottom: 12px; font-size: 20px; }
.muted { color: var(--muted); }

.panel { padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 8px 24px rgba(25, 45, 55, .05); }
.login { width: min(100%, 460px); margin-top: 36px; }
.login > .muted { margin-top: 8px; }
.login label, .privacy-request label { display: block; margin-top: 16px; color: #475467; font-size: 13px; font-weight: 750; }
input, select, textarea { width: 100%; min-height: 42px; margin-top: 6px; padding: 9px 11px; border: 1px solid #c7d3d0; border-radius: 8px; background: #fff; color: var(--text); font: inherit; }
textarea { resize: vertical; }
.remember-row { display: flex !important; align-items: center; gap: 9px; margin: 16px 0 14px !important; color: var(--text) !important; }
.remember-input { width: auto; min-height: auto; margin: 0; }
.login-submit { width: 100%; }
.login-help { margin-top: 12px; color: var(--muted); font-size: 13px; }
.session-loading { min-height: 168px; }
.loading-line { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 17px; font-weight: 800; }
.spinner { width: 18px; height: 18px; border: 2px solid #bfdbfe; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.msg { margin: 0 0 14px; padding: 11px 13px; border: 1px solid #b7d7c3; border-radius: 9px; background: #edf9f1; color: #146c3a; }
.msg:empty { display: none; }
.msg.err { border-color: #f1b7b2; background: #fff1f0; color: var(--red); }

.dash { display: grid; grid-template-columns: 230px minmax(0, 1fr); align-items: start; gap: 18px; }
.side { position: sticky; top: 88px; display: grid; gap: 3px; height: max-content; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.side button { display: block; width: 100%; padding: 11px 12px; border: 0; border-radius: 8px; background: transparent; color: #203330; font: inherit; font-weight: 800; text-align: left; cursor: pointer; }
.side button:hover { background: #f5f8fa; }
.side button.active, .side button[aria-selected="true"] { background: #eaf4ff; color: var(--blue); }
.dashboard-content { min-width: 0; }
.section { min-width: 0; scroll-margin-top: 94px; }
.section:focus { outline: none; }
.section:focus-visible { outline: 3px solid rgba(37, 99, 235, .28); outline-offset: 5px; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.card span { display: block; color: var(--muted); font-size: 13px; }
.card strong { display: block; margin-top: 4px; font-size: 21px; overflow-wrap: anywhere; }
.card p { margin-top: 10px; }
.cards[aria-busy="true"]::before { content: "正在加载…"; grid-column: 1 / -1; min-height: 84px; padding: 24px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(100deg, #fff 20%, #f2f5f7 45%, #fff 70%); color: var(--muted); }

.module-feedback { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 12px 14px; border: 1px solid #efd79f; border-radius: 9px; background: #fff8e8; color: #7a4b00; }
.module-feedback[hidden] { display: none; }
.module-feedback .btn { width: auto; flex: 0 0 auto; }
.empty-state { padding: 24px 16px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 16px; }
.empty-state .btn { width: auto; margin-top: 12px; }

.table { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.table table { width: 100%; min-width: 820px; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 14px; text-align: left; vertical-align: middle; }
th { background: #fafcfc; color: var(--muted); font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.tag { display: inline-flex; padding: 3px 8px; border-radius: 999px; background: #eaf7ef; color: #0f6b35; font-size: 12px; font-weight: 800; }
.tag.warn { background: #fff4e5; color: #9a3412; }
.tag.bad { background: #fef0f0; color: var(--red); }

.subscriptions { margin-top: 16px; }
.subgrid { display: grid; gap: 10px; }
.subitem { padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.subitem strong { display: block; margin-bottom: 8px; }
.subitem code { display: block; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: #f7faf9; color: #203330; font-size: 13px; overflow-wrap: anywhere; }
.subitem .actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 10px; }
.subitem a.btn { display: inline-flex; width: auto; text-decoration: none; }
.subscription-note, .subscription-actions, .section-intro { margin-bottom: 12px; }
.privacy-request { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.password-row { display: grid; grid-template-columns: 130px minmax(180px, 1fr) 110px minmax(180px, 1fr) auto; }
.password-row label { margin: 0; }
.password-row input { margin: 0; }
.align-end { align-self: end; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

@media (max-width: 1000px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .password-row { grid-template-columns: 1fr 2fr; }
  .password-row .btn { grid-column: 1 / -1; width: max-content; }
}

@media (max-width: 860px) {
  main { padding-top: 18px; }
  .dash { grid-template-columns: 1fr; gap: 14px; }
  .side { top: 70px; z-index: 6; display: flex; width: 100%; overflow-x: auto; padding: 8px; border-radius: 10px; box-shadow: 0 5px 16px rgba(16, 24, 40, .08); scrollbar-width: thin; }
  .side button { width: auto; min-height: 42px; flex: 0 0 auto; padding: 9px 13px; white-space: nowrap; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .table { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .table table { min-width: 0; border-collapse: separate; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { margin-bottom: 12px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 8px 20px rgba(16, 24, 40, .05); }
  .table td { display: grid; grid-template-columns: minmax(86px, .8fr) minmax(0, 1.4fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid #edf1f3; overflow-wrap: anywhere; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 800; }
  .table td:last-child { border-bottom: 0; }
  .table .empty-row { padding: 0; }
  .table .empty-row td { display: block; padding: 0; border: 0; }
  .table .empty-row td::before { content: none; }
  .table .btn { width: auto; }
}

@media (max-width: 560px) {
  .wrap { width: calc(100% - 24px) !important; }
  .login { margin-top: 18px; }
  .panel { padding: 18px !important; }
  .cards { grid-template-columns: 1fr; }
  .module-feedback { align-items: stretch; flex-direction: column; }
  .module-feedback .btn { width: 100%; }
  .password-row { grid-template-columns: 1fr; }
  .password-row .btn { grid-column: auto; width: 100%; }
  .subitem .btn { width: 100% !important; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}
