:root {
  --ground: #F4F6F3;
  --surface: #FFFFFF;
  --ink: #1F262B;
  --muted: #5D6871;
  --line: #E1E6E0;
  --accent: #16606B;
  --accent-soft: #E3EEEF;
  --ok: #2F8A5B;
  --ok-soft: #E4F2E9;
  --warn: #A9741B;
  --warn-soft: #FBF0DA;
  --edit: #4A5B8C;
  --edit-soft: #E8ECF6;
  --k-ground: #10151A;
  --k-tile: #181F26;
  --k-tile-in: #16281F;
  --k-line: #242E37;
  --k-text: #E8EDF0;
  --k-muted: #77848E;
  --k-green: #3FB878;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Kiosk ---------- */
.k-frame {
  min-height: 100vh;
  background: var(--k-ground);
  color: var(--k-text);
  padding: 14px clamp(12px, 2vw, 28px) 10px;
  display: flex;
  flex-direction: column;
}
.k-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; padding-bottom: 12px; }
.k-clock { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 650; font-variant-numeric: tabular-nums; }
.k-date { color: var(--k-muted); font-size: 0.95rem; text-transform: capitalize; }
.k-counts { margin-left: auto; display: flex; gap: 16px; font-size: 0.92rem; color: var(--k-muted); align-items: center; }
.k-counts b { color: var(--k-text); font-weight: 650; font-variant-numeric: tabular-nums; }
.k-counts .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.k-counts .dot.in { background: var(--k-green); }
.k-counts .dot.out { background: #3A4650; }
.k-counts .dot.absent { background: #232B33; border: 1px solid #3A4650; }
/* Compact one-line tiles: ~60 fit on a small screen, 130+ on a 1080p kiosk — no scrolling. */
/* Multi-column layout: fills VERTICALLY (A, B, C down the first column, then the next) —
   people scan name lists top-to-bottom, not left-to-right. Column count stays responsive. */
.k-grid { flex: 1; columns: 215px; column-gap: 8px; column-fill: balance; }
.k-tile {
  display: flex; align-items: center; gap: 8px;
  break-inside: avoid; margin-bottom: 5px;
  border-radius: 5px; padding: 5px 10px; min-height: 32px;
  background: var(--k-tile); border-left: 3px solid var(--k-line); color: var(--k-muted);
}
.k-tile .nm {
  flex: 1; min-width: 0; font-weight: 600; font-size: 0.85rem; color: var(--k-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.k-tile .hrs { font-variant-numeric: tabular-nums; font-size: 0.85rem; font-weight: 650; color: var(--k-text); }
.k-tile.in { background: var(--k-tile-in); border-left-color: var(--k-green); }
.k-tile.in .hrs { color: var(--k-green); }
.k-tile.out { opacity: 0.68; border-left-color: #3A4650; }
.k-tile.out .hrs { color: var(--k-muted); }
.k-tile.absent { opacity: 0.35; background: transparent; border-left-color: #2A333C; }
.k-tile.absent .nm { color: var(--k-muted); }
.k-tile.absent .hrs { color: var(--k-muted); font-weight: 400; }
.k-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; color: var(--k-muted); font-size: 0.78rem; }
.k-foot .k-hint { margin-left: 26px; }
.k-foot .leg.in { color: var(--k-green); }
.k-foot .leg.out { color: #8B98A2; }
.k-foot .leg.absent { color: #5A6570; }
.k-reconnect { color: var(--warn); font-size: 0.8rem; }
.k-banner {
  border-radius: 6px; padding: 10px 16px; margin-bottom: 10px;
  font-size: 1rem; font-weight: 650; text-align: center;
}
.k-banner.warn { background: #3D2F12; color: #F0C060; border: 1px solid #6B5320; }
.k-banner.err { background: #3D1512; color: #F09080; border: 1px solid #6B2A20; }
.k-banner.info {
  background: #13232E; color: #A8CCE8; border: 1px solid #2A5070;
  display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap;
  font-weight: 500;
}
.k-strip-actions { display: flex; gap: 8px; }
.k-btn {
  font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; text-decoration: none;
  border: 1px solid #2A5070; background: #1B2C38; color: #A8CCE8;
  border-radius: 6px; padding: 5px 14px;
}
.k-btn.primary { background: var(--k-green); border-color: var(--k-green); color: #0C1611; }

/* Office variant (/tavle): board sits under the app nav, not full-bleed. */
/* Min-height, not fixed height: fits-in-viewport gives NO scrollbar (board stretches to the
   bottom), while a small window lets the page GROW and scroll — never clip people away. */
.tavle-page { min-height: 100dvh; display: flex; flex-direction: column; }
.k-frame.k-embedded { flex: 1; min-height: auto; } /* not the kiosk's 100vh — the nav is above */
.k-tile.clickable { cursor: pointer; }
.k-tile.clickable:hover { outline: 1px solid #3A5A6E; }
.k-tile .bell { font-size: 0.8rem; }
.k-empty { color: var(--k-muted); padding: 40px 4px; font-size: 1rem; }

/* ---------- Web app ---------- */
.appbar { display: flex; align-items: center; gap: 18px; padding: 14px 26px; border-bottom: 1px solid var(--line); background: var(--surface); }
.appbar .logo { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.appbar .logo em { font-style: normal; color: var(--accent); }
.appbar nav { display: flex; gap: 4px; margin-left: 12px; flex-wrap: wrap; }
.appbar nav a {
  font-size: 0.88rem; font-weight: 600; color: var(--muted); text-decoration: none;
  padding: 7px 12px; border-radius: 6px;
}
.appbar nav a.on { color: var(--accent); background: var(--accent-soft); }
.userchip { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 0.88rem; color: var(--muted); }
.userchip .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 0.74rem; font-weight: 700;
}
.app-body { max-width: 1080px; margin: 0 auto; padding: 24px 26px 48px; display: flex; flex-direction: column; gap: 22px; }
.weekhead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.weekhead h1 { margin: 0; font-size: 1.2rem; font-weight: 650; }
.weekhead .nav { display: flex; gap: 6px; }
.weekhead .spacer { flex: 1; }
.btn {
  font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 6px; padding: 6px 12px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table.wk { border-collapse: collapse; width: 100%; min-width: 720px; font-size: 0.9rem; }
.wk th {
  text-align: left; font-size: 0.72rem; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FAFBF9;
}
.wk td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.wk tbody tr:last-child td { border-bottom: 0; }
.wk tbody tr { cursor: pointer; }
.wk tbody tr:hover { background: #F7F9F6; }
.wk tbody tr.sel { background: var(--accent-soft); }
.wk .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.wk .day b { font-weight: 650; }
.wk .day span { color: var(--muted); font-size: 0.8rem; display: block; }
.ivl { display: flex; flex-wrap: wrap; gap: 6px; }
.ivl code {
  font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.82rem;
  background: #F1F4F0; border: 1px solid var(--line); border-radius: 4px; padding: 2px 7px; white-space: nowrap;
}
.ivl code.anomaly { background: #FBE3E0; border-color: #E4A9A2; color: #9A2A20; font-weight: 650; }
.badge { display: inline-block; font-size: 0.72rem; font-weight: 650; border-radius: 4px; padding: 2px 8px; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
.badge.edit { color: var(--edit); background: var(--edit-soft); }
.wk tfoot td { padding: 12px 14px; font-weight: 650; background: #FAFBF9; border-top: 1px solid var(--line); }

.detail { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.detail-head { display: flex; align-items: baseline; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.detail-head h3 { margin: 0; font-size: 0.95rem; font-weight: 650; }
.detail-head span { color: var(--muted); font-size: 0.82rem; }
.detail-head .btn { margin-left: auto; }
.reglist { list-style: none; margin: 0; padding: 8px 0; }
.reglist li { display: flex; align-items: baseline; gap: 12px; padding: 9px 18px; font-size: 0.88rem; flex-wrap: wrap; }
.reglist li + li { border-top: 1px solid #EFF2ED; }
.reglist .t { font-variant-numeric: tabular-nums; font-weight: 650; width: 52px; }
.reglist .dir { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; width: 34px; }
.reglist .dir.ind { color: var(--ok); }
.reglist .dir.ud { color: var(--edit); }
.reglist .src { color: var(--muted); font-size: 0.82rem; }
.reglist .note { color: var(--muted); font-size: 0.8rem; font-style: italic; }
.reglist li.superseded { opacity: 0.55; }
.reglist li.superseded .t, .reglist li.superseded .src { text-decoration: line-through; }
.reglist li.manual .src { color: var(--edit); font-weight: 600; }
.line-actions { margin-left: auto; display: flex; gap: 6px; }
.btn.tiny { font-size: 0.72rem; padding: 2px 8px; }

.correction-form { border-bottom: 1px solid var(--line); padding: 14px 18px 16px; background: #FAFBF9; display: flex; flex-direction: column; gap: 10px; }
.cf-title { font-weight: 650; font-size: 0.9rem; }
.cf-fields { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.cf-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.cf-fields label.grow { flex: 1; min-width: 200px; }
.cf-fields input, .cf-fields select {
  font: inherit; font-size: 0.88rem; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; background: var(--surface);
}
.cf-error { color: #9A2A20; background: #FBE3E0; border-radius: 6px; padding: 8px 12px; font-size: 0.85rem; }
.cf-actions { display: flex; gap: 8px; }
.cf-signed { font-size: 0.82rem; color: var(--muted); align-self: center; }
.login-name { font-size: 0.85rem; color: var(--ink); font-weight: 600; }
.no-permission { font-size: 0.8rem; color: var(--muted); font-style: italic; }
tr.badge-ignored td { opacity: 0.5; }
.row-input, .row-select {
  font: inherit; font-size: 0.85rem; color: var(--ink);
  border: 1px solid var(--line); border-radius: 5px; padding: 4px 8px; background: var(--surface);
  max-width: 230px; width: 100%;
}
.toggle-label { display: flex; align-items: center; gap: 7px; font-size: 0.85rem; cursor: pointer; white-space: nowrap; }
.toggle-label input { width: 16px; height: 16px; cursor: pointer; }
.reglist li.missing { color: var(--warn); }
.reglist li.problem { background: #FBE3E0; }
.reglist li.problem .t, .reglist li.problem .dir { color: #9A2A20; }
.problem-reason { color: #9A2A20; font-size: 0.8rem; font-weight: 650; margin-left: auto; }
.reglist li.note-line { color: var(--ok); font-size: 0.82rem; }
.reglist li.note-line::before { content: "✓ "; font-weight: 700; }
.reglist li.paid-line { color: var(--ok); font-size: 0.82rem; }
.reglist li.paid-line::before { content: "☕ "; }
.reglist li.other-line { color: var(--warn); font-size: 0.82rem; }
.reglist li.other-line::before { content: "− "; font-weight: 700; }

.status-chip { font-size: 0.78rem; font-weight: 650; border-radius: 4px; padding: 4px 9px; white-space: nowrap; cursor: default; }
.status-chip.ok { color: var(--ok); background: var(--ok-soft); }
.status-chip.warn { color: var(--warn); background: var(--warn-soft); }
.status-chip.err { color: #9A2A20; background: #FBE3E0; }
.tag-shadow {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); border-radius: 3px; padding: 4px 9px;
}
.select-label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.select {
  font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--ink);
  border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 6px 10px; cursor: pointer;
  max-width: 260px;
}
.notice {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 16px 18px; color: var(--muted); font-size: 0.9rem;
}
.notice.error { border-color: #E4B9B9; background: #FBEDED; color: #9A3A3A; }
.wk td.empty { color: var(--muted); font-style: italic; }
.wk tbody tr.empty-row { cursor: default; }
.wk tbody tr.empty-row:hover { background: transparent; }
.tablewrap.loading { opacity: 0.55; }

/* ---------- Week overview (Ugeoversigt) ---------- */
.app-body.wide { max-width: 1280px; }
.ov-legend { color: var(--muted); font-size: 0.8rem; display: flex; align-items: center; gap: 4px; }
.wk.ov th.num-h { text-align: right; white-space: nowrap; }
.wk.ov td.num { text-align: right; }

/* ---------- Absence (Fravær) ---------- */
.monthlabel { min-width: 150px; text-align: center; text-transform: capitalize; }
.wk.cal { table-layout: fixed; }
.wk.cal th:first-child, .wk.cal td:first-child { width: 190px; }
.wk.cal th.cal-d, .wk.cal td.cal-d { width: 26px; padding: 3px 1px; text-align: center; font-size: 0.72rem; }
.wk.cal td.cal-d { height: 24px; border-left: 1px solid var(--line); }
.cal-d.free { background: #F0F2F4; color: var(--muted); }
.cal-leg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; background: #DDD; }
.cal-d.req { opacity: 0.45; outline: 1px dashed #8A6D1A; outline-offset: -2px; }
.cal-weeks th { border-bottom: none; padding: 2px 0; }
.cal-weeks .cal-w { text-align: center; font-size: 0.7rem; color: var(--muted); font-weight: 600; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.cal-leg.free { background: #F0F2F4; border: 1px solid var(--line); }
/* Category colors by seeded id: Ferie, Feriefridag, Fleks, Sygdom, Barns 1. sygedag, Fri u. løn, Andet */
.cat-1 { background: #7FB77E !important; }
.cat-2 { background: #A3C9A8 !important; }
.cat-3 { background: #8EB8D6 !important; }
.cat-4 { background: #E6A57E !important; }
.cat-5 { background: #E8C07D !important; }
.cat-6 { background: #B9A6D6 !important; }
.cat-7 { background: #C9C9C9 !important; }
.panel { border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; margin-bottom: 16px; background: #FAFBFC; }
.panel h2 { margin-top: 0; }
.wk.slim td { padding: 4px 10px; }
.dlg-backdrop { position: fixed; inset: 0; background: rgba(20, 26, 32, 0.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.dlg { background: #fff; border-radius: 12px; padding: 20px 24px; min-width: 380px; max-width: 480px; box-shadow: 0 12px 40px rgba(0,0,0,0.25); }
.dlg h2 { margin-top: 0; font-size: 1.05rem; }
.dlg label { display: block; margin: 10px 0 4px; font-size: 0.85rem; color: var(--muted); }
.dlg .row-input, .dlg .row-select { width: 100%; }
.dlg-row { display: flex; gap: 8px; margin-top: 14px; align-items: center; }

/* ---------- Flex + Min side (mobil/PWA) ---------- */
.flex-pos { color: #2E7D32; }
.flex-neg { color: #B3392B; }
.row-input.norm { width: 64px; text-align: right; }
.row-input[type="date"] { width: 150px; }
.mig { max-width: 560px; margin: 0 auto; padding: 14px 14px 40px; }
.mig-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.mig-desktop { font-size: 0.8rem; color: var(--muted); text-decoration: none; }
.mig h1 { font-size: 1.3rem; margin: 8px 0 12px; }
.mig h2 { font-size: 0.95rem; margin: 20px 0 8px; color: var(--muted); }
.mig-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mig-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; background: #fff; }
.mig-card b { font-size: 1.1rem; }
.mig-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.mig-sub { font-size: 0.72rem; color: var(--muted); }
.mig-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.mig-actions .btn { padding: 12px 8px; font-size: 0.95rem; }
.mig-day { display: flex; align-items: baseline; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.mig-day.warn { background: #FFF7EC; }
.mig-day-date { min-width: 74px; color: var(--muted); }
.mig-day-iv { flex: 1; }
@media (max-width: 640px) {
  .mig-cards { grid-template-columns: 1fr 1fr; }
  .appbar nav { flex-wrap: wrap; }
}

/* Board tile: registered absence (ferie/fravær) — distinct from plain "not met" */
.k-tile.away { opacity: 0.75; background: transparent; border-left-color: #7FB77E; }
.k-tile.away .nm { color: var(--k-muted); }
.k-tile.away .hrs { color: #7FB77E; font-weight: 600; font-size: 0.72rem; }
.wk.ov td.ov-empty { color: #C6CEC7; }
.wk.ov td.ov-attn { background: var(--warn-soft); text-align: center; }
.wk.ov td.ov-edit { background: var(--edit-soft); }
.wk.ov td.total { border-left: 1px solid var(--line); background: #FAFBF9; white-space: nowrap; }
.wk.ov td.total .badge { margin-left: 6px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
