/* Clarke Sagsoverblik — app.css
 * Tokenbaseret tema. VinkelOS kan senere erstatte token-værdierne
 * uden at ændre komponentstrukturen.
 */

:root {
  /* Overflader — varm papir som bund, rolige kort ovenpå */
  --bg: #EDEADE;
  --surface: #FBFAF4;
  --surface-2: #F4F2E8;
  --surface-invert: #072C2C;

  /* Blæk */
  --fg: #17211F;
  --fg-2: #3D4A47;
  --muted: #6B7672;
  --fg-on-invert: #F2F0E6;

  /* Linjer */
  --border: #D8D4C4;
  --border-soft: #E6E3D6;
  --border-invert: rgba(242, 240, 230, 0.16);

  /* Handlinger */
  --accent: #072C2C;            /* dyb grøn — primær handling */
  --accent-on: #F2F0E6;
  --accent-hover: #0C3D3D;
  --accent-active: #051F1F;
  --signal: #FF5F03;            /* sikkerhedsorange — max 2 synlige pr. skærm */
  --signal-on: #FFFFFF;

  /* Semantik */
  --success: #1E7A46;
  --success-bg: #E3EFE4;
  --warn: #B45309;
  --warn-bg: #F5E8D6;
  --danger: #B91C1C;
  --danger-bg: #F6E0DC;
  --info-bg: #E4E9E4;

  /* Typografi */
  --font-display: "Oswald", "Arial Narrow", sans-serif;
  --font-body: "Ubuntu", system-ui, sans-serif;
  --font-mono: "Ubuntu Mono", ui-monospace, Menlo, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-lg: 17px;
  --text-xl: 22px;
  --text-2xl: 30px;
  --text-3xl: 42px;
  --leading-body: 1.5;
  --leading-tight: 1.1;

  /* Rum */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-pill: 999px;

  --elev-raised: 0 12px 32px rgba(23, 33, 31, 0.10);
  --elev-drawer: 0 18px 48px rgba(23, 33, 31, 0.22);
  --focus-ring: 0 0 0 3px rgba(255, 95, 3, 0.35);

  --motion-fast: 150ms;
  --motion-base: 220ms;
  --ease-standard: cubic-bezier(0.23, 1, 0.32, 1);

  --nav-w: 236px;
  --nav-w-collapsed: 60px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
  margin: 0;
  font-weight: 600;
}

.num, td.num, .kpi-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 480px) 1fr;
}

.login-panel {
  background: var(--surface);
  padding: var(--space-12) var(--space-10);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-6);
  border-right: 1px solid var(--border);
}

.login-brand { display: flex; align-items: center; gap: var(--space-3); }
.brand-logo { display: block; object-fit: contain; }
.brand-logo-login { width: 190px; height: auto; flex: none; }
.login-brand .sub {
  font-size: var(--text-xs);
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-side {
  background: var(--surface-invert);
  color: var(--fg-on-invert);
  padding: var(--space-12);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--space-4);
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 47px, rgba(242,240,230,0.05) 47px, rgba(242,240,230,0.05) 48px),
    repeating-linear-gradient(90deg, transparent, transparent 47px, rgba(242,240,230,0.05) 47px, rgba(242,240,230,0.05) 48px);
}
.login-side h2 { font-size: var(--text-3xl); font-weight: 600; max-width: 18ch; }
.login-side p { color: rgba(242,240,230,0.72); max-width: 52ch; margin: 0; }

.login-note {
  font-size: var(--text-xs);
  color: var(--muted);
  border-top: 1px solid var(--border-soft);
  padding-top: var(--space-3);
}

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.login-users { font-size: var(--text-xs); color: var(--muted); }
.login-users button {
  background: none; border: none; padding: 0;
  color: var(--accent); text-decoration: underline;
  cursor: pointer; font-size: inherit;
}

