:root {
  --ink: #1F2924;
  --ink-soft: #55655D;
  --paper: #F6F7F2;
  --paper-raised: #FFFFFF;
  --line: #DDE3DA;
  --forest: #2F5D50;
  --forest-dark: #234339;
  --marigold: #E8A33D;
  --brick: #C25B4A;
  --brick-bg: #FBEAE7;
  --good: #3E7A5B;
  --good-bg: #E7F1EA;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31,41,36,0.06), 0 4px 14px rgba(31,41,36,0.06);
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* Make the native "hidden" attribute always win, even on elements whose
   classes set their own display (e.g. .login-screen sets display:flex).
   Without this, [hidden] silently loses to author CSS at equal specificity
   and the "hidden" screen keeps rendering. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 650; letter-spacing: -0.01em; margin: 0 0 0.4em; }
p { margin: 0 0 0.6em; }
button, input, select, textarea { font-family: inherit; font-size: 1rem; }

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

:focus-visible {
  outline: 3px solid var(--marigold);
  outline-offset: 2px;
}

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--forest) 0%, var(--forest-dark) 100%);
  padding: 24px;
}
.login-card {
  background: var(--paper-raised);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.brand-mark { color: var(--forest); display: inline-flex; }
.login-brand h1 { font-size: 1.5rem; margin-top: 8px; }
.login-sub { color: var(--ink-soft); font-size: 0.92rem; }
.login-form label { display: block; font-size: 0.85rem; font-weight: 600; margin: 14px 0 6px; }
.login-form input {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--line);
  border-radius: 8px; background: var(--paper);
}
.login-form input:focus { border-color: var(--forest); }
.form-error {
  margin-top: 12px; padding: 10px 12px; border-radius: 8px;
  background: var(--brick-bg); color: var(--brick); font-size: 0.88rem;
}
.form-error .inline-signin-link {
  color: var(--ink); font-weight: 600; text-decoration: underline; margin-left: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-weight: 600; font-size: 0.92rem; transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--forest); color: white; }
.btn-primary:hover { background: var(--forest-dark); }
.btn-block { width: 100%; margin-top: 18px; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--forest); color: var(--forest); }
.btn-small { padding: 6px 12px; font-size: 0.82rem; }
.btn-danger { background: var(--brick); color: white; }

/* ---------- App shell ---------- */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 64px 1fr;
  grid-template-rows: 60px 1fr;
  grid-template-areas: "topbar topbar" "nav content";
}
.app-topbar {
  grid-area: topbar;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--paper-raised); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1rem; font-family: inherit; color: var(--forest); background: none; border: 0; padding: 6px 8px; margin-left: -8px; border-radius: 8px; cursor: pointer; }
.topbar-brand:hover { background: var(--paper); }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; }
.role-pill {
  background: var(--good-bg); color: var(--good); padding: 3px 10px;
  border-radius: 999px; font-weight: 600; font-size: 0.75rem; text-transform: capitalize;
}
/* Floating menu rail: icons only until opened, then it slides out over the page
   (the page itself never shifts) and folds back as soon as a choice is made. */
