/* ============================================================
 * style.css · 无外链、无字体下载（用系统字体栈）
 * 约束：375px 无横向滚动 · 触控目标 ≥44px · 焦点可见 · 打印洁净版
 * ============================================================ */

:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #131922;
  --ink-2: #454f61;
  --muted: #5b6577;
  --line: #d9dfe9;
  --brand: #1b3d7a;
  --brand-ink: #ffffff;
  --brand-soft: #e8eefa;
  --ok: #14603a;
  --err: #a1121b;
  --warn: #8a5200;
  --b1: #dceadd;
  --b2: #fbf0d4;
  --b3: #fbe3cf;
  --b4: #f8d6d3;
  --b5: #f0c9c6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c;
    --card: #161d28;
    --ink: #eef2f8;
    --ink-2: #c6cedd;
    --muted: #a8b3c6;
    --line: #2b3546;
    --brand: #8fb4ff;
    --brand-ink: #0b1220;
    --brand-soft: #1d2637;
    --ok: #7fd6a1;
    --err: #ffa2aa;
    --warn: #ffcf87;
    --b1: #1e3025;
    --b2: #33301d;
    --b3: #382a1c;
    --b4: #3a2323;
    --b5: #43242a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden; /* 兜底：任何子元素都不把页面撑出横向滚动 */
}

a { color: var(--brand); }
a:hover { text-decoration: underline; }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--card);
  padding: 10px 14px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 0;
  z-index: 20;
}
.skip:focus { left: 0; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 14px; }

/* ---------- 页头 ---------- */
.dun-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--brand); color: var(--brand-ink); font-weight: 700;
}
.brand strong { display: block; font-size: 16px; }
.brand-tag { display: block; font-size: 12.5px; color: var(--muted); }
.header-right { display: flex; align-items: center; gap: 10px; }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.lang-btn {
  min-height: 44px; min-width: 52px; padding: 8px 14px;
  border: 0; background: transparent; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.lang-btn.is-active { background: var(--brand); color: var(--brand-ink); }
.lang-link { min-height: 44px; display: inline-flex; align-items: center; padding: 0 6px; font-weight: 600; }

/* ---------- 首屏 ---------- */
.dun-hero { padding: 6px 0 14px; }
.dun-hero h1 { font-size: 27px; line-height: 1.22; margin: 0 0 8px; }
.dun-hero .lead { margin: 0 0 10px; color: var(--ink-2); max-width: 74ch; }
.notice {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 10px;
  background: var(--brand-soft); color: var(--ink); font-size: 14px;
  border: 1px solid var(--line);
}
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; flex-direction: column; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; min-width: 132px; box-shadow: var(--shadow);
}
.chip-label { font-size: 12px; color: var(--muted); }
.chip strong { font-size: 17px; }

/* ---------- 通用区块 ---------- */
section { padding: 14px 0; }
.sec-title { font-size: 19px; margin: 6px 0 6px; }
.sub-title { font-size: 15px; margin: 16px 0 8px; }
.sec-hint { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; max-width: 80ch; }
.muted { color: var(--muted); }

