/* Sämling oktatói naptár v2 — single stylesheet (no inline styles: the CSP forbids them) */

:root {
  --brand: #025428;
  --brand-700: #003a16;
  --brand-500: #1f7a45;
  --brand-300: #94bca0;
  --brand-100: #e3ede4;
  --brand-50: #f2f7f3;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --bg: #f5f7f5;
  --surface: #fff;
  --danger: #b42318;
  --danger-50: #fef3f2;
  --warn: #b54708;
  --warn-50: #fffaeb;
  --off: #fbeeee;
  --off-head: #f6d6d6;
  --off-ink: #9b1c1c;
  --holiday: #b42318;
  --today: #eef7f0;
  --accent: #025428;
  --surface-2: #f9fafb;
  --surface-3: #fafafa;
  --faint: #c0c4cc;
  --hover: rgb(17 24 39 / 5%);
  --disabled: #f3f4f6;
  --drop: #e6f3ea;
  --line-hover: #c4c9d0;
  --danger-line: #f1b8b3;
  --ok-bg: #e7f6ec;
  --ok-ink: #146c35;
  --muted-bg: #f2f4f7;
  --muted-ink: #475467;
  --head-bg: #dde4df;
  --head-ink: #1f2937;
  --head-line: #b8c4bc;
  --hidden-row: #cdd1d6;
  --hidden-head: #b6bcc4;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 10%);
  --shadow-lg: 0 20px 40px -12px rgb(16 24 40 / 28%);
  --name-w: 176px;
  --cell-min: 75px;
  --ev-font: 11px;
  --focus: 0 0 0 3px rgb(148 188 160 / 70%);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); }
