:root {
  --bg: #f2f4f3;
  --card: #ffffff;
  --ink: #1d2422;
  --muted: #5d6b66;
  --line: #d8dfdc;
  --brand: #1f5c4a;
  --brand-ink: #ffffff;
  --brand-soft: #e3efea;
  --ok: #14573f; --ok-bg: #e2f2ea;
  --warn: #8a5a00; --warn-bg: #fff4d6;
  --bad: #b3261e; --bad-bg: #fdecea;
  --info-bg: #e8f0f7;
  --radius: 12px;
  --tap: 48px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.app { max-width: 680px; margin: 0 auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
.loading { padding: 2rem 0; color: var(--muted); }
h1 { font-size: 1.45rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1.3rem 0 .4rem; }
a { color: var(--brand); }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .85rem; }
.center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 0 12px; }
.topbar.sticky { position: sticky; top: 0; z-index: 10; background: var(--bg); padding-top: calc(10px + env(safe-area-inset-top)); border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.topbar .grow, .grow { flex: 1; min-width: 0; }
.topbar > div:first-child:not(.grow) { flex: 1; }
.kicker { margin: 0 0 2px; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.h-week { font-size: 1.2rem; }
.iconbtn { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); border-radius: 50%; color: var(--ink); text-decoration: none; background: var(--card); border: 1px solid var(--line); flex: none; }
#save-state { font-size: .8rem; color: var(--muted); }
#save-state[data-state="pending"] { color: var(--warn); }
#save-state[data-state="error"] { color: var(--bad); font-weight: 700; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; scroll-margin-top: 90px; }
.card h2 .num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: .85rem; margin-right: 6px; vertical-align: 1px; }
.section-title { margin: 22px 0 10px; }
.demo-banner { background: #fff3c4; border: 2px dashed #b88a00; color: #6b5000; font-weight: 700; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; text-align: center; }

/* Fields */
.field { display: block; margin: 0 0 14px; font-weight: 600; font-size: .95rem; }
.field > label { display: block; }
.field input, .field select, .field textarea, .numrow input, .numrow select {
  display: block; width: 100%; margin-top: 6px; min-height: var(--tap);
  font: inherit; font-weight: 400; color: var(--ink);
  padding: 10px 12px; border: 1.5px solid #b9c4c0; border-radius: 10px; background: #fff;
}
.field textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 3px solid #9fcfb7; outline-offset: 0; border-color: var(--brand); }
input[aria-invalid="true"] { border-color: var(--bad); background: var(--bad-bg); }
.numrow { display: flex; gap: 8px; }
.numrow input { flex: 1; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.numrow select { width: 112px; flex: none; }
.opt { font-weight: 400; color: var(--muted); font-size: .85rem; }
.help { color: var(--muted); font-size: .88rem; margin: 6px 0 12px; font-weight: 400; }
.help.strong { color: var(--ink); background: var(--brand-soft); padding: 8px 10px; border-radius: 8px; }
.err { color: var(--bad); font-size: .85rem; margin: 4px 0 0; font-weight: 600; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; }
.row > .field.small { flex: 0 0 96px; }
.row > .field.grow { flex: 1 1 140px; }
.lbl { display: block; }
.check, .radio { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-weight: 500; cursor: pointer; }
.check input, .radio input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }
.choice { border: 0; padding: 0; margin: 0 0 8px; }
.choice .radio { border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
.choice .radio:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.calc { background: var(--brand-soft); border-radius: 10px; padding: 12px; margin: 0 0 14px; font-size: 1.02rem; }
.bad { color: var(--bad); font-weight: 700; }

.seg { border: 0; padding: 0; margin: 0 0 14px; }
.seg legend { font-weight: 600; font-size: .95rem; margin-bottom: 6px; }
.seg label { display: block; margin-bottom: 6px; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 11px 12px; border: 1.5px solid #b9c4c0; border-radius: 10px; }
.seg input:checked + span { border-color: var(--brand); background: var(--brand); color: #fff; font-weight: 600; }
.seg input:focus-visible + span { outline: 3px solid #9fcfb7; }

/* Alerts & status */
.alert { border-radius: 10px; padding: 12px; margin: 0 0 14px; font-size: .93rem; }
.alert p { margin: 4px 0; }
.alert.warn { background: var(--warn-bg); border: 1px solid #e8c873; }
.alert.info { background: var(--info-bg); border: 1px solid #bcd0e2; }
.alert .btn { margin-top: 8px; }
.status-card.ok { background: var(--ok-bg); border-color: #9fcfb7; color: var(--ok); }
.status-card.warn { background: var(--warn-bg); border-color: #e8c873; }
.status-card.late { background: var(--bad-bg); border-color: #efb1aa; }
.status-card strong { display: block; }
.status-card details { margin-top: 8px; }
.status-card summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.missing { margin: 6px 0 0; padding-left: 1.1em; }
.missing li { margin: 4px 0; }
.missing a { color: var(--ink); }

/* Banner */
.banner { display: flex; gap: 12px; background: #fff4d6; border: 1px solid #e8c873; border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.banner p { margin: 4px 0 10px; }
.banner-ico { color: var(--warn); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 10px 16px; border-radius: 10px; border: 1.5px solid var(--brand); background: #fff; color: var(--brand); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.sm { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.btn.wide { width: 100%; margin-bottom: 10px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger-ghost { border-color: transparent; color: var(--bad); background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.linkbtn { background: none; border: 0; font: inherit; color: var(--brand); cursor: pointer; min-height: 40px; padding: 0 4px; }
.linkbtn.danger { color: var(--bad); }
.bottom-actions { margin-top: 20px; }

/* Week list */
.weeklist { list-style: none; padding: 0; margin: 0; }
.weekitem { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; text-decoration: none; color: var(--ink); }
.chip { display: inline-block; font-size: .78rem; font-weight: 700; padding: 4px 9px; border-radius: 99px; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.late { background: var(--bad-bg); color: var(--bad); }
.chip.demo { background: #fff3c4; color: #6b5000; border: 1px dashed #b88a00; }
.empty { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; }

/* Waste */
.waste-list { list-style: none; padding: 0; margin: 0; }
.waste-entry { border: 1.5px solid var(--line); border-left: 5px solid var(--brand); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.waste-entry.incomplete { border-left-color: #e0a800; }
.entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.entry-problems { color: var(--warn); font-size: .85rem; margin: 0; font-weight: 600; }
.entry-problems:empty { display: none; }

/* Settings */
.switch { display: flex; align-items: center; gap: 12px; min-height: var(--tap); font-weight: 600; margin-bottom: 8px; }
.switch input { width: 26px; height: 26px; accent-color: var(--brand); }
.status-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: .9rem; margin: 10px 0; background: #f6f8f7; padding: 10px; border-radius: 8px; }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; font-weight: 600; }

/* Report */
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.report-actions .btn { flex: 1 1 180px; }
.report-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 40px); background: #1d2422; color: #fff; padding: 12px 16px; border-radius: 10px; max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: .25s; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); }

@media print {
  body { background: #fff; }
  .app { max-width: none; padding: 0; }
  .no-print, .toast { display: none !important; }
  .report-wrap { border: 0; padding: 0; }
  @page { margin: 16mm; }
}

[hidden] { display: none !important; }
#pick .field.grow { flex: 1 1 100%; margin-top: 4px; }
#pick .field.grow .lbl { display: none; }
#pick .field.grow .btn { width: 100%; }

/* Bilagor */
.attach { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 12px; }
.attach-title { font-weight: 600; font-size: .95rem; margin: 0 0 8px; }
.attach-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-bottom: 8px; }
.attach-list:empty { display: none; }
.att-item { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #f6f8f7; }
.att-img a { display: block; aspect-ratio: 1; }
.att-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-doc { grid-column: 1 / -1; }
.att-doc a { display: flex; align-items: center; gap: 8px; padding: 10px 44px 10px 12px; min-height: var(--tap); color: var(--ink); text-decoration: none; }
.att-doc a span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-doc small { color: var(--muted); white-space: nowrap; }
.att-del { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(29,36,34,.75); color: #fff; font-size: 1.3rem; line-height: 1; cursor: pointer; }
.att-doc .att-del { top: 50%; transform: translateY(-50%); background: transparent; color: var(--bad); }
.attach-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.attach-btns .btn { gap: 6px; flex: 1 1 140px; }
.attach-btns .btn:focus-within { outline: 3px solid #9fcfb7; }
