:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #fff;
  --text: #17202a;
  --muted: #5f6f82;
  --line: #dce3ec;
  --accent: #b4233a;
  --accent-dark: #8f1b2e;
  --soft: #fff1f3;
  --focus: #2663eb;
  --success: #17623a;
  --danger: #9f1d1d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input { font: inherit; }

.page-shell { width: min(1280px, calc(100% - 32px)); margin: 0 auto; padding: 40px 0 56px; }
.intro { max-width: 810px; margin-bottom: 24px; }
.eyebrow, .section-number { margin: 0 0 8px; color: var(--accent); font-size: .82rem; font-weight: 750; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(2rem, 4vw, 2.35rem); line-height: 1.1; }
h2 { margin-bottom: 6px; font-size: 1.25rem; }
h3 { margin: 0 0 4px; font-size: 1rem; }
.intro p:not(.eyebrow), .hint, .summary-card span, small { color: var(--muted); }
.hint { margin: 0; font-size: .92rem; }

.panel { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 10px 30px rgb(15 23 42 / .06); padding: 24px; }
.calculator-form { display: grid; gap: 16px; }
.section-heading, .inline-heading { display: flex; align-items: start; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.section-heading .hint { max-width: 380px; text-align: right; }
.field-grid { display: grid; gap: 16px; }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 8px; font-weight: 700; }
.field small { font-size: .8rem; font-weight: 400; }
input { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; color: var(--text); background: #fff; }
input:focus, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus), transparent 70%); outline-offset: 2px; }
.input-with-suffix { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.input-with-suffix:focus-within { outline: 3px solid color-mix(in srgb, var(--focus), transparent 70%); outline-offset: 2px; }
.input-with-suffix input { border: 0; outline: 0; min-width: 0; }
.input-with-suffix b { min-width: 36px; padding: 0 10px; color: var(--muted); font-size: .9rem; text-align: center; }
.emphasis-field .input-with-suffix { border-color: color-mix(in srgb, var(--accent), var(--line) 60%); }

.special-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.inline-heading { align-items: center; margin-bottom: 14px; }
.special-payments { display: grid; gap: 12px; }
.special-payment-row { display: grid; grid-template-columns: minmax(180px, .6fr) minmax(180px, .6fr) auto; gap: 12px; align-items: end; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #f8fafc; }
.special-payment-row label { display: grid; gap: 6px; font-size: .9rem; font-weight: 700; }

.rate-rule { display: grid; align-content: center; gap: 4px; min-height: 90px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #f8fafc; }
.rate-rule span, .rate-rule small { color: var(--muted); font-size: .82rem; }
.rate-rule strong { font-size: 1.1rem; }
.legal-note { grid-column: 1 / -1; margin-top: 20px; border-left: 4px solid var(--accent); padding: 14px 16px; background: var(--soft); }
.legal-note p { margin: 6px 0; color: #5c2330; }
.legal-note a { color: var(--accent-dark); font-weight: 700; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.form-actions { justify-content: flex-end; }
button { min-height: 44px; border: 0; border-radius: 6px; padding: 10px 18px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
button:hover { background: var(--accent-dark); }
button.secondary { border: 1px solid var(--line); background: #fff; color: var(--text); }
button.secondary:hover { background: #f8fafc; }

.message { margin: 0 0 16px; border: 1px solid #f3a9a9; border-radius: 8px; padding: 12px 14px; background: #fff5f5; color: var(--danger); }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin: 24px 0 16px; }
.summary-card { display: grid; gap: 7px; min-height: 112px; padding: 18px; }
.summary-card strong { align-self: end; font-size: 1.2rem; }
.accent-card { border-color: #efb8c0; background: var(--soft); }
.table-panel { padding: 0; overflow: hidden; }
.table-heading { padding: 24px 24px 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 1140px; border-collapse: collapse; font-size: .9rem; }
th, td { border-top: 1px solid var(--line); padding: 12px 14px; text-align: right; white-space: nowrap; }
thead th { background: #f8fafc; color: var(--muted); font-size: .78rem; font-weight: 750; vertical-align: bottom; }
th:first-child, td:first-child { padding-left: 24px; text-align: left; }
tbody tr:hover { background: #fafcff; }
.status { display: inline-block; border-radius: 999px; padding: 4px 8px; font-size: .77rem; font-weight: 700; white-space: nowrap; }
.status.exempt { background: #eaf8ef; color: var(--success); }
.status.taxable { background: #fff0f1; color: var(--danger); }
.empty-state { margin: 16px 24px 24px; border: 1px dashed var(--line); border-radius: 6px; padding: 24px; color: var(--muted); background: #f8fafc; }
.legal-disclaimer { max-width: 900px; margin: 24px 0; border-top: 1px solid var(--line); padding: 22px 0; color: var(--muted); font-size: .9rem; }
.legal-disclaimer h2 { color: var(--text); }

@media (max-width: 960px) {
  .three-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .page-shell { width: min(100% - 24px, 1280px); padding-top: 28px; }
  .panel { padding: 18px; }
  .section-heading, .inline-heading { display: grid; gap: 12px; }
  .section-heading .hint { text-align: left; }
  .three-columns, .summary-grid, .special-payment-row { grid-template-columns: 1fr; }
  .summary-card { min-height: 0; }
  .form-actions { justify-content: stretch; }
  .form-actions button { flex: 1; }
}
