/* ProRataWise — quiet, trustworthy insurance-ops tool. No marketing gradients. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #18222e;
  --text-muted: #5a6675;
  --border: #e2e7ec;
  --border-strong: #c9d2db;
  --teal: #0f766e;
  --teal-strong: #0d5c55;
  --teal-soft: #e7f2f0;
  --teal-accent: #14b8a6;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .04), 0 10px 28px rgba(16, 24, 32, .06);
  --maxw: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; color: var(--text); margin: 0 0 .5em; }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.375rem; letter-spacing: -.01em; }
h3 { font-size: 1.0625rem; margin-top: 1.6em; }
p { margin: 0 0 1em; }
a { color: var(--teal-strong); }
code, pre { font-family: var(--mono); }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 760px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--teal); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 3px solid var(--teal-accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--teal); color: #fff; font-weight: 800; font-size: .95rem;
}
.brand-name { letter-spacing: -.01em; }
.site-nav { display: flex; gap: 20px; }
.site-nav a { text-decoration: none; color: var(--text-muted); font-size: .9375rem; font-weight: 500; }
.site-nav a:hover { color: var(--text); }

/* ---------- Tool section ---------- */
.tool-section { padding: 40px 0 56px; }
.tool-section h1 { margin-bottom: 8px; }
.lead { color: var(--text-muted); font-size: 1.0625rem; max-width: 60ch; margin-bottom: 28px; }

.tool-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px;
  min-width: 0;
}

/* ---------- Form ---------- */
.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field > label, .field-row label {
  display: block; font-size: .875rem; font-weight: 600; margin-bottom: 6px; color: var(--text);
}
input[type="text"], input[type="date"] {
  width: 100%; font: inherit; color: var(--text);
  padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, input[type="date"]:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}
.input-money { position: relative; }
.input-money .currency {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-weight: 600; pointer-events: none;
}
.input-money input { padding-left: 26px; }
.field-help { font-size: .8125rem; color: var(--text-muted); margin: 6px 0 0; }
.field-help code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: .85em; }

.mode-control { border: 0; padding: 0; margin: 0 0 8px; }
.mode-control legend { font-size: .875rem; font-weight: 600; margin-bottom: 8px; padding: 0; }
.mode-control { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg { position: relative; display: block; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; padding: 10px 12px; text-align: center;
  font-size: .875rem; color: var(--text-muted); border-radius: 0; transition: background .15s, color .15s;
}
.seg input:checked + span { background: var(--teal); color: #fff; font-weight: 600; }
.seg:first-child span { border-right: 1px solid var(--border-strong); }
.seg:hover span { color: var(--text); }
.seg input:checked + span strong { color: #fff; }
.seg input:focus-visible + span { box-shadow: inset 0 0 0 3px var(--teal-accent); }

.actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 600; padding: 11px 20px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-strong); }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal-strong); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.form-error {
  margin-top: 14px; padding: 10px 14px; background: var(--danger-soft);
  border: 1px solid #f5c6c2; color: var(--danger); border-radius: var(--radius-sm); font-size: .9rem;
}

.examples-inline { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 14px; }
.examples-inline summary { cursor: pointer; font-size: .875rem; color: var(--text-muted); font-weight: 500; }
.example-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  font: inherit; font-size: .8125rem; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.chip:hover { border-color: var(--teal); color: var(--teal-strong); }

/* ---------- Results ---------- */
.results { min-height: 420px; display: flex; }
.results-empty, .results-body { width: 100%; }
.results-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; color: var(--text-muted); padding: 32px 16px; }
.results-empty-icon {
  width: 56px; height: 56px; border-radius: 14px; background: var(--teal-soft); color: var(--teal);
  display: grid; place-items: center; font-size: 1.6rem; font-weight: 800;
}
.results-empty p { margin: 0; max-width: 36ch; }

