/* Clientkeep — stilark bygget på designpakken (design-tokens.json, BRAND.md).
   Ingen hardkodede farger utenfor :root. */

:root {
  --ink: #121614;
  --ink-2: #1b211e;
  --ink-3: #212925;
  --ink-line: #2b322e;
  --paper: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #edece4;
  --line: #e2e1d9;
  --line-soft: #f1f0e9;
  --fg: #121614;
  --fg-2: #2e3733;
  --fg-3: #4a544f;
  --fg-muted: #5d6862;
  --fg-on-dark: #f5f4ef;
  --fg-muted-dark: #9ba49e;
  --brand: #14584a;
  --brand-dark: #0d3e33;
  --brand-soft: #e3efe9;
  --brand-light: #b9d8cc;
  --signal: #b4502a;
  --ok-bg: #e3efe9;
  --ok-fg: #14584a;
  --warn-bg: #f7ebd6;
  --warn-fg: #7a4b06;
  --danger-bg: #f9e2dd;
  --danger-fg: #8e2c18;

  --font-sans: "Schibsted Grotesk", "Helvetica Neue", system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-full: 9999px;

  --control: 44px;
  --row: 70px;
  --sidebar: 244px;
  --topbar: 76px;
  --tabbar: 52px;
  --card-head: 52px;
  --gutter: 32px;
  --pop: 0 8px 24px rgba(18, 22, 20, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 26px; }
h2 { font-size: 16px; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--r-xs); }

