:root {
  --sky: #F3F7F5;
  --paper: #FFFFFF;
  --ink: #14271F;
  --ink-soft: #4A5E55;
  --ink-faint: #7A8C84;
  --canopy: #1E5B41;
  --canopy-deep: #143F2D;
  --canopy-tint: #E3EEE8;
  --leaf: #9CCB5B;
  --ochre: #D9A441;
  --line: #D6E2DC;
  --line-soft: #E8EFEB;
  --good: #1E7A50;
  --bad: #B8542F;
  --bad-tint: #F7E7DF;
  --warn-tint: #FBF1DC;
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky: #0F1B16; --paper: #16261F; --ink: #E8F0EC; --ink-soft: #A7B9B0; --ink-faint: #7F948A;
    --canopy: #5FAE84; --canopy-deep: #0B1611; --canopy-tint: #1C3328; --line: #27392F; --line-soft: #1F3027;
    --good: #6CC495; --bad: #E58A62; --bad-tint: #3A2219; --warn-tint: #3A311A; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sky: #0F1B16; --paper: #16261F; --ink: #E8F0EC; --ink-soft: #A7B9B0; --ink-faint: #7F948A;
  --canopy: #5FAE84; --canopy-deep: #0B1611; --canopy-tint: #1C3328; --line: #27392F; --line-soft: #1F3027;
  --good: #6CC495; --bad: #E58A62; --bad-tint: #3A2219; --warn-tint: #3A311A; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--sky); color: var(--ink);
  font-family: "Schibsted Grotesk", system-ui, sans-serif; font-size: 1rem; line-height: 1.55;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ochre); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Header */