.grid-3, .grid-4 { display: grid; gap: 12px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.step-card, .stat, .action-list, .letter-card, .toolbar, .bucket-bars {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.step-card { padding: 14px; }
.step-card h3 { font-size: 15px; margin: 6px 0 4px; }
.step-card p { margin: 0; color: var(--ink-2); font-size: 14px; }
.step-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13px;
}

.stat { padding: 12px 14px; }
.stat-label { display: block; font-size: 12.5px; color: var(--muted); }
.stat-value { display: block; font-size: 19px; margin-top: 3px; }

.bucket-bars { padding: 10px 14px; display: grid; gap: 8px; }
.bucket-row { display: grid; grid-template-columns: 118px 1fr 34px; align-items: center; gap: 10px; font-size: 13.5px; }
.bucket-name { color: var(--ink-2); }
.bucket-bar { display: block; height: 10px; background: var(--brand-soft); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--brand); }
.bar-b1 { background: #5f9e6a; } .bar-b2 { background: #c9a227; }
.bar-b3 { background: #d1813a; } .bar-b4 { background: #c9564f; } .bar-b5 { background: #8f3a44; }
.bucket-count { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 按钮 / 输入 ---------- */
.toolbar { padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.btn {
  min-height: 44px; padding: 10px 15px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn-ghost { background: transparent; }
.btn-icon { min-width: 44px; padding: 8px; font-size: 16px; }

input[type="text"], input[type="date"], input[type="file"], select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px;
  min-height: 44px; width: 100%; min-width: 0; max-width: 100%;
}
textarea { min-height: 92px; resize: vertical; }

:focus-visible { outline: 3px solid #0b63d6; outline-offset: 2px; }

.firm-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
#firm-name { max-width: 420px; }

.dun-status { min-height: 24px; margin: 6px 0 0; font-size: 14px; }
.dun-status.is-ok { color: var(--ok); }
.dun-status.is-error, .status-error { color: var(--err); }
.dun-status.is-error { font-weight: 600; }

/* ---------- 表格 ---------- */
.dun-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dun-table th, .dun-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; overflow-wrap: anywhere; }
.dun-table th { background: var(--brand-soft); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.dun-table tr:last-child td { border-bottom: 0; }
.dun-table td input, .dun-table td select { min-height: 44px; padding: 6px 8px; }
.dun-table.schedule-table td { vertical-align: middle; }
.dun-table .cell-remove { width: 56px; }
.dun-table tr.is-invalid td { background: rgba(161, 18, 27, .06); }
.cell-error { color: var(--err); font-size: 13px; }

.badge {
  display: inline-block; padding: 4px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: #131922; white-space: nowrap;
}
.badge-b0 { background: var(--brand-soft); color: var(--ink-2); }
.badge-b1 { background: var(--b1); }
.badge-b2 { background: var(--b2); }
.badge-b3 { background: var(--b3); }
.badge-b4 { background: var(--b4); }
.badge-b5 { background: var(--b5); }
@media (prefers-color-scheme: dark) {
  .badge { color: #eef2f8; }
  .badge-b0 { color: var(--ink-2); }
}

.empty-state { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px; color: var(--ink-2); }

/* ---------- 待办 ---------- */
.action-list { padding: 6px 12px; }
.action-item {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere; min-width: 0;
}
.action-item:last-child { border-bottom: 0; }
.action-main { min-width: 160px; flex: 1 1 200px; overflow-wrap: anywhere; }
.action-stage { font-size: 13.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.action-amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.action-next { font-size: 13px; overflow-wrap: anywhere; }

/* ---------- 信件 ---------- */
.letter-list { display: grid; gap: 14px; }
.letter-card { padding: 14px; }
.letter-head h3 { font-size: 16px; margin: 0 0 6px; overflow-wrap: anywhere; }
.letter-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.letter-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.letter-tools select { max-width: 320px; }
.inline-label { font-size: 13px; color: var(--muted); }
.letter-subject { font-weight: 600; margin: 0 0 8px; overflow-wrap: anywhere; }
.letter-body {
  margin: 0; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: inherit; font-size: 14.5px; line-height: 1.6;
}
.import-paste { margin-top: 12px; }
.import-paste summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-size: 14px; color: var(--brand); }

/* ---------- 页脚 ---------- */
.dun-footer { padding: 18px 0 30px; color: var(--muted); font-size: 13px; }
.dun-footer p { margin: 0 0 8px; max-width: 80ch; }
.dun-footer .pricing strong { color: var(--ink); }
/* 页脚链接也做成 ≥44px 触控目标，不留「只能手指尖点」的行内小链接 */
.page-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }

/* ---------- 探针容器 ---------- */
#intent-slot { padding: 0 14px; }

/* ---------- 打印 ---------- */
.print-only { display: none; }

@media print {
  :root { --bg: #fff; --card: #fff; --ink: #000; --ink-2: #222; --muted: #444; --line: #bbb; }
  body { background: #fff; color: #000; }
  .skip, .dun-header, .dun-hero, .dun-steps, .dun-firm, #dun-table, #dun-summary,
  #dun-actions, #dun-schedule, #dun-letters, #dun-tools, .dun-status, .dun-footer,
  #intent-slot, #bac-intent { display: none !important; }
  .print-only { display: block !important; }
  #print-doc { display: block !important; padding: 0; max-width: none; }
  .print-letter { page-break-inside: avoid; border: 0; padding: 0 0 14px; margin: 0 0 14px; border-bottom: 1px solid #999; }
  .print-letter h2 { font-size: 15px; margin: 0 0 4px; }
  .print-meta-line { font-size: 12px; color: #333; margin: 0 0 6px; }
  .print-letter .letter-body { border: 0; background: #fff; padding: 0; font-size: 12.5pt; }
  .print-foot { font-size: 11px; color: #444; margin-top: 12px; }
  a[href]::after { content: ""; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .dun-hero h1 { font-size: 22px; }
  .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .bucket-row { grid-template-columns: 96px 1fr 30px; }
  .bucket-name, .bucket-count { overflow-wrap: anywhere; }

  table.dun-table, table.dun-table thead, table.dun-table tbody,
  table.dun-table tr, table.dun-table td { display: block; width: 100%; min-width: 0; }
  table.dun-table thead { display: none; }
  table.dun-table { border: 0; background: transparent; }
  table.dun-table tr {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: 12px; padding: 8px 10px;
  }
  table.dun-table td {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 10px; padding: 6px 0; border: 0; min-width: 0;
  }
  table.dun-table td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere;
  }
  table.dun-table td > *:not(input):not(select):not(button) { min-width: 0; overflow-wrap: anywhere; }
  table.dun-table td input, table.dun-table td select { flex: 1 1 auto; min-width: 0; }
  table.dun-table td.cell-remove { justify-content: flex-end; }
  table.dun-table td.cell-remove::before { flex: 0 0 auto; }
  table.dun-table td.cell-error { display: block; }
  table.dun-table td.cell-error::before { content: ""; }
  .letter-tools select { max-width: 100%; flex: 1 1 100%; }
}

@media (max-width: 400px) {
  .brand-tag { display: none; }
  .dun-hero h1 { font-size: 20px; }
}
