/* Gassautomat Admin — Linear/Vercel-style dense control panel */

:root {
  /* Dark (default) */
  --bg: #0a0a0b;
  --bg-elev: #101013;
  --surface: #131318;
  --surface-2: #181820;
  --surface-3: #1f1f28;
  --border: #25252e;
  --border-strong: #34343f;
  --border-focus: #4a4a5a;

  --text: #f4f4f6;
  --text-dim: #a4a4b0;
  --text-faint: #6c6c78;
  --text-disabled: #45454f;

  --accent: #f59e0b;          /* amber — gas/industrial */
  --accent-soft: rgba(245, 158, 11, 0.14);
  --accent-strong: #fbb538;

  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.13);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.13);
  --violet: #a78bfa;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  --shadow-sm: 0 1px 0 rgba(255,255,255,0.03), 0 1px 2px rgba(0,0,0,0.5);
  --shadow-md: 0 6px 24px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.04);
  --shadow-lg: 0 24px 60px rgba(0,0,0,0.6), 0 2px 0 rgba(255,255,255,0.04);

  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --sidebar-w: 232px;
  --row-h: 36px;
  --row-h-sm: 30px;

  --pad-x: 24px;
  --pad-y: 20px;
  --gap: 16px;
}

:root[data-theme="light"] {
  --bg: #f7f7f8;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f1f1f3;
  --border: #e7e7eb;
  --border-strong: #d4d4dc;
  --border-focus: #b0b0bc;

  --text: #0b0b0e;
  --text-dim: #54545f;
  --text-faint: #8a8a96;
  --text-disabled: #b8b8c2;

  --accent-soft: rgba(245, 158, 11, 0.12);
  --success-soft: rgba(16, 185, 129, 0.12);
  --warn-soft: rgba(245, 158, 11, 0.13);
  --danger-soft: rgba(239, 68, 68, 0.10);
  --info-soft: rgba(59, 130, 246, 0.11);

  --shadow-sm: 0 1px 0 rgba(0,0,0,0.02), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.06), 0 1px 0 rgba(0,0,0,0.03);
}

:root[data-density="compact"] {
  --pad-x: 18px;
  --pad-y: 14px;
  --gap: 12px;
  --row-h: 30px;
  --row-h-sm: 26px;
}