.top { padding: 18px 0; }
.top-inner { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand svg { width: 34px; height: 34px; }
.top-link { font-weight: 600; font-size: 0.92rem; color: var(--ink-soft); text-decoration: none; }
.top-link:hover { color: var(--ink); text-decoration: underline; }
main { padding-bottom: 80px; outline: none; }

/* Type */
h1 { font-size: clamp(1.9rem, 3.6vw, 2.75rem); line-height: 1.08; letter-spacing: -0.03em; font-weight: 800; margin: 0 0 12px; }
h2 { font-size: 1.25rem; letter-spacing: -0.015em; margin: 0 0 4px; font-weight: 750; }
h3 { font-size: 1.02rem; margin: 0 0 4px; font-weight: 700; }
.lede { color: var(--ink-soft); font-size: 1.12rem; margin: 0; max-width: 58ch; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.88rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px; padding: 11px 20px; font-weight: 700; font-size: 0.97rem;
  cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.btn-primary { background: var(--canopy); color: #fff; }
.btn-primary:hover { background: var(--canopy-deep); }
:root[data-theme="dark"] .btn-primary, .btn-primary { color: #fff; }
.btn-secondary { background: var(--paper); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ink-faint); }
.btn-ghost { background: transparent; color: var(--canopy); padding: 8px 10px; }
.btn-ghost:hover { text-decoration: underline; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.link { background: none; border: 0; padding: 0; color: var(--canopy); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* Start screen */
.start { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 48px; padding-top: 32px; align-items: start; }
.start > * { min-width: 0; }
.seg { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); margin: 28px 0 16px; }
.seg button { border: 0; background: transparent; padding: 8px 18px; border-radius: 999px; font-weight: 650; color: var(--ink-soft); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--canopy); color: #fff; }
.drop {
  display: block; border: 2px dashed var(--line); border-radius: var(--radius-lg); background: var(--paper);
  padding: 40px 28px; text-align: center; cursor: pointer; transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop.over { border-color: var(--canopy); background: var(--canopy-tint); }
.drop strong { display: block; font-size: 1.15rem; margin-bottom: 4px; }
.drop .muted { font-size: 0.95rem; }
.drop input { display: none; }
.drop-icon { display: block; width: 44px; height: 44px; margin: 0 auto 12px; color: var(--canopy); }
.drop-icon svg { width: 100%; height: 100%; display: block; }
.privacy { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; color: var(--ink-soft); font-size: 0.9rem; max-width: 62ch; }
.privacy svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--canopy); }
.samples { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.samples p { margin: 0 0 12px; font-weight: 650; }
.samples .row { display: flex; flex-wrap: wrap; gap: 10px; }
.formats { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }
.formats h2 { margin-bottom: 14px; }
.formats ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.formats li h3 { font-size: 0.98rem; }
.formats li p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }
.formats .tpl { margin-top: 6px; font-size: 0.88rem; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.formats .tpl a { color: var(--canopy); font-weight: 600; }

/* Notices */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); background: var(--warn-tint); margin: 16px 0; font-size: 0.95rem; }
.notice.error { background: var(--bad-tint); }
.notice.info { background: var(--canopy-tint); }
.notice svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.notice p { margin: 0; }
.notice .actions { margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }

/* Review screen */
.page-head { padding: 28px 0 8px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head > div { min-width: 0; }
.sources { display: grid; gap: 18px; margin-top: 20px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; min-width: 0; }
.source-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.source-head h3 { margin: 0; word-break: break-word; }
.badge { display: inline-block; font-size: 0.8rem; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: var(--canopy-tint); color: var(--canopy); white-space: nowrap; }
.badge.warn { background: var(--warn-tint); color: #8A5A00; }
:root[data-theme="dark"] .badge.warn { color: var(--ochre); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 16px; margin-bottom: 16px; }
.field label, .field .label { display: block; font-size: 0.84rem; font-weight: 650; color: var(--ink-soft); margin-bottom: 4px; }
.field select, .field input[type="text"], .field input[type="number"] {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper);
}
.field select:focus, .field input:focus { border-color: var(--canopy); outline: none; box-shadow: 0 0 0 3px var(--canopy-tint); }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 0.93rem; }
.radio-row label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; font-weight: 500; color: var(--ink); }
.preview-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
table.preview { border-collapse: collapse; font-size: 0.84rem; width: 100%; }
table.preview th, table.preview td { padding: 6px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
table.preview th { background: var(--sky); font-weight: 650; }
table.preview th.use { background: var(--canopy-tint); color: var(--canopy); }
table.preview td.use { color: var(--ink); }
table.preview td:not(.use) { color: var(--ink-faint); }
.review-foot { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 24px; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }

/* Progress */
.progress { max-width: 520px; margin: 72px auto; }
.progress ol { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 14px; }
.progress li { display: flex; gap: 12px; align-items: center; color: var(--ink-faint); font-weight: 600; }
.progress li.active { color: var(--ink); }
.progress li.done { color: var(--ink-soft); }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; }
.active .dot { border-color: var(--canopy); border-top-color: transparent; animation: spin .8s linear infinite; }
.done .dot { background: var(--canopy); border-color: var(--canopy); }
.done .dot::after { content: ""; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Dashboard */
.dash-head { padding: 28px 0 4px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 18px; }
.dash-head .sub { color: var(--ink-soft); font-weight: 600; margin: 0; }
.dash-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 22px 0; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; border-left: 4px solid var(--line); min-width: 0; }
.kpi.good { border-left-color: var(--good); }
.kpi.bad { border-left-color: var(--bad); }
.kpi .label { font-size: 0.88rem; color: var(--ink-soft); font-weight: 600; }
.kpi .val { font-size: clamp(1.5rem, 2.6vw, 1.95rem); font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; margin: 2px 0; }
.kpi .delta { font-size: 0.9rem; font-weight: 650; }
.kpi.good .delta { color: var(--good); }
.kpi.bad .delta { color: var(--bad); }
.kpi .of { color: var(--ink-faint); font-weight: 500; }

.dash-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 18px; align-items: start; }
.dash-grid > * { min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 0; color: var(--ink-faint); font-size: 0.86rem; }

/* Variance chart */
.vchart { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
.vrow { display: grid; grid-template-columns: minmax(90px, 11em) 1fr 4.8em; gap: 12px; align-items: center; font-size: 0.92rem; }
.vrow .name { line-height: 1.25; overflow-wrap: anywhere; }
.vtrack { position: relative; height: 16px; }
.vtrack::before { content: ""; position: absolute; left: 50%; top: -5px; bottom: -5px; width: 1px; background: var(--line); }
.vbar { position: absolute; top: 0; height: 100%; border-radius: 4px; animation: grow .7s cubic-bezier(.2,.7,.2,1) both; }
.vbar.pos { left: 50%; transform-origin: left; }
.vbar.neg { right: 50%; transform-origin: right; }
.vbar.good { background: var(--good); }
.vbar.bad { background: var(--bad); }
.vrow .amt { text-align: right; font-weight: 700; }
.vrow .amt.good { color: var(--good); }
.vrow .amt.bad { color: var(--bad); }
.vlegend { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--ink-faint); margin-top: 14px; padding: 0 4.8em 0 0; }
.vlegend span:first-child { margin-left: calc(min(11em, 40%) + 12px); }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.empty { color: var(--ink-soft); font-size: 0.95rem; margin: 0; }

