/* ============================================================
 * style.css · Fixed-Fee Quoter
 * 设计约束：移动优先、触控 ≥44px、键盘焦点可见、深浅色自适应、
 * 无外链资源（字体用系统栈）、打印一页报价单、长词不撑破布局。
 * ============================================================ */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #141a24;
  --muted: #55607a;
  --line: #d9dfea;
  --line-soft: #e8ecf4;
  --brand: #123a6b;
  --brand-ink: #ffffff;
  --accent: #0b6b52;
  --accent-soft: #e6f4ee;
  --warn-bg: #fff4e5;
  --warn-line: #e0a34a;
  --warn-ink: #7a4a05;
  --err: #a1121b;
  --ok: #10603a;
  --focus: #0b63d6;
  --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: #0f1319;
    --card: #171d27;
    --ink: #eef2f8;
    --muted: #b3bdcd;
    --line: #2c3543;
    --line-soft: #232b38;
    --brand: #8fb4ff;
    --brand-ink: #0c1220;
    --accent: #7fd6a1;
    --accent-soft: #16281f;
    --warn-bg: #2e2415;
    --warn-line: #9a7433;
    --warn-ink: #f2cf94;
    --err: #ff9aa2;
    --ok: #7fd6a1;
    --focus: #8fb4ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { 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 Neue", Arial, sans-serif;
  overflow-wrap: break-word;
  word-break: normal;
}

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 16px; }

.wrap, .card, td, th, dd, dt, li, p { min-width: 0; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--brand); color: var(--brand-ink);
  padding: 12px 16px; border-radius: 0 0 10px 0; z-index: 50;
}
.skip:focus { left: 0; }

/* ---------- 头部 ---------- */
.site-head {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.head-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 60px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 700; font-size: 17px; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--brand); color: var(--brand-ink); font-family: Georgia, serif; font-size: 17px;
}
.lang { display: flex; gap: 6px; }
.lang-btn {
  min-height: 44px; min-width: 56px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.lang-btn[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* ---------- 主体 ---------- */
.page-title { font-size: clamp(21px, 4.6vw, 30px); line-height: 1.25; margin: 26px 0 8px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0; }
.hint.note { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 10px; }
.muted { color: var(--muted); font-size: 13px; }

.banner {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px; margin: 0 0 20px;
}
.banner p { margin: 0 0 8px; font-size: 14px; }
.banner p:last-child { margin-bottom: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px 20px;
  margin: 0 0 20px;
}
.card > h2 { font-size: 19px; margin: 0 0 6px; }
.card h3 { font-size: 16px; margin: 18px 0 6px; }

.warn-box {
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink);
  border-radius: 10px; padding: 12px 14px; margin: 12px 0;
}

/* ---------- 表单控件 ---------- */
label { font-size: 14px; font-weight: 600; display: block; margin-bottom: 4px; }

input[type="text"], input[type="number"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  font: inherit;
}
input[type="number"] { font-variant-numeric: tabular-nums; }

input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px;
}
input[aria-invalid="true"] { border-color: var(--err); border-width: 2px; }

.field-err, .cell-err { color: var(--err); font-size: 12.5px; margin: 4px 0 0; min-height: 0; display: block; }
.field-err:empty, .cell-err:empty { display: none; }

.btn {
  min-height: 44px; padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-quiet { font-weight: 500; background: transparent; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 0; }
.btn-icon {
  min-height: 44px; min-width: 44px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--err);
  font: inherit; cursor: pointer;
}

.mode { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.mode legend { font-size: 13px; color: var(--muted); padding: 0 6px; }
.radio, .check { display: flex; align-items: center; gap: 10px; font-weight: 500; min-height: 44px; margin: 0; }
.radio input, .check input { width: 20px; height: 20px; margin: 0; flex: 0 0 auto; }
.pane { margin-top: 8px; }

.field { margin: 0 0 12px; }
.rates { display: grid; gap: 14px; grid-template-columns: 1fr; margin-top: 18px; }
.correction { margin-top: 8px; border-top: 1px solid var(--line-soft); padding-top: 12px; }

/* ---------- 表格 ---------- */
.grid { width: 100%; border-collapse: collapse; margin: 12px 0 14px; }
.grid th, .grid td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 1px solid var(--line-soft); }
.grid thead th { font-size: 12.5px; color: var(--muted); text-transform: none; font-weight: 600; border-bottom: 1px solid var(--line); }
.grid td.num, .grid td .num { font-variant-numeric: tabular-nums; }
.grid td.num { white-space: nowrap; }
.grid tfoot th, .grid tfoot td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 600; }
.grid td.act { width: 56px; text-align: right; }
.grid tbody tr:last-child td { border-bottom: 1px solid var(--line-soft); }