/* ---------- Appshell ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--motion-base) var(--ease-standard);
}
.shell.nav-collapsed { grid-template-columns: var(--nav-w-collapsed) 1fr; }

.sidenav {
  background: var(--surface-invert);
  color: var(--fg-on-invert);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.sidenav-brand {
  display: flex; align-items: center; justify-content: center;
  padding: 0 var(--space-3);
  background: #F7F7F7;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
  overflow: hidden;
}
.brand-logo-nav { width: 138px; height: auto; max-width: none; flex: none; }

.nav-list { padding: var(--space-3) var(--space-2); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  color: rgba(242,240,230,0.78);
  text-decoration: none;
  font-size: var(--text-sm);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease-standard);
  position: relative;
}
.nav-item:hover { background: rgba(242,240,230,0.08); color: var(--fg-on-invert); }
.nav-item.active {
  background: rgba(242,240,230,0.12);
  color: var(--fg-on-invert);
  font-weight: 500;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--signal);
  border-radius: 0 2px 2px 0;
}
.nav-item svg { width: 18px; height: 18px; flex: none; stroke-width: 1.7; }
.nav-item .nav-label { white-space: nowrap; overflow: hidden; flex: 1; }

.nav-badge {
  background: var(--signal);
  color: var(--signal-on);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: var(--radius-pill);
  flex: none;
}
.nav-badge.muted-badge { background: rgba(242,240,230,0.18); color: var(--fg-on-invert); }

.shell.nav-collapsed .nav-label,
.shell.nav-collapsed .nav-badge { display: none; }
.shell.nav-collapsed .nav-item { justify-content: center; padding: 10px 0; }

@media (min-width: 761px) {
  .shell.nav-collapsed .sidenav-brand { justify-content: flex-start; padding: 0; }
  .shell.nav-collapsed .brand-logo-nav {
    margin-left: 8px;
    clip-path: inset(0 94px 0 0);
  }
}

.nav-collapse-btn {
  margin: var(--space-3);
  padding: var(--space-2);
  background: none;
  border: 1px solid var(--border-invert);
  color: rgba(242,240,230,0.7);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-size: var(--text-xs);
}
.nav-collapse-btn:hover { background: rgba(242,240,230,0.08); }

/* ---------- Topbar ---------- */

.maincol { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .crumb {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: var(--text-sm);
  color: var(--fg-2);
  white-space: nowrap;
}

.global-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.global-search input {
  width: 100%;
  padding: 8px var(--space-3) 8px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: var(--text-sm);
}
.global-search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted);
  pointer-events: none;
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--elev-raised);
  max-height: 320px;
  overflow-y: auto;
  z-index: 50;
}
.search-results button {
  display: flex; width: 100%; gap: var(--space-3); align-items: baseline;
  padding: var(--space-2) var(--space-3);
  background: none; border: none; cursor: pointer; text-align: left;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-soft);
}
.search-results button:hover { background: var(--surface-2); }
.search-results .kind { font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; flex: none; }

.topbar-filters { display: flex; gap: var(--space-2); align-items: center; margin-left: auto; }
.topbar-filters select {
  padding: 7px var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-sm);
  max-width: 150px;
}

.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--fg-2);
  position: relative;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 17px; height: 17px; stroke-width: 1.7; }
.icon-btn .dot {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px;
  background: var(--signal);
  color: var(--signal-on);
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-family: var(--font-mono);
  display: grid; place-items: center;
  padding: 0 4px;
}

.user-chip {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 5px var(--space-3) 5px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  cursor: pointer;
  font-size: var(--text-sm);
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-on);
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.user-menu {
  position: absolute;
  right: var(--space-6);
  top: calc(var(--topbar-h) - 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--elev-raised);
  min-width: 250px;
  z-index: 60;
  padding: var(--space-2);
}
.user-menu .um-head { padding: var(--space-3); border-bottom: 1px solid var(--border-soft); margin-bottom: var(--space-2); }
.user-menu .um-head strong { display: block; }
.user-menu .um-head span { font-size: var(--text-xs); color: var(--muted); }
.user-menu button {
  display: flex; width: 100%;
  padding: var(--space-2) var(--space-3);
  background: none; border: none; cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  text-align: left;
}
.user-menu button:hover { background: var(--surface-2); }