/* Summary */
.summary .headline { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; margin: 0 0 10px; }
.summary p { margin: 0 0 14px; }
.summary h3 { font-size: 0.92rem; color: var(--ink-soft); margin: 18px 0 8px; }
.summary ul { margin: 0; padding-left: 1.1em; display: grid; gap: 8px; }
.summary li strong { font-weight: 700; }
.summary mark { background: var(--warn-tint); color: inherit; border-bottom: 2px solid var(--ochre); padding: 0 2px; }
.summary-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.86rem; color: var(--ink-soft); }
.verify { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; }
.verify.ok { color: var(--good); }
.verify.warn { color: #8A5A00; }
:root[data-theme="dark"] .verify.warn { color: var(--ochre); }
.verify svg { width: 16px; height: 16px; }
.skeleton { display: grid; gap: 10px; }
.skeleton span { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--line-soft), var(--sky), var(--line-soft)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton span.h { height: 22px; width: 80%; margin-bottom: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Category table */
.cats { margin-top: 18px; }
.cat-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.cat-table th { text-align: right; font-size: 0.82rem; color: var(--ink-soft); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cat-table th:first-child, .cat-table td:first-child { text-align: left; }
.cat-table td { padding: 10px; border-bottom: 1px solid var(--line-soft); text-align: right; vertical-align: middle; }
.cat-table tr.cat-row { cursor: pointer; }
.cat-table tr.cat-row:hover td { background: var(--sky); }
.cat-table .cname { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.chev { width: 16px; height: 16px; flex: none; transition: transform .15s; color: var(--ink-faint); }
tr[aria-expanded="true"] .chev { transform: rotate(90deg); }
.type-tag { font-size: 0.74rem; font-weight: 650; color: var(--ink-faint); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }
.cat-table input.budget { width: 7.5em; text-align: right; padding: 5px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; font-variant-numeric: tabular-nums; }
.cat-table input.budget:hover { border-color: var(--line); }
.cat-table input.budget:focus { border-color: var(--canopy); background: var(--paper); outline: none; box-shadow: 0 0 0 3px var(--canopy-tint); }
.cat-table input.budget::placeholder { color: var(--canopy); font-weight: 600; }
.diff.good { color: var(--good); font-weight: 650; }
.diff.bad { color: var(--bad); font-weight: 650; }
.used { width: 120px; }
.usedbar { height: 8px; border-radius: 4px; background: var(--line-soft); position: relative; overflow: hidden; }
.usedbar span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--good); }
.usedbar span.over { background: var(--bad); }
tr.items-row > td { padding: 0 0 8px 34px; background: var(--sky); }
.items { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.items td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); text-align: right; }
.items td:first-child { text-align: left; }
.items .who { font-weight: 600; }
.items .meta { color: var(--ink-faint); font-size: 0.82rem; }
.items select { font-size: 0.84rem; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); max-width: 170px; }
.flag { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ochre); margin-right: 6px; vertical-align: middle; }
.table-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 0.88rem; color: var(--ink-soft); }
.total-row td { font-weight: 800; border-bottom: 0; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--sky); padding: 12px 18px; border-radius: 999px; font-weight: 600; font-size: 0.93rem; z-index: 10; max-width: calc(100% - 32px); }

/* Print report */
.print-only { display: none; }

@media (max-width: 960px) {
  .start { grid-template-columns: 1fr; gap: 32px; }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .card { padding: 18px 16px; }
  .drop { padding: 30px 18px; }
  .used, .cat-table th.used-h, .cat-table td.used { display: none; }
  .cat-table { font-size: 0.9rem; }
  .cat-table td, .cat-table th { padding: 9px 6px; }
  .cat-table input.budget { width: 5.6em; }
  tr.items-row > td { padding-left: 8px; }
  .items .hide-sm { display: none; }
  .vrow { grid-template-columns: minmax(70px, 7.6em) 1fr 4.4em; gap: 8px; font-size: 0.86rem; }
  .vlegend { padding-right: 4.4em; }
  .vlegend span:first-child { margin-left: calc(7.6em + 8px); }
  .dash-actions .btn { padding: 9px 14px; font-size: 0.9rem; }
  .kpis { grid-template-columns: 1fr; gap: 10px; }
  .kpis.four { grid-template-columns: 1fr 1fr; }
  .kpis.four .of { display: none; }
  .kpi { padding: 12px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .vbar, .active .dot, .skeleton span { animation: none; }
}

@media print {
  @page { margin: 14mm; }
  .cats .card-head p { display: none; }
  :root { --sky: #fff; --paper: #fff; }
  body { font-size: 11pt; }
  .top, .dash-actions, .no-print, .toast, .notice, .summary-foot .btn, .table-foot button, tr.items-row, .chev { display: none !important; }
  .print-only { display: block; }
  .wrap { max-width: none; padding: 0; }
  .card, .kpi { break-inside: avoid; border-color: #ccc; }
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .cat-table input.budget { border: 0; }
  .vbar { animation: none; }
  a { text-decoration: none; }
}
