:root {
  --bg: #edf0ec;
  --surface: #ffffff;
  --ink: #141c18;
  --muted: #56645d;
  --line: #d3dad4;
  --accent: #1f5b49;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe3;
  --amber: #7a4e00;
  --amber-soft: #f7e8c4;
  --ok: #1a6a3c;
  --ok-soft: #d8efdf;
  --danger: #a32d2d;
  --danger-soft: #f6dcdc;
  --focus: #0b6bd3;
  --pad-bg: #ffffff;
  --pad-ink: #101613;
  --head: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1310;
    --surface: #171f1b;
    --ink: #eaf0ec;
    --muted: #9ba8a1;
    --line: #2a3630;
    --accent: #5cc7a0;
    --accent-ink: #06231a;
    --accent-soft: #1e3b31;
    --amber: #f0be5b;
    --amber-soft: #3a2e12;
    --ok: #7fd69c;
    --ok-soft: #173424;
    --danger: #ff8f8f;
    --danger-soft: #3d1c1c;
    --focus: #6db3ff;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1310;
  --surface: #171f1b;
  --ink: #eaf0ec;
  --muted: #9ba8a1;
  --line: #2a3630;
  --accent: #5cc7a0;
  --accent-ink: #06231a;
  --accent-soft: #1e3b31;
  --amber: #f0be5b;
  --amber-soft: #3a2e12;
  --ok: #7fd69c;
  --ok-soft: #173424;
  --danger: #ff8f8f;
  --danger-soft: #3d1c1c;
  --focus: #6db3ff;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; }
html { color-scheme: light dark; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 560px; margin-inline: auto; padding-inline: 16px; padding-block: 0 112px; }
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-block: 18px 12px; }
.brand { font-family: var(--head); font-weight: 700; font-size: 28px; letter-spacing: 0.01em; line-height: 1; }
.count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
h1, h2 { font-family: var(--head); margin: 0; line-height: 1.1; text-wrap: balance; }
h2 { font-size: 24px; font-weight: 700; }
.label { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.notice { background: var(--amber-soft); color: var(--amber); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-block-end: 12px; }
.banner { background: var(--ok-soft); color: var(--ok); border-radius: 8px; padding: 12px 14px; font-weight: 600; margin-block-end: 14px; }

.tools { display: flex; flex-direction: column; gap: 10px; margin-block-end: 14px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 10px 8px; border-radius: 7px; font-weight: 600; font-size: 15px; color: var(--muted); min-height: 44px; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 13px; color: var(--muted); font-weight: 400; }
input[type="text"], input[type="tel"], input[type="search"], input[type="date"], select, textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px; font-size: 16px;
}
select { appearance: auto; padding-inline: 10px; }
textarea { min-height: 112px; resize: vertical; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
.form { display: flex; flex-direction: column; gap: 18px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.error { color: var(--danger); font-weight: 600; font-size: 14px; }
.error:empty { display: none; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; cursor: pointer; }
.item:active { background: var(--accent-soft); }
.item .who { font-weight: 600; font-size: 17px; overflow-wrap: anywhere; }
.item .where { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.item .sum { font-family: var(--head); font-weight: 700; font-size: 19px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item .when { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; margin-block-end: 4px; margin-inline-end: 4px; }
.chip.tillegg { background: var(--amber-soft); color: var(--amber); }
.chip.tilbud { background: var(--accent-soft); color: var(--accent); }
.chip.klar { background: var(--ok-soft); color: var(--ok); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-block-end: 8px; }
.empty p { margin: 0 auto; max-width: 34ch; }

.cta { position: fixed; inset-inline: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--bg); border-top: 1px solid var(--line); }
.cta .inner { max-width: 560px; margin-inline: auto; display: flex; gap: 10px; }
.btn { appearance: none; border: 0; border-radius: 12px; min-height: 56px; padding: 0 20px; font-weight: 600; font-size: 17px; cursor: pointer; flex: 1; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); flex: 0 0 auto; }
.btn.small { min-height: 46px; font-size: 15px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.link { appearance: none; background: none; border: 0; padding: 8px 0; min-height: 44px; color: var(--accent); font-weight: 600; font-size: 15px; cursor: pointer; }
.link.danger { color: var(--danger); }
.actions { display: flex; justify-content: space-between; gap: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.card dl { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.card dt { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.card dd { margin: 2px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.card dd.big { font-family: var(--head); font-size: 24px; font-weight: 700; line-height: 1.15; }

.lines { white-space: normal; display: flex; flex-direction: column; margin-block-start: 4px; }
.ln { display: flex; justify-content: space-between; gap: 12px; padding-block: 10px; border-bottom: 1px solid var(--line); }
.ln-t { font-weight: 600; }
.ln-m { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.ln-s { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.tot { display: flex; justify-content: space-between; gap: 12px; padding-block: 6px 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.tot:first-of-type { padding-block-start: 12px; }
.tot span:last-child { white-space: nowrap; }
.tot.big { align-items: baseline; color: var(--ink); font-family: var(--head); font-size: 24px; font-weight: 700; padding-block-start: 8px; }

.customer-bar { background: var(--accent); color: var(--accent-ink); border-radius: 12px; padding: 14px 16px; margin-block-end: 14px; }
.customer-bar strong { font-family: var(--head); font-size: 22px; display: block; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; }
.check input { width: 26px; height: 26px; flex: none; margin: 0; accent-color: var(--accent); }
.check span { font-size: 16px; font-weight: 500; }

.pad { position: relative; background: var(--pad-bg); border: 2px solid var(--line); border-radius: 10px; overflow: hidden; }
.pad canvas { display: block; width: 100%; aspect-ratio: 2 / 1; touch-action: none; cursor: crosshair; }
.pad::after { content: ""; position: absolute; left: 44px; right: 16px; top: 72%; border-top: 2px solid #9aa79f; pointer-events: none; }
.pad .x { position: absolute; left: 14px; top: calc(72% - 24px); color: #6b7871; font-size: 24px; line-height: 1; pointer-events: none; font-family: var(--head); font-weight: 700; }
.pad .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #8d9a93; font-size: 17px; pointer-events: none; padding-bottom: 30px; }
.pad .ph[hidden] { display: none; }
.padbar { display: flex; justify-content: space-between; align-items: center; }

.line { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.line-grid { display: grid; grid-template-columns: 0.8fr 1fr 1.2fr; gap: 8px; }
.line-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); }
.line-grid input, .line-grid select { min-height: 46px; padding-inline: 10px; }
.line-foot { display: flex; justify-content: space-between; align-items: center; }
.line-sum { font-weight: 600; font-variant-numeric: tabular-nums; }
.lines-edit { display: flex; flex-direction: column; gap: 10px; }
.sums { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.sums .tot:first-child { padding-block-start: 0; }

.sigimg { background: #ffffff; border: 1px solid var(--line); border-radius: 8px; width: 100%; aspect-ratio: 2 / 1; object-fit: contain; display: block; }
.sigwait { aspect-ratio: 2 / 1; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; }
.meta { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 14px; }
@media (prefers-reduced-motion: no-preference) { .item, .btn { transition: background-color 0.12s; } }

input[type="password"] { width: 100%; min-height: 50px; padding: 12px 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; font-size: 16px; }
a.btn { display: grid; place-items: center; text-decoration: none; }
.userbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-block-end: 10px; color: var(--muted); font-size: 14px; }
.userbar .links { display: flex; gap: 14px; }
.userbar .link { min-height: 36px; padding-block: 4px; }
.login { padding-block: 64px 24px; display: flex; flex-direction: column; gap: 18px; }
.login .brand { font-size: 36px; }
.login p { margin: 0; color: var(--muted); }
.urow { display: flex; flex-direction: column; gap: 8px; padding-block: 12px; border-bottom: 1px solid var(--line); }
.urow:last-child { border-bottom: 0; }
.urow-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.urow-h .nm { font-weight: 600; overflow-wrap: anywhere; }
.urow .off { color: var(--muted); }
.urow-a { display: flex; gap: 16px; flex-wrap: wrap; }
.pwrow { display: flex; gap: 8px; }
.pwrow input { flex: 1; }
.pwrow .btn { flex: 0 0 auto; min-height: 50px; }
.chip.rolle { background: var(--accent-soft); color: var(--accent); }
.chip.rolle.snekker { background: var(--amber-soft); color: var(--amber); }

.okmsg { color: var(--ok); font-weight: 600; font-size: 14px; }
.okmsg:empty { display: none; }
