:root {
  color-scheme: light;
  --paper: #f3f5f8;
  --card: #ffffff;
  --ink: #16202f;
  --muted: #5d6879;
  --line: #d9dee6;
  --blue: #2350d1;
  --blue-ink: #1a3ea6;
  --done: #1f8a5b;
  --proc: #d99a1b;
  --pend: #5b7be0;
  --free: #e4e8ee;
  --bad: #c03a33;
  --r-sm: 4px;
  --r: 8px;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1 { font-size: 22px; line-height: 1.3; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 12px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: #eef1f5; padding: 1px 4px; border-radius: var(--r-sm); word-break: break-all; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; margin: 8px 0 0; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.text-bad { color: var(--bad); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.main { padding-top: 24px; padding-bottom: 48px; }

/* 顶栏 */
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-admin { background: var(--ink); border-bottom: 0; }
.top-admin .brand, .top-admin .top-nav a, .top-admin .link-btn { color: #dfe5ee; }
.top-admin .top-nav a[aria-current="page"] { color: #fff; box-shadow: inset 0 -2px 0 #fff; }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); font-size: 16px; }
.brand small { font-weight: 400; margin-left: 8px; opacity: .7; font-size: 13px; }
.top-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.top-nav a { color: var(--muted); padding: 16px 0; }
.top-nav a:hover { text-decoration: none; color: var(--ink); }
.top-admin .top-nav a:hover { color: #fff; }
.top-nav form { margin: 0; }
.top-nav .sep { width: 1px; height: 16px; background: rgba(255,255,255,.25); }
.who { color: var(--muted); }

/* 按钮与表单 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: var(--r-sm); font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #b8c0cc; text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-ink); border-color: var(--blue-ink); }
.btn-danger { color: var(--bad); border-color: #e7c2bf; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link-btn { border: 0; background: none; padding: 0; color: var(--blue); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; padding: 6px 10px; height: 36px; min-width: 0; }
textarea { height: auto; width: 100%; resize: vertical; line-height: 1.55; font-family: ui-monospace, Consolas, "Microsoft YaHei", monospace; font-size: 13.5px; padding: 10px 12px; }
textarea:disabled { background: #f0f2f5; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(35,80,209,.35); outline-offset: 0; border-color: var(--blue); }
.stack { display: grid; gap: 14px; }
.stack label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.stack label input { color: var(--ink); }
.stack label .hint { margin: 0; font-size: 12.5px; }
.stack label.check { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--ink); }
.stack label.check .hint { flex-basis: 100%; }
input:disabled { background: #f0f2f5; color: var(--muted); }
.row-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0 0; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline form { margin: 0; }
.inline input[type="number"] { width: 110px; }
.inline input[name="note"] { flex: 1; min-width: 180px; }

/* 面板 */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 20px; }
.narrow { max-width: 560px; }
.auth { max-width: 380px; margin: 9vh auto 0; }
.auth h1 { font-size: 24px; }
.auth .stack { margin-top: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; }
.dash { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; align-items: start; }
.dash > .panel { margin-bottom: 0; }
.dash + .panel, .dash + section { margin-top: 20px; }
.crumbs { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.crumbs .clear { margin-left: 12px; }

/* 额度 */
.quota-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.quota-head p { margin: 0; }
.big { font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.big span { font-size: 15px; font-weight: 400; letter-spacing: 0; margin-left: 8px; color: var(--muted); }
.quota-head .muted { margin-top: 8px; }
.expiry { font-size: 13px; color: var(--muted); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.expiry.is-expired { color: var(--bad); border-color: #e7c2bf; }
.h-user { display: flex; align-items: center; gap: 10px; margin: 0; }

.cells { display: grid; grid-template-columns: repeat(auto-fill, 14px); gap: 3px; }
.cells i { display: block; width: 14px; height: 14px; border-radius: 2px; }
.cells-sm { grid-template-columns: repeat(auto-fill, 8px); gap: 2px; }
.cells-sm i { width: 8px; height: 8px; border-radius: 1px; }
.bar { display: flex; height: 18px; border-radius: var(--r-sm); overflow: hidden; background: var(--free); }
.bar i { display: block; min-width: 2px; }
.c-done { background: var(--done); }
.c-processing { background: var(--proc); }
.c-pending { background: var(--pend); }
.c-free { background: var(--free); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* 提交 */
.submit-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.line-count { font-size: 13px; color: var(--muted); }
.line-count.is-over { color: var(--bad); font-weight: 600; }
.blocked { background: #fbefee; color: #8f2a24; padding: 10px 12px; border-radius: var(--r-sm); margin: 0 0 12px; }
.result { border-left: 3px solid var(--done); background: #eef7f2; padding: 10px 14px; margin-bottom: 14px; border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: 14px; }
.result-bad { border-left-color: var(--bad); background: #fbefee; }
.result-ask { border-left-color: var(--proc); background: #fdf6e7; }
.confirm { margin: 8px 0 4px; }
.confirm .row-actions { margin-top: 8px; }
.file-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-row .hint { margin: 0; }
.file-pick { position: relative; display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border: 1px dashed #aab4c3; border-radius: var(--r-sm); color: var(--ink); font-size: 14px; cursor: pointer; background: #fafbfc; }
.file-pick:hover { border-color: var(--blue); color: var(--blue); }
.file-pick:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-pick.is-disabled { opacity: .45; pointer-events: none; }
.file-chosen { color: var(--ink); }
.scope { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.scope label { display: flex; gap: 6px; align-items: center; }
.list-form { display: grid; gap: 14px; max-width: 720px; }
.list-form label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.subs td, .subs th { font-size: 13px; }
.result p { margin: 4px 0; }
.result-main { font-weight: 600; }
.bad-lines { margin: 4px 0 8px; padding-left: 18px; max-height: 180px; overflow: auto; }

/* 提示 */
.notice { padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 16px; background: #eef7f2; color: #17603f; border: 1px solid #cfe7da; }
.notice-error { background: #fbefee; color: #8f2a24; border-color: #efcfcc; }

/* 列表 */
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-size: 14px; }
.tabs a b { font-weight: 500; margin-left: 2px; font-variant-numeric: tabular-nums; }
.tabs a:hover { background: #eef1f5; text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--ink); color: #fff; }
.search { display: flex; gap: 8px; flex-wrap: wrap; }
.search input[type="search"] { width: 200px; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid #edf0f4; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8f9fb; }
.table form { margin: 0; }
.table .url { word-break: break-all; min-width: 260px; }
.table .reason { color: var(--muted); font-size: 13px; min-width: 120px; }
.col-check { width: 34px; }
.tag { display: inline-block; font-size: 12.5px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.tag-pending { background: #e9eefc; color: #2b47a8; }
.tag-processing { background: #fdf3df; color: #8a5a00; }
.tag-done { background: #e3f3eb; color: #17603f; }
.tag-rejected { background: #fbe9e8; color: #9b2c26; }
.tag-withdrawn { background: #eef0f3; color: #5d6879; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; margin: 0; }
.pager { display: flex; justify-content: center; gap: 16px; align-items: center; padding-top: 16px; font-size: 14px; color: var(--muted); }

/* 管理端 */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px; color: var(--ink); display: flex; flex-direction: column; }
a.stat:hover { border-color: var(--blue); text-decoration: none; }
.stat b { font-size: 30px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.stat-pending b { color: var(--blue); }
.stat-processing b { color: #a46f00; }
.settings { display: grid; gap: 0; padding-top: 8px; padding-bottom: 8px; }
.setting { padding: 14px 0; border-bottom: 1px solid #edf0f4; }
.setting:last-child { border-bottom: 0; }
.setting h2 { font-size: 14px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.export { display: flex; gap: 16px; align-items: center; font-size: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.bulk-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; background: #f3f5f8; border-radius: var(--r-sm); margin-bottom: 8px; position: sticky; top: 0; z-index: 2; }
.bulk-bar input[name="reason"] { flex: 1; min-width: 180px; }
.bulk-bar [hidden] { display: none; }
.check-all { display: flex; gap: 6px; align-items: center; font-size: 14px; }
input[type="checkbox"] { height: 16px; width: 16px; padding: 0; }
.reveal { font-family: inherit; font-size: 14.5px; background: #f8f9fb; margin: 8px 0 0; }

@media (max-width: 860px) {
  .dash { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .big { font-size: 38px; }
  .search input[type="search"] { width: auto; flex: 1 1 100%; }
  .search input[type="date"] { flex: 1 1 40%; }
  .search { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