/* ---------- View / layout ---------- */

.view {
  padding: var(--space-6) var(--space-8) var(--space-12);
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.view-head h1 { font-size: var(--text-2xl); text-transform: uppercase; letter-spacing: 0.02em; }
.view-head .lede { color: var(--muted); font-size: var(--text-sm); margin-top: var(--space-1); max-width: 70ch; }
.view-head .actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.grid { display: grid; gap: var(--space-4); }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-kpi { grid-template-columns: repeat(6, 1fr); }
.grid.span-2 { grid-column: span 2; }

/* ---------- Cards / panels ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.card-head h3 {
  font-size: var(--text-base);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.card-head .hint { font-size: var(--text-xs); color: var(--muted); }

.kpi-card { padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); }
.kpi-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.kpi-value { font-size: var(--text-2xl); font-weight: 500; line-height: 1.1; }
.kpi-sub { font-size: var(--text-xs); color: var(--muted); }
.kpi-sub .up { color: var(--success); }
.kpi-sub .down { color: var(--danger); }
.kpi-card.alert { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.kpi-card.alert .kpi-value { color: var(--warn); }

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

.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 9px var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease-standard), transform var(--motion-fast) var(--ease-standard);
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-on); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); }
.btn-signal { background: var(--signal); color: var(--signal-on); }
.btn-signal:hover { background: color-mix(in srgb, var(--signal), black 10%); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--fg); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: none; color: var(--fg-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px var(--space-3); font-size: var(--text-xs); }
.btn svg { width: 15px; height: 15px; stroke-width: 1.8; }

/* ---------- Chips / badges / tags ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip.phase-tilbud { background: var(--info-bg); color: var(--fg-2); }
.chip.phase-vundet { background: var(--warn-bg); color: var(--warn); }
.chip.phase-aktiv { background: var(--success-bg); color: var(--success); }
.chip.phase-overdragelse { background: var(--warn-bg); color: var(--warn); }
.chip.phase-lukket { background: var(--surface-2); color: var(--muted); }
.chip.phase-tabt { background: var(--danger-bg); color: var(--danger); }
.chip.phase-parkert { background: var(--surface-2); color: var(--fg-2); }
.chip.neutral { background: var(--surface-2); color: var(--fg-2); border-color: var(--border); }
.chip.blocking { background: var(--signal); color: var(--signal-on); }
.chip.ok { background: var(--success-bg); color: var(--success); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }

.filter-chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.filter-chip {
  padding: 5px var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--text-xs);
  cursor: pointer;
  letter-spacing: 0.02em;
}
.filter-chip:hover { background: var(--surface-2); }
.filter-chip.on { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }

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

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
table.data th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}
table.data th.num, table.data td.num { text-align: right; }
table.data td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  white-space: nowrap;
}
table.data td.wrap { white-space: normal; min-width: 200px; }
table.data tbody tr { cursor: pointer; transition: background var(--motion-fast); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.stale { background: color-mix(in srgb, var(--warn-bg) 45%, var(--surface)); }
table.data tbody tr.selected { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
table.data .cell-main { font-weight: 500; }
table.data .cell-sub { font-size: var(--text-xs); color: var(--muted); }

.progressbar {
  width: 90px; height: 6px;
  background: var(--border-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}
.progressbar > i {
  display: block; height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
}
.progressbar > i.hot { background: var(--signal); }

.freshness { font-size: var(--text-xs); color: var(--muted); }
.freshness.old { color: var(--warn); font-weight: 500; }
.freshness.bad { color: var(--danger); font-weight: 500; }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
  overflow-x: auto;
}
.tab {
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--fg-2);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.tab:hover { color: var(--fg); }
.tab.on {
  color: var(--fg);
  font-weight: 500;
  border-bottom-color: var(--signal);
}

/* ---------- Formularer ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.field label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fg-2);
  font-weight: 500;
}
.field input, .field select, .field textarea {
  padding: 9px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-sm);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.field textarea { resize: vertical; min-height: 80px; }
.field .help { font-size: var(--text-xs); color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

.derived-field {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}
.derived-field .dv-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: flex; justify-content: space-between; align-items: baseline;
}
.derived-field .dv-value { font-family: var(--font-mono); font-size: var(--text-lg); margin-top: 2px; }
.derived-field .dv-formula {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: var(--space-1);
  font-family: var(--font-mono);
}
.lock-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

/* ---------- Drawer ---------- */

.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(23, 33, 31, 0.4);
  z-index: 80;
  animation: fadeIn var(--motion-fast) var(--ease-standard);
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(720px, 94vw);
  background: var(--bg);
  z-index: 90;
  box-shadow: var(--elev-drawer);
  overflow-y: auto;
  animation: slideIn var(--motion-base) var(--ease-standard);
}
.drawer.wide { width: min(960px, 96vw); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.drawer-head {
  padding: var(--space-5) var(--space-6);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.drawer-body { padding: var(--space-6); }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(23, 33, 31, 0.45);
  z-index: 100;
  display: grid; place-items: center;
  padding: var(--space-4);
  animation: fadeIn var(--motion-fast) var(--ease-standard);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--elev-drawer);
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: var(--space-6);
}
.modal h3 { margin-bottom: var(--space-4); }
.modal .modal-actions { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-5); }

