/* =========================================================
   Svinnkontroll – stil
   Rolig bladgrønn bakgrunn, dyp skoggrønn topp, KIWI-grønn
   bare på hovedknappene. Bricolage Grotesque til titler og tall,
   Figtree til tekst.
   ========================================================= */

:root {
  --bg: #e8eee4;          /* lys bladgrønn bakgrunn */
  --surface: #f7f9f4;     /* kort – svakt grønnhvit, ikke kritthvit */
  --surface-2: #eef3ea;
  --ink: #18261d;
  --ink-2: #3d4d42;
  --muted: #66766a;
  --line: #d2dccd;
  --line-strong: #b9c7b3;

  --forest: #1d4630;      /* topp og mørke flater */
  --forest-2: #275b3f;
  --kiwi: #45a83a;        /* KIWI-grønn: hovedknapper */
  --kiwi-dark: #2f7d27;
  --kiwi-soft: #dcefd5;

  --good: #2f7d27;
  --warn: #c7771c;
  --warn-soft: #fbecd6;
  --bad: #c0412d;
  --bad-soft: #f8e1dc;

  --blue: #3c5f94;        /* Kreditert */
  --blue-soft: #e1e8f4;
  --blue-fill: #3c5f94;

  /* Flater som ellers ville vært hardkodet – får egne verdier i mørk modus */
  --accent: #275b3f;      /* lenker, grafer */
  --field: #fff;          /* inndatafelt */
  --seg-on: #fff;
  --due-bg: #fbf3f1;
  --tabbar-bg: rgba(247, 249, 244, .92);
  --tabbar-shadow: 0 8px 28px rgba(24, 38, 29, .16);
  --tab-on: #1d4630;
  --warn-ink: #8a5208;
  --bad-ink: #842b1d;
  --bad-line: #efc2b8;
  --hover-tint: rgba(29, 70, 48, .06);
  --kind-blue-line: #b9c8e2;
  --kind-green-line: #b7d8ae;
  --danger-line: #e5b4aa;
  color-scheme: light;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --shadow: 0 1px 2px rgba(24, 38, 29, .06), 0 4px 14px rgba(24, 38, 29, .05);
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font: "Figtree", "Segoe UI", system-ui, sans-serif;
}

/* ---------- Mørk modus: natt i skogen ---------- */
:root[data-theme="dark"] {
  --bg: #0d1611;
  --surface: #15211a;
  --surface-2: #1b2a21;
  --ink: #e3ebe1;
  --ink-2: #c0cdbf;
  --muted: #8d9e91;
  --line: #26362c;
  --line-strong: #36493d;

  --forest: #0f2418;
  --forest-2: #2c6345;
  --kiwi: #4fb343;
  --kiwi-dark: #7ccc70;
  --kiwi-soft: #1d3a22;

  --good: #7ccc70;
  --warn: #e2a24a;
  --warn-soft: #3a2c14;
  --bad: #e0634d;
  --bad-soft: #3b1d18;

  --blue: #86a7dc;
  --blue-soft: #1c2840;
  --blue-fill: #3d63a0;

  --accent: #8fd09a;
  --field: #101a14;
  --seg-on: #2a3b30;
  --due-bg: #2a1915;
  --tabbar-bg: rgba(21, 33, 26, .9);
  --tabbar-shadow: 0 8px 28px rgba(0, 0, 0, .5);
  --tab-on: #a5dd9b;
  --warn-ink: #f0c27a;
  --bad-ink: #f3a596;
  --bad-line: #6a2e24;
  --hover-tint: rgba(143, 208, 154, .08);
  --kind-blue-line: #3a5078;
  --kind-green-line: #35603a;
  --danger-line: #6a2e24;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--kiwi-dark); }
img { max-width: 100%; }
[hidden] { display: none !important; }

h1, h2 { font-family: var(--font-display); color: var(--ink); letter-spacing: -.02em; }
h1 { font-size: 2rem; font-weight: 700; line-height: 1.1; margin: .25em 0 .35em; }
h2 { font-size: 1.25rem; font-weight: 650; line-height: 1.2; margin: 1.6em 0 .6em; }
.card h2:first-child { margin-top: 0; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 64px; }
.muted { color: var(--muted); }
.small, small { font-size: .875rem; }
.right { text-align: right; }
.center { text-align: center; }
.sub { margin-top: -4px; }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }

