/* Where the money really goes — CFAG CI: Open Sans, Forest / Emerald / Lime */

@font-face { font-family: 'Open Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/OpenSans-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Open Sans'; font-weight: 600; font-style: normal; font-display: swap; src: url('fonts/OpenSans-SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Open Sans'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/OpenSans-Bold.ttf') format('truetype'); }

:root {
  color-scheme: light;
  --forest: #004000;
  --emerald: #006838;
  --lime: #87C03F;
  --lime-dark: #6BA32E;
  --lime-light: #C8E49E;
  --text: #2A2A2A;
  --text-2: #4A4A4A;
  --muted: #6B7366;
  --soft: #F5F9F2;
  --soft-2: #E8F2E0;
  --extra-dark: #003020;
  --line: #DDE5D6;
  --surface: #FFFFFF;
  --danger: #A12020;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 48, 32, .06), 0 4px 16px rgba(0, 48, 32, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Open Sans', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--soft);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
main { flex: 1; padding: 28px 0 48px; }
h1, h2, h3 { color: var(--forest); line-height: 1.2; margin: 0; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
a { color: var(--emerald); }
a:hover { color: var(--forest); }
img { max-width: 100%; height: auto; }
code { font-family: Consolas, Menlo, monospace; font-size: .9em; color: var(--forest); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 760px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }

/* ---------------------------------------------------------------- header, footer */

.site-header { background: var(--surface); border-bottom: 3px solid var(--lime); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.brand img { display: block; width: 300px; max-width: 64vw; }
.user-nav { display: flex; align-items: center; gap: 16px; font-size: 14px; color: var(--text-2); flex-wrap: wrap; }
.user-nav form { margin: 0; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--emerald); text-decoration: underline; cursor: pointer; }
.site-footer { background: var(--extra-dark); color: #fff; font-size: 13px; }
.site-footer a { color: var(--lime); }
.footer-row { display: flex; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; padding-top: 18px; padding-bottom: 18px; }

/* ---------------------------------------------------------------- buttons, fields */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 20px; border-radius: 8px; border: 2px solid transparent;
  font: 600 15px/1.2 'Open Sans', Arial, sans-serif; text-decoration: none; cursor: pointer; text-align: center;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--forest); color: #fff; }
.btn-primary:hover { background: var(--emerald); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--forest); border-color: var(--forest); }
.btn-secondary:hover { background: var(--soft-2); color: var(--forest); }
.btn-lime { background: var(--lime); color: var(--forest); }
.btn-lime:hover { background: var(--lime-light); color: var(--forest); }
.btn-ghost { background: transparent; color: var(--emerald); border-color: var(--line); width: 100%; margin-top: 18px; }
.btn-ghost:hover { border-color: var(--emerald); }
.btn-outline-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); min-height: 38px; font-size: 13px; padding: 6px 14px; }
.btn-outline-light:hover { border-color: #fff; color: #fff; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; font-weight: 600; color: var(--text); }
input[type=text], input[type=email], input[type=tel], input[type=number] {
  font: 400 16px/1.3 'Open Sans', Arial, sans-serif; color: var(--text);
  padding: 10px 12px; border: 1px solid #B9C4B1; border-radius: 6px; background: #fff; width: 100%; min-height: 44px;
}
input:focus { border-color: var(--emerald); outline: none; box-shadow: 0 0 0 3px rgba(135, 192, 63, .35); }
.has-error input { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 13px; margin: 0; }
.field-hint, .hint, .small { font-size: 13px; color: var(--text-2); margin: 4px 0 0; }
.field-hint { margin: -8px 0 16px; }
.req { color: var(--emerald); }
.alert { background: #FBEDED; color: #6E1515; border-left: 4px solid var(--danger); padding: 12px 14px; border-radius: 6px; margin: 16px 0; font-size: 14px; }
.alert-ok { background: var(--soft-2); color: var(--forest); border-left-color: var(--lime); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 6px; font-size: 14px; }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--emerald); flex: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------------------------------------------------------------- sign-in, registration */

.auth-layout { display: grid; gap: 24px; align-items: start; }
@media (min-width: 900px) { .auth-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 32px; } }
.auth-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 22px; }
@media (min-width: 720px) { .auth-card { padding: 36px 40px; } }
.auth-card h1 { margin: 6px 0 12px; }
.auth-card .lead { font-size: 17px; color: var(--text-2); margin: 0 0 20px; }
.auth-card .btn { width: 100%; }
.auth-card.message .btn, .form-actions .btn { width: auto; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 700; color: var(--emerald); margin: 0; }
.stack { display: flex; flex-direction: column; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 22px 0 14px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-aside { background: var(--forest); color: #fff; border-radius: var(--radius); padding: 28px 24px; }
.auth-aside .eyebrow { color: var(--lime); }
.driver-list { list-style: none; padding: 0; margin: 16px 0 0; counter-reset: d; }
.driver-list li { counter-increment: d; display: grid; grid-template-columns: 34px 1fr; padding: 12px 0; border-top: 1px solid rgba(255, 255, 255, .14); }
.driver-list li::before { content: counter(d); grid-row: span 2; font-weight: 700; color: var(--lime); font-size: 18px; }
.driver-list strong { font-weight: 600; }
.driver-list span { font-size: 13px; color: rgba(255, 255, 255, .75); }
.aside-note { font-size: 14px; color: rgba(255, 255, 255, .85); margin: 16px 0 0; }

.form-section { border: 0; padding: 0; margin: 0 0 18px; }
.form-section legend { font-weight: 700; color: var(--forest); font-size: 15px; padding: 0 0 10px; border-bottom: 1px solid var(--soft-2); width: 100%; margin-bottom: 14px; }
.grid-2, .grid-3 { display: grid; gap: 0 16px; }
@media (min-width: 600px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 2fr 1.4fr; } }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 22px; }

