/* oversikt.medmalin.no — designsystem (godkjent skisse 2026-07-11) */

/* Palett fra medmalin.no-merkevaren: dyp magenta som aksent, varme
   mauve-gråtoner. Critical-rød er dyttet mot oransjerød så den aldri
   forveksles med aksenten. */
:root {
  --ground: #FAF6F8;
  --surface: #FFFFFF;
  --surface-2: #F4E9F0;
  --line: #EADDE4;
  --ink: #2A1B23;
  --ink-2: #6E5761;
  --ink-3: #A18C97;
  --accent: #C43D83;
  --accent-ink: #FFFFFF;
  --accent-soft: #FBE7F1;
  --good: #1F7A4D;   --good-soft: #E2F0E8;
  --warn: #A8690F;   --warn-soft: #F6ECDC;
  --crit: #C2402E;   --crit-soft: #F9E5E1;
  --shadow: 0 1px 2px rgba(42,27,35,.05), 0 4px 16px rgba(42,27,35,.06);
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #191016; --surface: #231721; --surface-2: #2C1E29; --line: #3A2A35;
    --ink: #F0E6EC; --ink-2: #BCA3B1; --ink-3: #84687A;
    --accent: #E6529E; --accent-ink: #2B0E1E; --accent-soft: #3D1F30;
    --good: #4CBB84; --good-soft: #143123;
    --warn: #D99A45; --warn-soft: #352811;
    --crit: #E0685A; --crit-soft: #3A1B18;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; max-width: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

/* ---------- Sidebar (desktop) ---------- */
.side {
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
/* Merkeblokk: «oversikt.» i merkevare-magenta med Med Malin-logoen som den
   dominerende delen under — proporsjoner fra panel.medmalin.no. */
.brand { padding: 0 10px; display: grid; gap: 7px; justify-items: start; }
.wordmark { font-size: 20px; font-weight: 700; letter-spacing: -.03em; line-height: 1; color: var(--accent); }
.wordmark em { font-style: normal; }
.brand-logo { height: 50px; width: auto; display: block; margin-left: -5px; }
.topbar .brand { gap: 4px; }
.topbar .wordmark { font-size: 15px; }
.topbar .brand-logo { height: 24px; margin-left: -3px; }
.login .brand { justify-items: center; margin-bottom: 26px; padding: 8px 0 0; }
.login .wordmark { font-size: 25px; }
.login .brand-logo { height: 52px; margin-left: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
/* Supersøket: felt i sidebaren (desktop) og lupe i toppbaren (mobil) */
.sidesok {
  display: flex; align-items: center; gap: 8px; margin: -8px 0;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface);
}
.sidesok svg { width: 15px; height: 15px; flex: none; color: var(--ink-3); }
.sidesok input {
  border: 0; outline: 0; background: transparent; width: 100%;
  font: inherit; font-size: 13.5px; color: var(--ink);
}
.sidesok input::placeholder { color: var(--ink-3); }
.sidesok:focus-within { border-color: var(--accent); }
.topsok { display: flex; color: var(--ink-2); }
.topsok svg { width: 19px; height: 19px; }

.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--ink-2); font-weight: 500; font-size: 14.5px;
}
.nav a svg { width: 17px; height: 17px; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .count {
  margin-left: auto; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2);
  border-radius: 99px; padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}
.nav a.on .count { background: var(--accent); color: var(--accent-ink); }
.side-foot { margin-top: auto; padding: 12px 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); display: grid; gap: 6px; }
.sync-dot { width: 7px; height: 7px; border-radius: 99px; display: inline-block; flex: none; }
.sync-dot.ok { background: var(--good); }
.sync-dot.bad { background: var(--crit); }
.sync-line { display: flex; align-items: center; gap: 7px; }