/* ---------- Board ---------- */

.board { display: flex; gap: var(--space-3); overflow-x: auto; padding-bottom: var(--space-3); align-items: flex-start; }
.board-col {
  min-width: 250px;
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.board-col h4 {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fg-2);
  margin-bottom: var(--space-3);
  display: flex; justify-content: space-between;
  font-family: var(--font-body);
  font-weight: 600;
}
.board-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: border-color var(--motion-fast), transform var(--motion-fast) var(--ease-standard);
}
.board-card:hover { border-color: var(--fg-2); transform: translateY(-1px); }
.board-card .bc-title { font-weight: 500; margin-bottom: 2px; }
.board-card .bc-meta { font-size: var(--text-xs); color: var(--muted); display: flex; justify-content: space-between; gap: var(--space-2); }

/* ---------- Kapacitet-matrix ---------- */

.matrix-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: var(--text-xs); }
table.matrix th, table.matrix td {
  border-bottom: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
  padding: 6px 8px;
  text-align: center;
  min-width: 74px;
}
table.matrix th {
  background: var(--surface);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
table.matrix th.current-week { background: color-mix(in srgb, var(--signal) 8%, var(--surface)); color: var(--fg); }
table.matrix td.current-week { background: color-mix(in srgb, var(--signal) 5%, var(--surface)); }
table.matrix .rowhead {
  position: sticky;
  left: 0;
  background: var(--surface);
  text-align: left;
  min-width: 170px;
  z-index: 3;
  font-size: var(--text-xs);
  font-weight: 500;
  border-right: 1px solid var(--border);
}
table.matrix th.rowhead { z-index: 4; }
table.matrix .rowhead .sub { font-weight: 400; color: var(--muted); font-size: 10px; }

.cell-heat { font-family: var(--font-mono); border-radius: 3px; padding: 3px 4px; display: inline-block; min-width: 42px; }
.heat-0 { background: var(--surface-2); color: var(--muted); }
.heat-1 { background: var(--success-bg); color: var(--success); }
.heat-2 { background: color-mix(in srgb, var(--success) 22%, var(--surface)); color: var(--fg); }
.heat-3 { background: var(--warn-bg); color: var(--warn); }
.heat-4 { background: var(--danger-bg); color: var(--danger); font-weight: 700; }
.cell-leave { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 4px, var(--border-soft) 4px, var(--border-soft) 8px); color: var(--muted); font-size: 10px; }

