:root {
    --bg: #f7f4ec;
    --surface: #ffffff;
    --surface-2: #efeadc;
    --text: #1f2a1c;
    --muted: #5b6455;
    --line: #ddd5c2;
    --brand: #2f4a2a;
    --brand-2: #4c7a3d;
    --wheat: #c8922a;
    --wheat-soft: #f6e7c4;
    --good: #2e7d32;
    --warn: #b26a00;
    --bad: #b3261e;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(31, 42, 28, .06), 0 6px 24px rgba(31, 42, 28, .06);
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #12160f; --surface: #1a2016; --surface-2: #222a1d; --text: #ecefe6; --muted: #a9b29f;
        --line: #333d2c; --brand: #9cc78a; --brand-2: #7fb069; --wheat: #e6b45a; --wheat-soft: #3a3020;
        --good: #7bc47f; --warn: #f0b057; --bad: #ef8a80; --shadow: none; color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #12160f; --surface: #1a2016; --surface-2: #222a1d; --text: #ecefe6; --muted: #a9b29f;
    --line: #333d2c; --brand: #9cc78a; --brand-2: #7fb069; --wheat: #e6b45a; --wheat-soft: #3a3020;
    --good: #7bc47f; --warn: #f0b057; --bad: #ef8a80; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 'Inter', system-ui, sans-serif; }
a { color: var(--brand-2); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(32px, 5vw, 52px); margin: 0 0 16px; font-weight: 800; }
h2 { font-size: clamp(24px, 3vw, 32px); margin: 0 0 12px; }
h3 { font-size: 20px; margin: 0 0 8px; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--surface); padding: 8px 12px; z-index: 99; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.header-row { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 18px; }
.site-nav { display: flex; gap: 4px; }
.site-nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px; padding: 8px 12px; border-radius: 8px; }
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--brand); color: #fff; }
.menu-btn { display: none; font: inherit; font-weight: 600; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; }
@media (max-width: 860px) {
    .menu-btn { display: block; }
    .site-nav { display: none; position: absolute; left: 0; right: 0; top: 64px; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 16px; }
    .site-nav.open { display: flex; }
    .site-nav a { padding: 12px; font-size: 17px; }
}