:root[data-density="roomy"] {
  --pad-x: 32px;
  --pad-y: 28px;
  --gap: 22px;
  --row-h: 42px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.42;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { min-height: 100vh; }
#root { min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

::selection { background: var(--accent-soft); color: var(--text); }

/* Scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; border: 2px solid transparent; }
*::-webkit-scrollbar-track { background: transparent; }

/* ===== App shell ===== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #d97706);
  display: grid; place-items: center;
  color: #1a1100; font-weight: 700; font-size: 13px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15), 0 0 0 1px rgba(245,158,11,0.2);
}
.sidebar-brand { font-weight: 600; font-size: 13px; letter-spacing: -0.005em; }
.sidebar-brand small { color: var(--text-faint); font-weight: 500; font-size: 11px; display:block; margin-top:1px; }

.tenant-pick {
  margin: 10px 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.tenant-pick:hover { background: var(--surface-2); border-color: var(--border-strong); }
.tenant-pick .tenant-avatar {
  width: 22px; height: 22px; border-radius: 5px;
  background: var(--surface-3); display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  border: 1px solid var(--border);
}
.tenant-pick .tenant-name { flex: 1; font-size: 12.5px; font-weight: 500; }
.tenant-pick .tenant-sub { color: var(--text-faint); font-size: 11px; }

.nav-section {
  padding: 4px 12px;
  display: flex; flex-direction: column;
  gap: 1px;
}
.nav-label {
  padding: 12px 8px 6px;
  color: var(--text-faint);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, color .12s;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.nav-item .icon { width: 16px; height: 16px; flex: 0 0 16px; color: var(--text-faint); }
.nav-item.active .icon { color: var(--accent); }
.nav-item .badge {
  margin-left: auto;
  font-size: 10.5px;
  background: var(--surface-3);
  color: var(--text-dim);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 500;
}
.nav-item .badge.danger { background: var(--danger-soft); color: var(--danger); }

.sidebar-foot {
  margin-top: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-foot .avatar { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, #4f46e5, #a78bfa); color: #fff; font-size:11px; font-weight:600; display:grid; place-items:center; }
.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot .who-name { font-size: 12.5px; font-weight: 500; }
.sidebar-foot .who-role { font-size: 11px; color: var(--text-faint); }

/* Topbar */
.topbar {
  display: flex; align-items: center;
  gap: 12px;
  padding: 0 var(--pad-x);
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.crumbs .sep { color: var(--text-disabled); }
.crumbs .here { color: var(--text); font-weight: 500; }

.topbar-spacer { flex: 1; }

.search {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  min-width: 260px;
  color: var(--text-faint);
  font-size: 12.5px;
}
.search:hover { border-color: var(--border-strong); }
.search input {
  background: transparent; border: 0; outline: 0;
  color: var(--text); flex: 1; font: inherit;
}
.search input::placeholder { color: var(--text-faint); }
.search kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
}

.icon-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .12s, border-color .12s, color .12s;
}
.icon-btn:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.icon-btn.active { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn .icon { width: 16px; height: 16px; }

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 2px;
  font-size: 11.5px;
}
.lang-toggle button {
  padding: 2px 7px;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--text-faint);
  cursor: pointer;
  font-weight: 500;
}
.lang-toggle button.on { background: var(--surface-3); color: var(--text); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  height: 30px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.primary { background: var(--accent); color: #1a1100; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--border); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.sm { height: 26px; padding: 3px 9px; font-size: 12px; }
.btn .icon { width: 14px; height: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Layout helpers ===== */
.main { display: flex; flex-direction: column; min-width: 0; }
.page { padding: var(--pad-y) var(--pad-x); display: flex; flex-direction: column; gap: var(--gap); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.page-sub { color: var(--text-faint); font-size: 12.5px; margin-top: 4px; }

/* Cards / panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-head .actions { display: flex; gap: 6px; align-items: center; }
.panel-body { padding: 14px 16px; }
.panel-body.no-pad { padding: 0; }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--gap);
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 11.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.kpi-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum";
}
.kpi-value .unit { color: var(--text-faint); font-size: 13px; font-weight: 500; margin-left: 3px; }
.kpi-delta {
  font-size: 11.5px;
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono);
}
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.neutral { color: var(--text-faint); }
.kpi-spark { position: absolute; right: 10px; bottom: 8px; opacity: 0.7; }

/* Machine grid */
.machine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: var(--gap);
}
.machine-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s, transform .15s;
}
.machine-card:hover { border-color: var(--border-strong); }
.machine-card .mc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.machine-card .mc-name { font-weight: 600; font-size: 13.5px; }
.machine-card .mc-loc { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.machine-card .mc-id { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }

.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; }
.status-dot::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.04);
}
.status-dot.online::before { background: var(--success); box-shadow: 0 0 0 2px var(--success-soft); }
.status-dot.warn::before { background: var(--warn); box-shadow: 0 0 0 2px var(--warn-soft); }
.status-dot.offline::before { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); }
.status-dot.idle::before { background: var(--text-faint); }

