/* Dankatraz: samma utseende som prototypen (design/prototyp-kundorder.html).
   Fast vänstermeny och toppbalk, arbetsytan scrollar. Täta tabeller, en accentfärg, färg bara för status.
   Typsnitten ligger i static/typsnitt (SIL Open Font License), så att inget hämtas utifrån. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("typsnitt/inter-latin.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url("typsnitt/jetbrains-mono-latin.woff2") format("woff2"); }

:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f1f3f6; --surface-3: #e9edf1;
  --line: #e2e6eb; --line-strong: #cbd2da;
  --fg: #151d26; --fg-2: #46525f; --fg-3: #737f8b;
  --accent: #1f5689; --accent-hover: #194873; --accent-fg: #ffffff; --accent-soft: #e7eff8; --accent-line: #b9cfe6;
  --ok: #1d7347; --ok-soft: #e4f3ea; --warn: #8f5600; --warn-soft: #fcf0d9; --bad: #b3261e; --bad-soft: #fbe9e7;
  --info: #3d5aa8; --info-soft: #eaeefb; --muted: #5d6873; --muted-soft: #eceff2;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.10);
  --scrim: rgba(15,22,30,.32);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0e1318; --surface: #151b21; --surface-2: #1a2129; --surface-3: #222b34;
  --line: #252f39; --line-strong: #344150;
  --fg: #e5e9ed; --fg-2: #a7b2bd; --fg-3: #7b8792;
  --accent: #6ea5da; --accent-hover: #8ab7e3; --accent-fg: #0b1622; --accent-soft: #182a3c; --accent-line: #2d4a68;
  --ok: #5fc48f; --ok-soft: #12291d; --warn: #e3a74b; --warn-soft: #2d2311; --bad: #f2776c; --bad-soft: #341a19;
  --info: #93a8ec; --info-soft: #1a2140; --muted: #9aa5b0; --muted-soft: #212931;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.45); --scrim: rgba(0,0,0,.5);
  color-scheme: dark;
} }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 13px/1.45 var(--font); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
table { font-size: inherit; line-height: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 20px; font-weight: 600; letter-spacing: -.015em; margin: 0 0 4px; }
h2 { font-size: 14px; font-weight: 600; margin: 20px 0 8px; }
h2 .dim { font-weight: 400; font-variant-numeric: tabular-nums; margin-left: 4px; }
p { margin: 0 0 12px; }
.dim { color: var(--fg-3); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
.kod { font-family: var(--mono); font-size: 12px; letter-spacing: -.01em; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rod { color: var(--bad); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; }

/* ---- skal ---- */
.meny-vaxel { position: absolute; opacity: 0; pointer-events: none; }
.app { display: grid; grid-template-columns: 228px minmax(0, 1fr); height: 100%; }
.nav { background: var(--surface-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { height: 48px; flex: none; display: flex; align-items: center; gap: 9px; padding: 0 14px; border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none !important; }
.brand-mark, .logo { width: 22px; height: 22px; border-radius: 5px; background: var(--fg); color: var(--bg); display: grid; place-items: center; font: 600 12px var(--font); flex: none; }
.brand b { font-weight: 600; font-size: 14px; letter-spacing: -.01em; }
.brand span:last-child { margin-left: auto; font-size: 11px; color: var(--fg-3); }
.nav-scroll { overflow: auto; padding: 10px 8px 16px; flex: 1; }
.nav h6 { margin: 14px 8px 4px; font-size: 11px; font-weight: 500; color: var(--fg-3); letter-spacing: .04em; text-transform: uppercase; }
.nav-scroll a { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px; border-radius: 5px; color: var(--fg-2); text-decoration: none; font-weight: 450; }
.nav-scroll a svg { width: 16px; height: 16px; flex: none; stroke: currentColor; opacity: .8; }
.nav-scroll a:hover { background: var(--surface-3); color: var(--fg); }
.nav-scroll a.on { background: var(--surface); color: var(--fg); font-weight: 500; box-shadow: 0 0 0 1px var(--line); }
.me { border-top: 1px solid var(--line); padding: 10px 10px 10px 14px; display: flex; align-items: center; gap: 9px; }
.me div { line-height: 1.25; min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { color: var(--fg-3); display: block; }
.me form { margin: 0; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 10px; font-weight: 600; flex: none; }
.skrim { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { height: 48px; flex: none; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: var(--surface); padding: 0 24px; }
.sok-topp { position: relative; display: flex; align-items: center; flex: 1; max-width: 460px; margin: 0; }
.sok-topp svg { position: absolute; left: 9px; width: 15px; height: 15px; stroke: var(--fg-3); pointer-events: none; }
.sok-topp input { width: 100%; height: 30px; padding: 0 10px 0 30px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.sok-topp input:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.las { margin-left: auto; font-size: 11px; color: var(--fg-3); white-space: nowrap; }
.meny-knapp { display: none !important; }
.sida { flex: 1; overflow: auto; min-height: 0; padding: 20px 24px 48px; }
.sida > * { max-width: 1760px; }

/* ---- knappar och fält ---- */
.knapp { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); font-weight: 500; white-space: nowrap; text-decoration: none !important; cursor: pointer; }
.knapp:hover { background: var(--surface-2); }
.knapp.primar { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.knapp.primar:hover { background: var(--accent-hover); }
.knapp.ghost { border-color: transparent; background: transparent; color: var(--fg-2); padding: 0 8px; }
.knapp.ghost:hover { background: var(--surface-3); color: var(--fg); }
.knapp.ikon { width: 30px; padding: 0; }
.knapp svg { width: 16px; height: 16px; stroke: currentColor; }
.filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.filter input[type=search], .filter input[type=text], .filter select { height: 30px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); min-width: 0; }
.filter input[type=search], .filter input[type=text] { flex: 0 1 320px; }
.filter select { flex: 0 0 auto; max-width: 260px; }
.filter :is(input, select):focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kryss { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--fg-2); }
input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; vertical-align: middle; }

/* ---- sidhuvud ---- */
.rubrik { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 4px; }
.rubrik h1 { margin: 0; }
.under { color: var(--fg-2); margin: 2px 0 8px; }
.artikelhuvud { display: flex; gap: 16px; align-items: flex-start; }
.artikelhuvud > div { min-width: 0; flex: 1; }
.artikelbild { flex: none; width: 88px; height: 88px; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: grid; place-items: center; overflow: hidden; }
.artikelbild img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
@media (max-width: 600px) { .artikelbild { width: 64px; height: 64px; } }
.sida > p.dim { max-width: 960px; }
.smulor { color: var(--fg-3); margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.smulor a { color: var(--fg-3); } .smulor a:hover { color: var(--fg); }
.smulor span:last-child { color: var(--fg); font-weight: 500; }
.kod-stor { font-family: var(--mono); font-weight: 600; letter-spacing: -.02em; }

/* ---- nyckeltal: en remsa med avdelare ---- */
.kpier { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); margin: 14px 0 16px; overflow: hidden; }
.kpi { padding: 12px 16px; min-width: 0; box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line); color: inherit; }
.kpi small { display: block; color: var(--fg-3); font-size: 12px; margin-bottom: 2px; }
.kpi b { display: block; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.kpi span { display: block; color: var(--fg-3); font-size: 12px; margin-top: 1px; }
.kpi.lank { text-decoration: none !important; }
.kpi.lank:hover { background: var(--surface-2); }

/* ---- kort ---- */
.ruta { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 14px 12px; min-width: 0; }
.ruta > h2:first-child { margin: 0 -14px 12px; padding: 0 14px; height: 44px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.ruta p { margin: 0 0 6px; }
.ruta .tabell-ruta { border: 0; border-radius: 0; margin: 0 -14px; }
.ruta > .tabell-ruta:last-child { margin-bottom: -12px; }
.kolumner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.kol { display: grid; gap: 16px; min-width: 0; }
.dl { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 5px 12px; margin: 0; }
.dl dt { color: var(--fg-3); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.adress { padding: 8px 0; border-top: 1px solid var(--line); }
.adress:first-of-type { border-top: 0; padding-top: 0; }
.fritext { white-space: pre-wrap; }
.fler summary { cursor: pointer; color: var(--accent); padding: 8px 0 0; }
.kundpris { margin: 6px 0 2px; font-size: 24px; font-weight: 600; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }

/* ---- tabeller ---- */
.tabell-ruta { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.tabell { width: 100%; border-collapse: separate; border-spacing: 0; }
.tabell th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 500; font-size: 12px; color: var(--fg-3); height: 34px; padding: 0 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tabell th.num { text-align: right; }
.tabell td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: baseline; }
.tabell tbody tr:last-child td { border-bottom: 0; }
.tabell tbody tr:hover td { background: var(--surface-2); }
.tabell td a:not(.kod) { color: var(--fg); font-weight: 500; }
.tabell td a:not(.kod):hover { color: var(--accent); }
.tabell .namn { color: var(--fg); font-weight: 500; }
.tabell .tom { text-align: center; padding: 40px 16px; }
.tabell tfoot td { padding: 8px 12px; border-top: 1px solid var(--line); font-weight: 500; background: var(--surface-2); }
.tabell tr.ny-dag td { border-top: 2px solid var(--line-strong); }
.ruta .tabell th:first-child, .ruta .tabell td:first-child { padding-left: 14px; }

/* ---- status ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 8px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--muted-soft); color: var(--muted); vertical-align: 1px; }
.pill:is(.ok, .warn, .bad, .info)::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }

/* ---- flikar och sidbläddring ---- */
.flikar { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 4px 0 12px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.flikar a { padding: 8px 10px 9px; color: var(--fg-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; white-space: nowrap; }
.flikar a:hover { color: var(--fg); }
.flikar a[aria-current] { color: var(--fg); border-bottom-color: var(--fg); }
.flikar a .dim, .flikar a .pill { margin-left: 4px; font-size: 11px; font-variant-numeric: tabular-nums; font-weight: 400; }
.sidor { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 16px 0; }

/* ---- inloggning ---- */
.inlogg { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.kort { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 28px; }
.kort .marke { margin-bottom: 24px; }
.kort .knapp { width: 100%; margin-top: 8px; height: 40px; }
.marke { color: var(--fg); text-decoration: none !important; display: flex; align-items: center; gap: 8px; }
.meddelande { background: var(--warn-soft); color: var(--warn); border-radius: var(--r); padding: 8px 12px; margin: 0 0 12px; }

/* ---- smala skärmar ---- */
@media (max-width: 1100px) { .kolumner { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 55; transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow); }
  .meny-vaxel:checked ~ .app .nav { transform: none; }
  .meny-vaxel:checked ~ .app .skrim { display: block; position: fixed; inset: 0; z-index: 50; background: var(--scrim); }
  .meny-knapp { display: inline-flex !important; }
  .top, .sida { padding-left: 16px; padding-right: 16px; }
  .sok-topp { max-width: none; }
  .las { display: none; }
  .filter input[type=search], .filter input[type=text] { flex: 1 1 100%; }
  .dl { grid-template-columns: 120px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.tabell-ruta + p { margin-top: 8px; }
@media (max-width: 860px) { .kpier { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi b { font-size: 16px; } }

/* ---- demon (design/skuggmiljo.md): en orange balk överst, som inte går att missa ---- */
.demo-balk { position: fixed; inset: 0 0 auto 0; z-index: 60; height: 28px; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #c2620a; color: #ffffff; font-size: 12px; font-weight: 500; padding: 0 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-balk b { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
body.demo { padding-top: 28px; }
body.demo .app { height: calc(100% - 28px); }
body.demo .nav-scroll a.on { box-shadow: 0 0 0 1px #c2620a; }
body.demo .brand span:last-child { color: #c2620a; font-weight: 600; }
@media (max-width: 860px) { body.demo .nav { top: 28px; } }
