/* Schichtplan: base styles. No inline styles in the HTML (Content-Security-Policy). */

/* Colours: light here, dark below (:root[data-theme="dark"], set by theme-init.js).
   Contrast (WCAG AA) is checked by tests/test_theme.py: text 4.5:1 on every background
   it appears on, borders of controls, focus rings and markers 3:1. A new colour or a
   new pair of colours needs a line there. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #5d6677;
  --border: #d5d9e0; /* lines between cells and rows: only decoration */
  --control-border: #7d8697; /* edges of inputs, buttons, the switch */
  --accent: #1f5fa8;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --ok: #1e7a3c;
  --outside: #e3e6eb; /* around the page box on wide windows */
  --backdrop: rgb(0 0 0 / 0.3); /* behind dialogs */
  /* The plan */
  --weekend: #e6e9ee;
  --holiday-federal: #ffbf8f;
  --holiday-nrw: #fbe08a;
  --holiday-other: #c9def5;
  --badge: #8a5a00;
  --selected: #cfe0f5; /* days of a range selection */
  --row-hover: rgb(31 95 168 / 0.13);
  --label-text: #1d2330; /* the absence name in a cell, on its own pill */
  --label-bg: rgb(255 255 255 / 0.75);
  --radius: 6px;
  /* The page box: wide enough for a 31-day month (name column 9rem + 31 days of
     2.6rem + page padding), the same on every page; wider only for wider content. */
  --box: 92rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light;
}
/* Dark: only on screen, paper stays light. Holidays stay stronger than weekends. */
@media screen {
  :root[data-theme="dark"] {
    --bg: #15191f;
    --surface: #1d232b;
    --text: #e7eaef;
    --muted: #a7b0bd;
    --border: #353d48;
    --control-border: #7b8595;
    --accent: #7fb2ff;
    --accent-text: #0b1a2e;
    --danger: #ff8a80;
    --ok: #66cc88;
    --outside: #0c0f13;
    --backdrop: rgb(0 0 0 / 0.6);
    --weekend: #2a313b;
    --holiday-federal: #7a3510;
    --holiday-nrw: #4a4a10;
    --holiday-other: #1c3757;
    --badge: #f0c35a;
    --selected: #23446c;
    --row-hover: rgb(127 178 255 / 0.14);
    --label-text: #ffffff;
    --label-bg: rgb(0 0 0 / 0.62);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html { background: var(--outside); }

/* The whole page is one box in the middle of the window: as wide as its content,
   at least --box (or the window), with equal space left and right. A column, so
   the version can sit at the bottom of the box. */
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: fit-content;
  min-width: min(var(--box), 100%);
  max-width: 100%; /* a wider plan scrolls inside its frame, never the page */
  margin: 0 auto;
  border-inline: 1px solid var(--border);
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }

a { color: var(--accent); }

/* Bottom right of the box, in view while scrolling. */
.version {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  align-self: flex-end;
  padding: 0.25rem 0.75rem 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
}
/* The version links to /info but looks like plain text until pointed at. */
.version a { color: inherit; text-decoration: none; }
.version a:hover, .version a:focus-visible { text-decoration: underline; }

code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; }

/* Login: the card in the middle of the window, no page box. */
.login-page {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  margin: 0;
  border: none;
}
.login-page .version { position: fixed; right: 0; bottom: 0; }

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: min(22rem, calc(100vw - 2rem));
}

.hint { color: var(--muted); font-size: 0.875rem; font-weight: normal; }
[hidden] { display: none !important; }

/* Top bar with navigation */
/* The navigation stays at the top of the window on every page. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
  min-height: 3rem;
}
.topbar .brand { font-weight: 600; }
.topbar nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--text); padding: 0.25rem 0; }
.topbar nav a.active { border-bottom: 2px solid var(--accent); }
.topbar .user { display: flex; gap: 1rem; align-items: center; color: var(--muted); }
/* Admins: open wishes, a red pill in the top bar (common.js showWishBadge) */
.wish-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--danger); color: var(--accent-text); font-weight: 600; font-size: 0.85rem;
  border-radius: 999px; padding: 0.2rem 0.7rem; text-decoration: none; white-space: nowrap;
}
.wish-badge:hover, .wish-badge:focus-visible { text-decoration: underline; }
.wish-badge .bell { width: 1rem; height: 1rem; flex: none; }
.wish-badge-slot:empty { display: none; }