.mc-inv-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.mc-inv-cell {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.mc-inv-cell .lbl { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.mc-inv-cell .val { font-size: 16px; font-weight: 600; font-feature-settings: "tnum"; }

.mc-rev-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; border-top: 1px dashed var(--border); }
.mc-rev-cell { display: flex; flex-direction: column; gap: 2px; }
.mc-rev-cell .lbl { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.mc-rev-cell .val { font-size: 13px; font-weight: 600; font-feature-settings: "tnum"; }

/* Spark */
.sparkline { display: block; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left;
  font-weight: 500;
  color: var(--text-faint);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 9px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.tbl td {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl td.num, .tbl th.num { font-family: var(--font-mono); text-align: right; font-feature-settings: "tnum"; }
.tbl td.mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }

/* Pill / badge */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-feature-settings: "tnum";
}
.pill.ok { color: var(--success); background: var(--success-soft); border-color: transparent; }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pill.danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.pill.info { color: var(--info); background: var(--info-soft); border-color: transparent; }
.pill.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.pill.empty { color: var(--text-faint); }

/* Split layouts */
.split-2 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--gap); }
.split-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--gap); }
.split-7-5 { display: grid; grid-template-columns: 7fr 5fr; gap: var(--gap); }

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  padding: 0 var(--pad-x);
  background: var(--bg);
  position: sticky; top: 52px; z-index: 9;
}
.tab {
  padding: 10px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color .12s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--surface-3);
  color: var(--text-faint);
  border-radius: 999px;
  padding: 1px 5px;
}

/* Empty */
.empty {
  padding: 36px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* Shelf grid (2 cabinets back-to-back) */
.cabinets { display: flex; flex-direction: column; gap: 20px; }
.cabinet {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  padding: 14px;
}
.cabinet-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.cabinet-head .title { font-size: 12.5px; font-weight: 600; }
.cabinet-head .sub { font-size: 11.5px; color: var(--text-faint); }
.cabinet-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
}
.shelf {
  position: relative;
  /* Kompakt (2026-09-04): lavere fliser så hele lageret synes uten scrolling;
     flasketypen vises som tydelig etikett i ramma i stedet for høyt bilde. */
  aspect-ratio: 1.05;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: border-color .12s, transform .12s;
  overflow: hidden;
}
.shelf:hover { border-color: var(--border-focus); }
.shelf.selected { box-shadow: 0 0 0 2px var(--accent); }
/* Fargespråk fra det gamle automat-programmet:
   GRØNN ramme = full (salgbar) flaske, RØD ramme = TOM returflaske i hylla. */
.shelf.state-full  { border-color: var(--success);
  background: linear-gradient(180deg, var(--surface) 0%, color-mix(in oklab, var(--success-soft) 55%, var(--surface)) 100%); }
.shelf.state-empty { border-color: var(--danger);
  background: linear-gradient(180deg, var(--surface) 0%, color-mix(in oklab, var(--danger-soft) 45%, var(--surface)) 100%); }