.app-nav { grid-area: nav; position: relative; }
.nav-panel {
  position: fixed; top: 60px; bottom: 0; left: 0; z-index: 45; width: 64px; box-sizing: border-box;
  background: var(--paper-raised); border-right: 1px solid var(--line);
  padding: 10px 8px; display: flex; flex-direction: column; gap: 4px; overflow: hidden auto;
  transition: width .18s ease, box-shadow .18s ease;
}
.app-shell.nav-open .nav-panel { width: 250px; box-shadow: 6px 0 28px rgba(31,41,36,.22); }
.nav-backdrop { display: none; position: fixed; inset: 60px 0 0 0; z-index: 40; background: rgba(31,41,36,.18); }
.app-shell.nav-open .nav-backdrop { display: block; }
.nav-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.nav-link {
  display: flex; align-items: center; gap: 16px; height: 46px; padding: 0 12px; border-radius: 10px;
  color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 0.95rem; cursor: pointer;
  background: none; border: 0; font-family: inherit; text-align: left; white-space: nowrap; flex: none;
}
.nav-icon { width: 24px; height: 24px; flex: none; }
.nav-text { opacity: 0; transition: opacity .12s; }
.app-shell.nav-open .nav-text { opacity: 1; transition-delay: .06s; }
.nav-link:hover { background: var(--paper); }
/* Mouse / trackpad: the rail also opens when hovered. (After a choice it stays shut until the pointer leaves.) */
@media (hover: hover) {
  .app-shell:not(.nav-hover-off) .nav-panel:hover { width: 250px; box-shadow: 6px 0 28px rgba(31,41,36,.22); }
  .app-shell:not(.nav-hover-off) .nav-panel:hover .nav-text { opacity: 1; transition-delay: .06s; }
  /* The Menu button is only needed on touch screens, where there is no hover. */
  .nav-toggle { display: none; }
  .nav-list { margin-top: 0; padding-top: 0; border-top: 0; }
}
.nav-link:focus-visible { outline: 2px solid var(--forest); outline-offset: -2px; }
.nav-link.active { background: var(--forest); color: white; }
.app-content { grid-area: content; padding: 20px 20px; overflow-y: auto; max-width: 1300px; }
.app-content.wide { max-width: none; }
.no-wrap { white-space: nowrap; }