.lib-scroll { margin-top: 14px; }
.lib-scroll.capped { max-height: 62vh; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: 10px; }
.lib-scroll.capped .grid { margin: 0; }
.lib-scroll.capped thead th { position: sticky; top: 0; background: var(--card); }

.empty {
  border: 1px dashed var(--line); border-radius: 10px;
  padding: 16px; margin-top: 14px; color: var(--muted);
}
.empty p { margin: 0 0 6px; }
.empty p:last-child { margin-bottom: 0; }

.form-status { min-height: 22px; font-size: 14px; margin: 8px 0 0; }
.form-status.ok { color: var(--ok); font-weight: 600; }
.form-status.err { color: var(--err); font-weight: 600; }

.copy-preview {
  margin: 12px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink);
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.copy-preview:empty { display: none; }

/* ---------- 报价结果 ---------- */
.hero {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px; margin: 14px 0 18px;
}
.hero-label { margin: 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.hero-value {
  margin: 2px 0 4px; font-size: clamp(30px, 8vw, 44px); line-height: 1.1;
  font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent);
}
.hero-sub { margin: 0; font-size: 14px; color: var(--muted); }

.facts { margin: 0 0 12px; display: grid; gap: 12px; }
.facts > div { border-bottom: 1px solid var(--line-soft); padding-bottom: 10px; }
.facts > div:last-child { border-bottom: 0; padding-bottom: 0; }
.facts dt { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.facts dd { margin: 0; font-size: 17px; font-variant-numeric: tabular-nums; }
.facts dd .muted { display: block; font-weight: 400; }

.sub-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.range { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.range li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px 12px;
  font-variant-numeric: tabular-nums;
}
.range .rname { font-size: 13px; color: var(--muted); }
.range b { font-size: 16px; }

.correction-box { margin-top: 14px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.correction-box h3 { margin: 0 0 4px; font-size: 15px; }
.correction-box p { margin: 0; font-size: 14px; color: var(--muted); }

.budget { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.budget-out { font-size: 14px; margin: 8px 0 0; }
.budget-out:empty { display: none; }

/* ---------- 页脚 ---------- */
.site-foot {
  border-top: 1px solid var(--line);
  background: var(--card);
  margin-top: 8px; padding: 18px 0 26px;
  font-size: 13px; color: var(--muted);
}
.site-foot p { margin: 0; }

/* ---------- 打印：只留报价单 ---------- */
.print-only { display: none; }

@media print {
  :root { --ink: #000; --muted: #333; --line: #999; --line-soft: #ccc; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .site-head, .skip, #bac-intent, #intent-slot, .site-foot, main { display: none !important; }
  .print-only { display: block !important; }
  #print-sheet { padding: 0; }
  #print-sheet h1 { font-size: 20pt; margin: 0 0 10pt; }
  #print-sheet h2 { font-size: 13pt; margin: 14pt 0 4pt; }
  #print-sheet .sheet-meta { width: 100%; border-collapse: collapse; margin-bottom: 8pt; }
  #print-sheet .sheet-meta th { text-align: left; width: 32%; font-weight: 600; padding: 2pt 0; }
  #print-sheet .sheet-meta td { padding: 2pt 0; }
  #print-sheet ul { margin: 0 0 6pt 0; padding-left: 16pt; }
  #print-sheet .sheet-fee {
    font-size: 16pt; border-top: 1pt solid #000; border-bottom: 1pt solid #000;
    padding: 6pt 0; margin: 10pt 0;
  }
  #print-sheet .small { font-size: 9pt; color: #333; margin: 4pt 0; }
  @page { margin: 16mm; }
}

/* ---------- ≤720px：表格变卡片，避免横向滚动 ---------- */
@media (max-width: 720px) {
  .grid, .grid tbody, .grid tr, .grid td, .grid tfoot, .grid tfoot tr, .grid tfoot th, .grid tfoot td {
    display: block; width: 100%;
  }
  .grid thead { display: none; }
  .grid tr {
    border: 1px solid var(--line); border-radius: 10px;
    padding: 8px; margin-bottom: 10px;
  }
  .grid td { border: 0; padding: 6px 0; }
  .grid td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 2px;
  }
  .grid td.act { text-align: left; }
  .grid tfoot tr { border: 0; padding: 0; margin: 0; }
  .grid tfoot th { padding: 4px 0 0; font-size: 13px; }
  .grid tfoot td { padding: 0 0 6px; font-weight: 600; }
  .lib-scroll.capped { max-height: none; }
  .lib-scroll.capped thead th { position: static; }
}

@media (min-width: 721px) {
  .rates { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts > div { border-bottom: 0; padding-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