[hidden] { display: none !important; }
.muted { color: var(--fg-muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.text-red { color: var(--danger-fg); }
.text-amber { color: var(--warn-fg); }
.spacer { flex: 1; }
.pre { white-space: pre-wrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link { color: var(--brand); font-size: 13px; font-weight: 500; }
.mono, .num, .kundenr { font-family: var(--font-mono); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.linklike:hover { color: var(--brand); text-decoration: underline; }
.count {
  font-family: var(--font-mono); font-size: 11px; background: var(--surface-2); color: var(--fg-muted);
  border-radius: var(--r-full); padding: 1px 7px;
}

/* ---------- Skall ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar); flex: none; background: var(--ink); color: var(--fg-muted-dark);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 22px 16px 16px;
}
.brand { display: block; color: var(--fg-on-dark); padding: 0 8px 22px; }
.brand:hover { text-decoration: none; }
.lockup { display: flex; align-items: center; gap: 12px; }
.lockup .mark { width: 28px; height: 28px; flex: none; }
.lockup .wordmark { font-size: 18px; letter-spacing: -0.025em; font-weight: 400; }
.lockup .wordmark b { font-weight: 700; }
.brand-firma {
  display: block; margin-top: 8px; padding-left: 40px; font-size: 12px; color: var(--fg-muted-dark);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sidebar .nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar .nav a {
  display: flex; align-items: center; gap: 12px; height: var(--control); padding: 0 12px;
  border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--fg-muted-dark);
}
.sidebar .nav a svg { width: 18px; height: 18px; flex: none; }
.sidebar .nav a:hover { background: var(--ink-2); color: var(--fg-on-dark); text-decoration: none; }
.sidebar .nav a.active { background: var(--ink-3); color: var(--fg-on-dark); font-weight: 600; }
.sidebar-foot {
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--ink-line);
  display: flex; align-items: center; gap: 8px;
}
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.me-text strong { font-size: 13px; font-weight: 600; color: var(--fg-on-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { font-size: 11px; color: var(--fg-muted-dark); }

.avatar {
  width: 34px; height: 34px; border-radius: var(--r-full); background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; letter-spacing: 0.02em;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; background: var(--brand-soft); color: var(--brand); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar); flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--gutter); background: var(--paper); border-bottom: 1px solid var(--line);
}
.search { position: relative; display: flex; align-items: center; width: 330px; max-width: 100%; }
.search svg { position: absolute; left: 14px; width: 17px; height: 17px; color: var(--fg-muted); }
.search input { height: var(--control); padding-left: 40px; }
.view { padding: 26px var(--gutter) 48px; max-width: 1500px; width: 100%; }
.scrim { display: none; }
.loading { padding: 40px; color: var(--fg-muted); }

.stopwatch { margin-left: auto; }
.sw-running {
  display: flex; align-items: center; gap: 10px; height: var(--control);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 0 6px 0 14px;
}
.sw-dot { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--signal); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.sw-time { font-family: var(--font-mono); font-weight: 500; font-size: 14px; }
.sw-label { color: var(--fg-muted); font-size: 13px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Knapper ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--control); padding: 0 16px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); color: var(--fg-2);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger-fg); border-color: var(--danger-fg); color: #fff; }
.btn.danger-ghost { color: var(--danger-fg); border-color: var(--line); background: transparent; }
.btn.danger-ghost:hover { background: var(--danger-bg); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn.sm svg { width: 15px; height: 15px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--control); height: var(--control); flex: none;
  border-radius: var(--r-md); border: 1px solid transparent; background: transparent; color: var(--fg-3); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn.on-dark { color: var(--fg-muted-dark); }
.icon-btn.on-dark:hover { background: var(--ink-3); color: var(--fg-on-dark); }
.menu-btn { display: none; }
.seg { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Skjemafelt ---------- */

input, select, textarea {
  font: inherit; font-size: 14px; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px; width: 100%; height: var(--control);
}
textarea { height: auto; resize: vertical; line-height: 1.55; }
input:hover, select:hover, textarea:hover { border-color: var(--fg-muted); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}
input[type=date], input[type=month] { font-family: var(--font-mono); font-size: 13px; }
textarea.mono { font-family: var(--font-mono); font-size: 13px; }
select {
  appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-muted) 50%), linear-gradient(135deg, var(--fg-muted) 50%, transparent 50%);
  background-position: right 16px center, right 11px center; background-size: 5px 5px; background-repeat: no-repeat;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fg-muted); font-weight: 500;
}
.field small { font-size: 12px; color: var(--fg-muted); }
.field .static { padding: 10px 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; min-height: var(--control); cursor: pointer; }
.check input { width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2.tight { gap: 10px; }
.span-2 { grid-column: span 2; }
.form-grid { display: flex; flex-direction: column; gap: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.input-btn { display: flex; gap: 8px; }
.input-btn .btn { flex: none; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; margin: 0 0 16px; }
legend {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--fg-muted); padding: 0 6px;
}
.form-error { color: var(--danger-fg); background: var(--danger-bg); border-radius: var(--r-sm); padding: 10px 14px; font-size: 13px; }
.hint { color: var(--fg-muted); font-size: 12px; margin-top: 8px; }

/* Vedlegg: lenke til kvitteringen bak et bilag */
.vedlegg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.vedlegg-lenke {
  display: inline-flex; align-items: center; gap: 5px; max-width: 220px; white-space: nowrap;
  padding: 3px 9px 3px 7px; border: 1px solid var(--line); border-radius: var(--r-full);
  font-size: 12px; color: var(--fg); background: var(--surface); text-decoration: none;
}
.vedlegg-lenke:hover { border-color: var(--brand); color: var(--brand); }
.vedlegg-lenke svg { width: 14px; height: 14px; flex: none; }
.vedlegg-lenke span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
input[type=file] {
  font-family: var(--font-sans); font-size: 13px; padding: 9px 12px;
  border: 1px dashed var(--line); border-radius: var(--r-sm); background: var(--surface-2);
}
input[type=file]::file-selector-button {
  font: inherit; font-weight: 500; margin-right: 10px; padding: 5px 10px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r-xs); background: var(--surface); color: var(--fg);
}
.warn { color: var(--warn-fg); background: var(--warn-bg); border-radius: var(--r-sm); padding: 10px 14px; font-size: 13px; margin-top: 12px; }
.warn-card { border-left: 3px solid var(--warn-fg); }
.file-input { height: auto; padding: 22px; border: 1px dashed var(--line); background: var(--surface-2); }

/* ---------- Sider ---------- */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.crumb {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-muted); margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.crumb a:hover { color: var(--brand); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar select, .toolbar input { width: auto; min-width: 150px; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; min-height: 68px; }
.filters input[type=search] { max-width: 330px; }
.filters select { width: auto; min-width: 160px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: var(--control); padding: 0 18px;
  border-radius: var(--r-full); border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; font-weight: 500; cursor: pointer; color: var(--fg-2);
}
.chip:hover { background: var(--surface-2); text-decoration: none; }
.chip span { font-family: var(--font-mono); font-size: 11px; color: var(--fg-muted); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--fg-on-dark); font-weight: 600; }
.chip.on span { color: var(--fg-muted-dark); }
.tag {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--fg-2); font-size: 11px; white-space: nowrap;
}
.tags { display: flex; gap: 6px; flex-wrap: wrap; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tabs a {
  height: var(--tabbar); display: inline-flex; align-items: center; gap: 8px; padding: 0 14px;
  font-size: 14px; font-weight: 500; color: var(--fg-muted); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--fg); text-decoration: none; }