/* The switch "Dunkelmodus" (common.js, themeSwitch): a moon, then a track with a
   knob, on = dark. */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  background: none;
  padding: 0.2rem 0;
  color: var(--muted);
  white-space: nowrap;
}
.switch-track {
  position: relative;
  flex: none;
  width: 2.2rem;
  height: 1.25rem;
  border: 1px solid var(--control-border);
  border-radius: 999px;
  background: var(--surface);
  transition: background-color 0.15s, border-color 0.15s;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.25rem - 6px);
  height: calc(1.25rem - 6px);
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s;
}
.theme-switch .moon {  /* a crescent: the inset shadow of an empty circle */
  flex: none;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  box-shadow: inset 0.28rem -0.12rem 0 0 currentColor;
}
.theme-switch:hover { color: var(--text); }
.theme-switch:hover .switch-track { border-color: var(--text); }
.theme-switch[aria-checked="true"] .switch-track { background: var(--accent); border-color: var(--accent); }
.theme-switch[aria-checked="true"] .switch-track::after { transform: translateX(0.95rem); background: var(--accent-text); }
@media (prefers-reduced-motion: reduce) {
  .switch-track, .switch-track::after { transition: none; }
}

/* Page layout */
.page { padding: 1rem 1.25rem 3rem; }
.page.narrow { max-width: 28rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.page-head h1 { margin: 0; }
/* A second section of a page, its heading as big as the page's ("Meine Wünsche": Schichtwünsche). */
.page-head.section-head { margin-top: 2.5rem; }
.page-head.section-head h2 { margin: 0; font-size: 1.5rem; }

/* Forms and buttons */
.form { display: flex; flex-direction: column; gap: 0.85rem; }
.form label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 500; }
.form label.check { flex-direction: row; align-items: center; gap: 0.5rem; }
.form .buttons { display: flex; gap: 0.5rem; }