.legend { display: flex; gap: var(--space-4); font-size: var(--text-xs); color: var(--muted); flex-wrap: wrap; align-items: center; }
.legend .sw { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* ---------- Kalender (ferie) ---------- */

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.cal-dow {
  padding: var(--space-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  text-align: center;
}
.cal-day {
  min-height: 96px;
  border-bottom: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
  padding: 6px;
  font-size: var(--text-xs);
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day .dnum { font-family: var(--font-mono); color: var(--muted); }
.cal-day.today { background: color-mix(in srgb, var(--signal) 6%, var(--surface)); }
.cal-day.today .dnum { color: var(--signal); font-weight: 700; }
.cal-day.off { background: var(--surface-2); }
.cal-ev {
  display: block;
  margin-top: 3px;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-ev.ferie { background: var(--info-bg); color: var(--fg-2); }
.cal-ev.kursus { background: var(--warn-bg); color: var(--warn); }
.cal-ev.sygdom { background: var(--danger-bg); color: var(--danger); }

/* ---------- Tidslinje (sagsdetalje) ---------- */

.timeline { display: flex; align-items: center; gap: 0; margin: var(--space-4) 0; overflow-x: auto; padding-bottom: var(--space-2); }
.tl-step { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 110px; flex: 1; position: relative; }
.tl-step::before {
  content: "";
  position: absolute; top: 11px; left: -50%; right: 50%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.tl-step:first-child::before { display: none; }
.tl-step.done::before { background: var(--success); }
.tl-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  z-index: 1;
  display: grid; place-items: center;
  font-size: 10px;
  color: var(--muted);
}
.tl-step.done .tl-dot { border-color: var(--success); background: var(--success); color: #fff; }
.tl-step.now .tl-dot { border-color: var(--signal); background: var(--signal); color: #fff; }
.tl-label { font-size: var(--text-xs); color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: 0.05em; }
.tl-step.now .tl-label { color: var(--fg); font-weight: 600; }
.tl-date { font-size: 10px; color: var(--muted); font-family: var(--font-mono); }

/* ---------- Afklaringer ---------- */

.afkl-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(340px, 1fr); gap: var(--space-4); align-items: start; }
.afkl-detail { position: sticky; top: calc(var(--topbar-h) + var(--space-4)); }

.comment { border-left: 2px solid var(--border); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3); }
.comment .c-meta { font-size: var(--text-xs); color: var(--muted); margin-bottom: 2px; }
.comment p { margin: 0; font-size: var(--text-sm); }

.audit-list { font-size: var(--text-xs); color: var(--fg-2); }
.audit-list li { margin-bottom: var(--space-2); list-style: none; padding-left: var(--space-4); position: relative; }
.audit-list li::before {
  content: "";
  position: absolute; left: 0; top: 7px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border);
}
.audit-list li.decision::before { background: var(--signal); }

/* ---------- Diverse ---------- */

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border-soft) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius-sm);
  min-height: 14px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.empty-state, .error-state, .denied-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--muted);
}
.empty-state h3, .error-state h3, .denied-state h3 { color: var(--fg-2); margin-bottom: var(--space-2); font-size: var(--text-lg); }
.error-state h3 { color: var(--danger); }
.denied-state .lock-ic { margin: 0 auto var(--space-3); width: 44px; height: 44px; color: var(--muted); }

