:root {
  --bg: #faf7f2; --surface: #fff; --ink: #1f1b16; --muted: #6b6258; --line: #e7e0d5;
  --brand: #c2410c; --brand-ink: #fff;
  --ok: #2f7d4f; --mid: #a8670f; --low: #c0392b;
  --ok-bg: #e4f3ea; --mid-bg: #fbeed6; --low-bg: #fbe3df;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 10px 28px rgba(0,0,0,.12);
  --r: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f; --surface: #211d18; --ink: #f3ede4; --muted: #a79c8e; --line: #352f27;
    --brand: #ea6a2d; --brand-ink: #1a0e06;
    --ok: #5cc08a; --mid: #e0a53a; --low: #ef6b5b;
    --ok-bg: #1d3328; --mid-bg: #3a2e16; --low-bg: #3d211d;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: calc(56px + env(safe-area-inset-top)) 0 calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); font-size: .875rem; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  padding: env(safe-area-inset-top) 16px 0; height: calc(52px + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between;
  background: var(--brand); color: var(--brand-ink);
}
.top h1 { font-size: 1.15rem; }
.pill { font-size: .75rem; padding: 3px 10px; border-radius: 99px; background: rgba(255,255,255,.22); }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; border: 0; background: none; padding: 8px 2px 9px; font-size: .72rem; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 56px;
}
.tabs button span { font-size: 1.25rem; line-height: 1; }
.tabs button[aria-current="page"] { color: var(--brand); font-weight: 600; }

.fab {
  position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 11;
  display: flex; align-items: center; gap: 8px; border: 0; border-radius: 99px;
  padding: 14px 20px; font-weight: 600; background: var(--brand); color: var(--brand-ink);
  box-shadow: var(--shadow);
}

/* Oversikt */
.hero { display: flex; align-items: center; gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.hero h2 { font-size: 1.1rem; margin-bottom: 4px; }
.hero p { margin: 2px 0; }
.ring { position: relative; width: 96px; height: 96px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.4rem; }
.chips { display: flex; gap: 8px; margin: 14px 0; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 99px;
  padding: 7px 14px; font-size: .9rem; white-space: nowrap;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }

ul { list-style: none; margin: 0; padding: 0; }
.rows, .items { display: flex; flex-direction: column; gap: 8px; }
.row {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px;
}
.ic { width: 40px; height: 40px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.lvl-ok { background: var(--ok); } .lvl-mid { background: var(--mid); } .lvl-low { background: var(--low); }
.pct { font-weight: 700; min-width: 3ch; text-align: right; }

.empty { text-align: center; padding: 32px 12px; color: var(--muted); }
.empty b { color: var(--ink); display: block; font-size: 1.1rem; margin-bottom: 6px; }

/* Lager */
.search, .form input, .form select, .form textarea, .manual input, .add-row input {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); min-height: 44px;
}
.toolbar { display: flex; gap: 8px; }
.toolbar select { width: auto; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-height: 44px; }
.item { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding-right: 8px; }
.item-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; background: none; border: 0; padding: 10px 6px 10px 12px; text-align: left; }
.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex: none; }
.badge { align-self: flex-start; font-size: .75rem; padding: 1px 8px; border-radius: 99px; margin-top: 2px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.mid { background: var(--mid-bg); color: var(--mid); }
.badge.low { background: var(--low-bg); color: var(--low); }
.stepper { display: flex; align-items: center; gap: 2px; flex: none; }
.stepper button, .big-step button {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 1.3rem; line-height: 1;
}
.stepper output { min-width: 2.2ch; text-align: center; font-weight: 700; }
.fine { margin-top: 12px; text-align: center; }

/* Handleliste */
h3.sec { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; }
.check { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; min-height: 52px; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }
.check.done .grow { text-decoration: line-through; opacity: .55; }
.check label { flex: 1; display: flex; flex-direction: column; }
.add-row { display: flex; gap: 8px; margin-top: 8px; }

/* Knapper og skjema */
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 0 16px; min-height: 44px; font-weight: 500;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.danger { color: var(--low); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btns .btn { flex: 1 1 auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 14px; }
.card h2 { font-size: 1rem; margin-bottom: 10px; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.kv input[type=number] { width: 90px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-height: 40px; text-align: right; }
.kv + .kv { border-top: 1px solid var(--line); }

.sheet-wrap { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--bg);
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
}
.sheet h2 { font-size: 1.2rem; margin-bottom: 4px; }
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: .875rem; font-weight: 500; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .with-btn { display: flex; gap: 8px; align-items: stretch; }
.photo { display: flex; align-items: center; gap: 12px; }
.photo img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.photo .ph { width: 72px; height: 72px; border-radius: 10px; background: var(--surface); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 1.5rem; }
.big-step { display: flex; align-items: center; justify-content: center; gap: 20px; margin: 20px 0 6px; }
.big-step button { width: 64px; height: 64px; font-size: 2rem; border-radius: 16px; }
.big-step output { font-size: 3rem; font-weight: 700; min-width: 2ch; text-align: center; }
.center { text-align: center; }

.pick { max-height: 40vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }

/* Skanner */
.scan { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.scan-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.scan .btn { background: rgba(255,255,255,.14); color: #fff; border-color: transparent; }
#reader { width: 100%; flex: 1; min-height: 0; overflow: hidden; }
#reader video { object-fit: cover; }
.scan-msg { text-align: center; margin: 10px 16px; color: #ddd; }
.manual { display: flex; gap: 8px; padding: 0 16px 16px; }
.manual input { background: #1c1c1c; border-color: #333; color: #fff; }

@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 20px; } }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) { .bar i { transition: width .35s; } }

a { color: var(--brand); }
main { padding-bottom: 96px; } /* plass til Skann-knappen under siste vare */