/* Page sections */
.page-head { padding-top: 48px; padding-bottom: 24px; }
.page-head p { font-size: 19px; color: var(--muted); max-width: 720px; margin: 0; }
.section { padding-top: 24px; padding-bottom: 48px; }
.hero { background: linear-gradient(160deg, var(--brand) 0%, #3d5e33 60%, #6b7f2e 100%); color: #fff; padding: 72px 0 64px; }
.hero h1 { color: #fff; max-width: 780px; }
.hero p { font-size: 20px; max-width: 640px; color: #e8efe2; margin: 0 0 28px; }
.hero .btn-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* Components */
.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 700; padding: 12px 20px; border-radius: 10px; border: 0; background: var(--wheat); color: #1f1a0e; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: transparent; color: inherit; border: 2px solid currentColor; }
.grid { display: grid; gap: 20px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) { .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }
a.card { display: block; text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; }
a.card:hover { transform: translateY(-2px); border-color: var(--brand-2); }
.card .icon { font-size: 28px; line-height: 1; margin-bottom: 12px; }
.card .more { font-weight: 700; color: var(--brand-2); }
.notice { border-left: 4px solid var(--wheat); background: var(--wheat-soft); padding: 16px 20px; border-radius: 0 10px 10px 0; margin: 0 0 24px; }
.notice.bad { border-color: var(--bad); }
.notice strong { display: block; margin-bottom: 4px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.badge.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.stat { font-size: 32px; font-weight: 800; }
.stat-label { font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; }
thead th { white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.neg { color: var(--bad); }
.pos { color: var(--good); }

/* Forms */
label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 4px; }
input, select { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
input:focus, select:focus, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--wheat) 60%, transparent); outline-offset: 2px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-unit { position: relative; }
.input-unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.input-unit input { padding-right: 56px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* Contracts guide */
details.contract { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
details.contract summary { cursor: pointer; padding: 18px 22px; font-weight: 700; font-size: 19px; list-style: none; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
details.contract summary::-webkit-details-marker { display: none; }
details.contract summary::after { content: "+"; font-size: 24px; color: var(--muted); }
details.contract[open] summary::after { content: "\2212"; }
details.contract .body { padding: 0 22px 22px; }
details.contract .one-liner { font-weight: 400; font-size: 15px; color: var(--muted); display: block; margin-top: 2px; }
.pros-cons { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.pros-cons > div { background: var(--surface-2); border-radius: 10px; padding: 14px 16px; }
.pros-cons ul { margin: 6px 0 0; padding-left: 20px; }
@media (max-width: 640px) { .pros-cons, .field-row { grid-template-columns: 1fr; } }
.example { border: 1px dashed var(--line); border-radius: 10px; padding: 14px 16px; margin: 12px 0; }
.example strong { color: var(--brand-2); }
dl.glossary dt { font-weight: 700; margin-top: 16px; }
dl.glossary dd { margin: 4px 0 0; color: var(--muted); }

/* Weather */
.loc-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 20px; }
.loc-bar .field { flex: 1 1 260px; margin: 0; }
.now { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
.now .temp { font-size: 56px; font-weight: 800; line-height: 1; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; }
.facts div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.facts b { display: block; font-size: 18px; }
.facts span { font-size: 13px; color: var(--muted); }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.day h4 { margin: 0 0 6px; font-size: 15px; }
.day img { width: 40px; height: 34px; }
.day .t { font-weight: 800; font-size: 20px; }
.hours { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.hour { flex: 0 0 86px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 8px; text-align: center; font-size: 14px; }
.hour .h { font-weight: 700; }
.hour .tt { font-size: 18px; font-weight: 800; }
.spray-good { border-top: 4px solid var(--good); }
.spray-marginal { border-top: 4px solid var(--warn); }
.spray-no { border-top: 4px solid var(--bad); }
.warning-box { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); border: 1px solid var(--bad); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; }

/* Almanac */
.month-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.month { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.month.current { border: 2px solid var(--wheat); }
.month h3 { display: flex; justify-content: space-between; align-items: baseline; }
.month ul { margin: 8px 0 0; padding-left: 20px; }
.month .tag { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--wheat); letter-spacing: .05em; margin-top: 10px; }

/* Break-even */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.calc > * { min-width: 0; }
@media (max-width: 860px) { .calc { grid-template-columns: minmax(0, 1fr); } .results { position: static; } }
.results { position: sticky; top: 84px; }
.result-big { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.result-big > div { background: var(--surface-2); border-radius: 12px; padding: 16px; }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 6px; margin: 0 0 16px; background: var(--surface); }
legend { font-weight: 800; padding: 0 6px; }

/* Footer */
.site-footer { margin-top: 48px; background: var(--surface); border-top: 1px solid var(--line); padding: 40px 0 24px; font-size: 15px; }
.footer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.footer-grid p { color: var(--muted); margin: 6px 0 0; }
.fineprint { margin-top: 28px; font-size: 13px; color: var(--muted); }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr; } }

@media print {
    .site-header, .site-footer, .menu-btn, .btn { display: none !important; }
    body { background: #fff; }
}

/* Phones: stack wide tables into cards, shrink big numbers */
.result-big { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) {
    table.stack thead { display: none; }
    table.stack tr, table.stack td { display: block; }
    table.stack tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
    table.stack tr:last-child { border-bottom: 0; }
    table.stack td { border: 0; padding: 2px 16px; }
    table.stack th { display: block; background: none; border: 0; padding: 4px 16px 0; }
    table.stack td:first-child { font-weight: 700; }
    .stat { font-size: 26px; }
}