input, select, textarea, button { font: inherit; }
input:not([type="checkbox"]), select, textarea {
  border: 1px solid var(--control-border);
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  border: 1px solid var(--control-border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}
button:hover { border-color: var(--text); }
input[type="checkbox"] { accent-color: var(--accent); }
button:disabled { opacity: 0.6; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.link { border: none; background: none; padding: 0; color: var(--accent); text-decoration: underline; }

.message { margin: 0; min-height: 0; }
.message.error { color: var(--danger); }
.message.ok { color: var(--ok); }

/* Tables */
.table { border-collapse: collapse; background: var(--surface); margin-top: 1rem; }
.table th, .table td { border-bottom: 1px solid var(--border); padding: 0.45rem 0.75rem; text-align: left; }
.table th { font-weight: 600; background: var(--bg); }
.table td.num { text-align: right; }
.table td.actions { display: flex; gap: 0.5rem; }
.table tr.inactive td { color: var(--muted); }

/* Dialogs */
dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: min(30rem, calc(100vw - 2rem));
}
dialog::backdrop { background: var(--backdrop); }
dialog h2 { margin-top: 0; }

.form .row { display: flex; gap: 1rem; }
.form .row label { flex: 1; }
input[type="color"] { width: 4rem; height: 2.2rem; padding: 0.15rem; }

/* Coloured labels, e.g. shift codes */
.chip {
  display: inline-block;
  border-radius: 4px;
  padding: 0.05rem 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
/* Background patterns of shift types, over the type's colour. A 1px outline in that
   colour (--chip-color, set by chip()) keeps the text readable on top of the pattern.
   Dots: 4px grid (wider grids blur into little crosses at 1x), each dot centred on a
   pixel so it stays one small pixel at 1x (on a pixel corner it spreads over 2x2). */
.chip.pattern-stripes {
  background-image: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.4) 0 2px, transparent 2px 6px);
}
.chip.pattern-dots {
  background-image: radial-gradient(circle at 1.5px 1.5px, #000 0.5px, transparent 0.8px);
  background-size: 4px 4px;
}
.chip.pattern-stripes, .chip.pattern-dots {
  text-shadow: 1px 0 var(--chip-color), -1px 0 var(--chip-color), 0 1px var(--chip-color),
    0 -1px var(--chip-color), 0 0 2px var(--chip-color);
}
.type-preview { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 500; }
.type-preview .chip { align-self: flex-start; font-size: 1rem; padding: 0.3rem 0.7rem; }

/* Month plan */
.plan-page { padding-top: 0; padding-bottom: 4rem; }
/* Navigation, toolbar and legend stay at the top of the window as one block;
   the months scroll underneath. */
.plan-top { position: sticky; top: 0; z-index: 10; }
.plan-top .topbar { position: static; }
.plan-head {
  contain: inline-size; /* wraps within the box, doesn't widen it */
  background: var(--bg);
  padding: 0.6rem 1.25rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.plan-toolbar { display: flex; align-items: center; gap: 0.5rem 0.75rem; flex-wrap: wrap; }
.plan-toolbar h1 { margin: 0 0.5rem 0 0; font-size: 1.4rem; }
/* Loading a year above the visible months: plan.js keeps the view in place
   itself; the browser's own scroll anchoring (not in every browser) would add to that. */
.plan-doc, .plan-doc body { overflow-anchor: none; }
.load-more { text-align: center; padding: 0.75rem 0; }
.month { margin-bottom: 1.75rem; }
.month h2 { margin: 0 0 0.3rem; font-size: 1.2rem; }
.month-head { display: flex; align-items: baseline; gap: 1rem; }
.month-head .autoplan { font-size: 0.8rem; padding: 0.15rem 0.6rem; }
.month .holiday-list { margin: 0 0 0.4rem; font-size: 0.85rem; }

.plan-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  background: var(--surface);
}
.plan { border-collapse: separate; border-spacing: 0; font-size: 0.8rem; }
.plan th, .plan td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.15rem;
  text-align: center;
  vertical-align: middle;
}
.plan thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  font-weight: 600;
  min-width: 2.6rem;
}
.plan th.name {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  white-space: nowrap;
  padding: 0.2rem 0.6rem;
  min-width: 9rem;
}
.plan thead th.corner { z-index: 3; }
.plan .weekday, .plan .daynum { display: block; line-height: 1.15; }
.plan .weekday { font-weight: 400; color: var(--muted); }
.plan thead th:is(.weekend, .holiday-federal, .holiday-nrw, .holiday-other) .weekday { color: var(--text); }
.plan td.day { height: 2.3rem; min-width: 2.6rem; }
.plan td.day .chip { display: block; margin: 1px auto; font-size: 0.72rem; padding: 0 0.2rem; }

/* Columns: weekend, holidays (the holiday colour wins), week start, today */
.plan .weekend { background-color: var(--weekend); }
.plan .holiday-federal { background-color: var(--holiday-federal); }
.plan .holiday-nrw { background-color: var(--holiday-nrw); }
.plan .holiday-other { background-color: var(--holiday-other); }
.plan thead th.weekend, .plan thead th.holiday-federal,
.plan thead th.holiday-nrw, .plan thead th.holiday-other { font-weight: 700; }
.plan .week-start { border-left: 2px solid var(--muted); }
.plan thead th.today { box-shadow: inset 0 -3px 0 var(--accent); color: var(--accent); }
.plan thead th.today:is(.holiday-federal, .holiday-nrw, .holiday-other) { color: var(--text); }
.plan td.today { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }

.badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--badge);
  border: 1px solid var(--badge);
  border-radius: 3px;
  padding: 0 0.15rem;
  line-height: 1.2;
}