:focus-visible { outline: 3px solid var(--kiwi); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Topp ---------- */
.top {
  background: var(--forest);
  color: #fff;
  margin-bottom: 18px;
  padding-top: env(safe-area-inset-top);
  position: relative;
  z-index: 5;
}
.top .wrap { max-width: 1240px; }
.top-inner { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.brand, .login-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand:hover { color: inherit; }
.brand-store {
  background: var(--kiwi); color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; letter-spacing: .02em;
  padding: 3px 10px; border-radius: 8px;
}
.brand-app { font-family: var(--font-display); font-weight: 650; font-size: 1.25rem; letter-spacing: -.01em; }
.desk-nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: 18px; flex: 1; }
.desk-nav a, .who-box a {
  color: rgba(255,255,255,.82); text-decoration: none; font-weight: 600; font-size: .95rem;
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
}
.desk-nav a:hover, .who-box a:hover { background: rgba(255,255,255,.1); color: #fff; }
.desk-nav a.on, .who-box a.on { background: rgba(255,255,255,.16); color: #fff; }
.who-box { display: flex; gap: 2px; margin-left: auto; }

.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--bad); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 20px;
  font-style: normal;
}

/* ---------- Fanelinje (mobil) ---------- */
.tabbar { display: none; }
.ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 1099px) {
  .desk-nav, .who-box .logout { display: none; }
  .brand-app { font-size: 1.1rem; }
  .who-box .who { font-size: .85rem; background: rgba(255,255,255,.12); max-width: 45vw; overflow: hidden; text-overflow: ellipsis; }
  body.has-tabbar main { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20;
    background: var(--tabbar-bg);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border: 1px solid var(--line); border-radius: var(--r-lg);
    box-shadow: var(--tabbar-shadow);
    padding: 6px;
  }
  .tabbar a {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 0 5px; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600;
    border-radius: 14px;
  }
  .tabbar a.on { color: var(--tab-on); background: var(--kiwi-soft); }
  .tabbar a.add .ico { background: var(--kiwi); color: #fff; border-radius: 12px; padding: 4px; width: 32px; height: 32px; stroke-width: 2.4; }
  .tabbar a.add { color: var(--ink); }
  .tabbar a.add.on { background: none; }
  .tabbar .badge { position: absolute; top: 1px; left: 54%; }
  h1 { font-size: 1.6rem; }
}

/* ---------- Kort og meldinger ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.empty { padding: 18px; color: var(--muted); margin: 0; }
.note { background: var(--warn-soft); border-radius: var(--r-sm); padding: 10px 14px; color: var(--ink-2); }

.flash {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--r); margin-bottom: 14px; font-weight: 600;
}
.flash.ok { background: var(--forest); color: #fff; }
.flash.err { background: var(--bad-soft); color: var(--bad-ink); border: 1px solid var(--bad-line); }
.flash form { margin: 0; }
.flash.ok .btn.ghost { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.3); }

.title-row { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.title-row h1 { margin-right: auto; }
.back { display: inline-block; margin-bottom: 2px; text-decoration: none; font-weight: 600; font-size: .95rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.actions form { margin: 0; }

/* ---------- Skjema ---------- */
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: .92rem; color: var(--ink-2); }
.lbl { display: block; font-weight: 600; font-size: .92rem; color: var(--ink-2); margin-bottom: 6px; }
input, select, textarea {
  font: inherit; font-weight: 500; color: var(--ink);
  padding: 11px 13px; width: 100%;
  background: var(--field); color: var(--ink); border: 1.5px solid var(--line-strong); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--kiwi); box-shadow: 0 0 0 4px rgba(69,168,58,.18); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span2 { grid-column: span 2; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.filters input[type=search] { flex: 1; min-width: 180px; }
.filters select, .filters label { width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font); font-weight: 700; font-size: 1rem; line-height: 1.2;
  padding: 11px 18px; border-radius: 12px; border: 1.5px solid transparent;
  background: var(--kiwi); color: #fff; text-decoration: none; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--kiwi-dark); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.big { width: 100%; padding: 15px; font-size: 1.1rem; border-radius: 14px; }
.btn.small { font-size: .9rem; padding: 6px 12px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger, .btn.ghost.danger { color: var(--bad); border-color: var(--danger-line); background: transparent; }
.btn.ghost.danger:hover { background: var(--bad-soft); }
.link { background: none; border: 0; padding: 4px 6px; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link.danger { color: var(--bad); }

/* Segmentvalg (kg/stk) */
.seg { display: flex; gap: 4px; flex-wrap: wrap; background: var(--surface-2); padding: 4px; border-radius: 14px; width: fit-content; }
.seg label { flex-direction: row; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span { display: block; padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg input:checked + span { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 3px rgba(24,38,29,.15); }
.seg input:focus-visible + span { outline: 3px solid var(--kiwi); outline-offset: 2px; }
.unit-switch a { padding: 8px 14px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-weight: 600; }
.unit-switch a.on { background: var(--seg-on); color: var(--ink); }

/* Brikker */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  display: inline-block; padding: 7px 14px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--line-strong); color: var(--ink-2);
  font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.chip-btn:hover { border-color: var(--accent); color: var(--ink); }
.chip-btn.on { background: var(--forest-2); border-color: var(--forest-2); color: #fff; }

/* Mengde + enhet */
.qty-row { display: flex; align-items: center; gap: 8px; }
.qty-row input { flex: 1; min-width: 0; font-size: 1.2rem; font-weight: 600; }
.qty-row.big input { font-family: var(--font-display); font-size: 1.7rem; padding: 12px 16px; border-radius: 14px; }
.qty-row .unit { font-family: var(--font-display); font-weight: 650; font-size: 1.15rem; color: var(--muted); min-width: 30px; }

.extras summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 4px 0; }
.extras[open] { display: flex; flex-direction: column; gap: 10px; }

/* Koder */
.plu { display: inline-block; font-family: var(--font-display); font-weight: 600; font-size: .78rem; letter-spacing: .02em;
       background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); padding: 1px 7px; border-radius: 6px; }
.plu-input, .codes-input { font-family: var(--font-display); font-weight: 600; letter-spacing: .03em; }
.plu-input { font-size: 1.3rem; }
.codes-input.missing { border-color: var(--warn); background: var(--warn-soft); }
.hint { margin-top: -6px; min-height: 1.2em; font-weight: 600; font-size: .88rem; }
.hint.good { color: var(--good); }

/* ---------- Merkelapper ---------- */
.tag { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.kind-kreditert { background: var(--blue-soft); color: var(--blue); }
.tag.kind-fortsatt_god { background: var(--kiwi-soft); color: var(--kiwi-dark); }
.tag.last-day { background: var(--warn-soft); color: var(--warn-ink); }
.tag.last-day.now { background: var(--bad); color: #fff; }

/* ---------- Oversikt ---------- */
.search-bar { position: sticky; top: 0; z-index: 4; display: flex; gap: 8px; background: var(--bg); padding: 10px 0; margin: -10px 0 4px; }
.search-bar input { flex: 1; font-size: 1.05rem; border-radius: 14px; background: var(--surface); }
.search-bar .btn { border-radius: 14px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 14px; }
.filter-chips .push { margin-left: auto; }

.list { display: grid; gap: 10px; }
.row-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
  margin: 0; padding: 14px 16px 14px 20px;
  position: relative; overflow: hidden;
}
.row-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--warn); }
.row-card.kind-border-kreditert::before { background: var(--blue); }
.row-card.kind-border-fortsatt_god::before { background: var(--kiwi); }
.row-card.closed { opacity: .6; }
.row-card.closed::before { background: var(--line-strong); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
.row-main:hover { color: inherit; }
.row-title { font-weight: 700; font-size: 1.05rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-meta { color: var(--muted); font-size: .9rem; }
.row-meta b { color: var(--ink); }
.left-big { font-family: var(--font-display); font-weight: 700; font-size: 1.45rem; color: var(--ink); letter-spacing: -.02em; margin-right: 2px; }

.row-tools { flex-basis: 100%; display: flex; gap: 8px; align-items: flex-start; }
.row-tools:has(.row-menu[open]) { flex-wrap: wrap; }
.row-tools:has(.row-menu[open]) .row-menu { flex-basis: 100%; order: 2; }
.row-tools .reduce-form { flex: 1; min-width: 0; margin: 0; }
.row-tools .reduce-form input { font-size: 1.05rem; padding: 9px 12px; }
.row-tools .reduce-form .btn { padding: 9px 14px; white-space: nowrap; }
.row-tools .unit { font-size: 1rem; min-width: 24px; }
.row-hint { flex: 1; align-self: center; }

.quick summary { list-style: none; cursor: pointer; }
.quick summary::-webkit-details-marker { display: none; }
.row-menu summary { padding: 8px 16px; font-size: 1.15rem; line-height: 1.1; letter-spacing: .1em; }
.row-menu[open] summary { background: var(--surface-2); }
.quick-form { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
.menu-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.menu-line form { margin: 0; }

.kind-form { display: flex; gap: 6px; flex: 1; margin: 0; }
.kind-btn { flex: 1 1 0; min-width: 0; padding: 9px 8px; font-size: .92rem; white-space: nowrap; }
.kind-btn-kreditert { color: var(--blue); border-color: var(--kind-blue-line); }
.kind-btn-fortsatt_god { color: var(--kiwi-dark); border-color: var(--kind-green-line); }
.kind-btn-kreditert:hover { background: var(--blue-soft); color: var(--blue); }
.kind-btn-fortsatt_god:hover { background: var(--kiwi-soft); color: var(--kiwi-dark); }
.kind-btn-kreditert.on { background: var(--blue-fill); border-color: var(--blue-fill); color: #fff; }
.kind-btn-fortsatt_god.on { background: var(--kiwi); border-color: var(--kiwi); color: #fff; }

/* Siste dag */
.due { margin-bottom: 20px; }
.due h2 { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.due-card { margin: 0; display: flex; flex-direction: column; gap: 10px; border: 2px solid var(--bad); background: var(--due-bg); }
.rest-card.open { border: 2px solid var(--bad); background: var(--due-bg); }
.rest-card h2 { color: var(--bad); }
.rest-form, .rest-none, .reduce-form { margin: 0; }
.rest-none .link { padding: 2px 0; font-size: .92rem; }
.last-day-pick { display: flex; flex-direction: column; gap: 8px; }
.last-day-pick input[type=date] { max-width: 220px; }
.reduce-wrap { margin-top: 14px; }
.reduce-form.big .btn { padding: 13px 18px; font-size: 1.05rem; }

/* ---------- Vareside ---------- */
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 14px; }
.mini-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; }
.mini-stats span { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.mini-stats strong { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0 16px; }
.bar > * { display: block; height: 100%; border-radius: 99px; background: var(--kiwi); }
.bar > .warn { background: var(--warn); } .bar > .bad { background: var(--bad); }

.history { padding: 0; }
.hist-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.hist-row:last-child { border-bottom: 0; }
.hist-main { flex: 1; min-width: 0; }
.hist-row form { margin: 0; }

/* ---------- Registrer ---------- */
.fast-form { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.plu-name { display: grid; grid-template-columns: 2fr 3fr; gap: 12px; }
.btn-row { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.btn-row .btn { width: 100%; }

/* ---------- Bilder ---------- */
.photo-pick { display: flex; flex-direction: column; gap: 8px; }
.photo-btn { position: relative; overflow: hidden; align-self: flex-start; }
.photo-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; padding: 0; border: 0; }
.photo-preview, .thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs { margin: 8px 0 12px; }
.hist-main .thumbs { margin: 8px 0 0; }
.photo-preview figure, .thumbs figure { position: relative; margin: 0; }
.photo-preview img, .thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; display: block; border: 1px solid var(--line); }
.hist-main .thumbs img { width: 56px; height: 56px; }
.x { position: absolute; top: -7px; right: -7px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); background: var(--ink); color: #fff; font-size: 1rem; line-height: 1; cursor: pointer; padding: 0; }
.thumbs form { display: inline; }
form.busy { opacity: .6; pointer-events: none; }
.add-photos { margin: 0; }

/* ---------- Tabeller ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); color: var(--muted); font-size: .82rem; font-weight: 700; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.inactive td { color: var(--muted); }
td form { display: inline; }
.user-actions { white-space: nowrap; }
table.compact th, table.compact td { padding: 7px 12px; }
table.products input, table.products select { padding: 8px 10px; }
table.products td:nth-child(3) { width: 96px; }
.sm-only { display: none; }

/* ---------- Tall og diagrammer ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat strong { font-family: var(--font-display); font-size: 2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.stat small { display: block; font-weight: 600; }
.pct { font-weight: 700; white-space: nowrap; }

.chart { width: 100%; max-width: 680px; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.base { stroke: var(--line-strong); }
.chart .ax { font-size: 10.5px; fill: var(--muted); font-family: var(--font); }
.chart .bar-mark { fill: var(--accent); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--hover-tint); }
.chart .ref { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .ref-label { fill: var(--ink); font-weight: 600; }
.spark { width: 110px; height: 28px; display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
td.trend { white-space: nowrap; font-weight: 600; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hbar { display: grid; grid-template-columns: 140px 1fr auto; gap: 10px; align-items: center; margin-bottom: 10px; font-size: .92rem; }
.hbar-track { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.hbar-track span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.hbar-val { color: var(--muted); white-space: nowrap; }

/* ---------- Mer-menyen ---------- */
.menu-list { display: grid; gap: 10px; }
.menu-item { position: relative; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); margin: 0; padding: 16px 44px 16px 18px; font-size: 1.05rem; }
.menu-item:hover { color: var(--ink); background: var(--surface-2); }
.menu-item::after { content: "›"; position: absolute; right: 18px; top: 50%; transform: translateY(-50%); font-size: 1.6rem; color: var(--muted); }
.danger-item strong { color: var(--bad); }

/* ---------- Innlogging ---------- */
.center-page {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(120% 80% at 50% 0%, var(--forest-2) 0%, var(--forest) 60%, #153523 100%);
}
.center-page .card { width: 100%; border: 0; box-shadow: 0 20px 50px rgba(0,0,0,.25); padding: 26px 22px; border-radius: var(--r-lg); }
.login-brand { justify-content: center; margin-bottom: 20px; color: var(--ink); }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 8px 0 20px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); transition: background .1s; }
.pin-dots span.on { background: var(--accent); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 0 auto 16px; }
.pinpad button {
  font-family: var(--font-display); font-size: 1.75rem; font-weight: 600; color: var(--ink);
  padding: 14px 0; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2);
  cursor: pointer; touch-action: manipulation;
}
.pinpad button:active { background: var(--kiwi-soft); }
.pinpad .fn { font-size: 1.3rem; background: transparent; }
.pinpad .ok { background: var(--kiwi); color: #fff; border-color: var(--kiwi); }

/* ---------- Mobil ---------- */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .card { padding: 14px; }
  .row-card { padding-left: 18px; }
  .plu-name { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 100px 1fr; }
  .hbar-val { grid-column: 2; }
  .hide-sm { display: none; }
  td.trend { white-space: normal; }
  .spark { width: 70px; }
  th, td { padding: 9px 12px; }
  .user-actions { white-space: normal; }

  table.products thead { display: none; }
  table.products, table.products tbody { display: block; }
  table.products tr { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line); }
  table.products td { display: block; padding: 0; border: 0; width: auto; }
  table.products td:nth-child(1), table.products td:nth-child(2) { grid-column: 1 / -1; }
  table.products td:nth-child(3) { grid-column: 1; max-width: 120px; }
  table.products td:nth-child(4) { text-align: left; align-self: center; }
  table.products td:nth-child(5) { grid-column: 2; grid-row: 3 / 5; align-self: center; }
  .sm-only { display: inline; }
}

/* Merke: Muninn, ravnen */
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-app { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; letter-spacing: -.01em; }
.login-brand { margin-bottom: 4px; }
.login-brand .brand-mark { width: 40px; height: 40px; }
.login-brand .brand-app { font-size: 1.8rem; }
.login-sub { margin: 0 0 18px; }
@media (max-width: 1099px) { .brand-app { font-size: 1.2rem; } .brand-mark { width: 26px; height: 26px; } }
.pin-gap { display: block; }

/* ---------- Kameraskanning ---------- */
.scan-row { display: flex; gap: 8px; align-items: stretch; }
.scan-row input { flex: 1; min-width: 0; }
.scan-btn { padding: 0 12px; flex: none; }
.scan-btn .ico { width: 24px; height: 24px; }
.search-bar .scan-btn { border-radius: 14px; background: var(--surface); }
.scan-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(12, 24, 17, .86); display: grid; place-items: center; padding: 16px; }
.scan-box { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.scan-view { position: relative; border-radius: var(--r-lg); overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 62vh; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; left: 10%; right: 10%; top: 36%; height: 28%; border: 3px solid #e6b53d; border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
.scan-frame::after { content: ""; position: absolute; left: 8px; right: 8px; top: 50%; height: 2px; background: rgba(230,181,61,.85); animation: scanline 1.6s ease-in-out infinite alternate; }
@keyframes scanline { from { transform: translateY(-40px); } to { transform: translateY(40px); } }
.scan-status { color: #fff; text-align: center; margin: 0; font-weight: 600; }
.scan-status a { color: #e6b53d; }
.scan-close { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }
.scan-close:hover { background: rgba(255,255,255,.2); color: #fff; }
body.scanning { overflow: hidden; }

/* Sletting */
.tag.pending { background: var(--warn-soft); color: var(--warn-ink); align-self: center; }
.btn.danger-solid { background: var(--bad); color: #fff; }
.btn.danger-solid:hover { background: #a3331f; color: #fff; }
.request-card { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.request-card .actions { margin-top: 4px; }

/* ---------- Mørk modus: detaljer ---------- */
:root[data-theme="dark"] .top { border-bottom: 1px solid var(--line); }
:root[data-theme="dark"] .flash.ok { background: #1f4a32; }
:root[data-theme="dark"] .center-page { background: radial-gradient(120% 80% at 50% 0%, #1d4630 0%, #0f2418 60%, #08130c 100%); }
:root[data-theme="dark"] img.thumb, :root[data-theme="dark"] .thumbs img { filter: brightness(.92); }
.theme-fade, .theme-fade * { transition: background-color .5s ease, color .5s ease, border-color .5s ease, fill .5s ease !important; }

/* ---------- Bryter for lys/mørk ---------- */
.theme-toggle {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 0; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; padding: 0;
  transition: background .15s, transform .15s;
}
.theme-toggle:hover { background: rgba(255,255,255,.18); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle .ico { width: 20px; height: 20px; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; color: #e6b53d; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
.who-box { align-items: center; }

.theme-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-choice label { position: relative; }
.theme-choice input { position: absolute; opacity: 0; }
.theme-choice span {
  display: block; text-align: center; padding: 11px 6px; border-radius: 12px; font-weight: 600;
  border: 1.5px solid var(--line-strong); background: var(--surface-2); cursor: pointer;
}
.theme-choice input:checked + span { border-color: var(--kiwi); background: var(--kiwi-soft); color: var(--ink); }
.theme-choice input:focus-visible + span { outline: 3px solid var(--kiwi); outline-offset: 2px; }

/* Ravneflokken ved bytte av utseende tegnes på et canvas i assets/tema.js */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-group(muninn-flock), ::view-transition-new(muninn-flock) { animation: none; }
::view-transition-old(muninn-flock) { display: none; }
:root.vt-light::view-transition-old(root) { z-index: 1; }