/* ---------------------------------------------------------------- calculator layout */

.calc { display: grid; gap: 20px; align-items: start; }
@media (min-width: 1000px) { .calc { grid-template-columns: 370px minmax(0, 1fr); gap: 24px; } }
.inputs { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 20px 20px; }
@media (min-width: 1000px) { .inputs { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; } }
.group { padding: 16px 0; border-bottom: 1px solid var(--soft-2); }
.group:last-child { border-bottom: 0; }
.group-title { display: flex; align-items: center; gap: 10px; font-size: 16px; margin-bottom: 14px; }
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--lime); color: var(--forest); font-size: 13px; font-weight: 700; }

.seg { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.seg legend { font-size: 14px; font-weight: 600; margin-bottom: 8px; padding: 0; }
.seg-options { display: grid; gap: 6px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 420px) { .seg-options.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.seg-options label { position: relative; cursor: pointer; }
.seg-options input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-options span { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 56px; padding: 6px 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); transition: border-color .12s, background .12s; }
.seg-options strong { font-size: 14px; font-weight: 600; color: var(--text); }
.seg-options small { font-size: 11.5px; color: var(--text-2); line-height: 1.25; }
.seg-options input:checked + span { background: var(--forest); border-color: var(--forest); }
.seg-options input:checked + span strong { color: #fff; }
.seg-options input:checked + span small { color: var(--lime-light); }
.seg-options input:focus-visible + span { outline: 3px solid var(--lime); outline-offset: 2px; }
.seg-options label:hover span { border-color: var(--emerald); }

.custom-panel { background: var(--soft); border-radius: 8px; padding: 14px 14px 2px; margin: -4px 0 14px; }
.custom-panel .field label { font-weight: 400; font-size: 13px; }
.custom-panel input { min-height: 38px; padding: 7px 10px; }

.slider { margin-bottom: 18px; }
.slider:last-child { margin-bottom: 0; }
.slider-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 6px; }
.slider-head label { font-size: 14px; font-weight: 600; }
.slider-value { display: flex; align-items: center; gap: 4px; flex: none; }
.slider-value input { width: 74px; min-height: 36px; padding: 5px 8px; text-align: right; font-weight: 700; color: var(--forest); }
.slider-value .unit { font-size: 14px; color: var(--text-2); width: 14px; }
input[type=range] { width: 100%; accent-color: var(--emerald); height: 28px; margin: 0; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; font-weight: 600; position: relative; }
.switch input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; cursor: pointer; }
.switch-track { flex: none; width: 44px; height: 26px; border-radius: 13px; background: #B9C4B1; position: relative; transition: background .15s; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + .switch-track { background: var(--emerald); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--lime); outline-offset: 2px; }

.rates { margin-top: 16px; font-size: 14px; }
.rates summary { cursor: pointer; color: var(--emerald); font-weight: 600; padding: 4px 0; }
.rates .field { margin-top: 10px; }
.rates label { font-weight: 400 !important; font-size: 13px !important; }

/* ---------------------------------------------------------------- results */

.results { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
/* Small screens: the total comes first, then the inputs, then the detail. */
@media (max-width: 999px) {
  .results { display: contents; }
  .hero { order: -1; }
  .inputs { order: 0; }
  .results > :not(.hero) { order: 1; }
  #stage-toggle { display: none; }
}
.hero { background: var(--forest); color: #fff; border-radius: var(--radius); padding: 24px 22px; display: grid; gap: 18px; }
@media (min-width: 760px) { .hero { grid-template-columns: minmax(0, 1fr) auto; padding: 28px 32px; align-items: center; } }
.hero .eyebrow { color: var(--lime); }
.hero-value { font-size: clamp(38px, 6vw, 60px); font-weight: 700; line-height: 1.05; margin: 8px 0 10px; letter-spacing: -.01em; }
.hero-statement { font-size: 17px; margin: 0; color: rgba(255, 255, 255, .92); max-width: 46ch; }
.talk-line { display: none; margin: 14px 0 0; font-size: 20px; color: var(--lime-light); }
.hero-actions { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
@media (min-width: 760px) { .hero-actions { align-items: flex-end; min-width: 240px; } }
.hero-note { font-size: 13px; color: rgba(255, 255, 255, .8); margin: 0 0 8px; max-width: 280px; }
@media (min-width: 760px) { .hero-note { text-align: right; } }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-left: 4px solid var(--lime); }
.tile-label { font-size: 13px; color: var(--text-2); margin: 0; }
.tile-value { font-size: 24px; font-weight: 700; color: var(--forest); margin: 4px 0 0; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 18px; min-width: 0; }
@media (min-width: 720px) { .card { padding: 24px 26px; } }
.card-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 12px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; font-size: 13px; color: var(--text-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw-total { background: var(--forest); }
.sw-driver { background: var(--lime); }
.sw-discount { background: var(--lime-light); }

.chart { width: 100%; min-height: 200px; }
.chart svg { display: block; overflow: visible; font-family: 'Open Sans', Arial, sans-serif; }
.chart .grid { stroke: #E6ECE1; stroke-width: 1; }
.chart .tick { font-size: 12px; fill: var(--text-2); font-variant-numeric: tabular-nums; }
.chart .xlabel { font-size: 12px; fill: var(--text-2); }
.chart .vlabel { font-size: 13px; font-weight: 700; fill: var(--text); }
.chart .connector { stroke: #9AA894; stroke-width: 1; }
.chart .bar-total { fill: var(--forest); }
.chart .bar-driver { fill: var(--lime); }
.chart .bar-discount { fill: var(--lime-light); }
.chart .hit { fill: transparent; }
.chart .bar-group { cursor: default; outline: none; }
.chart .bar-group:hover .bar-driver, .chart .bar-group:focus .bar-driver { fill: var(--lime-dark); }
.chart .bar-group:hover .bar-discount, .chart .bar-group:focus .bar-discount { fill: #B3D785; }
.chart .bar-group:hover .bar-total, .chart .bar-group:focus .bar-total { fill: var(--emerald); }
.chart .bar-group:focus-visible .hit { stroke: var(--lime); stroke-width: 2; }

.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--extra-dark); color: #fff; padding: 8px 12px; border-radius: 6px; font-size: 13px; display: flex; flex-direction: column; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); max-width: 260px; }
.tooltip[hidden] { display: none; }
.tooltip strong { font-weight: 600; }

.drivers { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: 14px; font-variant-numeric: tabular-nums; }
.drivers th, .drivers td { padding: 9px 10px; text-align: left; }
.drivers thead th { background: var(--forest); color: #fff; font-weight: 600; font-size: 13px; }
.drivers thead th:first-child { border-radius: 6px 0 0 0; }
.drivers thead th:last-child { border-radius: 0 6px 0 0; }
.drivers tbody tr:nth-child(even) { background: var(--soft); }
.drivers td.n { font-weight: 700; color: var(--forest); width: 32px; }
.drivers td.study { color: var(--text-2); }
.drivers .num { text-align: right; white-space: nowrap; }
.drivers tr.sub td { color: var(--text-2); }
.drivers tfoot th, .drivers tfoot td { background: var(--soft-2); color: var(--forest); font-weight: 700; border-top: 2px solid var(--lime); }
@media (max-width: 640px) { .drivers .study { display: none; } }

.delay-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
@media (min-width: 760px) { .delay-row { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.delay-row > div { background: var(--soft); border-radius: 8px; padding: 10px 14px; }
.delay-value { font-size: 19px; font-weight: 700; color: var(--forest); margin: 2px 0 0; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 0; }
@media (min-width: 760px) { .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.facts div { padding: 10px 0; border-bottom: 1px solid var(--soft-2); }
.facts dt { font-size: 13px; color: var(--text-2); }
.facts dd { margin: 2px 0 0; font-weight: 700; color: var(--text); }

.sources summary { cursor: pointer; font-weight: 700; color: var(--forest); font-size: 16px; }
.source-list { padding-left: 22px; font-size: 14px; }
.source-list li { margin-bottom: 8px; }
.source-list li::marker { color: var(--emerald); font-weight: 700; }

.mobile-total { display: none; }
@media (max-width: 999px) {
  .mobile-total { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; background: var(--forest); color: #fff; font-size: 13px; transform: translateY(100%); transition: transform .2s; box-shadow: 0 -2px 10px rgba(0, 0, 0, .15); }
  .mobile-total.visible { transform: translateY(0); }
  .mobile-total strong { font-size: 18px; }
  .page-calc main { padding-bottom: 72px; }
}

/* ---------------------------------------------------------------- stage view (projector) */

body.stage { font-size: 17px; }
body.stage .site-footer, body.stage .user-nav, body.stage .sources, body.stage [data-online-only] { display: none !important; }
body.stage .wrap { max-width: none; }
body.stage .hero-value { font-size: clamp(56px, 7.5vw, 112px); }
body.stage .hero-statement { font-size: 22px; max-width: 60ch; }
body.stage .talk-line { display: block; }
body.stage .tile-value { font-size: 32px; }
body.stage .chart .tick, body.stage .chart .xlabel { font-size: 14px; }
body.stage .chart .vlabel { font-size: 16px; }
body.stage .drivers { font-size: 16px; }
body.stage .mobile-total { display: none; }

/* ---------------------------------------------------------------- admin */

.admin-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.table-scroll { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--soft-2); vertical-align: top; }
.data-table thead th { background: var(--forest); color: #fff; font-weight: 600; white-space: nowrap; }
.data-table .num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.ok { color: var(--emerald); font-weight: 700; }
.fail { color: var(--danger); font-weight: 700; }

@media print {
  .site-header, .site-footer, .inputs, .hero-actions, .mobile-total, .tooltip { display: none !important; }
  body { background: #fff; }
  .calc { display: block; }
  .card, .tile { box-shadow: none; border: 1px solid var(--line); }
}