/* Absences: fixed ones filled, wishes hatched over the column colour */
.plan td.absence-fixed { background-color: var(--absence-color); background-image: none; }
.plan td.absence-wish {
  background-image: repeating-linear-gradient(135deg, var(--absence-color) 0 3px, transparent 3px 7px);
}
.plan .absence-label { font-size: 0.7rem; font-weight: 600; color: var(--label-text); background: var(--label-bg); border-radius: 3px; padding: 0 0.15rem; }

.plan tr.me th.name { font-weight: 700; }
.plan tr.me th.name::after { content: " (ich)"; font-weight: 400; color: var(--muted); }

/* Legend */
.legend { margin-top: 0.4rem; display: flex; flex-direction: column; gap: 0.3rem; }
.holiday-list { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.75rem; }
.holiday-label { font-weight: 600; }
.holiday-list ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1.25rem; }
.holiday-list li { display: flex; align-items: center; gap: 0.35rem; }
.legend-items { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; font-size: 0.85rem; }
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.plan-head .legend-items { gap: 0.2rem 1rem; font-size: 0.8rem; }
.swatch { display: inline-block; width: 1.1rem; height: 1.1rem; border: 1px solid var(--border); border-radius: 3px; }
.swatch.weekend { background: var(--weekend); }
.swatch.holiday-federal { background: var(--holiday-federal); }
.swatch.holiday-nrw { background: var(--holiday-nrw); }
.swatch.holiday-other { background: var(--holiday-other); }
.swatch.absence-wish-sample { background-image: repeating-linear-gradient(135deg, #4caf50 0 3px, transparent 3px 7px); }
.swatch.absence-fixed-sample { background: #4caf50; }

/* Shift wishes (a Mitarbeiter's wish for a shift): a dashed frame around the chip */
.chip.wish { outline: 2px dashed var(--text); outline-offset: -1px; }
.swatch.shift-wish-sample { border: 2px dashed var(--text); }

/* Editing in the plan */
.quick-entry { display: inline-flex; align-items: center; gap: 0.4rem; margin-left: 1rem; font-weight: 500; }
.plan td.editable { cursor: pointer; user-select: none; }
.plan td.day.selected { background-color: var(--selected); background-image: none; outline: 2px solid var(--accent); outline-offset: -2px; }
.plan td.editable:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
body.quick .plan td.editable { cursor: crosshair; }

.day-dialog { width: min(40rem, calc(100vw - 2rem)); }
.day-dialog h3 { font-size: 1rem; margin: 1.1rem 0 0.4rem; }
.holiday-note { margin: 0; color: var(--badge); font-weight: 600; white-space: pre-line; }
.entries { list-style: none; margin: 0 0 0.5rem; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.entries li { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.entries .entry-text { flex: 1; min-width: 10rem; }
.entries .entry-actions { display: flex; gap: 0.35rem; }
.entry-form { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 0.75rem; }
.entry-form h3 { margin-top: 0; }
.dialog-close { justify-content: flex-end; margin-top: 1rem; }
.check-inline { display: inline-flex; align-items: center; gap: 0.4rem; margin-top: 0.5rem; }

/* Change history */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin-top: 0.5rem; }
.filters label { display: flex; flex-direction: column; gap: 0.2rem; font-weight: 500; }
.history td { vertical-align: top; }
.history td.time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.history .context { display: block; color: var(--muted); font-size: 0.9em; }
.history ul.changes { list-style: none; margin: 0; padding: 0; }
.history ul.changes .field { color: var(--muted); }
.pager { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }

/* Bugtracker */
.bug-form { max-width: 40rem; }
.bug-form textarea, .comment-form textarea { width: 100%; resize: vertical; }
.bugs td { vertical-align: top; }
.bugs td.nowrap { white-space: nowrap; }
.bugs td.bug-text { white-space: pre-wrap; max-width: 36rem; }
.comment-form { display: flex; flex-direction: column; gap: 0.3rem; min-width: 16rem; }
.comment-actions { display: flex; align-items: center; gap: 0.5rem; }
.bugs tr.done td { color: var(--muted); }
.bug-done { display: inline-flex; align-items: center; gap: 0.4rem; }

/* Software (info) */
.page.info { max-width: 56rem; }
/* Hilfe (/help): the handbook, lines short enough to read. */
.page.help { max-width: 56rem; line-height: 1.55; }
.page.help section { scroll-margin-top: 5rem; }
.page.help h2 { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.page.help h3 { margin-top: 1.75rem; }
.page.help h4 { margin: 1.25rem 0 0.25rem; }
.page.help li { margin: 0.25rem 0; }
.page.help .table { width: 100%; }
.page.help .table td { vertical-align: top; }
.page.help .table th[scope="row"] { background: none; font-weight: 500; white-space: nowrap; vertical-align: top; }
.help-toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 1.25rem 0.75rem; }
.page.help .help-toc h2 { margin: 0.5rem 0; padding: 0; border: none; font-size: 1.1rem; }
.help-toc ol ol { list-style: lower-alpha; }
.help-toc li { margin: 0.1rem 0; }
.help-faq dt { font-weight: 600; margin-top: 1rem; }
.help-faq dd { margin: 0.25rem 0 0 1.25rem; }
kbd { font-family: inherit; font-size: 0.85em; border: 1px solid var(--control-border); border-radius: 3px; padding: 0 0.3rem; }
.page.info .table { width: 100%; }
.page.info .table td { vertical-align: top; }
.page.info .table td:first-child, .page.info .table th[scope="row"] { white-space: nowrap; width: 14rem; }
.page.info .table th[scope="row"] { background: none; font-weight: 500; }
.page.info .hint { margin-top: 0.5rem; }

/* „Automatisch weiterplanen“: the proposal over the plan, as wide as the window */
.autoplan-dialog { width: calc(100vw - 2rem); max-width: none; max-height: calc(100vh - 2rem); }
.autoplan-dialog h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }
.autoplan-tool { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; margin: 0.75rem 0 0.4rem; font-weight: 500; }
.autoplan-warnings, .autoplan-gaps { margin: 0.4rem 0; padding-left: 1.25rem; }
.autoplan-warnings { color: var(--danger); }
.autoplan-summary { font-weight: 600; margin: 0.75rem 0 0; }
.autoplan-dialog .dialog-close { display: flex; gap: 0.5rem; }
.autoplan-grid td.auto-past { cursor: default; }
.autoplan-grid .chip.existing { opacity: 0.45; }
.autoplan-grid .chip.proposed { outline: 2px solid var(--accent); outline-offset: 0; }
.autoplan-grid .chip.proposed.wish { outline-style: dashed; }

/* Print dialog of the plan */
.print-dialog { width: min(32rem, calc(100vw - 2rem)); }
.print-choices { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.print-dialog .dialog-close { display: flex; }
.print-dialog .print-mine { margin: 0 0 0.75rem; }

/* Printing: A4 landscape, colours as on screen (no "print backgrounds" setting
   needed), without navigation, buttons and dialogs. plan.js marks what to print
   (body.print-chosen, months .print-this) and how: one month alone, two per page
   (body.print-two, smaller, a new page at .print-new-page), or only the own row
   (body.print-mine, as many months per page as fit). */
@page { size: A4 landscape; margin: 10mm; }
@media print {
  html { background: none; }
  body {
    background: none;
    min-height: 0;
    width: auto;
    min-width: 0;
    margin: 0;
    border: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .topbar, .version, dialog, button, .load-more { display: none !important; }
  .page { padding: 0; max-width: none; }

  .plan-top, .plan thead th, .plan th.name { position: static; }
  .plan-head { background: none; border: none; padding: 0 0 3mm; }
  .plan-toolbar h1 { font-size: 14pt; }
  .quick-entry, #admin-hint, #quick-hint { display: none !important; }
  .plan-head .legend-items { font-size: 7.5pt; gap: 0.5mm 4mm; }
  .plan-head .swatch { width: 3.5mm; height: 3.5mm; }
  .plan-head .legend-items .chip { font-size: 7pt; padding: 0 1mm; }

  .month { margin: 0; break-inside: avoid; }
  body.print-chosen .month:not(.print-this) { display: none; }
  .month.print-new-page { break-before: page; }
  .month h2 { font-size: 12pt; }
  .month .holiday-list { font-size: 7.5pt; margin-bottom: 1.5mm; }

  /* The grid fills the page width: fixed name column, equal day columns. */
  .plan-wrap { overflow: visible; }
  .plan { width: 100%; table-layout: fixed; font-size: 7pt; }
  .plan thead th, .plan td.day, .plan th.name { min-width: 0; }
  .plan th.name { width: 30mm; padding: 0.5mm 1mm; white-space: normal; overflow-wrap: anywhere; }
  .plan td.day { height: 6mm; padding: 0.3mm; }
  .plan td.day .chip { font-size: 6.5pt; padding: 0 0.3mm; overflow: hidden; }
  .plan .absence-label { font-size: 6pt; }
  .plan .badge { font-size: 5pt; }
  /* "today" and "(ich)" are about the screen, not the paper. */
  .plan thead th.today, .plan td.today { box-shadow: none; color: inherit; }
  .plan tr.me th.name::after { content: none; }

  /* Two months per page: smaller, with codes side by side instead of stacked, so two
     months of about 15 people fit on a page (the first one under the legend too). */
  body.print-two .plan-toolbar h1 { font-size: 12pt; }
  body.print-two .plan-head { padding-bottom: 2mm; }
  body.print-two .plan-head .legend { margin-top: 1mm; gap: 0.5mm; }
  body.print-two .plan-head .legend-items { font-size: 6.5pt; }
  body.print-two .plan-head .swatch { width: 3mm; height: 3mm; }
  body.print-two .plan-head .legend-items .chip { font-size: 6pt; }
  body.print-two .month { margin-bottom: 3mm; }
  body.print-two .month h2 { font-size: 10pt; margin-bottom: 0.5mm; }
  body.print-two .month .holiday-list { font-size: 6.5pt; margin-bottom: 0.5mm; }
  body.print-two .plan { font-size: 6.5pt; line-height: 1.15; }
  body.print-two .plan thead th { padding: 0.2mm; }
  body.print-two .plan th.name { padding: 0.2mm 1mm; }
  body.print-two .plan td.day { height: 3.3mm; padding: 0 0.1mm; }
  body.print-two .plan td.day .chip { display: inline-block; margin: 0 0.2mm; font-size: 5.5pt; line-height: 1.2; }
  body.print-two .plan .absence-label { font-size: 5.5pt; }
  body.print-two .plan tr.team-row th { font-size: 6pt; padding: 0 1mm; }

  /* Only the own row: no other rows or team dividers, the months one below the other. */
  body.print-mine .plan tbody tr:not(.me) { display: none; }
  body.print-mine .month { margin-bottom: 6mm; }
}

/* Teams in the plan: each team's rows start with a divider row carrying its name. */
.plan tr.team-row th {
  border-top: 3px solid var(--text);
  background: var(--bg);
  text-align: left;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
}
/* The name stays in view when the grid scrolls sideways. */
.plan tr.team-row th span { position: sticky; left: 0.6rem; display: inline-block; }
@media print {
  .plan tr.team-row th { font-size: 7.5pt; padding: 0.5mm 1mm; }
}

/* Team changes in the user dialog */
#user-dialog { width: min(38rem, calc(100vw - 2rem)); }
.team-changes { display: flex; flex-direction: column; gap: 0.35rem; }
.team-changes .label { font-weight: 500; }
.team-change { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.team-change input[type="number"] { width: 5.5rem; }
.team-change input.team-input { flex: 1; min-width: 8rem; }

/* The row under the mouse: tinted, with a line above and below, so the eye stays in
   the row. An overlay (::before; ::after is taken by "(ich)") instead of a background,
   so weekends, holidays and absences keep their colours. Only on screens with a
   mouse: no highlight stuck after a tap, nothing on paper. */
.plan td { position: relative; }  /* holds the overlay; th.name is sticky, also positioned */
@media screen and (hover: hover) {
  .plan tbody tr:not(.team-row):hover > :is(th, td)::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--row-hover);
    box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent);
    pointer-events: none;
  }
}