.shelf.state-vacant { border-style: dashed; }
.shelf.state-disabled { opacity: 0.55; background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 6px, var(--surface-2) 6px, var(--surface-2) 12px); }
.shelf.state-error { background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 8px, color-mix(in oklab, var(--danger-soft) 55%, var(--surface)) 8px, color-mix(in oklab, var(--danger-soft) 55%, var(--surface)) 16px); border-color: var(--danger); }
.shelf .sh-id { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); }
.shelf .sh-state { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.shelf .sh-state.full { color: var(--success); }
.shelf .sh-state.empty { color: var(--danger); }
.shelf .sh-state.vacant { color: var(--text-faint); }
.shelf .sh-state.disabled { color: var(--text-faint); }
.shelf .sh-state.error { color: var(--danger); }

/* Rikt hylle-kort (flaskebilde + status-pill + navn) */
.shelf-rich-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.shelf-status-pill {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 2px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim); white-space: nowrap;
}
.shelf-status-pill.full  { background: var(--success-soft); color: var(--success); }
.shelf-status-pill.empty { background: var(--danger-soft); color: var(--danger); }
.shelf-status-pill.error { background: var(--danger-soft); color: var(--danger); }
.shelf-status-pill.vacant, .shelf-status-pill.disabled { color: var(--text-faint); }
.shelf-rich-body {
  flex: 1; min-height: 0; display: flex; align-items: center;
  justify-content: center; padding: 3px 0;
}
.shelf-bottle-img { max-height: 100%; max-width: 82%; object-fit: contain; }
.shelf-bottle-img.is-empty { filter: grayscale(0.65) opacity(0.75); }
.shelf-rich-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 10.5px; color: var(--text-faint);
}
.shelf-rich-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.shelf-bottle-name {
  font-size: 10.5px; font-weight: 600; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Tydelig flasketype-etikett inne i flisa (vekt + materiale) */
.shelf-type-badge {
  font-size: 12px; font-weight: 800; letter-spacing: 0.01em;
  color: var(--text); line-height: 1.15; text-align: center;
}
.shelf-type-badge .mat { display: block; font-size: 9.5px; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.shelf-score { font-size: 10px; }
.shelf-corner-full, .shelf-corner-empty {
  position: absolute; top: 26px; right: 8px; font-size: 11px; line-height: 1;
}
.shelf-corner-full { color: var(--success); }
.shelf-corner-empty { color: var(--danger); }

/* «Flaska i kammeret» i hylle-detaljen */
.chamber-bottle {
  display: flex; align-items: center; gap: 14px;
  border: 2px solid var(--border); border-radius: var(--radius-lg);
  padding: 12px 14px; margin-bottom: 12px; background: var(--surface-2);
}
.chamber-bottle.state-full  { border-color: var(--success); }
.chamber-bottle.state-empty { border-color: var(--danger); }
.chamber-bottle.state-error { border-color: var(--danger); }
.chamber-bottle img { height: 96px; width: auto; }
.chamber-bottle-meta .name { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.shelf .sh-bottle { font-size: 11px; color: var(--text-dim); font-weight: 500; }
.shelf .sh-cam { position:absolute; top:6px; right:6px; font-size: 10px; color: var(--text-faint); font-family: var(--font-mono); }

/* Camera calibration */
.cam-canvas {
  position: relative;
  background: #050507;
  border-radius: var(--radius);
  overflow: hidden;
  user-select: none;
  border: 1px solid var(--border);
}
.cam-canvas .roi {
  position: absolute;
  border: 1.5px solid var(--accent);
  background: color-mix(in oklab, var(--accent) 8%, transparent);
  cursor: move;
}
.cam-canvas .roi.selected { border-color: var(--info); background: color-mix(in oklab, var(--info) 10%, transparent); }
.cam-canvas .roi-label {
  position: absolute; top: -1px; left: -1px;
  background: var(--accent); color: #1a1100;
  font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 0 0 4px 0;
  font-family: var(--font-mono);
}
.cam-canvas .roi.selected .roi-label { background: var(--info); color: #fff; }
.cam-canvas .roi .handle {
  position: absolute;
  width: 8px; height: 8px;
  background: var(--accent);
  border: 1px solid #1a1100;
}
.cam-canvas .roi.selected .handle { background: var(--info); border-color: #fff; }
.handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; color: var(--text-faint); font-weight: 500; }
.input, .select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 10px;
  font: inherit;
  font-size: 12.5px;
  outline: none;
  transition: border-color .12s;
  height: 30px;
}
.input:focus, .select:focus { border-color: var(--border-focus); }

/* Bar chart */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.bar { flex: 1; background: var(--surface-3); border-radius: 3px 3px 0 0; position: relative; }
.bar.active { background: var(--accent); }
.bar:hover { background: var(--accent); }

/* Misc */
.muted { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }
.num { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; }
.between { display: flex; align-items: center; justify-content: space-between; }
.right { text-align: right; }

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 0 5px;
  border-radius: 3px;
  height: 18px;
  display: inline-flex; align-items: center;
}

/* Slide-over (right drawer) */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 50;
  animation: fade .15s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(480px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 51;
  display: flex; flex-direction: column;
  animation: slidein .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Bred drawer (transaksjonsdetalj m.fl.). Én-klasse-selektor med samme
   spesifisitet som .drawer: mobil-reglene lengre ned i kaskaden vinner da
   på smale skjermer (kilde-rekkefølge avgjør ved lik spesifisitet). */
.drawer-wide { width: min(720px, 95vw); }

.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.drawer-body { padding: 16px 18px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* Image placeholder (camera shot) */
.cam-shot {
  background: #07070a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 10;
}
.cam-shot .label-overlay {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--font-mono); font-size: 10.5px;
  background: rgba(0,0,0,0.6); color: #fff;
  padding: 2px 6px; border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.1);
}
.cam-shot .ts-overlay {
  position: absolute; bottom: 8px; right: 8px;
  font-family: var(--font-mono); font-size: 10.5px;
  background: rgba(0,0,0,0.6); color: var(--success);
  padding: 2px 6px; border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.1);
}

/* Toolbar above tables */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.toolbar .grow { flex: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11.5px;
  color: var(--text-dim);
  cursor: pointer;
}
.chip.active { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }

/* Donut */
.donut { width: 130px; height: 130px; }

/* Legend */
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 11.5px; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; }