code { font: 12px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--brand-50); padding: 2px 6px; border-radius: 6px; color: var(--accent); }
kbd { font: 11px ui-monospace, Consolas, monospace; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--surface); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; box-shadow: var(--shadow); }
.skip-link:focus { top: 8px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.env-ribbon { background: #b45309; color: #fff; text-align: center; font-size: 12px; font-weight: 600; letter-spacing: .02em; padding: 3px 8px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink-2); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { background: var(--surface-2); border-color: var(--line-hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn-danger { background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn-danger:hover { background: var(--danger-50); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--hover); border-color: transparent; }
.btn-danger-text { color: var(--danger); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid transparent; border-radius: 10px; background: transparent; font-size: 22px; line-height: 1; color: var(--ink-2); text-decoration: none; cursor: pointer; }
.icon-btn:hover { background: var(--hover); }
.link-btn { border: 0; background: none; padding: 4px 0; color: var(--accent); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.is-busy { cursor: progress; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge-warn { background: var(--warn-50); color: var(--warn); }
.badge-danger { background: var(--danger-50); color: var(--danger); }
.badge-muted { background: var(--muted-bg); color: var(--muted-ink); }
.badge-brand { background: var(--brand-100); color: var(--accent); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 20px; min-height: 60px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 1px 2px rgb(16 24 40 / 4%); }
.brand { display: flex; align-items: center; gap: 12px; flex: none; align-self: stretch; }
.brand-logo { display: flex; border-radius: 6px; }
.brand img { height: 32px; width: auto; }
/* The title opens the team calendar and is marked like the active tab when it is open. */
.brand-title { position: relative; display: flex; align-items: center; align-self: stretch; padding: 0 14px; font-weight: 700; font-size: 15px; color: var(--ink); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.brand-title::before { content: ""; position: absolute; left: 0; top: 50%; height: 20px; margin-top: -10px; border-left: 1px solid var(--line); }
.brand-title:hover { color: var(--accent); }
.brand-title[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs { display: flex; gap: 4px; align-self: stretch; overflow-x: auto; scrollbar-width: none; }
.tab { display: flex; align-items: center; padding: 0 14px; color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.topbar-end { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
.zoom-controls { display: flex; align-items: center; gap: 2px; margin-right: 8px; padding-right: 8px; border-right: 1px solid var(--line); }
.zoom-controls .icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.zoom-controls .icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--hover); border-color: var(--line-strong); }
.top-search input { width: 170px; height: 34px; margin-right: 4px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.top-search input:focus { border-color: var(--brand-500); box-shadow: var(--focus); outline: none; }
.usermenu { position: relative; flex: none; }
.theme-toggle svg { display: block; }
/* The view button shows the next view: light → dark (moon) → classic (grid) → light (sun). */
.theme-toggle .icon-sun, .theme-toggle .icon-classic { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-classic { display: block; }
:root[data-theme="classic"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="classic"] .theme-toggle .icon-sun { display: block; }
.usermenu summary { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer; list-style: none; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--hover); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; }
.usermenu-name { font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-panel { position: absolute; right: 0; top: calc(100% + 6px); width: 240px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.usermenu-who { margin: 4px 8px 8px; display: flex; flex-direction: column; }
.usermenu-who span { color: var(--muted); font-size: 12px; }
.usermenu form { margin: 0; }
.menu-item { display: block; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--brand-50); }
a.menu-item { color: var(--ink); text-decoration: none; }

/* ---------- page structure ---------- */
.main { padding: 16px 20px 8px; outline: none; }
.footer { display: flex; justify-content: center; gap: 12px; padding: 14px 16px 18px; color: var(--muted); font-size: 12px; }
.footer a { color: inherit; font-weight: 600; text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-version { opacity: .8; }
.footer-legal { display: inline-flex; gap: 12px; }
.footer.has-note { flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 24px; padding: 8px 20px 10px; }
.footer-note { text-align: left; }

/* Team calendar: the page fills the screen and only the grid scrolls (no second scroll bar). */
body.view-naptar { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
body.view-naptar > :not(.main) { flex-shrink: 0; }
body.view-naptar .main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding-bottom: 0; }

/* Phone-only parts (page menu, day view, view switch, round + button) stay hidden on larger screens. */
.pagemenu, .view-switch, .fab, .day-view { display: none; }
.legend-fold > summary { display: none; }
/* Any touch screen: drag & drop is mouse-only, so its tip is not shown. */
@media (pointer: coarse) {
  .footer-note { display: none; }
  .footer.has-note { justify-content: center; }
}
body.view-naptar .grid-wrap { flex: 1 1 auto; min-height: 220px; max-height: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 4px 0 16px; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; }
.page-head p { margin: 0; max-width: 640px; }
/* Title, status and controls on one line (Ünnepnapok) */
.page-head-inline { align-items: center; justify-content: flex-start; gap: 12px 20px; }
.page-head-inline h1 { margin: 0; }
.head-source { font-size: 14px; cursor: help; }
.head-source.is-warning { color: var(--warn); }
.head-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.empty-state { padding: 40px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-bottom: 12px; }
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-title { margin: 0 6px; min-width: 150px; text-align: center; font-size: 20px; font-weight: 700; }
.month-jump input { height: 32px; padding: 2px 6px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; background: var(--ev-bg); border-left: 3px solid var(--ev-bar); }
.legend-off { background: var(--off-head); border-left-color: var(--holiday); }
.toolbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.person-heading { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.person-heading select { height: 34px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); font-weight: 600; }
.person-badge { font-weight: 700; font-size: 16px; }

/* ---------- event chips ---------- */
.c1 { --ev-bg: #eceef2; --ev-ink: #111827; --ev-bar: #1f2937; }
.c2 { --ev-bg: #fde7e7; --ev-ink: #891b1b; --ev-bar: #c62828; }
.c3 { --ev-bg: #e5ecfd; --ev-ink: #1b3a8c; --ev-bar: #2c56d6; }
.c4 { --ev-bg: #e1f2e5; --ev-ink: #19582a; --ev-bar: #2e8b45; }
.c5 { --ev-bg: #efe6fb; --ev-ink: #4c1d95; --ev-bar: #7c3aed; }
.ev { display: block; width: 100%; margin: 1px 0; padding: 1px 4px; border: 0; border-left: 3px solid var(--ev-bar); border-radius: 4px; background: var(--ev-bg); color: var(--ev-ink); font-size: var(--ev-font); line-height: 1.3; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.ev:hover { filter: brightness(.96); }
.ev[draggable="true"] { cursor: grab; }
.ev.is-dragging { opacity: .45; }
.ev.is-highlight { outline: 3px solid var(--warn); outline-offset: 1px; animation: highlight-pulse 1s ease-in-out 3; }
@keyframes highlight-pulse { 50% { outline-color: transparent; } }
.ev-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.ev-full { white-space: normal; font-size: 12px; padding: 3px 6px; margin: 2px 0; }
.ev-cont { border-left-style: dotted; opacity: .85; }
.ev-loc { display: block; font-size: 11px; opacity: .8; }
.ev-span:not(.ev-cont) { box-shadow: inset -2px 0 0 rgb(0 0 0 / 6%); }

/* ---------- team grid ---------- */
.grid-wrap { position: relative; overflow: auto; max-height: calc(100vh - 176px); min-height: 280px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overscroll-behavior: contain; }
.is-dev .grid-wrap { max-height: calc(100vh - 198px); }
.team-grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; }
/* Zoom changes only the width of the day columns; rows keep their height.
   Default: at least --cell-min wide and 1.5 times what fits the screen.
   zoom-fit: the whole month fits the screen width. zoom-NN: NN px wide columns. */
.team-grid.days-28 { --days: 28; }
.team-grid.days-29 { --days: 29; }
.team-grid.days-30 { --days: 30; }
.team-grid.days-31 { --days: 31; }
.team-grid { width: max(150%, calc(var(--name-w) + var(--days) * var(--cell-min))); }
.team-grid.zoom-fit { width: 100%; }
.team-grid.is-zoomed { width: max(100%, calc(var(--name-w) + var(--days) * var(--col-w))); }
.zoom-40 { --col-w: 40px; } .zoom-50 { --col-w: 50px; } .zoom-60 { --col-w: 60px; } .zoom-75 { --col-w: 75px; }
.zoom-90 { --col-w: 90px; } .zoom-110 { --col-w: 110px; } .zoom-135 { --col-w: 135px; } .zoom-165 { --col-w: 165px; }
.zoom-200 { --col-w: 200px; } .zoom-250 { --col-w: 250px; } .zoom-300 { --col-w: 300px; }
.team-grid th, .team-grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.team-grid thead th { position: sticky; top: 0; z-index: 3; background: var(--head-bg); border-bottom: 2px solid var(--head-line); }
.team-grid .corner { left: 0; z-index: 5; width: var(--name-w); padding: 8px 12px; text-align: left; font-size: 12px; font-weight: 600; color: var(--head-ink); border-right: 2px solid var(--head-line); }
.day-head { padding: 4px 0 5px; text-align: center; font-weight: 400; }
.day-head .dow { display: block; font-size: 11px; color: var(--muted); }
.day-head .dnum { display: block; font-size: 14px; font-weight: 700; color: var(--head-ink); }
.day-head.is-off { background: var(--off-head); }
.day-head.is-off .dow, .day-head.is-off .dnum { color: var(--off-ink); }
.day-head.is-holiday { background: var(--holiday); }
.day-head.is-holiday .dow, .day-head.is-holiday .dnum { color: #fff; }
.day-head.is-workday { box-shadow: inset 0 -3px 0 var(--brand-300); }
.day-head.is-today { background: var(--brand); }
.day-head.is-today .dow, .day-head.is-today .dnum { color: #fff; }
.person-cell { position: sticky; left: 0; z-index: 2; background: var(--head-bg); padding: 0 8px 0 12px; text-align: left; font-weight: 600; box-shadow: 2px 0 0 var(--head-line); }
.team-grid tr.own-row .person-cell { box-shadow: 2px 0 0 var(--head-line), inset 4px 0 0 var(--brand); }
.person-name { display: block; width: 100%; padding: 6px 0; border: 0; background: none; font-size: 13px; font-weight: 600; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.person-name { cursor: pointer; color: var(--head-ink); }
/* Superadmin: who appears for administrators and users; unticked rows are greyed. */
.person-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
.person-line .person-name { flex: 1 1 auto; min-width: 0; }
.visibility-check { flex: none; width: 15px; height: 15px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.team-grid tr.is-hidden-person .person-name { color: var(--muted); font-style: italic; }
.team-grid tr.is-hidden-person .cell > * { opacity: .5; }
.team-grid tr.is-hidden-person .cell { background: var(--hidden-row); }
.team-grid tr.is-hidden-person .person-cell { background: var(--hidden-head); }
span.person-name { color: var(--head-ink); }
button.person-name:hover { color: var(--accent); text-decoration: underline; }
.team-grid .cell { position: relative; height: 34px; padding: 2px; vertical-align: top; background: var(--surface); }
.team-grid .cell.is-off { background: var(--off); }
.team-grid .cell.is-today { background: var(--today); box-shadow: inset 1px 0 0 var(--brand-300), inset -1px 0 0 var(--brand-300); }
.team-grid tbody tr:hover .cell, .team-grid tbody tr:hover .person-cell { background-image: linear-gradient(rgb(2 84 40 / 4%), rgb(2 84 40 / 4%)); }
.can-edit .team-grid .cell { cursor: cell; }
.can-edit .team-grid .cell:hover::after, .can-edit .mcell:hover::after { content: "+"; position: absolute; right: 3px; bottom: 0; font-size: 13px; font-weight: 700; color: var(--brand-300); pointer-events: none; }
.row-limited.can-edit .team-grid .cell { cursor: default; }
.row-limited.can-edit .team-grid .cell:hover::after { content: none; }
.row-limited.can-edit .team-grid tr.own-row .cell { cursor: cell; }
.row-limited.can-edit .team-grid tr.own-row .cell:hover::after { content: "+"; }
.drop-target { outline: 2px dashed var(--brand) !important; outline-offset: -2px; background: var(--drop) !important; }
.add-person-row .person-cell { padding-top: 4px; padding-bottom: 4px; }
.add-person-row td { background: var(--surface-2); }


/* ---------- personal month view ---------- */
.month-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.month-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.month-grid th { padding: 8px; background: var(--head-bg); color: var(--head-ink); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; }
.month-grid th.is-off { color: var(--off-ink); }
.mcell { position: relative; height: 118px; padding: 4px 6px 16px; vertical-align: top; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.month-grid tr:last-child .mcell { border-bottom: 0; }
.mcell:last-child { border-right: 0; }
.mcell.is-off { background: var(--off); }
.mcell.is-holiday .mday { color: var(--holiday); }
.day-note { display: block; margin: -2px 0 3px; font-size: 11px; font-weight: 600; color: var(--off-ink); line-height: 1.25; }
.mcell.is-workday .day-note { color: var(--accent); }
.mcell.is-outside { background: var(--surface-3); }
.mcell.is-outside .mday { color: var(--faint); }
.can-edit .mcell { cursor: cell; }
.mday { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; margin-bottom: 2px; border-radius: 999px; font-weight: 700; font-size: 13px; color: var(--ink-2); }
.mcell.is-today .mday { background: var(--brand); color: #fff; }
.agenda { display: none; }
.agenda-day { padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.agenda-day.is-today { border-color: var(--brand-300); box-shadow: inset 3px 0 0 var(--brand); }
.agenda-date { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); }

/* ---------- tables (users, audit) ---------- */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table thead th { background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted); }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tbody th { font-weight: 600; }
.data-table .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.audit-table td:last-child { max-width: 560px; }
/* Password field and delete icon on the Felhasználók tab */
.pw-field { position: relative; display: inline-flex; align-items: center; }
.pw-input { width: 150px; height: 32px; padding: 4px 32px 4px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; letter-spacing: .08em; }
.pw-input::placeholder { letter-spacing: normal; color: var(--faint); }
.pw-input:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--focus); }
.pw-eye { position: absolute; right: 4px; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.pw-eye:hover, .pw-eye[aria-pressed="true"] { color: var(--accent); background: var(--hover); }
.pw-eye[hidden] { display: none; }
.trash-btn { width: 32px; height: 32px; color: var(--danger); }
.trash-btn:hover { background: var(--danger-50); }
/* Hozzáférés dropdown on the Felhasználók tab */
.access-select { height: 32px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.access-select:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--focus); }
.access-select.is-admin { color: var(--accent); border-color: var(--brand-300); }
.access-select.is-blocked { color: var(--danger); border-color: var(--danger-line); background: var(--danger-50); }
.access-select:disabled { opacity: .6; cursor: default; }
/* superadmin: cells edited in place */
.cell-input { width: calc(100% + 9px); min-width: 10.5rem; height: 32px; margin: -4px 0 -4px -9px; padding: 4px 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: inherit; font: inherit; transition: background-color .4s, border-color .4s; }
.cell-input:hover { border-color: var(--line-strong); background: var(--surface); }
.cell-input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); background: var(--surface); }
.cell-input::placeholder { color: var(--faint); font-weight: 400; }
.cell-input.cell-code { font: 13px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--accent); }
.cell-input.is-saving { opacity: .6; }
.cell-input.is-saved { border-color: var(--ok-ink); background: var(--ok-bg); }
.cell-input.is-error { border-color: var(--danger); }
.inline-form { display: flex; gap: 8px; }
.inline-form input { width: 240px; height: 38px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.deleted-people { margin-top: 16px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.deleted-people summary { cursor: pointer; font-weight: 600; }
.deleted-people ul { margin: 10px 0 0; padding: 0; list-style: none; }
.deleted-people li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.pager { text-align: center; margin: 16px 0; }
.status-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); }
.status-card.is-warning { border-left-color: var(--warn); background: var(--warn-50); }
.status-card p { margin: 6px 0 0; font-size: 13px; }
.card-form { margin-top: 16px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-form h2 { margin: 0 0 4px; font-size: 16px; }
.card-form p { margin: 0 0 12px; font-size: 13px; }
.field-row .stack-wide { flex: 2 1 240px; }
.is-overridden td { opacity: .55; text-decoration: line-through; }
.is-overridden td:last-child, .is-overridden td:nth-child(4) { text-decoration: none; }

/* ---------- dialogs & forms ---------- */
.dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.dialog-wide { width: min(680px, calc(100vw - 24px)); }
.dialog-narrow { width: min(400px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgb(17 24 39 / 45%); }
.dialog[open] { animation: dialog-in .16s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); margin: 0; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.choice-list { margin: 0 0 12px; padding-left: 18px; display: grid; gap: 10px; font-size: 14px; line-height: 1.45; }
.dialog-body { padding: 16px 20px; overflow-y: auto; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.spacer { flex: 1; }
.action-list { display: grid; gap: 8px; }
.field { margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { display: block; margin-bottom: 6px; padding: 0; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.optional { font-weight: 400; color: var(--muted); }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="date"], .field input[type="time"], .field input[type="search"], .field select, .when-grid input { width: 100%; height: 38px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.field input:focus, .field select:focus, .inline-form input:focus, .month-jump input:focus, .person-heading select:focus { border-color: var(--brand-500); box-shadow: var(--focus); outline: none; }
.field input:disabled, .field select:disabled { background: var(--disabled); color: var(--muted); }
.field-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.field-row .stack { display: flex; flex-direction: column; gap: 4px; flex: 1 1 140px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field-row .stack input, .field-row .stack select { width: 100%; height: 38px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 400; font-size: 14px; }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.field > .field-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.field-static { margin: 0; padding: 8px 10px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--surface-2); }

/* ---------- own settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; max-width: 1000px; }
.settings-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.settings-card { padding: 18px 20px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.settings-card h2 { margin: 0 0 14px; font-size: 16px; }
.settings-card .form-error { margin-bottom: 12px; }
.settings-form > .field-hint:first-child { margin: 0 0 14px; }
.settings-actions { display: flex; justify-content: flex-end; }
.device-list { margin: 0 0 10px; padding: 0; list-style: none; }
.device-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.device-list li:last-child { border-bottom: 0; }
.device-name { font-weight: 600; }
.device-name .field-hint { display: block; margin: 2px 0 0; font-weight: 400; }
.device-list ~ .settings-actions { margin-top: 12px; }
.when-grid { display: grid; grid-template-columns: auto minmax(0, 1.3fr) minmax(0, 1fr); align-items: center; gap: 8px 10px; }
.when-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.check-row { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.check .muted { font-weight: 400; }
.info-note { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--muted-bg); color: var(--ink-2); font-size: 13px; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-50); color: var(--danger); font-weight: 600; }
.summary { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--brand-50); color: var(--accent); font-weight: 600; }
.summary.is-warning { background: var(--warn-50); color: var(--warn); }

.color-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.color-option { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; font-weight: 600; }
.color-option small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.color-option input { position: absolute; opacity: 0; pointer-events: none; }
.color-option .swatch { flex: none; width: 18px; height: 18px; border-radius: 5px; background: var(--ev-bg); border-left: 5px solid var(--ev-bar); }
.color-option:has(input:checked) { border-color: var(--ev-bar); box-shadow: 0 0 0 1px var(--ev-bar); background: var(--ev-bg); }
.color-option:has(input:focus-visible) { box-shadow: var(--focus); }

.people-tools, .scope-tools { display: flex; gap: 6px; margin-bottom: 8px; }
.people-tools input { flex: 1; }
.people-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 12px; max-height: 190px; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.people-list label { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.people-list input, .scope-item input { width: 16px; height: 16px; accent-color: var(--brand); }
.scope-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.scope-item { display: grid; grid-template-columns: auto minmax(150px, max-content) 1fr auto; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.scope-item:last-child { border-bottom: 0; }
.scope-item.is-anchor { background: var(--brand-50); font-weight: 600; }
.scope-item .scope-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.scope-empty { margin: 0; padding: 10px 12px; color: var(--muted); }

/* ---------- toasts ---------- */
.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 12px; background: #0f2e1b; color: #fff; font-weight: 600; box-shadow: var(--shadow-lg); animation: toast-in .2s ease-out; transition: opacity .3s, transform .3s; }
.toast-error { background: var(--danger); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- login & error ---------- */
.login-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: #fff; }
.login-header { padding: 16px 24px; border-bottom: 1px solid var(--line); }
.login-header img { height: 44px; width: auto; }
.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 16px; background: linear-gradient(180deg, #fff, var(--brand-50)); }
.login-card { width: 100%; max-width: 420px; padding: 36px 32px 28px; background: var(--brand-100); border: 1px solid #62856c; border-bottom: 8px solid var(--brand); border-radius: 16px; box-shadow: 0 20px 25px -5px rgb(0 0 0 / 10%), 0 8px 10px -6px rgb(0 0 0 / 10%); }
.login-icon { display: flex; align-items: center; justify-content: center; width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 50%; background: #fff; color: var(--brand); box-shadow: inset 0 2px 4px rgb(0 0 0 / 5%); }
.login-card h1 { margin: 0; text-align: center; font-size: 24px; color: #1f2937; }
.login-lead { margin: 6px 0 20px; text-align: center; color: var(--ink-2); }
.login-form label { display: block; margin: 12px 0 6px; font-weight: 600; font-size: 13px; }
.login-form input { display: block; width: 100%; height: 48px; padding: 10px 14px; border: 2px solid var(--brand); border-radius: 12px; background: #fff; font-size: 16px; }
.login-form input:focus { outline: none; box-shadow: var(--focus); }
.login-form .btn { margin-top: 20px; min-height: 48px; font-size: 16px; border-radius: 12px; }
.login-error { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: #fff; color: var(--danger); font-weight: 600; font-size: 13px; }
.login-help { margin: 16px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
.login-installed { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--accent); font-weight: 600; }
.error-card .btn { margin-top: 8px; }

/* ---------- dark theme (per-user preference, rendered server-side as <html data-theme="dark">) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #1f7a45;
  --brand-700: #196b3c;
  --brand-500: #5cc38a;
  --brand-300: #3f7a57;
  --brand-100: #1d3326;
  --brand-50: #17261d;
  --accent: #6fd39b;
  --ink: #e6e8eb;
  --ink-2: #c9ced6;
  --muted: #9aa3ae;
  --faint: #5b6470;
  --line: #2b3038;
  --line-strong: #3a414b;
  --line-hover: #4a525d;
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1d222a;
  --surface-3: #13171c;
  --hover: rgb(255 255 255 / 7%);
  --disabled: #20252c;
  --drop: #1f3a2a;
  --danger: #f97066;
  --danger-50: #3a1d1b;
  --danger-line: #7a2e28;
  --warn: #fdb022;
  --warn-50: #33260f;
  --off: #2a1a1c;
  --off-head: #3b2124;
  --off-ink: #f4a5a5;
  --today: #16301f;
  --ok-bg: #173524;
  --ok-ink: #6ce19b;
  --muted-bg: #262b33;
  --muted-ink: #b4bcc6;
  --head-bg: #2a323c;
  --head-ink: #eef1f4;
  --head-line: #46505c;
  --hidden-row: #0a0c0f;
  --hidden-head: #14181d;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-lg: 0 20px 40px -12px rgb(0 0 0 / 65%);
  --focus: 0 0 0 3px rgb(111 211 155 / 45%);
}
:root[data-theme="dark"] .c1 { --ev-bg: #2a2f37; --ev-ink: #e6e8eb; --ev-bar: #aeb6c2; }
:root[data-theme="dark"] .c2 { --ev-bg: #3d1f22; --ev-ink: #ffb3b0; --ev-bar: #f04438; }
:root[data-theme="dark"] .c3 { --ev-bg: #1c2a4a; --ev-ink: #a9c1ff; --ev-bar: #5b84f5; }
:root[data-theme="dark"] .c4 { --ev-bg: #173524; --ev-ink: #8fdcaa; --ev-bar: #3bb36a; }
:root[data-theme="dark"] .c5 { --ev-bg: #2d2147; --ev-ink: #d0b8ff; --ev-bar: #9b6cf5; }
:root[data-theme="dark"] .brand-logo { background: #fff; padding: 2px 6px; }
:root[data-theme="dark"] .team-grid tbody tr:hover .cell, :root[data-theme="dark"] .team-grid tbody tr:hover .person-cell { background-image: linear-gradient(rgb(255 255 255 / 4%), rgb(255 255 255 / 4%)); }
:root[data-theme="dark"] .ev:hover { filter: brightness(1.15); }
:root[data-theme="dark"] .dialog::backdrop { background: rgb(0 0 0 / 60%); }

/* ---------- classic theme: the look of the old calendar ----------
   Black frame with light text; the grid, cards and dialogs in the old light greys;
   grey day headers, dark red weekends, striped rows; entries as plain coloured text. */
:root[data-theme="classic"] {
  color-scheme: light;
  --font: Tahoma, Verdana, "Segoe UI", Arial, sans-serif;
  --bg: #000000;
  --surface: #f2f2f2;
  --surface-2: #e4e4e4;
  --surface-3: #e9e9e9;
  --line: #bbbbbb;
  --line-strong: #999999;
  --line-hover: #888888;
  --head-bg: #bbbbbb;
  --head-ink: #555555;
  --head-line: #999999;
  --off: #f2eaea;
  --off-head: #990000;
  --off-ink: #f3d6d6;
  --holiday: #990000;
  --today: #e6efe8;
  --hidden-row: #b4b4b4;
  --hidden-head: #a4a4a4;
  --shadow: none;
}
:root[data-theme="classic"] .c1 { --ev-bg: transparent; --ev-ink: #000000; --ev-bar: #000000; }
:root[data-theme="classic"] .c2 { --ev-bg: transparent; --ev-ink: #990000; --ev-bar: #990000; }
:root[data-theme="classic"] .c3 { --ev-bg: transparent; --ev-ink: #0000cc; --ev-bar: #0000cc; }
:root[data-theme="classic"] .c4 { --ev-bg: transparent; --ev-ink: #339900; --ev-bar: #339900; }
:root[data-theme="classic"] .c5 { --ev-bg: transparent; --ev-ink: #660099; --ev-bar: #660099; }
:root[data-theme="classic"] .legend-dot, :root[data-theme="classic"] .color-option .swatch { background: var(--ev-bar); border: 0; }
/* Black frame: top bar, page headings, toolbar and footer in light text */
:root[data-theme="classic"] .topbar { background: #000; border-bottom-color: #333; box-shadow: none; }
:root[data-theme="classic"] .brand-logo { background: #fff; padding: 2px 6px; }
:root[data-theme="classic"] .brand-title, :root[data-theme="classic"] .pagemenu > summary { color: #fff; }
:root[data-theme="classic"] .brand-title::before { border-left-color: #444; }
:root[data-theme="classic"] .tab { color: #bbb; }
:root[data-theme="classic"] .tab:hover, :root[data-theme="classic"] .brand-title:hover { color: #fff; }
:root[data-theme="classic"] .tab.is-active, :root[data-theme="classic"] .brand-title[aria-current="page"] { color: #fff; border-bottom-color: #fff; }
:root[data-theme="classic"] .topbar .icon-btn, :root[data-theme="classic"] .usermenu summary, :root[data-theme="classic"] .toolbar .icon-btn { color: #fff; }
:root[data-theme="classic"] .topbar .icon-btn:hover, :root[data-theme="classic"] .usermenu summary:hover { background: rgb(255 255 255 / 12%); }
:root[data-theme="classic"] .zoom-controls { border-right-color: #333; }
:root[data-theme="classic"] .top-search input { background: #1a1a1a; border-color: #444; color: #fff; }
:root[data-theme="classic"] :is(.page-head, .toolbar, .footer, .pager) { color: #e6e6e6; }
:root[data-theme="classic"] :is(.page-head, .footer) .muted, :root[data-theme="classic"] .footer { color: #9a9a9a; }
:root[data-theme="classic"] .month-title, :root[data-theme="classic"] .page-head h1 { color: #fff; }
:root[data-theme="classic"] .legend, :root[data-theme="classic"] .legend-fold > summary { color: #ddd; }
:root[data-theme="classic"] .head-source { color: #fff; }
:root[data-theme="classic"] :is(.toolbar, .page-head) .btn-ghost { color: #fff; }
:root[data-theme="classic"] :is(.toolbar, .page-head) .btn-ghost:hover { background: rgb(255 255 255 / 12%); }
:root[data-theme="classic"] .head-source.is-warning { color: #fdb022; }
/* Light content areas keep dark text */
:root[data-theme="classic"] :is(.table-card, .settings-card, .card-form, .status-card, .day-view, .month-wrap, .agenda-day, .empty-state, .deleted-people, .dialog, .usermenu-panel, .pagemenu-panel) { color: var(--ink); }
/* The grid: grey headers, dark red weekends, striped rows, thin grey lines */
:root[data-theme="classic"] .grid-wrap { background: #000; border-color: #333; border-radius: 0; }
:root[data-theme="classic"] .team-grid th, :root[data-theme="classic"] .team-grid td { border-color: #999; }
:root[data-theme="classic"] .team-grid thead th { background: #bbb; border-bottom: 1px solid #999; }
:root[data-theme="classic"] .team-grid .corner { color: #666; border-right-color: #999; }
:root[data-theme="classic"] .day-head .dow { color: #666; font-size: 10px; }
:root[data-theme="classic"] .day-head .dnum { color: #666; font-size: 12px; }
:root[data-theme="classic"] .day-head.is-off, :root[data-theme="classic"] .day-head.is-holiday { background: #990000; }
:root[data-theme="classic"] .day-head.is-off :is(.dow, .dnum), :root[data-theme="classic"] .day-head.is-holiday :is(.dow, .dnum) { color: #f0d4d4; }
:root[data-theme="classic"] .day-head.is-workday { box-shadow: none; }
:root[data-theme="classic"] .day-head.is-today { box-shadow: inset 0 -3px 0 #025428; }
:root[data-theme="classic"] .team-grid tbody tr:nth-child(odd) > :is(.cell, .person-cell) { background: #eeeeee; }
:root[data-theme="classic"] .team-grid tbody tr:nth-child(even) > :is(.cell, .person-cell) { background: #dddddd; }
:root[data-theme="classic"] .team-grid tbody tr:nth-child(odd) > .cell.is-off { background: #f2eaea; }
:root[data-theme="classic"] .team-grid tbody tr:nth-child(even) > .cell.is-off { background: #e3d7d7; }
:root[data-theme="classic"] .team-grid .cell.is-today { box-shadow: inset 1px 0 0 #025428, inset -1px 0 0 #025428; }
:root[data-theme="classic"] .team-grid tbody tr.is-hidden-person > :is(.cell, .person-cell) { background: var(--hidden-row); }
:root[data-theme="classic"] .person-cell { box-shadow: 1px 0 0 #999; }
:root[data-theme="classic"] .team-grid .person-name { color: #555; font-weight: 400; font-size: 11px; }
:root[data-theme="classic"] .add-person-row td { background: #ddd; }
/* Entries: plain coloured text, as on the old site */
:root[data-theme="classic"] .team-grid .ev { padding: 0 2px; border-left: 0; border-radius: 0; font-size: 11px; }
:root[data-theme="classic"] .ev:hover { filter: none; text-decoration: underline; }
/* A small "+" in every cell one may add to, like the old calendar */
:root[data-theme="classic"] .can-edit .team-grid .cell::after { content: "+"; position: absolute; right: 3px; bottom: 0; font-size: 11px; font-weight: 400; color: #999; pointer-events: none; }
:root[data-theme="classic"] .row-limited .team-grid tr:not(.own-row) .cell::after { content: none; }
/* ---------- responsive ---------- */
/* Laptops: a slightly tighter top bar so every tab fits next to the zoom buttons and search. */
@media (max-width: 1320px) and (min-width: 1021px) {
  .topbar { gap: 12px; }
  .tab, .brand-title { padding: 0 10px; }
  .top-search input { width: 130px; }
}
@media (max-width: 1100px) and (min-width: 1021px) {
  .usermenu-name { display: none; }
  .top-search input { width: 110px; }
  .zoom-controls { margin-right: 4px; padding-right: 4px; }
}
/* Narrower screens: the tabs move to their own row instead of being cut off. */
@media (max-width: 1020px) {
  .topbar { flex-wrap: wrap; gap: 0 12px; padding: 8px 12px 0; }
  .tabs { order: 3; width: 100%; height: 44px; }
}
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 0 12px; padding: 8px 12px 0; }
  .brand-title { padding: 0 10px; font-size: 14px; }
  .tabs { order: 3; width: 100%; height: 44px; }
  .usermenu-name { display: none; }
  .top-search input { width: 130px; }
  .main { padding: 12px 12px 8px; }
  .toolbar-actions { margin-left: 0; }
  .legend { order: 3; }
  .grid-wrap { max-height: calc(100dvh - 200px); }
  :root { --name-w: 132px; }
}
/* ---------- phones (and phones held sideways): same app, laid out for a small touch screen ---------- */
@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  .month-wrap { display: none; }
  .agenda { display: block; }
  .agenda .ev-full { cursor: pointer; }
  .month-title { min-width: 0; font-size: 17px; }
  .month-jump { display: none; }
  .zoom-controls { display: none; }
  .when-grid { grid-template-columns: 1fr 1fr; }
  .when-label { grid-column: 1 / -1; margin-top: 4px; }
  .scope-item { grid-template-columns: auto 1fr auto; }
  .scope-item .scope-person { grid-column: 2 / 4; }
  .data-table .actions { justify-content: flex-start; }
  /* 16 px text in fields, so iPhones do not zoom in when a field is tapped */
  input, select, textarea { font-size: 16px; }

  /* Top bar: one slim row — logo, page menu (pages + search), theme, account */
  .topbar { flex-wrap: nowrap; gap: 6px; min-height: 52px; padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left)); }
  .brand { flex: 1 1 auto; min-width: 0; gap: 6px; align-self: center; }
  .brand img { height: 24px; }
  .brand-title, .tabs, .top-search, .usermenu-name { display: none; }
  .topbar-end { gap: 0; }
  .icon-btn { width: 40px; height: 40px; }
  .pagemenu { display: block; min-width: 0; }
  .pagemenu > summary { display: flex; align-items: center; gap: 2px; min-width: 0; padding: 8px 8px; border-radius: 10px; color: var(--accent); font-weight: 700; font-size: 15px; white-space: nowrap; cursor: pointer; list-style: none; }
  .pagemenu > summary::-webkit-details-marker { display: none; }
  .pagemenu > summary span { overflow: hidden; text-overflow: ellipsis; }
  .pagemenu[open] > summary { background: var(--hover); }
  .pagemenu-panel { position: absolute; z-index: 40; top: calc(100% + 4px); left: 8px; right: 8px; max-height: calc(100dvh - 80px); overflow: auto; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); }
  .pagemenu-search { margin: 0 0 6px; }
  .pagemenu-search input { width: 100%; height: 44px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); }
  .pagemenu-link { display: block; padding: 12px 14px; border-radius: 10px; color: var(--ink); font-size: 16px; font-weight: 600; text-decoration: none; }
  .pagemenu-link.is-active { color: var(--accent); background: var(--brand-50); }
  .usermenu-panel { width: min(280px, calc(100vw - 20px)); }
  .main { padding: 10px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); }
  .footer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .footer-note { display: none; }
  .footer.has-note { justify-content: center; }

  /* Team calendar toolbar in one line; the colour legend folds into "Színek"; a round + button adds entries */
  .toolbar { gap: 8px; margin-bottom: 8px; }
  .month-nav { flex: 1 1 auto; min-width: 0; }
  .view-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
  .view-switch button { padding: 7px 12px; border: 0; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
  .view-switch button[aria-pressed="true"] { background: var(--brand); color: #fff; }
  .legend-fold { font-size: 13px; }
  .legend-fold > summary { display: inline-flex; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink-2); font-weight: 600; cursor: pointer; list-style: none; }
  .legend-fold > summary::-webkit-details-marker { display: none; }
  .legend-fold[open] { flex-basis: 100%; }
  .legend-fold[open] .legend { margin-top: 8px; }
  .toolbar-actions { display: none; }
  body.view-sajat .main { padding-bottom: 88px; }
  .fab { display: inline-flex; align-items: center; justify-content: center; position: fixed; z-index: 25; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border: 0; border-radius: 50%; background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgb(0 0 0 / 28%); cursor: pointer; }

  /* Compact month grid: one-line names in a narrower column, smaller day columns */
  :root { --name-w: 104px; --cell-min: 60px; }
  .team-grid .person-cell { padding: 0 6px 0 8px; }
  .team-grid .person-name { font-size: 12px; }

  /* Day view: one day, everyone listed; the default on phones */
  body.phone-day .grid-wrap { display: none; }
  body.phone-day .day-view { display: block; }
  body.view-naptar.phone-day .day-view { flex: 1 1 auto; min-height: 0; overflow: auto; padding-bottom: 84px; }
  .day-view { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overscroll-behavior: contain; }
  .day-nav { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 4px; padding: 4px; background: var(--head-bg); border-bottom: 2px solid var(--head-line); border-radius: var(--radius) var(--radius) 0 0; }
  .day-title { flex: 1 1 auto; margin: 0; text-align: center; font-size: 15px; font-weight: 700; color: var(--head-ink); }
  .day-title.is-off, .day-title.is-holiday { color: var(--off-ink); }
  .day-table { width: 100%; border-collapse: collapse; }
  .day-table th.day-person { width: 36%; padding: 10px 8px 10px 12px; text-align: left; vertical-align: top; font-size: 14px; font-weight: 600; color: var(--head-ink); background: var(--head-bg); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
  .day-table tr.own-row th.day-person { box-shadow: inset 4px 0 0 var(--brand); }
  .day-table td.day-cell { height: 44px; padding: 5px 8px; vertical-align: middle; background: var(--surface); border-bottom: 1px solid var(--line); cursor: pointer; }
  .day-table td.day-cell.is-off { background: var(--off); }
  .day-table td.day-cell .ev { padding: 6px 8px; margin: 3px 0; font-size: 14px; white-space: normal; }
  .can-edit .day-table td.day-cell:empty::after { content: "+"; color: var(--faint); font-size: 18px; font-weight: 700; }
  .row-limited .day-table tr:not(.own-row) td.day-cell { cursor: default; }
  .row-limited .day-table tr:not(.own-row) td.day-cell:empty::after { content: none; }
  .day-table tr.is-hidden-person > * { background: var(--hidden-row); color: var(--muted); }

  /* Tables become cards: each row a block, each value labelled */
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table th, .stack-table td { display: block; }
  .stack-table thead { display: none; }
  .stack-table tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .stack-table tbody tr:last-child { border-bottom: 0; }
  .stack-table th, .stack-table td { padding: 3px 0; border: 0; }
  .stack-table tbody th { font-size: 15px; }
  .stack-table td[data-label] { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 30px; }
  .stack-table td[data-label]::before { content: attr(data-label); flex: 0 0 100px; font-size: 12px; font-weight: 600; color: var(--muted); }
  .stack-table td:empty { display: none; }
  .stack-table td.actions { display: flex; justify-content: flex-end; }
  .stack-table .cell-input { flex: 1 1 150px; width: auto; min-width: 0; margin: 0; }
  .stack-table th .cell-input { width: 100%; }
  .stack-table .pw-field { flex: 1 1 150px; min-width: 0; }
  .stack-table .pw-input { width: 100%; }
  .table-card:has(.stack-table) { overflow: visible; }
  .inline-form { flex-wrap: wrap; width: 100%; }
  .inline-form input, .inline-form button { flex: 1 1 100%; width: 100%; }

  /* New-entry dialog: colours in a compact two-column grid */
  .color-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .color-option { padding: 8px; }
  .color-option small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .topbar, .toolbar-actions, .footer, .env-ribbon, .month-jump, .legend { display: none !important; }
  body.view-naptar { display: block; height: auto; }
  .grid-wrap { max-height: none; overflow: visible; box-shadow: none; }
  body { background: #fff; }
}