.tabs a.on { color: var(--fg); border-bottom-color: var(--brand); font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 18px; overflow: hidden; }
.card { padding: 18px 20px; }
.card.flush { padding: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  min-height: var(--card-head); margin: -18px -20px 14px; padding: 0 20px;
  border-bottom: 1px solid var(--line-soft);
}
.card.flush .card-head { margin: 0; padding: 0 20px; }
.card-title { font-size: 15px; font-weight: 600; }
.card > .card-title:first-child { margin: -4px 0 12px; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.columns.wide-left { grid-template-columns: 1.65fr 1fr; }
.stack > * { margin-bottom: 18px; }
.stack > *:last-child { margin-bottom: 0; }
.empty { text-align: center; color: var(--fg-muted); padding: 48px 20px; }
.empty h2 { margin-bottom: 12px; color: var(--fg); }
.empty-inline { color: var(--fg-muted); padding: 16px 0; font-size: 13px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpis.small { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 3px;
}
a.kpi:hover { border-color: var(--brand); text-decoration: none; }
.kpi span {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-muted);
}
.kpi strong { font-family: var(--font-mono); font-size: 26px; font-weight: 500; letter-spacing: -0.015em; }
.kpi small { font-size: 12px; color: var(--fg-muted); }
.kpi.alert strong { color: var(--danger-fg); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 0; font-size: 14px; }
.facts dt { color: var(--fg-muted); }
.facts dd { margin: 0; text-align: right; font-weight: 500; }
.facts dd a { color: var(--brand); }

/* ---------- Tabeller ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-family: var(--font-mono); font-size: 10px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--fg-muted); padding: 14px 20px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surface);
}
.table td { padding: 12px 20px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.table th.num { text-align: right; }
.table .desc { max-width: 380px; color: var(--fg-3); }
.table .actions { text-align: right; white-space: nowrap; }
.table .check-cell { width: 40px; }
.table .check-cell input { width: 18px; height: 18px; accent-color: var(--brand); }
.table tbody tr:hover { background: var(--line-soft); }
.table.clickable tbody tr { cursor: pointer; }
.table a.strong { color: var(--fg); font-weight: 600; }
.table a:hover { color: var(--brand); }
.table tfoot td { padding: 14px 20px; font-weight: 600; border-top: 1px solid var(--line); background: var(--surface-2); }
.table tfoot tr.total td { font-size: 15px; }
.table tr.done td { color: var(--fg-muted); }
.table tr.done .linklike { text-decoration: line-through; }
.table.kunder td { height: var(--row); }
.inline-select { height: 34px; padding: 0 28px 0 10px; font-size: 13px; border-color: transparent; background-color: transparent; }
tr:hover .inline-select { border-color: var(--line); background-color: var(--surface); }
.slim { height: 36px; padding: 6px 10px; font-size: 13px; }
.table.tjenester td, .table.linjer td { padding: 8px 12px; }
.table.tjenester input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.table.week th.today, .table.week td.today { background: var(--brand-soft); }
.sum-line { margin-top: 12px; text-align: right; color: var(--fg-muted); font-size: 13px; }

/* Fristmatrise */
.table.matrix td, .table.matrix th { border-right: 1px solid var(--line-soft); }
.table.matrix th small {
  display: block; font-family: var(--font-sans); font-weight: 400; text-transform: none;
  letter-spacing: 0; color: var(--fg-muted); font-size: 11px;
}
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 200px; }
.table.matrix tbody tr:hover .sticky-col { background: var(--line-soft); }
.cell { padding: 0 !important; text-align: center; }
.cell button {
  width: 100%; height: 100%; min-height: 44px; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); display: grid; place-items: center;
}
.cell button svg { width: 17px; height: 17px; }
.cell.done { background: var(--ok-bg); }
.cell.done button { color: var(--ok-fg); }
.cell.late { background: var(--danger-bg); }
.cell.late button { color: var(--danger-fg); font-weight: 600; }
.cell.empty { color: var(--line); }
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fg-muted); margin-top: 12px; flex-wrap: wrap; }
.legend.pad { padding: 0 20px 18px; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.legend .sw:first-child { margin-left: 0; }
.sw.billable { background: var(--brand); }
.sw.other { background: var(--brand-light); }
.sw.done { background: var(--ok-bg); border: 1px solid var(--ok-fg); }
.sw.late { background: var(--danger-bg); border: 1px solid var(--danger-fg); }
.sw.open { background: var(--surface); border: 1px solid var(--line); }

/* ---------- Statusmerker ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--fg-2); white-space: nowrap;
}
.badge.green { background: var(--ok-bg); color: var(--ok-fg); }
.badge.amber { background: var(--warn-bg); color: var(--warn-fg); }
.badge.red { background: var(--danger-bg); color: var(--danger-fg); }
.badge.blue { background: var(--brand-soft); color: var(--brand); }
.badge.gray { background: var(--surface-2); color: var(--fg-muted); }
.badge.outline { background: transparent; border: 1px solid var(--line); color: var(--fg-muted); font-weight: 500; }
a .badge:hover { text-decoration: none; }
.due { font-family: var(--font-mono); font-size: 13px; color: var(--fg-muted); }

/* Datobrikke i fristlister */
.datechip {
  width: 44px; flex: none; text-align: center; border-radius: var(--r-sm); background: var(--surface-2);
  padding: 5px 0; font-family: var(--font-mono); line-height: 1.1;
}
.datechip b { display: block; font-size: 15px; font-weight: 500; }
.datechip span { font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-muted); }
.datechip.late { background: var(--danger-bg); color: var(--danger-fg); }
.datechip.late span { color: var(--danger-fg); }

