:root {
  --navy: #1b4f8a;
  --gold: #ffed4a;
  --section: #375a7f;
  --section-sub: #5b7fa6;
  --input-bg: #fff2cc;
  --input-ink: #0000cc;
  --blue: #2e75b6;
  --blue-sum: #d6eaf8;
  --green: #2e7d6f;
  --green-sum: #d5f5e3;
  --total-bg: #fdecea;
  --total-ink: #c00000;
  --note: #555555;
  --note-bg: #f4f6f8;
  --line: #d7dee8;
  --page: #eef2f6;
  --card: #ffffff;
  --ink: #1a1a1a;
  --muted: #5c6773;
  --header: #f7f9fc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 36, 64, 0.06), 0 8px 24px rgba(16, 36, 64, 0.06);
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--page);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--header);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--navy);
}
.brand span { font-weight: 500; color: var(--muted); margin-left: 8px; }
.badge {
  font-size: 12px;
  color: var(--muted);
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

.wrap {
  width: min(920px, calc(100% - 24px));
  margin: 16px auto 32px;
  flex: 1;
}

.sheet {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid #e3e9f0;
}

.title {
  background: var(--navy);
  color: var(--gold);
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 16px 16px 14px;
  margin: 0;
}

.note {
  background: var(--note-bg);
  color: var(--note);
  font-size: 13px;
  padding: 8px 16px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 16px 0;
}
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.btn:hover { background: #f3f7fb; }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.block { padding: 12px 16px 16px; }
.block + .block { padding-top: 0; }

.section-h {
  background: var(--section);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 7px 12px;
  margin: 0 0 0;
  border-radius: 6px 6px 0 0;
}
.section-h.blue { background: var(--blue); }
.section-h.green { background: var(--green); }

.input-grid,
.rate-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.input-grid th,
.rate-grid th,
.data-table th {
  background: var(--section-sub);
  color: #fff;
  font-weight: 650;
  font-size: 13px;
  padding: 7px 10px;
  text-align: center;
}
.input-grid td,
.rate-grid td,
.rate-grid th[scope="row"] {
  border: 1px solid var(--line);
  padding: 6px 10px;
  background: #fff;
}
.rate-grid th[scope="row"] {
  text-align: left;
  font-weight: 500;
  width: 28%;
}
.hint {
  color: var(--note);
  font-size: 12px;
  background: var(--note-bg) !important;
}

input[type="text"],
input[type="number"] {
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--input-ink);
  background: var(--input-bg);
  border: 1px solid #e6d899;
  border-radius: 4px;
  padding: 6px 8px;
  width: 100%;
  max-width: 160px;
  text-align: right;
}
input:focus {
  outline: 2px solid #5b8def;
  outline-offset: 1px;
  border-color: #c9b44a;
}
/* hide number spinners */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.pct-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  justify-content: flex-end;
}
.pct-wrap input { max-width: 120px; }
.pct { color: var(--input-ink); font-weight: 700; font-size: 14px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 0 0 6px 6px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 640px;
}
.data-table.blue th { background: var(--blue); color: #fff; }
.data-table.green th { background: var(--green); color: #fff; }
.data-table td,
.data-table th[scope="row"] {
  border: 1px solid var(--line);
  padding: 7px 10px;
  background: #fff;
}
.data-table th[scope="row"] { text-align: left; font-weight: 500; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.data-table .total-row th,
.data-table.blue .total-row td { background: var(--blue-sum); font-weight: 700; }
.data-table.green .total-row th,
.data-table.green .total-row td { background: var(--green-sum); font-weight: 700; }

.grand {
  background: var(--total-bg);
  color: var(--total-ink);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 12px;
  margin: 0;
  border: 1px solid #f3c4c0;
  border-top: 0;
  border-radius: 0 0 6px 6px;
}
.grand[hidden] { display: none; }

.stack { margin-top: 18px; }

.site-footer {
  margin-top: auto;
  padding: 18px 16px 28px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}
.site-footer a {
  color: var(--navy);
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .title { font-size: 18px; letter-spacing: 0.03em; padding: 14px 12px; }
  .wrap { width: calc(100% - 16px); margin: 10px auto 24px; }
  .block { padding: 10px 10px 14px; }
  .topbar { padding: 10px 12px; }
  input[type="text"], input[type="number"] { max-width: none; }
  .input-grid, .rate-grid { font-size: 13px; }
  .hint { display: none; }
  .data-table { font-size: 13px; }
}

@media print {
  body { background: #fff; }
  .topbar .badge, .toolbar { display: none; }
  .wrap { width: 100%; margin: 0; }
  .sheet { box-shadow: none; border: 0; border-radius: 0; }
  .site-footer { padding-bottom: 0; }
  input[type="text"], input[type="number"] {
    border: 0;
    background: var(--input-bg);
    padding: 2px 4px;
    font-size: 13px;
  }
  .data-table { min-width: 0; font-size: 12px; }
  .block { break-inside: avoid; }
  @page { margin: 12mm; }
}
