[hidden] { display: none !important; }

:root {
  --page: #f6f8f8; --surface: #ffffff; --surface-2: #eef2f2;
  --ink: #12181a; --ink-2: #4c5658; --muted: #838f92;
  --ring: rgba(18,24,26,.10); --accent: #0e5f75; --accent-ink: #ffffff;
  --ok: #157a3e; --ok-bg: #e5f4ea;
  --warn: #a3670f; --warn-bg: #fbf0dd;
  --danger: #b5312b; --danger-bg: #fbe7e5;
  --grey: #6b7477; --grey-bg: #eceff0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d1213; --surface: #171e20; --surface-2: #1f2729;
    --ink: #edf1f1; --ink-2: #b7c0c2; --muted: #7e8a8c;
    --ring: rgba(255,255,255,.10); --accent: #3fa4c2;
    --ok: #49c17a; --ok-bg: #103322;
    --warn: #e0a83b; --warn-bg: #3a2c0c;
    --danger: #e2726b; --danger-bg: #3a1614;
    --grey: #a3adb0; --grey-bg: #232c2e;
  }
}
* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page); color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 620px; margin: 0 auto; padding: 0 14px calc(24px + env(safe-area-inset-bottom)); }

header { padding: 16px 0 10px; }
header h1 { font-size: 22px; margin: 0; }
.subtitle { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }

input {
  width: 100%; font-size: 16px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--ring); background: var(--surface); color: var(--ink); outline: none;
}
input:focus { border-color: var(--accent); }
textarea {
  width: 100%; font-size: 15px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--ring); background: var(--surface); color: var(--ink); outline: none;
  font-family: inherit; resize: vertical; min-height: 64px;
}
label { display: block; font-size: 13px; color: var(--ink-2); margin: 10px 0 4px; font-weight: 600; }
button {
  font-size: 15px; font-weight: 600; padding: 11px 16px; border-radius: 10px;
  border: 1px solid var(--ring); background: var(--surface); color: var(--ink); cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.ghost { background: transparent; color: var(--ink-2); }
button.danger { color: var(--danger); }
button:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn-row button { flex: 1 1 auto; }

/* ---------- hendelseskort ---------- */
.events-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.event-card {
  background: var(--surface); border: 1px solid var(--ring); border-radius: 14px;
  padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 6px;
}
.event-card h3 { margin: 0; font-size: 16px; }
.event-card .cat-tag { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.event-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.progress-line { font-size: 13px; color: var(--ink-2); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700;
  padding: 4px 9px; border-radius: 999px; white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-grey { background: var(--grey-bg); color: var(--grey); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- sheet (modal) ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet-card {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border-radius: 16px 16px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  margin: 0 auto; max-width: 620px;
}
.sheet-card-lg { max-height: 94vh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { font-size: 18px; margin: 0; }

/* ---------- hendelsesdetalj ---------- */
.ev-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.ev-leadtime {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2);
  background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin-bottom: 14px;
}
.ev-leadtime input { width: 64px; padding: 6px 8px; font-size: 14px; flex: 0 0 auto; }
.proc-group { margin-bottom: 16px; }
.proc-group h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 0 0 8px; }

.proc-item {
  border: 1px solid var(--ring); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
  background: var(--surface);
}
.proc-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.proc-name { font-weight: 600; font-size: 14.5px; }
.proc-qty { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.proc-oem { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.verify-flag {
  display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
}
.verify-flag.v-yes { background: var(--ok-bg); color: var(--ok); }
.verify-flag.v-no { background: var(--warn-bg); color: var(--warn); }
.source-note { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.4; }
.proc-note { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; background: var(--surface-2); border-radius: 8px; padding: 7px 9px; white-space: pre-wrap; }
.mismatch-panel {
  margin-top: 8px; background: var(--danger-bg); border-radius: 10px; padding: 9px 10px; font-size: 13px; color: var(--danger);
}
.mismatch-panel .mm-row { display: flex; justify-content: space-between; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }

.status-pill { flex: 0 0 auto; }
.proc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.proc-actions button { padding: 8px 12px; font-size: 13px; flex: 0 0 auto; }

.hint { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; line-height: 1.4; }

#toast {
  /* pointer-events: none — a toast is a passive notice, not an actionable element. Without
     this, a toast still fading out at the bottom of the screen sits ABOVE a sheet's own
     z-index (30 vs. this 50) and silently swallows taps on any sheet button that happens to
     render underneath it (found in browser verification, 14.08.26 — "Sjekk"/"Bestill mottatt"
     etc. all live near the bottom of a sheet, exactly where the toast renders). */
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50;
  max-width: 90vw; text-align: center; pointer-events: none;
}