.result-headline { text-align: center; padding-bottom: 20px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.result-label { font-size: .8125rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 4px; font-weight: 600; }
.result-amount { font-size: 2.5rem; font-weight: 800; color: var(--teal); margin: 0; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.result-sub { font-size: .8125rem; color: var(--text-muted); margin: 4px 0 0; }

.result-amounts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.amount-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.amount-label { font-size: .8125rem; color: var(--text-muted); margin: 0 0 2px; }
.amount-value { font-size: 1.25rem; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }

.day-grid, .factor-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 16px;
}
.factor-grid { grid-template-columns: 1fr 1fr; padding-top: 14px; border-top: 1px solid var(--border); }
.day-grid dt, .factor-grid dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 0 0 2px; font-weight: 600; }
.day-grid dd, .factor-grid dd { margin: 0; font-size: 1.0625rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.formula {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 16px 0; font-family: var(--mono); font-size: .8125rem;
  line-height: 1.9; color: var(--text); overflow-x: auto; min-width: 0;
}
.formula .fline { display: block; white-space: normal; overflow-wrap: break-word; }
.formula em { font-style: normal; color: var(--teal-strong); font-weight: 600; }

.disclaimer {
  font-size: .8125rem; color: var(--text-muted);
  background: var(--teal-soft); border: 1px solid #cde6e1;
  border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 16px;
}
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.copy-status { font-size: .8125rem; color: var(--teal-strong); margin: 8px 0 0; font-weight: 600; }

/* ---------- Content sections ---------- */
.content-section { padding: 48px 0; border-top: 1px solid var(--border); }
.content-section.tint { background: var(--surface); }
.content-section h2 { margin-bottom: 20px; }
.content-section h3 { color: var(--text); }
.content-section ul, .content-section ol { padding-left: 1.2em; }
.content-section li { margin-bottom: 10px; }
.content-section li strong { color: var(--text); }
.muted { color: var(--text-muted); }
.formula-block {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: .875rem; line-height: 1.9; overflow-x: auto; white-space: pre-wrap; margin: 16px 0;
}

.example-list, .mistake-list { padding-left: 1.3em; }
.example-list li, .mistake-list li { margin-bottom: 18px; padding-left: 6px; }
.example-list li p, .mistake-list li p { margin: 0 0 4px; }

.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-list details {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 16px;
}
.faq-list summary { cursor: pointer; font-weight: 600; padding: 12px 0; list-style: none; position: relative; padding-right: 24px; }
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after {
  content: "+"; position: absolute; right: 0; top: 12px; font-size: 1.25rem; color: var(--text-muted); font-weight: 400;
}
.faq-list details[open] summary::after { content: "−"; }
.faq-list details[open] summary { padding-bottom: 8px; }
.faq-list p { margin: 0 0 12px; color: var(--text-muted); }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 32px 0; margin-top: 0; }
.footer-row { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.footer-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.footer-nav { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.footer-nav a { text-decoration: none; color: var(--text-muted); font-size: .9rem; }
.footer-nav a:hover { color: var(--teal-strong); }
.footer-note { font-size: .8125rem; color: var(--text-muted); margin: 4px 0 0; max-width: 52ch; }
.footer-copy { font-size: .8125rem; color: var(--text-muted); margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .tool-grid { grid-template-columns: 1fr; }
  .results { min-height: auto; }
}
@media (max-width: 480px) {
  .tool-section { padding: 28px 0 40px; }
  .container { padding: 0 18px; }
  .content-section { padding: 36px 0; }
  h1 { font-size: 1.5rem; }
  .field-row { grid-template-columns: 1fr; }
  .day-grid { grid-template-columns: 1fr 1fr; }
  .day-grid > div:last-child { grid-column: 1 / -1; }
  .result-amount { font-size: 2rem; }
  .result-amounts { grid-template-columns: 1fr; }
  .header-row {
    height: auto; min-height: 60px; flex-wrap: wrap;
    padding-top: 8px; padding-bottom: 0;
  }
  .brand { min-height: 44px; }
  .site-nav {
    order: 2; width: 100%; gap: 0;
    border-top: 1px solid var(--border);
  }
  .site-nav a {
    flex: 1; min-height: 44px; padding: 10px 4px;
    text-align: center; white-space: nowrap; font-size: .8125rem;
  }
  .card { padding: 18px; }
}

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

/* ---------- Print ---------- */
@media print {
  :root { --bg: #fff; }
  body { background: #fff; }
  .site-header, .site-footer, .site-nav, .skip-link,
  .actions, .result-actions, .examples-inline, .inputs,
  #form-error { display: none !important; }
  .tool-grid { grid-template-columns: 1fr; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  .content-section { display: none; }
  .result-amount { color: #000; }
}