/* Live pulse */
.live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px;
  color: var(--success);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.live::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 var(--success);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--success) 50%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Section heading */
.section-title { font-size: 13px; font-weight: 600; letter-spacing: -0.005em; }

/* Compact stat row */
.stat-row { display: flex; align-items: center; gap: 14px; }
.stat-row .stat .lbl { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-row .stat .val { font-size: 18px; font-weight: 600; font-feature-settings: "tnum"; letter-spacing: -0.01em; }

/* Animated underline tab indicator */
.minitab {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 2px;
  font-size: 11.5px;
}
.minitab button {
  background: transparent; border: 0;
  color: var(--text-faint);
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}
.minitab button.on { background: var(--surface-3); color: var(--text); }

/* Stroke for SVG icons */
.icon { stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-fill { fill: currentColor; stroke: none; }

/* =====================================================================
   MOBIL-TILRETTELEGGING (2026-09-04)
   Vanlig desktop (mus, >900px) er i praksis urørt, med to bevisste unntak:
   togglere (Toggle/BoolToggle i JSX) er 44x24 overalt, og
   @media (pointer: coarse) gir større touch-mål også på brede touch-skjermer.
   - <=900px: sidemenyen blir en skyvbar overlay (hamburger i topbaren),
     alle flerkolonne-splitter stables, tabeller scroller horisontalt.
   - <=640px: telefon — tettere padding, større touch-mål, fullbredde
     drawers/modaler, 16px input-font (hindrer iOS auto-zoom).
   ===================================================================== */

.hamburger { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  /* --- Skall: én kolonne + sidebar som overlay --- */
  .app { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    height: 100vh; height: 100dvh;
    width: min(300px, 84vw);
    z-index: 80;
    transform: translateX(-103%);
    transition: transform .22s ease;
    overflow-y: auto;
  }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 79;
    background: rgba(0, 0, 0, 0.5);
    animation: fade .15s ease;
  }
  .hamburger { display: grid; flex: 0 0 auto; }

  /* Topbar: krummer trunkeres, dekorativt søkefelt skjules */
  .topbar { gap: 8px; }
  .search { display: none; }
  .crumbs { min-width: 0; overflow: hidden; }
  .crumbs span { white-space: nowrap; }
  .crumbs .here { overflow: hidden; text-overflow: ellipsis; }

  /* --- Layout: alle splitter -> én kolonne --- */
  .split-2, .split-3, .split-7-5 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }

  /* Faner (maskin-detalj) scroller horisontalt i stedet for å brekke */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex: 0 0 auto; }

  /* Tabeller: panelet blir scrollboks — tabellen klemmes til min-content og
     scroller horisontalt når kolonnene ikke får plass (panel klipper ellers
     pga. overflow:hidden for radius). Dekker også tabeller uten egen wrapper
     (kamera-oppsett, prisstyring, områder, analyse). */
  .panel, .panel-body, .panel-body.no-pad { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl th, .tbl td { padding: 9px 10px; }
  .tbl th { position: static; }   /* sticky-th kolliderer med scrollboksen */

  /* Selects/inputs skal aldri diktere bredde utover containeren */
  .input, .select { max-width: 100%; min-width: 0; }
  .tbl .input, .tbl .select { width: 100%; }

  /* Verktøylinjer og statrader bretter pent */
  .toolbar { flex-wrap: wrap; row-gap: 8px; }
  .stat-row { flex-wrap: wrap; gap: 10px 16px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; gap: 10px; }
  .legend { gap: 8px 12px; }

  /* Drawer: nesten fullbredde */
  .drawer { width: min(480px, 94vw); }
}