/* Two-row table headers (title row + filter-controls row underneath) */
table thead tr.filter-row th { padding-top: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
table thead tr:first-child th { padding-bottom: 2px; border-bottom: none; }

.name-suggestions {
  position: absolute; top: 100%; left: 0; z-index: 20; margin-top: 2px;
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: var(--shadow); min-width: 180px; max-height: 260px; overflow-y: auto;
  text-align: left; text-transform: none;
}
.name-suggestions div { padding: 6px 10px; cursor: pointer; font-size: 0.82rem; font-weight: 400; color: var(--ink); }
.name-suggestions div:hover { background: var(--paper); }
.name-suggestions div.active { background: var(--line); } /* darker than plain hover, so keyboard selection is clearly visible */
.name-suggestions .name-suggestions-empty { color: var(--ink-soft); cursor: default; }
.name-suggestions .name-suggestions-empty:hover { background: none; }
.name-filter-chip {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 1; min-width: 0;
  font-size: 0.72rem; font-weight: 600; text-transform: none; color: var(--good);
  background: var(--good-bg); padding: 2px 6px; border-radius: 999px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.name-filter-chip button {
  border: none; background: none; cursor: pointer; font-size: 0.95rem; line-height: 1;
  color: var(--good); padding: 0; font-weight: 700; flex-shrink: 0;
}
.app-tabbar { display: none; }

/* ---------- Cards / tables ---------- */
.card {
  background: var(--paper-raised); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 16px;
}
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }

.badge { padding: 3px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.badge-good { background: var(--good-bg); color: var(--good); }
.badge-bad { background: var(--brick-bg); color: var(--brick); }
.badge-neutral { background: var(--paper); color: var(--ink-soft); }

input, select, textarea {
  padding: 9px 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--paper);
  width: 100%;
}
label { font-size: 0.85rem; font-weight: 600; display: block; margin: 10px 0 4px; }
.field { margin-bottom: 10px; }

/* ---------- Ratio gauge ---------- */
.ratio-gauge {
  display: flex; align-items: center; gap: 14px; padding: 14px;
  border-radius: var(--radius); border: 1.5px solid var(--line);
}
.ratio-ring {
  width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem; flex-shrink: 0;
  border: 4px solid var(--good);
}
.ratio-ring.bad { border-color: var(--brick); color: var(--brick); }
.ratio-ring.good-text { color: var(--good); }
.ratio-detail h3 { margin: 0 0 2px; font-size: 1rem; }
.ratio-detail p { margin: 0; font-size: 0.85rem; color: var(--ink-soft); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.info-line { padding: 10px 12px; border-radius: 8px; background: var(--paper); font-size: 0.9rem; margin-bottom: 10px; }

/* ---------- Dashboard sub-tabs ---------- */
.dash-tabbar { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1.5px solid var(--line); }
.dash-tab {
  padding: 8px 16px; border: none; background: none; cursor: pointer;
  font-weight: 600; font-size: 0.92rem; color: var(--ink-soft); border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
}
.dash-tab.active { color: var(--forest); border-bottom-color: var(--forest); }

/* ---------- Occupancy screen ---------- */
.occ-month-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.occ-month-nav h2 { margin: 0; min-width: 150px; font-size: 1.15rem; }
.occ-legend {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; font-size: 0.72rem; color: var(--ink-soft);
}
.occ-legend-item { display: flex; align-items: center; gap: 4px; }
.occ-swatch {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 15px; border: 1px solid var(--line); border-radius: 2px;
  font-size: 0.58rem; font-weight: 700;
}
.occ-scroll { overflow-x: auto; }
.avail-scroll { overflow-x: hidden; }
.occ-table { border-collapse: collapse; font-size: 0.68rem; table-layout: fixed; width: 100%; border-bottom: 1px solid var(--line); }
.occ-table th, .occ-table td {
  border: 1px solid var(--line); padding: 1px 2px; text-align: center;
  overflow: hidden; text-overflow: clip; height: 20px;
}
.occ-table tr.occ-group-gap td { border: none; height: 10px; padding: 0; background: transparent; }
/* Name / D.O.B. / Age columns fixed width; day columns share whatever's left,
   sized so 31 of them fit alongside the fixed columns on a normal laptop screen. */
.occ-table col.occ-col-name { width: 130px; }
.occ-table col.occ-col-dob { width: 56px; }
.occ-table col.occ-col-age { width: 34px; }
.occ-table col.occ-col-day { width: 26px; }
.occ-table td:nth-child(1), .occ-table th:nth-child(1) { text-align: left; padding-left: 5px; }

/* Row 2 "Total across all sites": label bold, values not bold, no fill */
.occ-total-row td:first-child { font-weight: 700; }
.occ-total-row td { font-weight: 400; }

/* Rows 3-10 equivalent: nursery + room summary rows - label bold, values not
   bold, no fill (HDN) - ADN room rows get the light blue fill per spec. */
.occ-summary-row td:first-child { font-weight: 700; }
.occ-summary-row td { font-weight: 400; }
.occ-adn-row td { background-color: rgb(189, 215, 238); }

/* Staff rota (Occupancy tab) */
.staff-code-red { color: #FF0000; font-weight: 600; }
.occ-staff-under { background: #FF0000; color: #fff; font-weight: 600; }
.occ-staff-over { background: #0070C0; color: #fff; font-weight: 600; }
.occ-balance-excess { font-weight: 700; }
.occ-section-divider { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.occ-staff-cell { cursor: pointer; user-select: none; -webkit-user-select: none; }
/* Selected range / current cell on the staff grid (the inset shadow tints the
   cell without hiding its own colour; the outline marks the active cell). */
td.occ-sel { box-shadow: inset 0 0 0 9999px rgba(0, 112, 192, 0.20); }
td.occ-copied { outline: 2px dashed #0070C0; outline-offset: -2px; } /* copied, waiting to be pasted (Enter) */
td.occ-sel-focus { outline: 2px solid #0070C0; outline-offset: -2px; }
.rota-sel-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; min-height: 30px; font-size: 0.85rem; }
/* Hidden by visibility, not display, so it keeps its space: if it popped in
   on the first click it would push the grid down under the pointer and the
   drag logic would think the mouse had moved onto another cell. */
.rota-sel-bar.rota-sel-off { visibility: hidden; }
.rota-sel-hint { color: var(--ink-soft); font-size: 0.78rem; } /* clickable, deliberately no underline */
.occ-staff-cell:hover { background: var(--paper); outline: 1px solid var(--line); outline-offset: -1px; }

.occ-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; margin-right: 4px; padding: 0;
  border: 1px solid var(--ink-soft); border-radius: 2px; background: var(--paper-raised);
  font-size: 0.7rem; line-height: 1; font-weight: 700; cursor: pointer; color: var(--ink);
  vertical-align: middle;
}
.occ-toggle:hover { background: var(--paper); }
/* The whole room total row toggles its group, not just the +/- box. */
.occ-group-row { cursor: pointer; }
.occ-group-row:hover td { filter: brightness(0.96); }

/* The Name/D.O.B./Age/day-number header row - moved to sit directly above
   the first child, per spec - fully bold. */
.occ-header-row th { font-weight: 700; background: var(--paper-raised); }

/* Child rows: nothing bold */
.occ-table tbody tr:not(.occ-total-row):not(.occ-summary-row):not(.occ-header-row) td:first-child { font-weight: 400; }

.occ-fd { background: #ffffff; }
.occ-fd-extra { background: #FFFF00; color: #FF0000; font-weight: 700; }
.occ-fdh, .occ-fds, .occ-fda { background: #FFFF00; font-weight: 400; }
.occ-off-hh { background: #FFE699; }
.occ-off-ha { background: #92D050; }
.occ-off-aw { background: #00B0F0; }
.occ-child-cell { cursor: pointer; } /* clickable, deliberately no underline */
.occ-child-cell:hover { outline: 1px solid var(--line); outline-offset: -1px; }
.occ-bh { background: #D9D9D9; }
/* Content-type colour (yellow/red-on-yellow) wins over the weekend/bank-
   holiday grey where both would otherwise apply to the same cell. */
td.occ-fdh.occ-bh, td.occ-fds.occ-bh, td.occ-fda.occ-bh, td.occ-fd-extra.occ-bh { background: #FFFF00; }
td.occ-off-hh.occ-bh { background: #FFE699; }
td.occ-off-ha.occ-bh { background: #92D050; }
td.occ-off-aw.occ-bh { background: #00B0F0; }
span.occ-swatch.occ-bh { background: #D9D9D9; }


.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: white; padding: 10px 18px; border-radius: 999px;
  font-size: 0.88rem; box-shadow: var(--shadow); z-index: 999;
}
.toast-persistent {
  border-radius: 999px; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 18px;
}
.toast-persistent #session-expired-signin-btn { padding: 6px 16px; }

/* ---------- Mobile ---------- */
@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr 62px;
    grid-template-areas: "topbar" "content" "tabbar";
  }
  .app-nav, .nav-backdrop { display: none !important; }
  .app-content { padding: 16px; padding-bottom: 24px; }
  .app-tabbar {
    grid-area: tabbar; display: flex; background: var(--paper-raised); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); overflow-x: auto;
  }
  .tabbar-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
    padding: 6px 4px; border-radius: 8px; color: var(--ink-soft); font-size: 0.68rem; font-weight: 600;
    text-decoration: none; min-width: 58px;
  }
  .tabbar-link.active { color: var(--forest); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar-user span { display: none; }
  .card { padding: 14px 16px; }
}

/* Staff grid (Staff.xlsx-modelled view): grouped, collapsible columns
   with the Name column frozen while scrolling horizontally. */
.staff-scroll { overflow-x: auto; }
.staff-grid { border-collapse: collapse; font-size: 0.72rem; width: max-content; min-width: 100%; }
.staff-grid th, .staff-grid td {
  border: 1px solid var(--line); padding: 3px 6px; text-align: center;
  white-space: nowrap; height: 22px;
}
.staff-grid td:first-child, .staff-grid th.staff-name-header {
  text-align: left; position: sticky; left: 0; z-index: 2;
  background: var(--paper); box-shadow: 1px 0 0 0 var(--line);
}
.staff-grid thead th.staff-name-header { z-index: 3; background: var(--paper-raised); }
.staff-grid thead th { background: var(--paper-raised); font-weight: 700; }
.staff-grid .staff-group-toggle {
  border: none; background: none; cursor: pointer; font-weight: 700;
  font-size: 0.72rem; color: var(--ink); padding: 0; display: inline-flex;
  align-items: center; gap: 3px;
}
.staff-grid .staff-group-toggle:hover { color: var(--forest); }
.staff-grid .staff-collapsed-marker { color: var(--ink-soft); font-weight: 400; }
.staff-cell-yesno-no { background: #FF0000; color: #fff; font-weight: 600; }
.staff-cell-refe-none { background: #FF0000; color: #fff; font-weight: 600; }
.staff-cell-refe-one { background: #FFFF00; font-weight: 600; }
.staff-cell-date-past { background: #FF0000; color: #fff; font-weight: 600; }
.staff-name-link { font-weight: 600; }

/* Same-screen refresh that is taking a moment: see renderView() in app.js */
#app-content.refreshing { opacity: 0.6; transition: opacity 0.15s; pointer-events: none; }

/* ---------- Registers: printable weekly sheet (A4 landscape) ---------- */
.reg-tabs { display:flex; flex-wrap:wrap; gap:6px; align-items:center; margin:8px 0; }
.reg-sheet { background:#fff; color:#000; padding:10px 12px; min-width:900px; font-family:Arial, Helvetica, sans-serif; }
.reg-head { display:flex; align-items:center; gap:24px; margin-bottom:6px; }
.reg-logo { height:38px; width:auto; }
.reg-title { flex:1; text-align:center; font-size:22px; margin-right:150px; }
.reg-table { width:100%; border-collapse:collapse; table-layout:fixed; border:2px solid #000; margin-top:6px; font-size:12px; }
.reg-table:first-of-type { margin-top:0; }
.reg-col-name { width:14%; }
.reg-table td { border:1px solid #bbb; padding:1px 3px; text-align:center; height:19px; overflow:hidden; white-space:nowrap; }
.reg-table td.reg-name { text-align:right; border-right:1px solid #000; }
.reg-table td.reg-day-first { border-left:2px solid #000; }
.reg-table td.reg-day { border-bottom:2px solid #000; }
.reg-roomname { font-weight:700; }
.reg-count-row td { border-bottom:1px solid #000; }
.reg-day-row td { border-bottom:2px solid #000; }
.reg-ph { color:#bbb; }
.reg-collect { column-count:2; column-gap:16px; font-size:11px; padding:2px 3px 4px; border:1px solid #000; border-top:none; }
.reg-collect div { break-inside:avoid; }
.reg-foot { text-align:center; font-size:12px; margin-top:28px; }
.reg-table td.occ-child-cell { cursor:pointer; }
/* Single-day register (tablet / portrait friendly) */
.reg-sheet.reg-day-sheet { min-width:0; max-width:760px; margin:0 auto; padding:8px 10px; }
.reg-day-table { font-size:17px; margin-bottom:6px; }
.reg-day-table .reg-day-col-name { width:28%; }
.reg-day-table .reg-abs-col { width:13%; }
.reg-day-table .reg-abs-head { font-size:12px; text-align:center; }
.reg-day-table .reg-abs-cell { text-align:center; cursor:pointer; font-weight:600; font-size:14px; user-select:none; -webkit-tap-highlight-color:transparent; }
.reg-table.reg-day-table td.reg-abs-cell:not(.reg-abs-on) { background:#fff; }
.reg-table.reg-day-table td.reg-abs-cell:not(.reg-abs-on):active { background:#eee; }
.reg-day-table td { height:48px; }
.reg-day-table .reg-count-row td, .reg-day-table .reg-day-row td, .reg-day-table .reg-head-row td { height:30px; font-size:14px; }
.reg-day-collect { column-count:1; font-size:13px; }
.reg-day-nav h2 { font-size:1.1rem; }
/* Signed in = green, signed out = red */
.reg-table td.reg-state-in { background:#92D050; }
.reg-table td.reg-state-out { background:#FF0000; }

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body * { visibility: hidden; }
  #register-sheet, #register-sheet *, #emergency-sheet, #emergency-sheet * { visibility: visible; }
  #register-sheet, #emergency-sheet { position: absolute; left: 0; top: 0; width: 100%; min-width: 0; max-width: none; padding: 0; margin: 0; }
  .reg-table, .reg-table td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .reg-table td.occ-child-cell { cursor: default; }
  /* Printouts / PDFs save ink: coloured text instead of coloured cells */
  .reg-table td.reg-state-in { background: transparent; color: #92D050; }
  .reg-table td.reg-state-out { background: transparent; color: #FF0000; }
}
@media print { .reg-scroll, .occ-scroll { background: none !important; border: none !important; box-shadow: none !important; overflow: visible !important; } body, html { background: #fff !important; } }

/* Availability: frozen header rows and read-only cell selection. Separate
   borders (rather than collapsed) so the lines stay attached to the frozen
   cells while the children scroll underneath them. */
.avail-table { border-collapse: separate; border-spacing: 0; border-left: 1px solid var(--line); border-top: 1px solid var(--line); border-bottom: none; }
.avail-table th, .avail-table td { border-width: 0 1px 1px 0; }
.avail-scroll.avail-frozen { overflow-y: auto; }
.avail-table .av-stuck { position: sticky; z-index: 3; background: var(--paper-raised, #fff); }
.avail-table td[data-av-cell] { cursor: cell; user-select: none; -webkit-user-select: none; }
.avail-table td.av-sel { box-shadow: inset 0 0 0 9999px rgba(0, 112, 192, 0.20); }
.avail-table td.av-sel-focus { outline: 2px solid #0070C0; outline-offset: -2px; }

/* Occupancy: "-" / "+" beside the DOB heading collapse or expand every room */
.occ-header-row th.occ-dob-th { white-space: nowrap; padding-left: 1px; padding-right: 1px; }
.occ-toggle.occ-toggle-all { margin: 0 2px; width: 13px; height: 13px; vertical-align: baseline; }

.tabbar-icon { width: 22px; height: 22px; }

/* ---------- Dashboard: big tiles that use the whole screen ---------- */
.app-content.home { padding: clamp(12px, 2.2vw, 32px); }
.home-grid {
  display: grid; gap: clamp(10px, 1.8vw, 26px);
  grid-template-columns: repeat(auto-fit, minmax(clamp(140px, 22vw, 360px), 1fr));
  grid-auto-rows: minmax(clamp(110px, 20vh, 320px), 1fr);
  min-height: calc(100vh - 60px - 2 * clamp(12px, 2.2vw, 32px));
}
.home-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(8px, 1.6vh, 22px); padding: 12px; text-align: center; text-decoration: none; cursor: pointer;
  background: var(--forest); color: #fff; border-radius: clamp(12px, 1.6vw, 24px);
  box-shadow: var(--shadow); transition: background .15s, transform .1s;
}
.home-tile:hover { background: var(--forest-dark); }
.home-tile:active { transform: scale(.98); }
.home-tile:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
.home-icon { width: clamp(40px, 6.5vw, 110px); height: clamp(40px, 6.5vw, 110px); }
.home-label { font-weight: 700; font-size: clamp(1rem, 0.7rem + 1.1vw, 2.1rem); }
@media (max-width: 780px) {
  .home-grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: clamp(120px, 22vh, 200px); min-height: 0; align-content: start; }
  .app-content.home { padding: 16px; }
}

/* ---------- Emergency Contacts: printable list (A4 portrait) ---------- */
.reg-sheet.emerg-sheet { min-width: 0; max-width: 820px; margin: 0 auto; padding: 14px 16px; }
.emerg-table { width: 100%; border-collapse: collapse; border: 2px solid #000; margin-top: 8px; font-size: 12.5px; }
.emerg-col-child { width: 22%; }
.emerg-table th { text-align: left; padding: 5px 8px; border: 1px solid #000; border-bottom: 2px solid #000; background: transparent; color: #000; font-size: 13px; text-transform: none; letter-spacing: 0; }
.emerg-table td { text-align: left; vertical-align: top; padding: 4px 8px; border: 1px solid #888; white-space: normal; }
.emerg-table td.emerg-child { font-weight: 700; border-right: 1px solid #000; }
.emerg-table tr { break-inside: avoid; page-break-inside: avoid; }
.emerg-table thead { display: table-header-group; }
.emerg-table td div { line-height: 1.45; }
.emerg-sheet .reg-head { flex-direction: column; gap: 6px; margin-bottom: 4px; }
.emerg-sheet .reg-title { margin-right: 0; font-size: 20px; }