/* ---------- Lister ---------- */

.tasklist, .simple-list { list-style: none; margin: 0; padding: 0; }
.tasklist li, .simple-list li {
  display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line-soft);
}
.tasklist li:last-child, .simple-list li:last-child { border-bottom: 0; }
.tasklist li.done { opacity: 0.45; }
.task-check input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.task-main strong { font-weight: 500; font-size: 14px; }
.simple-list li > div:first-child { flex: 1; min-width: 0; }
.simple-list strong { font-weight: 500; font-size: 14px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 14px 0 14px 20px; border-left: 1px solid var(--line); position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: -4px; top: 21px; width: 7px; height: 7px;
  border-radius: var(--r-full); background: var(--line); border: 1px solid var(--surface);
}
.timeline li.flag::before { background: var(--signal); }
.timeline .tl-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.timeline .tl-head strong { font-weight: 600; }
.timeline p { color: var(--fg-3); white-space: pre-wrap; }

/* Søyler på oversikten */
.bars { display: flex; gap: 10px; align-items: flex-end; height: 140px; padding-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bar { flex: 1; width: 100%; background: var(--surface-2); border-radius: var(--r-xs); display: flex; align-items: flex-end; overflow: hidden; }
.bar-fill { width: 100%; background: var(--brand-light); display: flex; align-items: flex-end; min-height: 2px; }
.bar-billable { width: 100%; background: var(--brand); }
.bar-val { font-family: var(--font-mono); font-size: 11px; color: var(--fg-muted); }
.bar-label { font-size: 11px; color: var(--fg-muted); }
.bar-col.today .bar-label { color: var(--brand); font-weight: 600; }
.minibar { height: 8px; background: var(--surface-2); border-radius: var(--r-xs); overflow: hidden; min-width: 90px; }
.minibar-fill { height: 100%; background: var(--brand-light); }
.minibar-b { height: 100%; background: var(--brand); }
.bar-col-head { width: 140px; }

/* Hurtigregistrering av timer */
.quick-add { padding: 16px 20px; }
.quick-grid { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.quick-grid .field { flex: 0 0 160px; }
.quick-grid .field.grow { flex: 1 1 200px; }
.quick-grid .field.narrow { flex: 0 0 96px; }
.quick-end { display: flex; align-items: center; gap: 14px; }

/* Brønnøysund-søk */
.brreg-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 16px; }
.brreg-results { list-style: none; margin: 10px 0 0; padding: 0; max-height: 220px; overflow-y: auto; }
.brreg-results li { border-bottom: 1px solid var(--line-soft); }
.brreg-results button {
  width: 100%; text-align: left; background: none; border: 0; padding: 10px 8px; cursor: pointer; font: inherit;
  display: flex; flex-direction: column; gap: 2px; color: inherit; border-radius: var(--r-sm);
}
.brreg-results button:hover { background: var(--surface); }
.brreg-results .muted { font-family: var(--font-mono); font-size: 12px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

/* ---------- Innlogging ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--r-xl); padding: 34px;
  display: flex; flex-direction: column; gap: 16px;
}
.auth-card .lockup { color: var(--fg); margin-bottom: 6px; }
.auth-card h1 { font-size: 22px; }
.auth-foot { text-align: center; font-size: 13px; color: var(--fg-muted); }
.auth-foot .linklike { color: var(--brand); font-weight: 600; }

/* ---------- Dialoger ---------- */

dialog.modal {
  border: 0; border-radius: var(--r-xl); padding: 0; width: min(560px, calc(100vw - 32px)); max-height: 90vh;
  background: var(--surface); color: var(--fg); box-shadow: var(--pop);
}
dialog.modal.wide { width: min(900px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(18, 22, 20, 0.5); }
.modal-form { display: flex; flex-direction: column; max-height: 90vh; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; gap: 10px; align-items: center; padding: 16px 20px; border-top: 1px solid var(--line-soft); background: var(--surface-2); }
.modal-form .form-error { margin: 0 20px; }

.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: var(--fg-on-dark); padding: 12px 20px; border-radius: var(--r-md); font-size: 14px;
  box-shadow: var(--pop); animation: rise 0.18s ease-out;
}
.toast.error { background: var(--danger-fg); }
.toast.out { opacity: 0; transition: opacity 0.5s; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Utskrift av dokumenter ---------- */

.doc-bar { display: flex; gap: 10px; justify-content: space-between; margin-bottom: 20px; }
.doc {
  background: #fff; color: var(--ink); max-width: 820px; margin: 0 auto 40px; padding: 48px 56px;
  border: 1px solid var(--line); border-radius: var(--r-lg); font-size: 13.5px; line-height: 1.6;
}
.doc h1 { font-size: 22px; margin: 26px 0 18px; }
.doc h2 { font-size: 15px; margin: 22px 0 8px; }
.doc h3 { font-size: 13.5px; margin: 14px 0 4px; }
.doc p { margin: 0 0 7px; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--brand); padding-bottom: 14px; }
.doc-navn { font-size: 17px; font-weight: 600; }
.doc-firma { font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); margin-top: 4px; }
.doc address { font-style: normal; font-size: 12px; color: var(--fg-muted); text-align: right; }
.parter { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 20px 0 8px; }
.parter h2 {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--fg-muted); margin: 0 0 8px; font-weight: 500;
}
.doc-table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 13px; }
.doc-table th {
  text-align: left; border-bottom: 1.5px solid var(--fg); padding: 7px 8px; font-family: var(--font-mono);
  font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.14em;
}
.doc-table td { border-bottom: 1px solid var(--line); padding: 7px 8px; vertical-align: top; }
.doc-table .num { text-align: right; font-family: var(--font-mono); }
.doc-table tfoot td { font-weight: 600; border-top: 1.5px solid var(--fg); border-bottom: 0; }
.doc-table tfoot tr.total td { font-size: 15px; }
.doc-table.small { font-size: 12px; }
.vilkar p { margin: 0 0 6px; }
.signatur { margin-top: 32px; }
.sign-row { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 34px; }
.sign-line { border-top: 1px solid var(--fg); padding-top: 6px; font-size: 12px; color: var(--fg-muted); }
.doc-note { margin-top: 18px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--r-sm); }
.doc-foot { margin-top: 26px; font-family: var(--font-mono); font-size: 11px; color: var(--fg-muted); }