/* ---------- Main ---------- */
.main { padding: 26px 30px 90px; max-width: 1240px; width: 100%; margin: 0 auto; }
.crumbs { font-size: 13px; color: var(--ink-3); margin-bottom: 4px; }
.crumbs b { color: var(--ink-2); font-weight: 500; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; text-wrap: balance; }
.sub { color: var(--ink-2); margin: 0 0 22px; font-size: 14.5px; }
.eyebrow {
  font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); margin: 26px 0 10px;
}
.eyebrow small { font-weight: 500; text-transform: none; letter-spacing: 0; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; box-shadow: var(--shadow); display: block;
}
.tile .k { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.tile .v { font-size: 27px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .d { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.tile.alert { border-color: color-mix(in srgb, var(--crit) 35%, var(--line)); }
.tile.alert .v { color: var(--crit); }
.tile.warn-t .v { color: var(--warn); }

/* Cards & rows */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden;
}
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; font-size: 14.5px; }
.row .s { font-size: 13px; color: var(--ink-2); }
.stripe { align-self: stretch; width: 3px; border-radius: 99px; flex: none; }
.stripe.crit { background: var(--crit); }
.stripe.warn { background: var(--warn); }
.empty { padding: 26px 16px; text-align: center; color: var(--ink-3); font-size: 14px; }
/* Rå SVG-ikoner rett i en rad (f.eks. søketreff) skal aldri vokse fritt */
.row > svg { width: 18px; height: 18px; flex: none; color: var(--ink-3); }

/* Arkiverte tjenester (kundekortet) — samlet bak en utvid-knapp */
details.arkiv { border-top: 1px solid var(--line); background: var(--surface-2); }
details.arkiv summary {
  cursor: pointer; padding: 11px 16px; font-size: 13px; font-weight: 600;
  color: var(--ink-2); list-style: none; user-select: none;
}
details.arkiv summary::-webkit-details-marker { display: none; }
details.arkiv summary::before { content: '▸ '; color: var(--ink-3); }
details.arkiv[open] summary::before { content: '▾ '; }
details.arkiv .arkivrow { opacity: .72; background: var(--surface); }
details.arkiv .arkivrow:hover { opacity: 1; }

/* Prisknappen viser månedsprisen; manglende pris flagges varsomt */
.pricebtn { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pricebtn.mangler { color: var(--warn); border-color: var(--warn); }

/* Handlingsknappene på produktlinjene ligger i faste kolonner, så Pris-,
   Flytt- og Avslutt-knappene står vertikalt rett over hverandre på tvers
   av radene (tredje kolonne reserveres selv når Avslutt mangler). */
.rowactions { display: grid; grid-template-columns: 118px 62px 78px; gap: 6px; flex: none; align-items: center; }
.rowactions .btn { width: 100%; justify-content: center; padding-left: 8px; padding-right: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; border-radius: 99px; padding: 3px 10px;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.pill.good { color: var(--good); background: var(--good-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.crit { color: var(--crit); background: var(--crit-soft); }
.pill.mut  { color: var(--ink-2); background: var(--surface-2); }
.pill.pay  { color: var(--accent-ink); background: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; font-size: 13.5px;
  border: 0; border-radius: 8px; padding: 9px 14px; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); }
.btn.block { width: 100%; }

/* Table */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th {
  text-align: left; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600; padding: 10px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.domain { font-weight: 600; }
.prov { color: var(--ink-2); font-size: 13px; }

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input {
  font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; width: 100%;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.flash { border-radius: 8px; padding: 10px 14px; font-size: 13.5px; font-weight: 500; margin-bottom: 14px; }
.flash.err { color: var(--crit); background: var(--crit-soft); }
/* Info-meldinger går i merkevaretonen — grønt er reservert ekte «alt vel»-status. */
.flash.ok  { color: var(--accent); background: var(--accent-soft); }

/* Produkt-ikon og leverandør-merke foran rader */
.ico {
  width: 26px; height: 26px; flex: none;
  color: var(--ink-3);
  display: inline-grid; place-items: center;
}
.ico svg { width: 20px; height: 20px; }
.provbadge {
  display: inline-grid; place-items: center;
  min-width: 26px; height: 20px; padding: 0 5px; border-radius: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em; flex: none;
}
.provlogo {
  width: 24px; height: 24px; flex: none;
  object-fit: contain; display: block;
}
.sidegroup {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); padding: 14px 10px 4px;
}

/* Økonomi: horisontale inntektsbarer */
.barrow { display: grid; grid-template-columns: 190px 1fr auto; align-items: center; gap: 14px; padding: 8px 0; }
.barrow + .barrow { border-top: 1px solid var(--line); }
.barlabel { font-size: 14px; font-weight: 500; }
.bartrack { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.barfill { height: 100%; border-radius: 99px; background: var(--accent); min-width: 2px; }
.barval { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; white-space: nowrap; }
@media (max-width: 860px) {
  .barrow { grid-template-columns: 1fr auto; grid-template-areas: "label val" "track track"; row-gap: 6px; }
  .barlabel { grid-area: label; }
  .barval { grid-area: val; }
  .bartrack { grid-area: track; }
  .econ-cols { grid-template-columns: 1fr !important; }
}

/* Filtre og små skjemaer */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type="search"], .filters select, .rowform select, .rowform input {
  font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px;
}
.filters input[type="search"] { min-width: 220px; flex: 1; }
.chipbar { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 12.5px; font-weight: 600; border-radius: 99px; padding: 5px 12px;
  color: var(--ink-2); background: var(--surface-2); border: 1px solid transparent;
}
.chip.on { color: var(--accent); background: var(--accent-soft); }
.chipn { font-weight: 700; opacity: .6; margin-left: 2px; font-variant-numeric: tabular-nums; }
.chip.on .chipn { opacity: 1; }
/* Mobil: skjul orgnr-erstatning (årlig) i meta ikke aktuelt; kolonne 2 = årlig beløp. */
.btn.small { padding: 6px 10px; font-size: 12.5px; }
.rowform { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rowform select { max-width: 220px; }
.muted { color: var(--ink-3); font-size: 13px; }
.klist td a { font-weight: 600; }
.prodcol { text-align: center; width: 38px; padding-left: 4px; padding-right: 4px; }
th.prodcol svg { width: 16px; height: 16px; color: var(--ink-3); vertical-align: middle; }
.prodhas { display: inline-grid; place-items: center; color: var(--accent); }
.prodhas svg { width: 17px; height: 17px; }
.prodzero { color: var(--line); }
.history .s { font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .rowform { width: 100%; }
  .rowform select { flex: 1; max-width: none; }
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(21,37,43,.45); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
}
.modal[hidden], .modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 24px; width: 100%; max-width: 420px;
}
.modal h2 { font-size: 18px; font-weight: 700; margin: 0 0 2px; }
.modal .field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); display: block; margin-bottom: 6px; }
.modal select, .modal input[type="text"], .modal input[type="date"], .modal textarea {
  font: inherit; color: var(--ink); width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.modal .or { font-size: 12.5px; color: var(--ink-3); text-align: center; margin: 12px 0 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 30px 28px;
}
.login .wordmark { padding: 0; margin-bottom: 4px; font-size: 24px; }
.login .sub { margin-bottom: 20px; }
.otp-input { text-align: center; font-size: 22px; letter-spacing: .35em; font-variant-numeric: tabular-nums; }

/* Top bar + bottom nav: mobile only */
.topbar, .bottomnav { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 16px 96px; }

  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 10;
    background: color-mix(in srgb, var(--ground) 88%, transparent);
    backdrop-filter: blur(10px);
    padding: 14px 16px; margin: -16px -16px 14px;
    border-bottom: 1px solid var(--line);
  }
  .topbar .wordmark { font-size: 19px; padding: 0; }
  .topbar .sync-line { font-size: 12px; color: var(--ink-3); }

  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile .v { font-size: 24px; }
  h1 { font-size: 21px; }

  /* Tabeller blir kortlister på mobil */
  .tbl-wrap table, .tbl-wrap thead, .tbl-wrap tbody, .tbl-wrap tr, .tbl-wrap td { display: block; }
  .tbl-wrap thead { display: none; }
  .tbl-wrap tr { border-top: 1px solid var(--line); padding: 11px 16px; }
  .tbl-wrap tr:first-child { border-top: 0; }
  .tbl-wrap td { padding: 1px 0; border: 0; white-space: normal; }
  .tbl-wrap td.num { text-align: left; color: var(--ink-2); font-size: 13px; }
  .tbl-wrap td .pill { margin-top: 5px; }

  .bottomnav {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a {
    display: grid; justify-items: center; gap: 3px;
    padding: 6px 2px; border-radius: 9px;
    font-size: 10.5px; font-weight: 600; color: var(--ink-3);
  }
  .bottomnav a svg { width: 21px; height: 21px; }
  .bottomnav a.on { color: var(--accent); }
  .bottomnav .bdg { position: relative; }
  .bottomnav .bdg .n {
    position: absolute; top: -5px; right: -12px;
    background: var(--crit); color: #fff; font-size: 9.5px; font-weight: 700;
    border-radius: 99px; padding: 1px 5px;
  }
  .morebtn {
    display: grid; justify-items: center; gap: 3px;
    padding: 6px 2px; border: 0; background: none; cursor: pointer;
    font: inherit; font-size: 10.5px; font-weight: 600; color: var(--ink-3);
  }
  .morebtn svg { width: 21px; height: 21px; }
  .morebtn.on { color: var(--accent); }

  /* «Mer»-bunnark */
  .sheet-backdrop {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(21,37,43,.45); backdrop-filter: blur(3px);
    display: flex; align-items: flex-end;
  }
  .sheet-backdrop[hidden] { display: none; }
  .sheet {
    width: 100%; background: var(--surface);
    border-radius: 16px 16px 0 0; padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
    max-height: 80vh; overflow-y: auto;
    animation: sheetup .2s ease;
  }
  @keyframes sheetup { from { transform: translateY(100%); } }
  .sheet-handle { width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: 6px auto 10px; }
  .sheet-group { font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); padding: 12px 12px 4px; }
  .sheet-item {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 12px; border-radius: 10px; color: var(--ink); font-weight: 500;
  }
  .sheet-item svg { width: 20px; height: 20px; color: var(--ink-2); flex: none; }
  .sheet-item.on { background: var(--accent-soft); color: var(--accent); }
  .sheet-item.on svg { color: var(--accent); }
  .sheet-item .count { margin-left: auto; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border-radius: 99px; padding: 1px 8px; }

  /* Kort-rader: la pris/status/knapper bryte til ny linje i stedet for å
     dytte innholdet utenfor skjermen. */
  .card .row { flex-wrap: wrap; row-gap: 8px; }
  .card .row .grow { flex: 1 1 60%; min-width: 0; }
  /* Alt etter .grow (pris, statuspill, knapper) samles på egen linje til høyre. */
  .card .row > :not(.ico):not(.provlogo):not(.provbadge):not(.grow):not(.stripe) {
    margin-left: auto;
  }
  .card .row .rowform { flex-basis: 100%; }
  .filters input[type="search"] { min-width: 0; }

  /* Kundeliste som kompakt kort på mobil (ikke stablede tomme kolonner). */
  .klist tr { padding: 13px 16px; }
  .klist td { padding: 0; border: 0; }
  .klist td:nth-child(1) { font-weight: 700; font-size: 15px; }        /* Kunde */
  .klist td:nth-child(2), .klist td:nth-child(3) { display: inline; font-size: 12.5px; color: var(--ink-3); }
  .klist td:nth-child(2):empty { display: none; }
  .klist td:nth-child(3)::before { content: " · "; }
  .klist td:nth-child(4) { display: none; }            /* «Produkter»-tall — ikonene viser det */
  .klist td.prodcol { display: none; }                 /* skjul tomme */
  .klist td.prodcol:has(.prodhas) { display: inline-flex; margin: 6px 6px 0 0; }
  .klist td:last-child { display: block; margin-top: 8px; }  /* status */
}
@media (prefers-reduced-motion: no-preference) {
  .main > * { animation: rise .18s ease; }
  @keyframes rise { from { opacity: 0; transform: translateY(4px); } }
}
