:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-soft: #f7f7f4;
  --surface-strong: #171717;
  --border: #deddd8;
  --border-strong: #c7c6c0;
  --text: #171717;
  --text-muted: #77756f;
  --accent: #fee500;
  --accent-hover: #f4dc00;
  --accent-text: #241f00;
  --success: #12804a;
  --success-bg: #e8f7ef;
  --danger: #d44343;
  --danger-bg: #fff0f0;
  --warning: #a46700;
  --shadow: 0 16px 44px rgba(28, 27, 23, .08);
  --shadow-soft: 0 5px 18px rgba(28, 27, 23, .06);
  --radius: 18px;
  --radius-sm: 11px;
  --shell: 1040px;
  --cell: #dad9d3;
  --cell-border: #cecdc7;
  --banner-bg: #171717;
  --banner-border: #2c2c2c;
  --chip-bg: #e8e7e2;
  --notice-bg: #fffbeb;
  --notice-border: #fde68a;
  --balance-bg: #171717;
}

[data-theme="dark"] {
  --bg: #11110f;
  --surface: #1b1b18;
  --surface-soft: #23231f;
  --surface-strong: #f5f4ef;
  --border: #33332e;
  --border-strong: #484741;
  --text: #f5f4ef;
  --text-muted: #aaa89f;
  --accent-text: #201c00;
  --success: #55d58e;
  --success-bg: rgba(28, 141, 79, .14);
  --danger: #ff7777;
  --danger-bg: rgba(212, 67, 67, .12);
  --warning: #efb642;
  --shadow: 0 18px 48px rgba(0, 0, 0, .28);
  --shadow-soft: 0 7px 22px rgba(0, 0, 0, .2);
  --cell: #383832;
  --cell-border: #45453e;
  --banner-bg: #0d0d0c;
  --banner-border: #2a2a26;
  --chip-bg: #2a2a26;
  --notice-bg: #2a2410;
  --notice-border: #5c4d12;
  --balance-bg: #0d0d0c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { min-width: 320px; }
body {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, rgba(254, 229, 0, .12), transparent 27rem),
    var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
a { color: #2563eb; text-decoration: none; }
[data-theme="dark"] a { color: #7db4ff; }
a:hover { text-decoration: underline; }
button, textarea, input, select { font: inherit; color: inherit; }

.shell {
  width: min(var(--shell), 100%);
  margin: 0 auto;
  padding: 30px 24px 48px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.site-brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; flex: 0 0 44px;
  width: 44px; height: 44px; color: #3c1e1e; background: var(--accent);
  border: 1px solid rgba(60, 30, 30, .12); border-radius: 14px;
  font-size: 22px; font-weight: 950;
  box-shadow: inset 0 -2px 0 rgba(60, 30, 30, .08);
}
.site-kicker {
  margin-bottom: 2px; color: var(--text-muted);
  font-size: 10px; font-weight: 800; letter-spacing: 1.7px;
}
.site-brand h1 {
  font-size: 20px; line-height: 1.2; letter-spacing: -.35px; font-weight: 900;
}
.site-sub { color: var(--text-muted); font-weight: 700; font-size: 14px; margin-left: 4px; }

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-ghost, .theme-toggle {
  display: grid; place-items: center;
  flex: 0 0 40px; width: 40px; height: 40px; padding: 0;
  color: var(--text-muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-soft); cursor: pointer;
  transition: color .16s, border-color .16s, transform .16s;
  text-decoration: none; font-size: 12px; font-weight: 800;
}
.btn-ghost {
  width: auto; padding: 0 14px; display: inline-flex; align-items: center;
}
.btn-ghost:hover, .theme-toggle:hover {
  color: var(--text); border-color: var(--border-strong);
  transform: translateY(-1px); text-decoration: none;
}
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.balance-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 40px; padding: 0 14px; border-radius: 999px;
  background: var(--accent); color: var(--accent-text);
  font-size: 13px; font-weight: 900; border: 1px solid #e5ce00;
  box-shadow: 0 6px 16px rgba(210, 189, 0, .18);
}
.balance-chip em { font-style: normal; font-weight: 700; opacity: .75; }

/* Top ad */
.home-ad-banner {
  position: relative; display: flex; align-items: center; gap: 13px;
  width: 100%; margin-bottom: 14px; padding: 12px 14px; overflow: hidden;
  color: #fff; text-decoration: none; background: var(--banner-bg);
  border: 1px solid var(--banner-border); border-radius: 14px;
  box-shadow: var(--shadow-soft);
  transition: transform .16s, box-shadow .16s;
}
.home-ad-banner::before {
  position: absolute; top: -50px; right: 120px; width: 180px; height: 140px;
  background: rgba(254, 229, 0, .12); border-radius: 50%; filter: blur(8px); content: "";
}
.home-ad-banner:hover {
  transform: translateY(-1px); box-shadow: 0 10px 28px rgba(0,0,0,.17);
  text-decoration: none; color: #fff;
}
.home-ad-label {
  position: relative; flex: 0 0 auto; padding: 3px 7px; color: #242000;
  background: var(--accent); border-radius: 6px; font-size: 10px; font-weight: 900; letter-spacing: .7px;
}
.home-ad-copy {
  position: relative; display: flex; align-items: baseline; flex: 1; min-width: 0; gap: 12px;
}
.home-ad-copy strong { font-size: 14px; white-space: nowrap; }
.home-ad-copy > span { color: #aaa; font-size: 12px; }
.home-ad-action {
  position: relative; flex: 0 0 auto; padding: 6px 10px; color: #171717;
  background: #fff; border-radius: 8px; font-size: 11px; font-weight: 800; white-space: nowrap;
}

/* stats */
.extract-stats-panel {
  margin-bottom: 14px; padding: 17px 18px 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-soft);
}
.extract-stats-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
}
.extract-stats-eyebrow {
  display: flex; align-items: center; gap: 7px; margin-bottom: 3px;
  color: var(--text-muted); font-size: 10px; font-weight: 850; letter-spacing: 1.4px;
}
.extract-stats-eyebrow span {
  width: 7px; height: 7px; background: var(--accent);
  border: 1px solid rgba(60,30,30,.15); border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(254,229,0,.14);
}
.extract-stats-header h2 {
  font-size: 17px; line-height: 1.3; letter-spacing: -.25px; font-weight: 900;
}
.extract-stats-header p { margin-top: 2px; color: var(--text-muted); font-size: 11px; }
.extract-stats-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.extract-stats-legend {
  display: flex; gap: 13px; color: var(--text-muted); font-size: 10px; white-space: nowrap;
}
.extract-stats-legend span { display: inline-flex; align-items: center; gap: 5px; }
.extract-stats-legend i {
  width: 9px; height: 9px; background: var(--cell); border: 1px solid var(--cell-border); border-radius: 3px;
}
.extract-stats-legend i.is-success {
  background: #20bd70; border-color: #20bd70; box-shadow: 0 0 7px rgba(32,189,112,.35);
}
.extract-stats-updated {
  color: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.extract-stats-grid {
  display: grid; grid-template-columns: repeat(48, minmax(0, 1fr));
  gap: 4px; margin-top: 11px; padding: 9px;
  background: var(--surface-soft); border: 1px solid var(--border); border-radius: 12px;
}
.extract-stats-cell {
  position: relative; z-index: 0; width: 100%; aspect-ratio: 1;
  background: var(--cell); border: 1px solid var(--cell-border); border-radius: 4px;
  cursor: help; transition: transform .15s, filter .15s, box-shadow .15s;
}
.extract-stats-cell.is-success {
  background: linear-gradient(145deg, #3ddd8b, #119957);
  border-color: #38cf81; box-shadow: 0 0 7px rgba(25,183,103,.35);
}
.extract-stats-cell:hover {
  z-index: 2; filter: brightness(1.05);
  transform: translateY(-2px) scale(1.25);
  box-shadow: 0 5px 12px rgba(0,0,0,.16);
}

.notice-card {
  margin-bottom: 14px; padding: 14px 16px;
  background: var(--notice-bg); border: 1px solid var(--notice-border); border-radius: 14px;
}
.notice-title { font-weight: 850; font-size: 13px; margin-bottom: 4px; }
.notice-body { color: var(--text-muted); font-size: 12.5px; line-height: 1.6; }
.notice-meta { margin-top: 6px; font-size: 12px; color: var(--warning); }
.notice-meta a { color: var(--warning); font-weight: 800; }

.balance-mini {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; padding: 18px 20px;
  background: var(--balance-bg); color: #fff; border-radius: 16px; border: 1px solid var(--banner-border);
}
.bm-label { font-size: 12px; color: #aaa; font-weight: 700; }
.bm-tip { font-size: 11px; color: #777; margin-top: 2px; }
.bm-num { font-size: 40px; font-weight: 950; letter-spacing: -.04em; color: var(--accent); line-height: 1; }

.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--chip-bg); border-radius: 14px; padding: 5px; margin-bottom: 14px;
}
.tabs-3 { grid-template-columns: 1fr 1fr 1fr; }
.tab {
  text-align: center; padding: 12px 8px; color: var(--text-muted);
  border-radius: 10px; font-weight: 800; font-size: 13.5px;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft);
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 25px; margin-bottom: 14px;
}
.card h3 { margin: 0 0 16px; font-size: 16px; font-weight: 900; letter-spacing: -.2px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; color: var(--text); background: var(--surface-soft);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 13px; font-size: 13.5px; outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
input:focus, textarea:focus {
  background: var(--surface); border-color: #b7a600;
  box-shadow: 0 0 0 4px rgba(254, 229, 0, .17);
}
textarea {
  resize: vertical; min-height: 132px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px; line-height: 1.5;
}

.btn-primary-block {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 44px; border: 1px solid #e5ce00; border-radius: 12px;
  background: var(--accent); color: var(--accent-text);
  font-size: 14px; font-weight: 900; cursor: pointer;
  box-shadow: 0 7px 18px rgba(210, 189, 0, .18);
  transition: transform .15s, background .15s;
}
.btn-primary-block:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary-block:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-mini {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 4px 10px; cursor: pointer; margin-left: 8px; font-size: 12px; font-weight: 700; color: var(--text);
}
.msg { margin-top: 6px; font-size: 13px; min-height: 18px; font-weight: 700; }
.msg.ok { color: var(--success); }
.msg.err { color: var(--danger); }
.empty { text-align: center; color: var(--text-muted); padding: 36px 10px; }
.empty-icon { font-size: 32px; margin-bottom: 6px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 11px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.table th { color: var(--text-muted); font-weight: 800; font-size: 11px; }
.mono { font-family: ui-monospace, Consolas, monospace; word-break: break-all; font-size: 12px; }
.pill-plus {
  display: inline-block; background: var(--success-bg); color: var(--success);
  font-weight: 900; font-size: 12px; padding: 2px 8px; border-radius: 999px;
}
.api-tip code {
  display: block; background: var(--surface-soft); padding: 12px 14px;
  border-radius: 10px; margin: 8px 0; border: 1px solid var(--border);
}
.st { padding: 3px 9px; border-radius: 999px; font-size: 12px; background: var(--chip-bg); font-weight: 800; }
.st-success { background: var(--success-bg); color: var(--success); }
.st-extracting, .st-pending, .st-processing { background: rgba(37,99,235,.12); color: #3b82f6; }
.st-failed, .st-error, .st-rejected { background: var(--danger-bg); color: var(--danger); }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }

.dropzone {
  position: relative; border: 1.5px dashed var(--border-strong); border-radius: 14px;
  padding: 28px 16px 22px; background: var(--surface-soft); text-align: center;
  transition: .16s ease; cursor: pointer; overflow: hidden;
}
.dropzone:hover, .dropzone.is-drag { border-color: #b7a600; background: rgba(254,229,0,.08); }
.dropzone.is-ready { border-color: var(--success); border-style: solid; background: var(--success-bg); }
.dropzone-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; font-size: 0; }
.dropzone-icon {
  width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 14px; background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-soft); border: 1px solid var(--border);
}
.dropzone-title { font-weight: 900; font-size: 14px; margin-bottom: 4px; }
.dropzone-desc { color: var(--text-muted); font-size: 12.5px; margin-bottom: 4px; }
.dropzone-desc .linkish { color: var(--warning); font-weight: 800; }
.dropzone-meta { color: var(--text-muted); font-size: 11px; opacity: .85; }
.dropzone-file {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid rgba(18,128,74,.25); color: var(--success);
  padding: 7px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; max-width: 100%;
}
.dropzone-file[hidden] { display: none !important; }
.dropzone-file .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.dropzone-file .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.or-divider {
  display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 11px; font-weight: 700;
}
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.query-result {
  margin-top: 14px; border-radius: 14px; padding: 14px;
  background: var(--surface-soft); border: 1px solid var(--border);
}
.query-result .qr-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.query-result .qr-row:last-child { border-bottom: none; }
.query-result .qr-k { color: var(--text-muted); font-weight: 700; }
.query-result .qr-v { font-weight: 900; text-align: right; word-break: break-all; }
.query-result .badge-ok { color: var(--success); }
.query-result .badge-used { color: var(--danger); }
.query-result .badge-miss { color: var(--warning); }

/* admin */
.admin-layout { display: flex; min-height: 100vh; background: var(--bg); color: var(--text); }
.sidebar { width: 220px; background: #171717; color: #e2e8f0; padding: 20px 14px; flex-shrink: 0; }
.sidebar a { display: block; color: #cbd5e1; padding: 10px 12px; border-radius: 8px; margin-bottom: 4px; }
.sidebar a:hover { background: #2a2a2a; color: #fff; text-decoration: none; }
.admin-main { flex: 1; padding: 24px; }
.admin-main h1 { margin: 0 0 16px; font-size: 22px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stat { background: var(--surface); border-radius: 12px; padding: 18px; border: 1px solid var(--border); }
.stat .n { font-size: 28px; font-weight: 900; }
.login-box {
  max-width: 380px; margin: 10vh auto; background: var(--surface); padding: 28px;
  border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow);
}
.docs {
  max-width: 900px; margin: 24px auto; background: var(--surface); padding: 28px;
  border-radius: 16px; border: 1px solid var(--border);
}
.docs pre { background: #171717; color: #e2e8f0; padding: 14px; border-radius: 10px; overflow: auto; font-size: 13px; }
.docs table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.docs th, .docs td { border: 1px solid var(--border); padding: 8px; font-size: 13px; }
.checkline { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 700; }
.checkline input { width: auto; }
.preview-banner {
  margin-top: 12px; pointer-events: none;
}

@media (max-width: 760px) {
  .shell { padding: 20px 14px 34px; }
  .site-header { margin-bottom: 18px; }
  .home-ad-copy { display: block; }
  .home-ad-copy strong, .home-ad-copy > span { display: block; }
  .home-ad-copy > span { margin-top: 1px; }
  .extract-stats-header { flex-direction: column; gap: 8px; }
  .extract-stats-actions {
    width: 100%; flex-direction: row; align-items: center; justify-content: space-between;
  }
  .extract-stats-grid { grid-template-columns: repeat(36, minmax(0, 1fr)); }
  .card { padding: 18px; }
}
@media (max-width: 480px) {
  .site-kicker { display: none; }
  .site-brand h1 { font-size: 18px; }
  .brand-mark { width: 40px; height: 40px; flex-basis: 40px; border-radius: 12px; }
  .home-ad-label { display: none; }
  .home-ad-copy > span { display: none; }
  .home-ad-action { font-size: 0; }
  .home-ad-action span { font-size: 15px; }
  .extract-stats-panel { padding: 14px; }
  .extract-stats-actions { align-items: flex-start; flex-direction: column; }
  .extract-stats-grid { grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; padding: 7px; }
  .tabs-3 { grid-template-columns: 1fr; }
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .btn-ghost span.hide-sm { display: none; }
}
.qr-section-title {
  font-size: 12px; font-weight: 900; color: var(--text-muted);
  letter-spacing: .04em; margin-bottom: 6px; text-transform: uppercase;
}
.qr-tasks { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.qr-task {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 12px; padding: 12px;
}
.qr-task-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.qr-task-id { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.qr-task-line {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12.5px; padding: 3px 0; color: var(--text-muted);
}
.qr-task-line b { color: var(--text); font-weight: 750; text-align: right; word-break: break-all; max-width: 70%; }