@media (max-width: 640px) {
  :root { --pad-x: 12px; --pad-y: 12px; --gap: 12px; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 19px; }
  .machine-grid { grid-template-columns: 1fr; }

  /* Fullbredde drawers og panelhoder som kan brekke */
  .drawer { width: 100vw; border-left: 0; }
  .panel-head { flex-wrap: wrap; gap: 8px; }
  .panel-head .actions { flex-wrap: wrap; }

  /* Touch-mål: høyere knapper/inputs; 16px hindrer iOS-zoom ved fokus */
  .btn { height: 36px; padding: 6px 12px; }
  .btn.sm { height: 32px; }
  .icon-btn { width: 36px; height: 36px; }
  .input, .select, textarea.input { height: 38px; font-size: 16px; }
  .minitab { flex-wrap: wrap; }
  .minitab button { padding: 6px 10px; }
  .nav-item { padding: 10px 8px; }
  .tab { padding: 12px 10px; }

  /* Grafer/donuts litt mindre så de får plass ved siden av legend */
  .bars { height: 110px; }
  .donut { width: 110px; height: 110px; }
  /* KPI-sparklines ligger absolutt i hjørnet og kolliderer med tallet på
     smale kort — skjul dem på telefon */
  .kpi-spark { display: none; }

  /* Skjermtetthet: mindre plass rundt paneler */
  .panel-body { padding: 12px 12px; }
  .cabinet { padding: 10px; }
  .cabinet-grid { gap: 5px; }

  /* Hylle-flisene er ~70px: status-pillen får ellipse i stedet for å klippes
     midt i «TOMFLASKE»/«DEAKTIVERT» (fargeramma bærer også statusen) */
  .shelf-rich-head { min-width: 0; }
  .shelf-status-pill {
    min-width: 0; overflow: hidden; text-overflow: ellipsis;
    padding: 2px 5px; letter-spacing: 0;
  }

  .page-title { font-size: 18px; }
}

/* Svært smale skjermer: KPI-er i én kolonne, statrad komprimeres */
@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px 12px; }
  .stat-row .stat .val { font-size: 15px; }
}

/* Touch-enheter (uavhengig av bredde — også nettbrett i landskap):
   større treff-flater på de mest brukte kontrollene. */
@media (pointer: coarse) {
  .btn { height: 36px; }
  .btn.sm { height: 32px; padding: 5px 11px; }
  .icon-btn { width: 38px; height: 38px; }
  .minitab button { padding: 7px 11px; }
  .tbl td .icon-btn + .icon-btn { margin-left: 4px; }
  /* Tweaks-panelets dra/scrub-kontroller skal ikke kjempe mot side-scroll */
  .twk-seg, .twk-num-lbl, .twk-slider, .twk-hd { touch-action: none; }
}

/* Kart-siden: kart + automatliste (klasse satt i map.jsx) */
.map-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 12px;
  height: calc(100vh - 220px);      /* fallback for nettlesere uten dvh */
  height: calc(100dvh - 220px);
  min-height: 320px;
}
@media (max-width: 900px) {
  .map-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 55dvh) minmax(160px, 1fr);
    height: auto;
  }
}

/* Påfylling: automatliste + Lastebilen-panel (klasse satt i refill.jsx) */
.refill-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) {
  .refill-grid { grid-template-columns: 1fr; }
}

/* Skjema-grids i modaler (klasser satt i JSX): 2 kolonner -> 1 på smal
   skjerm. !important trengs fordi kolonnene/colspan står som inline styles. */
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr !important; }
  .form-grid > * { grid-column: auto !important; }
  .kvp-grid { grid-template-columns: 1fr !important; }
  .kvp-grid > * { grid-column: auto !important; }
  .modal-form-grid { grid-template-columns: 1fr !important; }
  .modal-form-grid > * { grid-column: auto !important; }
}
