:root {
  color-scheme: light;
  --paper: #f5f8fd;
  --panel: #fff;
  --ink: #12213a;
  --muted: #51617b;
  --line: #dbe5f1;
  --field-line: #b7c8df;
  --blue: #1851cc;
  --blue-dark: #1243ae;
  --blue-soft: #ecf3ff;
  --radius: 12px;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
input, button, select { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; text-underline-offset: .23em; }
p, h1, h2, h3, dl, dd { margin: 0; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }

.page { max-width: 1120px; margin: auto; padding: 0 32px 48px; }
.topbar { min-height: 67px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; gap: clamp(12px, 3vw, 23px); }
.topbar a { color: var(--muted); font-size: .875rem; text-decoration: none; }
.topbar a:hover { color: var(--blue); text-decoration: underline; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: .13em; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding-bottom: 6px; background: var(--blue); }
.brand-mark i { width: 3px; height: 6px; border-radius: 1px; background: white; }
.brand-mark i:nth-child(2) { height: 10px; }
.brand-mark i:nth-child(3) { height: 14px; }

.intro { padding: 36px 0 24px; }
h1 { font-size: clamp(2.4rem, 5.4vw, 3.65rem); font-weight: 800; letter-spacing: -.055em; line-height: 1.13; }
h1 span { color: var(--blue); letter-spacing: -.04em; }
.intro p { margin-top: 12px; color: var(--muted); }
.workbench { display: grid; grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr); gap: 16px; }
.panel, .results, .records { border-radius: var(--radius); padding: clamp(17px, 3.1vw, 27px); background: var(--panel); border: 1px solid var(--line); }
.panel, .records { scroll-margin-top: 12px; }
.panel-heading, .result-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 20px; }
h2 { font-size: 1.19rem; font-weight: 750; }
.text-button { background: transparent; border: 0; padding: 4px 2px; font-size: .875rem; color: var(--blue); }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.field-label, .mode-field legend { display: block; margin-bottom: 6px; font-weight: 650; font-size: .9375rem; }
.number-field { background: #fff; display: flex; min-width: 0; align-items: center; border: 1px solid var(--field-line); border-radius: 7px; }
.number-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px #1851cc20; }
.number-field:has(input[aria-invalid="true"]) { border-color: #b12e31; }
.number-field input { flex: 1; min-width: 0; width: 100%; border: 0; background: none; color: var(--ink); padding: 8px 12px; outline: none; font-size: 1.25rem; font-variant-numeric: tabular-nums; font-weight: 650; }
.number-field input::-webkit-inner-spin-button { appearance: none; }
.number-field input[type="number"] { appearance: textfield; }
.number-field > span { color: var(--muted); padding-right: 12px; }
.hint, .method > p { font-size: .875rem; color: var(--muted); margin-top: 6px; }
.mode-field { border: 0; margin: 17px 0 12px; padding: 0; min-width: 0; }
.switch { display: flex; border: 1px solid var(--line); background: #f1f5fb; border-radius: 7px; padding: 3px; }
.switch label { flex: 1; position: relative; text-align: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { display: block; border-radius: 5px; padding: 5px 4px; font-size: .875rem; }
.switch input:checked + span { background: var(--panel); box-shadow: 0 1px 2px #25396124; color: var(--blue-dark); font-weight: 700; }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }
.error { margin-top: 9px; font-size: .875rem; color: #a72a2f; }

.results { display: flex; flex-direction: column; }
.result-heading { margin-bottom: 16px; }
.result-heading > span, .result-metric p { font-size: .875rem; color: var(--muted); }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; flex: 1; }
.result-metric { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: clamp(11px, 2.2vw, 23px); background: var(--blue-soft); border: 1px solid #dbe7fc; border-radius: 8px; }
.result-metric.net-result { background: #f7faff; }
.result-metric h3 { font-size: 1rem; }
.result-number { margin-top: 10px; color: var(--blue); overflow-wrap: anywhere; }
.result-number output { font-weight: 750; font-size: clamp(1.9rem, 5.3vw, 3.35rem); line-height: 1; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.result-number span { margin-left: 3px; font-size: .875rem; }
.result-metric p { margin-top: 8px; }
.readout { padding: 10px 0 0; font-size: .875rem; color: var(--muted); }

.comparison { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 16px; row-gap: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-top: 16px; padding: 16px 20px; }
.comparison-copy p { font-size: .875rem; color: var(--muted); margin-top: 3px; }
.comparison-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.comparison-fields select { color: var(--ink); background: #fff; border: 1px solid var(--field-line); border-radius: 7px; padding: 7px; font-size: .875rem; min-width: 0; }
.compact input { font-size: 1rem; padding: 7px 9px; }
.compact > span { padding-right: 8px; font-size: .875rem; }
.comparison-result { grid-column: 1 / -1; font-size: .875rem; color: var(--muted); }
.comparison-result[data-state="under"] { color: #a72a2f; }
.comparison-result[data-state="over"] { color: #256044; }

.records { margin-top: 16px; }
.records-heading { margin-bottom: 14px; }
.records-heading p { margin-top: 3px; font-size: .875rem; color: var(--muted); }
.record-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.record-name-field { flex: 1 1 250px; max-width: 430px; min-width: 0; }
.record-name-field input { width: 100%; min-height: 42px; padding: 8px 11px; border: 1px solid var(--field-line); border-radius: 7px; background: #fff; color: var(--ink); }
.primary-button, .outline-button { border: 1px solid var(--blue); border-radius: 7px; font-weight: 650; }
.primary-button { min-height: 42px; padding: 8px 14px; background: var(--blue); color: white; }
.primary-button:hover { background: var(--blue-dark); }
.outline-button { padding: 5px 10px; background: var(--panel); color: var(--blue-dark); }
.outline-button:hover { background: var(--blue-soft); }
.record-status { font-size: .875rem; color: var(--blue-dark); overflow-wrap: anywhere; }
.record-status:not(:empty) { margin-top: 9px; }
.record-status[data-state="error"] { color: #a72a2f; }
.empty-state { color: var(--muted); font-size: .875rem; padding: 13px 0 0; }
.record-list { list-style: none; margin: 12px 0 0; padding: 0; }
.record-list:empty { display: none; }
.record-item { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.record-product h3 { font-size: 1rem; overflow-wrap: anywhere; }
.record-product time { color: var(--muted); font-size: .8125rem; }
.record-values { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.record-values dt { font-size: .8125rem; color: var(--muted); }
.record-values dd { color: var(--blue-dark); font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.record-actions { display: flex; align-items: center; gap: 8px; }
.delete-button { color: var(--muted); }
.delete-button:hover { color: #a72a2f; }

.method { padding-top: 24px; scroll-margin-top: 16px; }
.method dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.35fr); margin-top: 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.method dl > div { padding: 10px 12px; }
.method dl > div:first-child { padding-left: 0; }
.method dl > div + div { border-left: 1px solid var(--line); }
.method dt { font-weight: 650; }
.method dd { margin-top: 3px; color: var(--muted); font-size: .875rem; }

@media (max-width: 730px) {
  .page { padding: 0 18px 32px; }
  .topbar { min-height: 56px; }
  .intro { padding: 25px 0 19px; }
  .workbench { grid-template-columns: 1fr; gap: 12px; }
  .result-number output { font-size: clamp(1.9rem, 8.3vw, 3.35rem); }
  .comparison { margin-top: 12px; }
  .record-item { grid-template-columns: minmax(0, 1fr) auto; }
  .record-product { grid-column: 1; }
  .record-values { grid-column: 1 / -1; grid-row: 2; }
  .record-actions { grid-column: 2; grid-row: 1; }
}
@media (max-width: 530px) {
  .comparison { grid-template-columns: 1fr; }
  .record-name-field { flex-basis: 100%; max-width: none; }
  .record-values { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .method dl { grid-template-columns: 1fr; }
  .method dl > div { padding: 8px 0; }
  .method dl > div + div { border-left: 0; border-top: 1px solid var(--line); }
}
