/* Ambulatoriekalender - samme instrument-look som TAIA. IBM Plex Sans (labels) + Plex Mono (data). */
@font-face { font-family: 'Plex Sans'; src: url('vendor/fonts/plex-sans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Sans'; src: url('vendor/fonts/plex-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Plex Mono'; src: url('vendor/fonts/plex-mono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Mono'; src: url('vendor/fonts/plex-mono-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }

:root {
  --sans: 'Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'Plex Mono', ui-monospace, "SF Mono", Menlo, monospace;
  --paper: #f8fafa; --surface: #ffffff; --surface-2: #eef3f3;
  --ink: #16242a; --muted: #5d6c71; --line: #dde6e6; --line-faint: #eef2f3;
  --accent: #246b63; --accent-ink: #ffffff;
  --danger: #a33a2a; --warn-bg: #fff4d6; --ok-bg: #e3f1e6; --bad-bg: #f9e0d9;
  --closed: repeating-linear-gradient(135deg, rgba(120,132,135,.10) 0 6px, transparent 6px 12px);
  --lunch: rgba(120,132,135,.16);
  --shadow: 0 1px 2px rgba(20,36,42,.05);
  --row-h: 20px;
}
html[data-theme="dark"] {
  --paper: #0e1417; --surface: #141d20; --surface-2: #1a262a;
  --ink: #e2eaeb; --muted: #8a989c; --line: #233135; --line-faint: #1a242a;
  --accent: #57a79c; --accent-ink: #0c1416;
  --danger: #e07a68; --warn-bg: #3a3320; --ok-bg: #1f3326; --bad-bg: #3d2420;
  --closed: repeating-linear-gradient(135deg, rgba(150,162,165,.08) 0 6px, transparent 6px 12px);
  --lunch: rgba(150,162,165,.12);
  --shadow: none;
}

html { scrollbar-gutter: stable; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { font: 14px/1.5 var(--sans); color: var(--ink); margin: 0; background: var(--paper); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

/* ---------- app bar ---------- */
.appbar { display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 56px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.brand { font-family: var(--mono); font-weight: 600; font-size: 14.5px; display: flex; align-items: center; white-space: nowrap; }
.brand .mark { width: 10px; height: 10px; background: var(--accent); border-radius: 2px; margin-right: 10px; }
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 6px 13px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); font-weight: 600; }
.actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ctl { display: inline-flex; align-items: center; gap: 6px; }
.plabel { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); white-space: nowrap; }
select, input[type="text"], input[type="number"], textarea { font: inherit; font-size: 13px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
select { max-width: 260px; }
#cal-select, #edit-layer { width: 220px; min-width: 220px; max-width: 220px; text-overflow: ellipsis; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
input[type="color"] { width: 36px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.menu { position: relative; }
.btn, .btn-primary, .btn-danger { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 7px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--bad-bg); }
.btn:disabled, .btn-primary:disabled, .btn-danger:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.icon-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: var(--surface-2); }
.dropdown { position: absolute; top: calc(100% + 6px); left: 0; min-width: 190px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(16,28,34,.16); padding: 6px; z-index: 50; }
.dropdown.right { left: auto; right: 0; }
.dropdown button { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 9px 11px; border-radius: 7px; cursor: pointer; color: var(--ink); font: inherit; font-size: 14px; }
.dropdown button:hover { background: var(--surface-2); }
.user-ident { padding: 8px 11px 6px; font-family: var(--mono); font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* ---------- content ---------- */
.content { max-width: 1760px; margin: 0 auto; padding: 24px 28px 72px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 34px; }
.h2 { font-size: 15px; font-weight: 600; margin: 0; }
.h2.mt { margin-top: 34px; margin-bottom: 10px; }
.sub { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; flex-wrap: wrap; }
.status { color: var(--muted); font-family: var(--mono); font-size: 12px; margin-left: auto; min-height: 18px; }
.status.err { color: var(--danger); }
.hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; }
.err { color: var(--danger); font-size: 13px; margin: 6px 0 0; }
.daytabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; }
.daytabs button { border: 0; background: transparent; color: var(--muted); padding: 5px 12px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; }
.daytabs button.active { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }
.layer-toggles { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; user-select: none; }
.chip-check input { margin: 0; }
.chip-check.off { color: var(--muted); text-decoration: line-through; }
.chip-check .lock { font-size: 11px; margin-left: 2px; }
.tbl td.other { color: var(--muted); font-size: 12px; max-width: 320px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 14px; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); }

/* ---------- gitter ---------- */
.daygrid { margin-bottom: 34px; }
.daygrid h3 { font-size: 15px; margin: 0 0 8px; display: flex; align-items: baseline; gap: 12px; }
.daygrid h3 .muted { font-size: 12px; font-weight: 400; }
.grid { display: grid; position: relative; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }  /* no overflow:hidden - it would become the sticky header's scroll container */
.gh { position: sticky; top: 56px; z-index: 5; background: var(--surface-2); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line-faint); font-family: var(--mono); font-size: 12px; font-weight: 500; padding: 6px 8px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gh.closed { color: var(--muted); }
.gh small { display: block; font-weight: 400; font-size: 10px; color: var(--muted); text-transform: none; }
.gt { font-family: var(--mono); font-size: 11px; color: var(--muted); padding: 0 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-faint); line-height: var(--row-h); text-align: right; background: var(--surface); position: sticky; left: 0; z-index: 2; }
.gt.hour { color: var(--ink); font-weight: 500; }
.cell { border-right: 1px solid var(--line-faint); border-bottom: 1px solid var(--line-faint); min-height: var(--row-h); cursor: cell; }
.cell.hour { border-bottom-color: var(--line); }
.cell:hover { background: rgba(36,107,99,.10); }
.cell.closed { background: var(--closed); cursor: not-allowed; }
.cell.closed:hover { background: var(--closed); }
.cell.lunch { background: var(--lunch); }
.cell.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.cell.readonly { cursor: default; }
.cell.readonly:hover { background: transparent; }
.cell.readonly.lunch:hover { background: var(--lunch); }
.slot { position: relative; z-index: 3; margin: 1px 2px; border-radius: 4px; padding: 2px 5px; font-size: 11px; line-height: 1.25; overflow: hidden; cursor: pointer; border: 1px solid rgba(0,0,0,.18); box-shadow: 0 1px 1px rgba(0,0,0,.08); user-select: none; }
.slot:hover { filter: brightness(1.05); box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.slot.dark { color: #fff; }
.slot b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .t { font-family: var(--mono); font-size: 10px; opacity: .8; white-space: nowrap; }
.slot .lb { position: absolute; top: 2px; right: 3px; font-family: var(--mono); font-size: 9px; padding: 0 4px; border-radius: 3px; background: rgba(0,0,0,.55); color: #fff; letter-spacing: .04em; }
.slot.dragging { opacity: .4; }
.slot.readonly { cursor: default; }

/* ---------- tabeller ---------- */
table.tbl { border-collapse: collapse; width: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line-faint); border-right: 1px solid var(--line-faint); padding: 5px 10px; text-align: left; vertical-align: middle; }
.tbl th { background: var(--surface-2); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tbl td.n, .tbl th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tbl tr.total td { font-weight: 600; border-top: 2px solid var(--line); }
.tbl td.neg { background: var(--bad-bg); }
.tbl td.pos { background: var(--warn-bg); }
.tbl td.zero { color: var(--muted); }
.tbl td.closed { background: var(--closed); color: var(--muted); }
.tbl .tswatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; border: 1px solid rgba(0,0,0,.15); margin-right: 6px; vertical-align: -1px; }
.tbl tr.muted td { color: var(--muted); }
.tbl td.art-Fjernet { background: var(--bad-bg); }
.tbl td.art-Tilføjet { background: var(--ok-bg); }
.tbl td.art-Ændret { background: var(--warn-bg); }
.tbl input[type="text"], .tbl input[type="number"] { padding: 3px 6px; font-size: 13px; }
.tbl input[type="number"] { width: 70px; }
.tbl td.actions { white-space: nowrap; }
.tbl td.actions button { margin-right: 4px; }
.layer-block { margin-bottom: 26px; }
.layer-block h3 { font-size: 14px; margin: 0 0 8px; }
.layer-block h3 .muted { font-weight: 400; font-size: 12px; margin-left: 8px; }

/* ---------- indstillinger ---------- */
.subtabs { display: flex; gap: 2px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.subtab { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.subview { max-width: 1100px; }
.form { display: grid; gap: 14px; max-width: 720px; }
.form label { display: grid; gap: 4px; font-size: 13px; }
.form label > span { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.form .row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.form .row label { flex: 1; min-width: 140px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 18px; }
.card h3 { margin: 0 0 10px; font-size: 14px; }
.note-box { white-space: pre-wrap; font-size: 13px; color: var(--muted); }
.dayboxes { display: inline-flex; gap: 6px; }
.dayboxes label { display: inline-flex; gap: 3px; align-items: center; font-size: 11px; font-family: var(--mono); }

/* ---------- dialog ---------- */
.dlg { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--surface); color: var(--ink); max-width: 520px; width: calc(100vw - 32px); box-shadow: 0 16px 48px rgba(16,28,34,.28); }
.dlg::backdrop { background: rgba(10,20,24,.45); }
.dlg form { padding: 18px 20px 16px; display: grid; gap: 12px; }
.dlg h3 { margin: 0 0 4px; font-size: 15px; }
.dlg label { display: grid; gap: 4px; font-size: 13px; }
.dlg label > span { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.dlg .frow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dlg select, .dlg input { width: 100%; max-width: none; }
.dlg-actions { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.spacer { flex: 1; }

/* ---------- login ---------- */
.login-body { background: var(--paper); }
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: var(--surface-2); border-right: 1px solid var(--line); display: flex; align-items: center; padding: 48px; }
.login-hero-inner { max-width: 520px; }
.login-brand { margin-bottom: 36px; }
.login-headline { font-size: 30px; line-height: 1.2; margin: 0 0 16px; font-weight: 600; }
.login-sub { color: var(--muted); font-size: 15px; line-height: 1.6; margin: 0; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 26px; box-shadow: var(--shadow); }
.login-title { margin: 0 0 4px; font-size: 18px; }
.login-field { display: grid; gap: 5px; font-size: 13px; }
.login-field span { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.login-field input { width: 100%; }
.login-error { color: var(--danger); margin: 0; font-size: 13px; }
.login-submit { justify-content: center; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-hero { display: none; } }

/* ---------- print ---------- */
.print-head { display: none; }
@media print {
  .appbar, .sub, .legend, .hint, .subtabs { display: none !important; }
  .content { padding: 0; max-width: none; }
  .print-head { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; margin-bottom: 8px; }
  .daygrid { break-inside: avoid; page-break-inside: avoid; margin-bottom: 18px; }
  .gh { position: static; }
  .slot { box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cell { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  :root { --row-h: 14px; }
}

/* Gem: prik naar der er aendringer, der ikke er gemt */
#save-btn.dirty::after { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ffcf5c; margin-left: 8px; box-shadow: 0 0 0 2px rgba(0,0,0,.15); }
#save-btn:disabled { opacity: .55; }
.status.dirty { color: #a2720a; }
html[data-theme="dark"] .status.dirty { color: #ffcf5c; }

/* raekke der lige er flyttet (FLIP) */
@keyframes rowflash { 0% { background: rgba(36,107,99,.22); } 100% { background: transparent; } }
.tbl tr.moved td { animation: rowflash 900ms ease-out; }
.tbl td { will-change: transform; }

/* laas paa kalenderen: ikon, flueben, kort tekst, venstrestillet */
.form label.lockrow { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 13px; justify-self: start; cursor: pointer; }
.lockrow .lockicon { font-size: 14px; }
.lockrow input { margin: 0; }

.dlg label.radio { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.dlg label.radio input { width: auto; margin: 0; }
#new-cal-btn { font-size: 18px; line-height: 1; }

.tbl td.nw, .tbl th.nw { white-space: nowrap; }

/* kontekstlinje: label i mono-versaler, vaerdi i fed */
.context { display: inline-flex; gap: 22px; align-items: baseline; }
.context .kv { display: inline-flex; gap: 8px; align-items: baseline; }
.context .kv b { font-weight: 600; font-size: 14px; }

/* optaelling: samme bredde som tabellen nedenunder */
.tbl.wide { width: 100%; table-layout: fixed; }
.tbl.wide th:first-child, .tbl.wide td:first-child { width: 18%; }
.tbl.wide td.n, .tbl.wide th.n { text-align: center; padding-right: 10px; }
.tbl.wide td.n { font-size: 14px; }


/* ---------- AEndringer: ugen i gennemsynstilstand ---------- */
.cmp-controls { gap: 10px; }
.cmp-word { font-size: 14px; color: var(--muted); }
#cmp-a, #cmp-b { width: 260px; min-width: 260px; max-width: 260px; }
.cmp-controls .daytabs { margin-left: 18px; }
.daytabs button .cnt { font-family: var(--mono); font-size: 11px; margin-left: 5px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.cmp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.cmp-legend { margin-bottom: 10px; }
.cmp-legend .mark { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.2); }
.cmp-legend .mark.same { background: var(--surface-2); opacity: .7; }
.cmp-legend .mark.add { background: #cfe8d3; border-left: 3px solid #2f7d42; }
.cmp-legend .mark.rem { background: repeating-linear-gradient(135deg, rgba(201,79,61,.35) 0 3px, transparent 3px 6px); border: 1px dashed #a33a2a; }
.cmp-legend .mark.chg { background: #fde9b8; border-left: 3px solid #b8860b; }
/* tider i gitteret, gennemsyn */
.slot.rv-same { filter: saturate(.15) opacity(.38); cursor: default; }
.slot.rv-add { box-shadow: inset 4px 0 0 #2f7d42, 0 1px 1px rgba(0,0,0,.08); cursor: default; }
.slot.rv-chg { box-shadow: inset 4px 0 0 #b8860b, 0 1px 1px rgba(0,0,0,.08); cursor: default; }
.slot.rv-rem { background: repeating-linear-gradient(135deg, rgba(201,79,61,.28) 0 4px, rgba(255,255,255,.6) 4px 8px) !important; color: #7a2a1e; border: 1px dashed #a33a2a; text-decoration: line-through; cursor: default; }
html[data-theme="dark"] .slot.rv-rem { background: repeating-linear-gradient(135deg, rgba(240,144,127,.35) 0 4px, rgba(20,29,32,.7) 4px 8px) !important; color: #f0907f; }
.slot .was { display: block; font-size: 10px; color: inherit; opacity: .8; }
.slot.flash { animation: slotflash 1.6s ease-out; }
@keyframes slotflash { 0%, 30% { outline: 3px solid var(--accent); outline-offset: 1px; } 100% { outline: 3px solid transparent; } }
/* hoejre spalte */
.rail { position: sticky; top: 70px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 10px; }
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.rail-head b { font-size: 15px; }
.rail h4 { font-size: 13px; font-weight: 600; margin: 16px 0 6px; color: var(--ink); }
.rail .types { display: grid; grid-template-columns: 1fr auto auto auto; gap: 4px 12px; font-size: 13px; align-items: center; }
.rail .types .n { font-family: var(--mono); text-align: right; }
.rail .types .d { font-family: var(--mono); text-align: right; font-weight: 600; }
.rail .types .d.up { color: #2f7d42; } .rail .types .d.down { color: #a33a2a; }
html[data-theme="dark"] .rail .types .d.up { color: #7fd08f; } html[data-theme="dark"] .rail .types .d.down { color: #f0907f; }
.rail .day { font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.rail .chg { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: baseline; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 6px; padding: 5px 6px; cursor: pointer; font: inherit; font-size: 13px; color: var(--ink); }
.rail .chg:hover { background: var(--surface-2); }
.rail .chg .m { width: 12px; height: 12px; border-radius: 2px; margin-top: 2px; }
.rail .chg .m.add { background: #2f7d42; } .rail .chg .m.rem { background: #a33a2a; } .rail .chg .m.chg { background: #b8860b; }
.rail .chg .where { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.rail .chg .what { display: block; }
.rail .chg .what s { color: var(--muted); }
.rail .quiet { color: var(--muted); font-size: 13px; }
.rail-empty { padding: 6px 0 2px; color: var(--muted); font-size: 13px; }
@media (max-width: 1250px) { .cmp-layout { grid-template-columns: 1fr; } .rail { position: static; } }