.toast-stack { position: fixed; bottom: var(--space-5); right: var(--space-5); z-index: 200; display: flex; flex-direction: column; gap: var(--space-2); }
.toast {
  background: var(--surface-invert);
  color: var(--fg-on-invert);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  box-shadow: var(--elev-drawer);
  animation: slideIn var(--motion-base) var(--ease-standard);
  display: flex; gap: var(--space-3); align-items: center;
}
.toast .t-ok { color: #7FD3A0; }

.unsaved-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface-invert);
  color: var(--fg-on-invert);
  padding: var(--space-3) var(--space-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius-sm);
  margin-top: var(--space-4);
  font-size: var(--text-sm);
}

.divider { border: none; border-top: 1px solid var(--border); margin: var(--space-5) 0; }

.section-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: var(--space-6) 0 var(--space-3);
  font-weight: 600;
}

.snapshot-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}
.snapshot-tag.live { background: var(--success-bg); color: var(--success); border-color: transparent; }

.chart-note { font-size: var(--text-xs); color: var(--muted); margin-top: var(--space-2); }

/* studenter grid */
.stud-cell {
  width: 100%;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  font-size: var(--text-xs);
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 3px;
  text-align: center;
}
.stud-cell.s-praktik { background: var(--success-bg); color: var(--success); font-weight: 500; }
.stud-cell.s-remote { background: var(--info-bg); color: var(--fg-2); }
.stud-cell.s-ferie { background: var(--surface-2); color: var(--muted); }
.stud-cell.s-fri { color: var(--border); }

/* ---------- Mobile kort-liste ---------- */

.case-cards { display: none; }
.case-mobile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.case-mobile-card .cmc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); margin-bottom: var(--space-2); }
.case-mobile-card .cmc-title { font-weight: 600; font-size: var(--text-base); }
.case-mobile-card .cmc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2) var(--space-4); font-size: var(--text-xs); }
.case-mobile-card .cmc-grid .lbl { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 10px; }
.case-mobile-card .cmc-actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }

.mobile-quickbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: var(--space-2) var(--space-3);
  gap: var(--space-2);
  z-index: 70;
}
.mobile-quickbar .btn { flex: 1; justify-content: center; }

.nav-backdrop { display: none; }

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

@media (max-width: 1240px) {
  .grid.cols-kpi { grid-template-columns: repeat(3, 1fr); }
  .afkl-layout { grid-template-columns: 1fr; }
  .afkl-detail { position: static; }
}

@media (max-width: 1024px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .grid.span-2 { grid-column: auto; }
  .view { padding: var(--space-5) var(--space-5) var(--space-12); }
  .topbar-filters select { max-width: 110px; }
}

@media (max-width: 760px) {
  .shell, .shell.nav-collapsed { grid-template-columns: 1fr; }
  .sidenav {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 260px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--motion-base) var(--ease-standard);
  }
  .shell.nav-open .sidenav { transform: none; }
  .shell.nav-open .nav-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(23,33,31,0.4);
    z-index: 25;
  }
  .shell.nav-collapsed .nav-label,
  .shell.nav-collapsed .nav-badge { display: revert; }
  .shell.nav-collapsed .nav-item { justify-content: flex-start; padding: 9px var(--space-3); }
  .nav-collapse-btn { display: none; }
  .hamburger { display: grid !important; }

  .grid.cols-kpi { grid-template-columns: 1fr 1fr; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 var(--space-3); gap: var(--space-2); }
  .topbar-filters select { max-width: 84px; font-size: var(--text-xs); }
  .global-search { max-width: none; }
  .user-chip .uc-name { display: none; }
  .view { padding: var(--space-4) var(--space-3) 96px; }
  .field-row { grid-template-columns: 1fr; }

  .table-wrap.responsive-cards table.data { display: none; }
  .table-wrap.responsive-cards { border: none; background: none; overflow: visible; }
  .case-cards { display: block; }
  .mobile-quickbar { display: flex; }
  .cal-day { min-height: 64px; }
  .drawer { width: 100vw; }
}

.hamburger { display: none; }

@media print {
  .sidenav, .topbar, .mobile-quickbar, .view-head .actions { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .view { max-width: none; }
}