body.print-mode .sidebar, body.print-mode .topbar { display: none; }
body.print-mode .view { padding: 24px; }

@media print {
  body { background: #fff; }
  .doc-bar, .sidebar, .topbar, .toasts { display: none !important; }
  .view { padding: 0; }
  .doc { border: 0; padding: 0; max-width: none; }
  .doc h2 { break-after: avoid; }
  .doc-table, .signatur { break-inside: avoid; }
}

/* ---------- Responsivt ---------- */

@media (max-width: 1100px) {
  .columns, .columns.wide-left { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform 0.2s ease-out; }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(18, 22, 20, 0.45); z-index: 30; }
  .menu-btn { display: inline-grid; }
  .view { padding: 20px 16px 40px; }
  .topbar { padding: 0 16px; }
  .search { width: auto; flex: 1; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kpi strong { font-size: 22px; }
  .sw-label, .stopwatch .btn span, #quick-time span { display: none; }
  .doc { padding: 24px; }
  .parter, .sign-row { grid-template-columns: 1fr; }
}

.row-avatar { display: flex; align-items: center; gap: 10px; }
.row-avatar span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table.kunder th:nth-child(1) { width: 316px; }
.table.kunder th:nth-child(2) { width: 176px; }
.table.kunder th:nth-child(3) { width: 244px; }
.table.kunder th:nth-child(4) { width: 220px; }
.table.kunder th:nth-child(5) { width: 176px; }

/* ---------- Kundeportal ---------- */

body.portal-modus { background: var(--paper); }
.portal { max-width: 900px; margin: 0 auto; padding: 0 20px 48px; }
.portal-topp {
  display: flex; align-items: center; gap: 16px; height: var(--topbar);
  border-bottom: 1px solid var(--line); margin-bottom: 26px;
}
.portal-topp .lockup { color: var(--fg); }
.portal-firma { display: flex; flex-direction: column; line-height: 1.3; }
.portal-firma strong { font-size: 15px; font-weight: 600; }
.portal-innhold { display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 700px) {
  .portal-topp { height: auto; padding: 16px 0; flex-wrap: wrap; }
  .portal-topp .btn span { display: inline; }
}
