/* ============================================================================
   ReceiptCheck Cloud — 全站样式
   浅色主题：浅底 + 深字。无外部依赖、无构建步骤。
   ========================================================================= */

:root {
  --bg: #f6f7f9;
  --bg-soft: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #eceff5;
  --border: #e3e6ec;
  --border-strong: #d3d8e2;
  --text: #1a1d21;
  --text-2: #5b6472;
  --text-3: #8b94a3;

  --brand: #1f6feb;
  --brand-ink: #0b4fc4;
  --brand-soft: #e8f0fe;
  --brand-softer: #f3f7ff;

  --risk-high: #d92d20;
  --risk-high-soft: #fdecea;
  --risk-medium: #b54708;
  --risk-medium-soft: #fdf3e7;
  --risk-low: #0e7a5f;
  --risk-low-soft: #e7f5f0;

  --ok: #0e7a5f;
  --warn: #b54708;
  --danger: #d92d20;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;

  --sh-1: 0 1px 2px rgba(16, 24, 40, .06);
  --sh-2: 0 2px 6px -2px rgba(16, 24, 40, .10), 0 1px 2px rgba(16, 24, 40, .06);
  --sh-3: 0 12px 28px -12px rgba(16, 24, 40, .22), 0 2px 6px -2px rgba(16, 24, 40, .08);
  --sh-4: 0 28px 64px -28px rgba(16, 24, 40, .32);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;

  --topbar-h: 62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.55;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.2px; }
a { color: var(--brand); text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: .92em; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- 基础控件 */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  font: inherit; font-size: 13.5px; font-weight: 550;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-bd); border-radius: 10px;
  box-shadow: 0 1px 1px rgba(16, 24, 40, .04), inset 0 1px 0 rgba(255, 255, 255, .7);
  cursor: pointer; white-space: nowrap;
  transition: transform .12s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.btn:active { transform: translateY(0); box-shadow: var(--sh-1); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: var(--sh-1); }

.btn-primary {
  --btn-fg: #fff; --btn-bd: transparent;
  background: linear-gradient(180deg, #3b82f6 0%, var(--brand) 55%, var(--brand-ink) 100%);
  box-shadow: 0 6px 16px -8px var(--brand), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn-primary:hover { box-shadow: 0 12px 24px -10px var(--brand), inset 0 1px 0 rgba(255, 255, 255, .35); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); box-shadow: none; }
.btn-danger { --btn-fg: var(--danger); --btn-bd: #f3c4bf; }
.btn-danger:hover { background: var(--risk-high-soft); }
.btn-sm { height: 29px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }

.input, .textarea, .select {
  width: 100%; padding: 9px 12px;
  font: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, .04);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft), inset 0 1px 2px rgba(16, 24, 40, .04);
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.6; font-family: var(--mono); font-size: 13px; }
.select { appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

.field { margin-bottom: 14px; }
.field > label { display: block; margin-bottom: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { margin-top: 6px; font-size: 12px; color: var(--text-3); }
.row { display: flex; gap: 10px; align-items: center; }
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.chk input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .2px;
  background: var(--surface-3); color: var(--text-2);
}
.pill-brand { background: var(--brand-soft); color: var(--brand-ink); }
.pill-ok { background: var(--risk-low-soft); color: var(--risk-low); }
.pill-warn { background: var(--risk-medium-soft); color: var(--risk-medium); }
.pill-danger { background: var(--risk-high-soft); color: var(--risk-high); }

/* ---------------------------------------------------------------- 卡片面板 */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.card-pad { padding: 20px 22px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; }
.card-head .grow { min-width: 0; }

.sec { margin-bottom: 18px; }
.sec-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 13px; font-weight: 650; color: var(--text-2); }

.empty { padding: 40px 20px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.empty b { display: block; color: var(--text-2); margin-bottom: 4px; font-size: 14px; }

/* ---------------------------------------------------------------- 登录页 */

.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 28px 18px;
  background:
    radial-gradient(1000px 480px at 50% -12%, var(--brand-soft), transparent 72%),
    radial-gradient(700px 380px at 100% 108%, #e9f5f0, transparent 70%),
    var(--bg);
}
.auth-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-4);
  padding: 32px 30px 26px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand .mark {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px;
  background: linear-gradient(160deg, #4b8ef7, var(--brand-ink));
  box-shadow: 0 10px 22px -10px var(--brand), inset 0 1px 0 rgba(255,255,255,.4);
}
.auth-brand h1 { font-size: 19px; }
.auth-brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }

.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 22px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.tabs button {
  flex: 1; height: 32px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-2); background: transparent; border: 0; border-radius: 9px; cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] {
  color: var(--brand-ink); background: var(--surface);
  box-shadow: var(--sh-2), inset 0 0 0 1px var(--border);
}

.msg { border-radius: 10px; padding: 10px 12px; font-size: 12.8px; margin-bottom: 14px; display: flex; gap: 8px; }
.msg-err { background: var(--risk-high-soft); color: #a5261b; border: 1px solid #f6cfc9; }
.msg-ok { background: var(--risk-low-soft); color: #0a5c48; border: 1px solid #c6e7dd; }
.msg-info { background: var(--brand-soft); color: var(--brand-ink); border: 1px solid #cfe0fb; }

.auth-foot { margin-top: 16px; font-size: 11.5px; color: var(--text-3); text-align: center; }
.build-tag { font-family: var(--mono); }

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 9px; flex: none; }
.topbar .brand .mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 12px;
  background: linear-gradient(160deg, #4b8ef7, var(--brand-ink));
  box-shadow: 0 6px 14px -7px var(--brand);
}
.topbar .brand b { font-size: 14px; letter-spacing: -.2px; }

.batch-picker { display: flex; align-items: center; gap: 8px; min-width: 0; }
.batch-picker .select { height: 34px; width: 190px; font-size: 13px; }

.stats { display: flex; align-items: center; gap: 4px; }
.stat {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  height: 40px; padding: 0 13px; border-left: 1px solid var(--border);
}
.stat:first-child { border-left: 0; }
.stat span { font-size: 11px; color: var(--text-3); line-height: 1.2; }
.stat b { font-size: 14.5px; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat b.risk-high { color: var(--risk-high); }

.topbar .actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .stats { order: 3; width: 100%; overflow-x: auto; }
  .topbar .actions { margin-left: 0; }
  .batch-picker .select { width: 150px; }
}

/* ---------------------------------------------------------------- 布局 */

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 18px 60px; }
.grid { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 980px) { .grid { grid-template-columns: 1fr; } }
.sticky-col { position: sticky; top: calc(var(--topbar-h) + 16px); }
@media (max-width: 980px) { .sticky-col { position: static; } }

/* ---------------------------------------------------------------- 条目 */

.entry {
  position: relative;
  padding: 12px 14px 12px 16px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); margin-bottom: 9px;
  box-shadow: var(--sh-1);
  transition: box-shadow .16s ease, border-color .16s ease;
}
.entry:hover { box-shadow: var(--sh-2); border-color: var(--border-strong); }
.entry.excluded { opacity: .55; background: var(--surface-2); }
.entry::before {
  content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px;
  border-radius: 3px; background: var(--border-strong);
}
.entry[data-risk="high"]::before { background: var(--risk-high); }
.entry[data-risk="medium"]::before { background: var(--risk-medium); }
.entry[data-risk="low"]::before { background: var(--risk-low); }
.entry-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; flex-wrap: wrap; }
.entry-head .idx { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
.entry-body {
  font-family: var(--mono); font-size: 12.3px; line-height: 1.6; color: var(--text-2);
  white-space: pre-wrap; word-break: break-word;
  max-height: 92px; overflow: hidden; position: relative;
}
.entry-body.open { max-height: none; }
.entry.collapsed .entry-body::after {
  content: ''; position: absolute; inset: auto 0 0 0; height: 34px;
  background: linear-gradient(transparent, var(--surface));
}
.entry-foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.amount { font-family: var(--mono); font-weight: 650; font-variant-numeric: tabular-nums; }
.amount.big { font-size: 15px; }
.warn-text { font-size: 11.5px; color: var(--warn); }

/* ---------------------------------------------------------------- 结果卡 */

.result {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--sh-2); margin-bottom: 12px; overflow: hidden;
}
.result-head { display: flex; align-items: center; gap: 9px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.result[data-risk="high"] .result-head { background: var(--risk-high-soft); border-bottom-color: #f6cfc9; }
.result[data-risk="medium"] .result-head { background: var(--risk-medium-soft); border-bottom-color: #f3ddc0; }
.result[data-risk="low"] .result-head { background: var(--risk-low-soft); border-bottom-color: #c6e7dd; }
.result-body { padding: 14px 16px; }
.result-src { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; }
.src-box { border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; background: var(--surface-2); }
.src-box h5 { margin: 0 0 6px; font-size: 11.5px; font-weight: 650; color: var(--text-3); letter-spacing: .3px; }
.src-box ul { margin: 0; padding-left: 16px; font-size: 12.3px; color: var(--text-2); }
.src-box li { margin-bottom: 3px; }
.src-box .none { font-size: 12.3px; color: var(--text-3); }

.hit { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; margin: 0 5px 5px 0; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.hit-high { background: var(--risk-high-soft); color: var(--risk-high); }
.hit-medium { background: var(--risk-medium-soft); color: var(--risk-medium); }
.hit-low { background: var(--surface-3); color: var(--text-2); }
.hit small { font-weight: 500; opacity: .78; }

.summary-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; margin-bottom: 16px;
  border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--sh-2);
}
.summary-bar[data-risk="high"] { background: var(--risk-high-soft); border-color: #f6cfc9; }
.summary-bar[data-risk="medium"] { background: var(--risk-medium-soft); border-color: #f3ddc0; }
.summary-bar[data-risk="low"] { background: var(--risk-low-soft); border-color: #c6e7dd; }
.summary-bar b { font-size: 14.5px; }

/* ---------------------------------------------------------------- 抽屉 */

.drawer-mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(16, 24, 40, .34);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(520px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--sh-4);
  transform: translateX(102%); transition: transform .26s cubic-bezier(.22, .8, .3, 1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex: none; }
.drawer-head h3 { font-size: 15px; }
.drawer-body { padding: 18px 20px 40px; overflow-y: auto; flex: 1; }

/* ---------------------------------------------------------------- 表格 */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl th { background: var(--surface-2); font-size: 11.5px; font-weight: 650; color: var(--text-3); letter-spacing: .3px; }
table.tbl tbody tr:hover { background: var(--brand-softer); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------------------------------------------------------------- 统计卡 */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile {
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--sh-1);
}
.tile span { display: block; font-size: 11.5px; color: var(--text-3); margin-bottom: 4px; }
.tile b { font-size: 21px; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.tile b.sm { font-size: 15px; }

/* ---------------------------------------------------------------- 提示条 */

#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 220px; max-width: 380px; padding: 11px 14px;
  border-radius: var(--r-md); font-size: 13px;
  background: #1d2126; color: #fff; box-shadow: var(--sh-3);
  animation: toast-in .22s ease;
}
.toast.err { background: #b3261e; }
.toast.ok { background: #0b6b52; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- 进度 */

.progress { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 30%; border-radius: 4px; background: linear-gradient(90deg, var(--brand), var(--brand-ink)); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -32%; } 100% { margin-left: 102%; } }

.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 其他 */

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--text-3); white-space: nowrap; }
.kv dd { margin: 0; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.small { font-size: 12.3px; }
.mb0 { margin-bottom: 0; }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.nowrap { white-space: nowrap; }
.scroll-y { max-height: 460px; overflow-y: auto; padding-right: 4px; }
