/* Compliance Tracker
   Deep teal brand, cool neutral surfaces, one teal accent for action and focus. */
:root {
  --brand: #0E2E3D;
  --brand-2: #164b61;
  --accent: #0f7c93;
  --accent-soft: #e7f4f8;
  --tide: #B0D4E3;

  --ink: #10293a;
  --ink-2: #3a5464;
  --ink-3: #6a8190;
  --page: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --line: #e3e9ed;
  --line-strong: #cdd7de;
  --tide-soft: var(--accent-soft);
  --sand: #E8DCC8;
  --sand-soft: #f7f3ec;
  --brass: #A87A20;

  --bad: #b3371f;
  --bad-bg: #fdefeb;
  --bad-line: #f4cfc5;
  --warn: #8a5f0c;
  --warn-bg: #fdf4e1;
  --warn-dot: #e0a93a;
  --good: #1f7a52;
  --good-bg: #e5f5ec;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 41, 58, .05);
  --shadow: 0 1px 3px rgba(16, 41, 58, .06), 0 6px 18px rgba(16, 41, 58, .05);
  --font: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --side-w: 248px;
  --gutter: 32px;
  --bar-h: 58px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  color: var(--ink); background: var(--page);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1rem; font-weight: 650; }
:focus-visible { outline: 3px solid var(--tide); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
.fine { font-size: .82rem; color: var(--ink-3); margin: .6rem 0 0; }
.nowrap { white-space: nowrap; }
.ic { width: 18px; height: 18px; flex: none; }

/* ---------- App bar (full width, above everything) ---------- */
.appbar {
  position: sticky; top: 0; z-index: 40; height: var(--bar-h);
  display: flex; align-items: center; gap: 6px; padding: 0 14px 0 10px; color: #fff;
  background:
    radial-gradient(circle at 78% -60%, rgba(176, 212, 227, .22), transparent 45%),
    linear-gradient(90deg, #0a2431 0%, var(--brand) 38%, #155369 100%);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08), 0 2px 10px rgba(10, 36, 49, .18);
}
.appbar .spacer { flex: 1; }
.appbar-btn {
  position: relative; display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: rgba(255, 255, 255, .88); cursor: pointer;
  transition: background .15s, color .15s;
}
.appbar-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; text-decoration: none; }
.appbar-btn .ic { width: 21px; height: 21px; }
.badge {
  position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: #e5484d; color: #fff; border: 2px solid #0f3445;
  font-size: .64rem; font-weight: 700; line-height: 14px; text-align: center;
}
.badge-warn { background: #e0a93a; }
.appbar-brand { display: flex; align-items: center; gap: 10px; margin: 0 10px 0 4px; color: #fff; text-decoration: none; }
.appbar-brand:hover { text-decoration: none; }
.brand-mark, .auth-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background:
    radial-gradient(circle at 50% 125%, var(--brass) 0 40%, transparent 41%),
    linear-gradient(160deg, #d4ebf4, var(--tide));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .15);
}
.brand-app { font-weight: 700; font-size: 1rem; letter-spacing: -.015em; white-space: nowrap; }

/* Dropdown menus built on <details>: work without JS, app.js closes them on outside click. */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60; min-width: 240px; max-height: 70vh; overflow-y: auto;
  padding: 6px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(16, 41, 58, .18), 0 2px 6px rgba(16, 41, 58, .08);
}
.menu-pop-end { left: auto; right: 0; }
.menu-label { margin: 0; padding: 8px 10px 4px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--ink); font: inherit; font-size: .88rem; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item .ic { width: 17px; height: 17px; color: var(--ink-3); }
.menu-item.is-current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.menu-item.is-current .ic { color: var(--accent); }
.menu-initial { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); font-size: .72rem; font-weight: 700; }
.menu-item.is-current .menu-initial { background: var(--accent); color: #fff; }
.menu-user { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.menu-user strong { display: block; font-size: .9rem; }
.menu-user small { display: block; color: var(--ink-3); font-size: .78rem; }
.menu form { margin: 0; }

.house-switch > summary {
  display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 12px 0 4px; border-radius: 999px;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .12);
  font-weight: 600; font-size: .9rem; transition: background .15s;
}
.house-switch > summary:hover, .house-switch[open] > summary { background: rgba(255, 255, 255, .17); }
.house-switch-ic { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--tide); color: var(--brand); flex: none; }
.house-switch-ic .ic { width: 16px; height: 16px; }
.house-switch-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.house-switch > summary > .ic:last-child { width: 16px; height: 16px; opacity: .8; transition: transform .15s; }
.house-switch[open] > summary > .ic:last-child { transform: rotate(180deg); }

.user-menu { margin-left: 6px; }
.user-menu > summary.avatar { width: 38px; height: 38px; background: var(--brand-2); color: #fff; border: 2px solid rgba(255, 255, 255, .9); font-size: .82rem; letter-spacing: .02em; }
.user-menu > summary.avatar:hover { box-shadow: 0 0 0 3px rgba(255, 255, 255, .18); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--sand); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }

.appbar-search { position: relative; width: min(340px, 28vw); margin-right: 6px; }
.appbar-search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: rgba(255, 255, 255, .7); pointer-events: none; }
.appbar-search input[type=search] {
  height: 38px; padding-left: 36px; border-radius: 999px; color: #fff;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16);
}
.appbar-search input[type=search]::placeholder { color: rgba(255, 255, 255, .62); }
.appbar-search input[type=search]:hover { border-color: rgba(255, 255, 255, .3); }
.appbar-search input[type=search]:focus { background: #fff; color: var(--ink); border-color: #fff; box-shadow: 0 0 0 3px rgba(176, 212, 227, .45); }
.appbar-search:focus-within .ic { color: var(--ink-3); }
.appbar-search-btn { display: none; }

/* ---------- Sidebar + page ---------- */
.shell { display: flex; min-height: calc(100vh - var(--bar-h)); }
.side {
  width: var(--side-w); flex: none; color: #d5e7ee;
  background: linear-gradient(180deg, #145062 0%, #10404f 42%, #0c3241 100%);
  position: sticky; top: var(--bar-h); height: calc(100vh - var(--bar-h)); overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .22) transparent;
}
.side nav { padding: 8px 12px 20px; }
.nav-group { font-size: .68rem; color: rgba(213, 231, 238, .55); padding: 16px 10px 6px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); margin: 1px 0;
  color: rgba(255, 255, 255, .8); text-decoration: none; font-size: .89rem; font-weight: 500; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-link .ic { color: rgba(255, 255, 255, .7); }
.nav-ic {
  width: 20px; flex: none; text-align: center; font-size: 16px; line-height: 1;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}
.nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.nav-link.is-active { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--tide); }

/* Collapsed (desktop): a 68px icon rail floating over the page edge. Hover or keyboard focus
   reveals the full menu on top of the content; clip-path keeps the reveal off the layout. */
@media (min-width: 861px) {
  body.side-collapsed .main { margin-left: 68px; }
  body.side-collapsed .side {
    position: fixed; left: 0; top: var(--bar-h); z-index: 30;
    clip-path: inset(0 calc(var(--side-w) - 68px) 0 0);
    transition: clip-path .18s ease .12s, box-shadow .18s ease .12s;
  }
  body.side-collapsed .side .nav-group,
  body.side-collapsed .side .nav-link > span:not(.nav-ic) { opacity: 0; transition: opacity .12s; }
  body.side-collapsed .side:hover,
  body.side-collapsed .side:focus-within { clip-path: inset(0 -24px 0 0); box-shadow: 8px 0 24px rgba(10, 36, 49, .28); }
  body.side-collapsed .side:hover .nav-group, body.side-collapsed .side:hover .nav-link > span:not(.nav-ic),
  body.side-collapsed .side:focus-within .nav-group, body.side-collapsed .side:focus-within .nav-link > span:not(.nav-ic) { opacity: 1; transition-delay: .15s; }
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page-head { padding: 22px var(--gutter) 0; }
.page-title { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; }
.content { padding: 16px var(--gutter) 56px; width: 100%; }

/* ---------- Panels & layout ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.panel > h2 { margin-bottom: 12px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.spacer { flex: 1; }
.result-count { margin: 0; color: var(--ink-3); font-size: .88rem; }
.hint { margin: 0 0 14px; padding: 10px 14px; background: var(--sand-soft); border: 1px solid #efe5d4; border-left: 3px solid var(--brass); border-radius: var(--radius-sm); font-size: .88rem; color: var(--ink-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .87rem; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; line-height: 1.2;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); box-shadow: none; }
.btn-quiet:hover { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.btn-danger { color: var(--bad); border-color: var(--bad-line); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn-small { padding: 6px 11px; font-size: .83rem; }
.btn-block { width: 100%; justify-content: center; padding: 11px 14px; }
.btn .ic { width: 16px; height: 16px; }

/* ---------- Flash ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: .9rem; border: 1px solid transparent; }
.flash-success { background: var(--good-bg); color: var(--good); border-color: #c3e6d2; }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.flash-info { background: var(--accent-soft); color: var(--ink); border-color: #c6e2ec; }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill-good { background: var(--good-bg); color: var(--good); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-neutral { background: #edf1f4; color: var(--ink-2); }
.n-bad { color: var(--bad); }
.n-warn { color: var(--warn); }

/* ---------- Tables ---------- */
.table-wrap { position: relative; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel .table-wrap { border: 0; border-radius: 0; margin: 0 -22px; box-shadow: none; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: 10px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table thead th { background: var(--surface-2); font-size: .72rem; font-weight: 650; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr[data-href]:hover { background: #f4f9fb; }
.table td:first-child a { font-weight: 600; color: var(--ink); }
.table td:first-child a:hover { color: var(--accent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-compact th, .table-compact td { padding: 8px 12px; }
/* Row tone: a left rule shows state without flooding the row in color */
.table tr.tone-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.table tr.tone-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn-dot); }
.table tr.tone-muted td { color: var(--ink-3); }
.table tr.tone-good td { background: rgba(31, 122, 82, .07); }
.table tr.tone-good td:first-child { box-shadow: inset 3px 0 0 var(--good, #2e7d32); }
.detail-cell { max-width: 460px; color: var(--ink-2); font-size: .84rem; }

.matrix th small { display: block; font-weight: 400; color: var(--ink-3); font-size: .76rem; text-transform: none; letter-spacing: 0; }
.matrix tbody th, .perm-table tbody th { font-weight: 600; white-space: nowrap; }
.perm-table td { text-align: center; }
.perm-table thead th:not(:first-child) { text-align: center; }
.perm input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }

.pager { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: center; margin: 18px 0; font-size: .88rem; }
.pager-cur { font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--ink); color: #fff; }
.pager-gap { color: var(--ink-2); }
.pager-range { color: var(--ink-2); margin-left: 8px; }
.pager-size { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); margin-left: 8px; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin-bottom: 16px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.filters-inline { padding: 0; border: 0; background: none; margin: 0; box-shadow: none; }
.filter { display: flex; flex-direction: column; gap: 4px; font-size: .76rem; color: var(--ink-3); font-weight: 600; }
.filter select, .filter input { min-width: 150px; }
.filter-grow { flex: 1; min-width: 220px; }
.filter-grow input { width: 100%; }
.filter-actions { display: flex; gap: 6px; }

/* ---------- Forms ---------- */
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=time], input[type=number], input[type=search], input:not([type]), select, textarea {
  font: inherit; font-size: .9rem; color: var(--ink); background: #fff;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 11px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 76px; }
input:hover, select:hover, textarea:hover { border-color: #b7c4cd; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 124, 147, .16); }
input:disabled, select:disabled { background: #f3f5f6; color: var(--ink-3); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 16px 22px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field.wide { grid-column: 1 / -1; }
.field[hidden], .form-heading[hidden], .med-section[hidden], .med-subhead[hidden] { display: none; }
.label { font-size: .82rem; font-weight: 600; color: var(--ink-2); padding: 0; }
.req { color: var(--bad); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: .82rem; }
.form-heading { grid-column: 1 / -1; font-size: .78rem; font-weight: 700; margin-top: 12px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.form-grid > .form-heading:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 14px; }

.yn { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; width: fit-content; background: #fff; }
.yn label { cursor: pointer; position: relative; }   /* keeps the hidden radio inside its own label */
.yn input { position: absolute; opacity: 0; pointer-events: none; }
.yn span { display: block; padding: 7px 18px; font-size: .88rem; font-weight: 600; color: var(--ink-3); }
.yn label + label span { border-left: 1px solid var(--line-strong); }
.yn input:checked + span { background: var(--brand); color: #fff; }
.yn input:focus-visible + span { outline: 3px solid var(--tide); outline-offset: -3px; }

.check { display: flex; gap: 8px; align-items: center; font-size: .9rem; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 16px; margin-top: 8px; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.check-grid.is-disabled { opacity: .45; }
.role-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.role-choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); cursor: pointer; transition: border-color .15s, background .15s; }
.role-choice input { margin-top: 3px; accent-color: var(--brand); }
.role-choice small { display: block; color: var(--ink-3); font-size: .8rem; line-height: 1.35; margin-top: 2px; }
.role-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Details ---------- */
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px 28px; margin: 0 0 6px; }
.details > div.wide { grid-column: 1 / -1; }
.details dt { font-size: .76rem; font-weight: 600; color: var(--ink-3); }
.details dd { margin: 3px 0 0; }
.panel .form-heading { margin: 20px 0 14px; }
.record-meta { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 18px; }
.related-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.count { display: inline-block; min-width: 24px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .76rem; font-weight: 700; text-align: center; margin-left: 4px; }
.danger-zone { margin-top: 28px; padding-top: 16px; border-top: 1px dashed var(--line-strong); }

.empty { text-align: center; padding: 56px 20px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty h2 { font-size: 1.15rem; margin-bottom: 6px; }
.empty p { color: var(--ink-2); margin: 6px 0; }

.temp-pass { max-width: 560px; }
.temp-value code { display: inline-block; font-size: 1.35rem; padding: 10px 16px; background: var(--sand-soft); border: 1px solid var(--sand); border-radius: var(--radius-sm); letter-spacing: .06em; user-select: all; }

/* ---------- Auth ---------- */
.bare { min-height: 100vh; }
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-panel {
  color: #d6e6ed; padding: 56px; display: flex; flex-direction: column; justify-content: flex-end;
  background:
    radial-gradient(circle at 85% 15%, rgba(176, 212, 227, .16), transparent 45%),
    linear-gradient(150deg, #134459 0%, var(--brand) 55%, #0a2330 100%);
}
.auth-mark { width: 52px; height: 52px; border-radius: 14px; margin-bottom: auto; }
.auth-app { font-size: 2.4rem; font-weight: 700; color: #fff; margin: 0; letter-spacing: -.03em; line-height: 1.1; }
.auth-org { color: var(--tide); margin: 8px 0 0; font-size: 1.05rem; }
.auth-line { max-width: 34ch; margin: 22px 0 0; color: #b6cdd8; font-size: 1rem; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth-form form { width: 100%; max-width: 360px; }
.auth-form h1 { font-size: 1.6rem; margin-bottom: 4px; }

.print-only { display: none; }


/* ---------- Small shared pieces ---------- */
.inline-form { display: inline-flex; gap: 4px; margin: 0; }
.flush { margin-top: 0; }
.problem { color: var(--bad); font-size: .84rem; }
.problem-list { margin: 0 0 6px; padding-left: 16px; min-width: 260px; }
.problem-list li + li { margin-top: 2px; }
.risk-proto { display: block; font-size: .8rem; color: var(--ink-2); margin-bottom: 3px; }
.issue-cell { min-width: 220px; max-width: 360px; }
.period-label { font-weight: 650; min-width: 110px; text-align: center; align-self: center; }
.upload-row { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.upload-row input[type=file] { padding: 6px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li + li { border-top: 1px solid var(--line); }
.plain-list a { display: block; padding: 9px 0; text-decoration: none; font-size: .9rem; color: var(--ink); }
.plain-list a:hover strong { color: var(--accent); }
.when { display: inline-block; min-width: 92px; color: var(--ink-3); font-size: .84rem; font-variant-numeric: tabular-nums; }

/* ---------- Compliance score ---------- */
.score-list { display: grid; gap: 10px; margin: 0; }
.score-list > div { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; align-items: center; }
.score-list dt { font-size: .85rem; color: var(--ink-2); }
.score-list dd { margin: 0; display: flex; align-items: center; gap: 10px; font-size: .84rem; font-variant-numeric: tabular-nums; }
.ring { flex: none; display: block; }
.ring-bg { stroke: #e8eef1; }
.ring-good .ring-fg { stroke: var(--good); } .ring-warn .ring-fg { stroke: var(--warn-dot); } .ring-bad .ring-fg { stroke: var(--bad); } .ring-none .ring-fg { stroke: transparent; }
.ring text { font: 700 13px var(--font); fill: var(--ink); }
.ring[width="108"] text { font-size: 28px; letter-spacing: -.02em; }
.ring[width="92"] text { font-size: 24px; }
.ring[width="36"] text { font-size: 11px; }
.table-compact td .ring { margin: -6px 0; }

/* ---------- Dashboard ---------- */
.hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  color: #fff; border-radius: calc(var(--radius) + 4px); padding: 26px 30px; margin-bottom: 18px;
  background:
    radial-gradient(circle at 92% -20%, rgba(176, 212, 227, .28), transparent 42%),
    linear-gradient(120deg, var(--brand) 0%, #145068 58%, #1b6d86 100%);
  box-shadow: var(--shadow);
}
.hero .ring-bg { stroke: rgba(255, 255, 255, .14); }
.hero .ring text { fill: #fff; }
.hero .ring-good .ring-fg { stroke: #62d6a0; }
.hero .ring-warn .ring-fg { stroke: #f3c455; }
.hero .ring-bad .ring-fg { stroke: #ff9580; }
.hero-text { flex: 1; min-width: 240px; }
.hero-eyebrow { margin: 0 0 4px; font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--tide); }
.hero-text h2 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: 4px; }
.hero-text p { margin: 0; color: rgba(255, 255, 255, .78); }
.hero-stats { display: grid; grid-template-columns: repeat(4, minmax(96px, 1fr)); gap: 10px; }
.hero-stats > div, .hero-stats > a { text-align: center; color: inherit; text-decoration: none; padding: 12px 14px; border-radius: var(--radius); background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .1); }
.hero-stats .n { display: block; font-size: 1.7rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.hero-stats .l { display: block; font-size: .74rem; color: rgba(255, 255, 255, .7); margin-top: 2px; }
.hero-stats .n-alert { color: #ffb2a3; }

.dash-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.dash-layout { display: grid; grid-template-columns: minmax(0, 1fr) clamp(340px, 27vw, 460px); gap: 20px; align-items: start; }
.dash-main { min-width: 0; }
.dash-rail { position: sticky; top: calc(var(--bar-h) + 20px); display: flex; flex-direction: column; gap: 16px; }
.dash-rail .panel { margin-bottom: 0; }
.attention .attn-list { max-height: none; }
.all-clear { display: flex; gap: 12px; align-items: flex-start; }
.all-clear .ic { width: 34px; height: 34px; padding: 7px; border-radius: 50%; background: var(--good-bg); color: var(--good); }
.all-clear p { margin: 0; color: var(--ink-2); font-size: .88rem; }

.attn-list { list-style: none; margin: 0 -22px -20px; padding: 0; }
.attn { border-top: 1px solid var(--line); }
.attn a { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 11px 22px 11px 30px; text-decoration: none; position: relative; color: var(--ink); }
.attn a::before { content: ""; position: absolute; left: 14px; top: 18px; width: 8px; height: 8px; border-radius: 50%; }
.attn-bad a::before { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.attn-warn a::before { background: var(--warn-dot); box-shadow: 0 0 0 3px var(--warn-bg); }
.attn a:hover { background: #f4f9fb; }
.attn-head { grid-column: 1; grid-row: 1; font-weight: 600; font-size: .9rem; }
.attn-detail { grid-column: 1; grid-row: 2; font-size: .82rem; color: var(--ink-3); }
.attn-chevron { grid-column: 2; grid-row: 1 / 3; color: var(--ink-3); font-size: 1.3rem; padding-left: 12px; }
.attn-house { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 4px; background: #edf1f4; color: var(--ink-2); font-size: .74rem; }

.kpi-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 16px; }
.kpi-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 20px; box-shadow: var(--shadow-sm); }
.group-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-bottom: 12px; }
.section-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 28px 0 12px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.kpi {
  display: flex; flex-direction: column; justify-content: space-between; min-height: 96px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  text-decoration: none; color: var(--ink); transition: border-color .15s, background .15s, transform .15s, box-shadow .15s;
}
.kpi:hover { text-decoration: none; background: #fff; border-color: #bcd6e0; box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-n { display: block; font-size: 1.75rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-l { display: block; font-size: .8rem; color: var(--ink-2); margin-top: 6px; line-height: 1.3; }
.kpi-warn { background: var(--bad-bg); border-color: var(--bad-line); }
.kpi-warn .kpi-n { color: var(--bad); }
.kpi-warn:hover { background: #fff6f3; border-color: #eab7aa; }

.house-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.house-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s, transform .15s; }
.house-card:hover { text-decoration: none; border-color: #bcd6e0; box-shadow: var(--shadow); transform: translateY(-1px); }
.house-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.house-head h3 { flex: 1; font-size: 1rem; }
.house-avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.house-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin: 0; font-size: .85rem; }
.house-stats > div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 5px; }
.house-stats dt { color: var(--ink-3); }
.house-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Schedule ---------- */
.sched th, .sched td { padding: 5px 6px; }
.sched tbody th { min-width: 150px; }
.sched input { padding: 6px 8px; font-size: .86rem; }
.sched input.cell { text-align: center; text-transform: uppercase; min-width: 64px; }
.sched-week .related-head { flex-wrap: wrap; }

/* ---------- House checklist ---------- */
.freq-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.freq-tabs a { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; color: var(--ink-3); font-weight: 600; text-decoration: none; }
.freq-tabs a:hover { color: var(--ink); }
.freq-tabs a[aria-current="page"] { color: var(--accent); }
.freq-tabs a[aria-current="page"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.freq-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.freq-dot-bad { background: var(--bad); }
.freq-dot-warn { background: var(--warn-dot); }
.checklist .check-when { display: block; margin-top: 2px; color: var(--ink-3); }
.checklist .check-when:empty { display: none; }
.checklist li.is-locked .check-big > span { color: var(--ink-2, #4a5d68); }
.checklist li.is-locked input[type=checkbox] { cursor: not-allowed; opacity: .55; }
/* In-app confirm / alert dialog (appConfirm, appAlert) */
.modal.confirm-modal { width: min(460px, calc(100vw - 32px)); }
.confirm-modal [hidden] { display: none !important; }
.confirm-modal .confirm-msg { margin: 0; padding: 18px 22px 20px; line-height: 1.5; white-space: pre-line; }
.confirm-modal .form-actions { margin: 0; padding: 14px 22px; gap: 10px; background: var(--surface-2); border-top: 1px solid var(--line); }
.confirm-modal .btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.confirm-modal .btn-danger:hover { filter: brightness(.93); background: var(--bad); }
.checklist { list-style: none; margin: 0 -22px; padding: 0; }
.checklist li { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; align-items: center; padding: 11px 22px; border-top: 1px solid var(--line); }
.checklist li:first-child { border-top: 0; }
.checklist li.is-done { background: #f5fbf8; }
.check-big { align-items: flex-start; }
.check-big input { width: 20px; height: 20px; margin-top: 1px; }
.check-big small { display: block; color: var(--good); font-size: .8rem; }
.check-note { font-size: .88rem; }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; box-shadow: var(--shadow-sm); }
.cal-dow { background: var(--surface-2); padding: 8px 10px; font-size: .72rem; font-weight: 650; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.cal-day { background: var(--surface); min-height: 118px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.cal-day.out { background: #f8fafb; }
.cal-day.out .cal-num { color: #b3c1c8; }
.cal-day.today .cal-num { background: var(--brand); color: #fff; border-radius: 50%; }
.cal-num { font-size: .78rem; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; color: var(--ink-2); }
.cal-ev { display: block; font-size: .77rem; line-height: 1.3; padding: 3px 7px; border-radius: 5px; text-decoration: none; border-left: 3px solid; color: var(--ink); }
.cal-ev:hover { text-decoration: none; filter: brightness(.97); }
.cal-neutral { background: var(--accent-soft); border-color: var(--accent); }
.cal-good { background: var(--good-bg); border-color: var(--good); }
.cal-warn { background: var(--warn-bg); border-color: var(--warn-dot); }
.cal-bad { background: var(--bad-bg); border-color: var(--bad); }

/* ---------- Reports ---------- */
.report { max-width: none; }   /* uses the full width of the page */
.report-head { border-bottom: 2px solid var(--brand); padding-bottom: 12px; margin-bottom: 8px; }
.report-head h1 { font-size: 1.4rem; margin: 2px 0 4px; }
.report-head p { margin: 0; }
.report-org { font-size: .85rem; color: var(--ink-3); }
.report-h { margin: 22px 0 8px; }

/* ---------- Help ---------- */
.glossary { margin: 0; display: grid; gap: 12px; }
.glossary dt { font-weight: 650; }
.glossary dd { margin: 2px 0 0; color: var(--ink-2); font-size: .9rem; }

/* ---------- Pick-list chips (Settings) ---------- */
.chip-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px 3px 11px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: .84rem; background: var(--surface); }
.chip-x { border: 0; background: none; color: var(--ink-3); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 50%; }
.chip-x:hover { color: var(--bad); background: var(--bad-bg); }
.chip-file { text-decoration: none; padding: 3px 10px; background: var(--accent-soft); border-color: #c6e2ec; font-size: .8rem; }

/* ---------- Audit diffs ---------- */
.chg { display: inline-block; margin-right: 10px; }
.chg s { color: var(--ink-3); }
.file-mini { max-width: 150px; font-size: .78rem; padding: 3px; }
fieldset.is-disabled { opacity: .5; }

/* ---------- Responsive ---------- */
@media (min-width: 1800px) {
  :root { --gutter: 40px; }
}
@media (max-width: 1200px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-rail { position: static; order: -1; }
  .attention .attn-list { max-height: none; }
}
@media (max-width: 1100px) {
  .appbar-search { display: none; }
  .appbar-search-btn { display: grid; }
}
@media (max-width: 860px) {
  :root { --gutter: 18px; --bar-h: 54px; }
  .side { position: fixed; left: 0; top: var(--bar-h); z-index: 50; width: min(280px, 84vw); transform: translateX(-102%); transition: transform .2s ease; box-shadow: none; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(14, 46, 61, .4); }
  .appbar { padding: 0 8px 0 4px; gap: 2px; }
  .appbar-brand { margin: 0 6px 0 2px; }
  .house-switch-name { max-width: 34vw; }
  .page-title { font-size: 1.2rem; }
  .page-head { padding-top: 16px; }
  .content { padding: 16px var(--gutter) 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .score-list > div { grid-template-columns: 1fr; gap: 2px; }
  .checklist li { grid-template-columns: 1fr; }
  .cal { grid-template-columns: 1fr; background: none; border: 0; gap: 6px; box-shadow: none; }
  .cal-dow, .cal-day.out:not(:has(.cal-ev)) { display: none; }
  .cal-day { min-height: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
  .cal-day:not(:has(.cal-ev)) { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-panel { padding: 32px 24px; min-height: 0; }
  .auth-mark { margin-bottom: 20px; }
  .auth-app { font-size: 1.7rem; }
  .auth-line { display: none; }
  .hero { padding: 20px; gap: 18px; }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
}
@media (max-width: 560px) {
  .appbar-brand .brand-app { display: none; }
  .appbar-btn[href*="r=help"] { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .kpi:hover, .house-card:hover { transform: none; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; font-size: 11pt; }
  .appbar, .side, .page-head, .toolbar, .filters, .form-actions, .danger-zone, .pager, .btn, .related-head .btn,
  .upload-row, .inline-form, .dash-bar { display: none !important; }
  .content { padding: 0; }
  .panel, .table-wrap, .kpi-group, .house-card { border: 0; padding: 0; box-shadow: none; }
  .hero { color: var(--ink); background: none; box-shadow: none; padding: 0; }
  .print-only { display: block; }
  .print-head { font-size: 9pt; color: #555; border-bottom: 1px solid #999; padding-bottom: 6px; margin-bottom: 12px; }
  .table thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table tr.tone-bad td:first-child, .table tr.tone-warn td:first-child { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cal-day { min-height: 80px; }
  .report { border: 0; }
  a { text-decoration: none; }
}

/* ---------- Resident profile ---------- */
.resident-overview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; align-items: stretch; margin-bottom: 16px; }
.resident-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: stretch; }
.resident-kpis .kpi { background: var(--surface); box-shadow: var(--shadow-sm); }
.resident-kpis .kpi-warn { background: var(--bad-bg); }
.resident-scores { margin-bottom: 0; }
.resident-scores .score-list > div { grid-template-columns: minmax(180px, 280px) minmax(0, 1fr); }
.row-actions { width: 1%; }
.row-actions .btn { padding: 4px 9px; }
.packet .details { margin-bottom: 4px; }
@media (max-width: 1100px) { .resident-overview { grid-template-columns: 1fr; } .resident-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 640px) { .resident-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .resident-scores .score-list > div { grid-template-columns: 1fr; } }
@media print { .row-actions { display: none; } .resident-kpis .kpi { border: 1px solid #ccc; box-shadow: none; } }

/* ---------- Modal (forms opened from data-modal links) ---------- */
.modal {
  width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0;
  border-radius: calc(var(--radius) + 4px); background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 64px rgba(10, 36, 49, .32), 0 4px 12px rgba(10, 36, 49, .12);
}
.modal::backdrop { background: rgba(10, 36, 49, .45); backdrop-filter: blur(2px); }
.modal[open] { animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-body { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; font-size: 1.15rem; font-weight: 700; }
.modal-x { width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.modal-x:hover { background: var(--surface-2); color: var(--ink); }
.modal-body > .flash { margin: 14px 22px 0; }
.modal-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-form > .flash, .modal-form > .hint { margin: 16px 22px 0; }
.modal-form > .form-grid { padding: 18px 22px 8px; overflow-y: auto; min-height: 0; }
.modal-form > .form-actions { margin: 0; padding: 14px 22px; background: var(--surface-2); border-top: 1px solid var(--line); border-radius: 0 0 calc(var(--radius) + 4px) calc(var(--radius) + 4px); }
@media (prefers-reduced-motion: reduce) { .modal[open] { animation: none; } }

/* ---------- Tabs (resident profile) ---------- */
.tabs { padding: 0; overflow: hidden; }
.tab-list { display: none; }
.tabs.is-ready .tab-list {
  display: flex; flex-wrap: wrap; gap: 0 2px; padding: 0 12px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 13px 11px 12px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: .87rem; font-weight: 600; color: var(--ink-3); white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.tab .count { margin-left: 0; }
.tab[aria-selected="true"] .count { background: var(--accent); color: #fff; }
.tab-panel { padding: 16px 22px 20px; }
.tab-panel:focus-visible { outline-offset: -3px; }
.tab-panel + .tab-panel { border-top: 1px solid var(--line); }
.tabs.is-ready .tab-panel + .tab-panel { border-top: 0; }
.tab-panel-title { font-size: 1rem; margin-bottom: 10px; }
.tabs.is-ready .tab-panel-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tab-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; min-height: 30px; }
.tab-panel .table-wrap { margin: 0 -22px; border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.tab-empty { margin: 4px 0 0; }
/* The Documents panel brings its own card and heading; inside a tab it's just content. */
.tab-panel > .panel { border: 0; box-shadow: none; padding: 0; margin: 0; }
.tab-panel > .panel > .related-head { display: none; }
@media print { .tab-list { display: none !important; } .tab-panel[hidden] { display: block !important; } }
/* Modal forms: two columns where there's room (long text, headings and cards span both). */
.modal { width: min(760px, calc(100vw - 32px)); overflow: hidden; }
/* One scrollbar: while a modal is open, only the form inside it scrolls, not the page behind. */
html:has(.modal[open]) { overflow: hidden; }
.modal-form > .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; position: relative; align-items: start; }
@media (max-width: 640px) { .modal-form > .form-grid { grid-template-columns: 1fr; } }
.modal-form > .form-actions { align-items: center; }
.modal-form .form-heading { margin-top: 6px; padding-top: 14px; }
.upload-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.upload-inline input[type=file] { flex: 1; min-width: 200px; padding: 6px; font-size: .85rem; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }
.upload-inline input[type=file]::file-selector-button { margin-right: 10px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); font: inherit; font-weight: 600; font-size: .83rem; color: var(--ink); cursor: pointer; }
.upload-inline select { width: auto; min-width: 170px; flex: none; }
.upload-field small { font-size: .78rem; }

/* ---------- Progress rows (resident compliance status) ---------- */
.progress-list { display: grid; gap: 16px; margin-top: 4px; }
.progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.progress-label { font-size: .86rem; font-weight: 600; color: var(--ink); }
.progress-value { flex: none; font: 600 .78rem/1 ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; color: var(--ink-3); white-space: nowrap; }
.progress-bar { display: block; overflow: visible; }
.progress-track { fill: #e3e9ed; }
.progress-none .progress-track { fill: #c9d3d8; }
.progress-good .progress-fill { fill: var(--good); }
.progress-warn .progress-fill { fill: var(--warn-dot); }
.progress-bad .progress-fill { fill: var(--bad); }
.progress-good .progress-value { color: var(--good); }
.progress-bad .progress-value { color: var(--bad); }

/* A flash message with an action button beside it (archived record banner) */
.flash-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.flash-row > span { flex: 1; min-width: 220px; }

/* ---------- List summary cards (incidents) and report text ---------- */
.list-summary { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 16px; }
.list-summary .kpi { min-height: 84px; background: var(--surface); box-shadow: var(--shadow-sm); }
.list-summary .kpi-warn { background: var(--bad-bg); }
.cell-note { margin-top: 4px; max-width: 260px; font-size: .8rem; color: var(--ink-2); white-space: normal; }
.report-text { margin: 0 0 6px; }

/* ---------- Staff credentials ---------- */
.cred-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.cred-upload input[type=file] { flex: 1; min-width: 180px; padding: 4px; font-size: .8rem; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }
.cred-upload input[type=file]::file-selector-button { margin-right: 8px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); font: inherit; font-weight: 600; font-size: .78rem; cursor: pointer; }
.cred-table .cred-group th { background: var(--surface-2); font-size: .72rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.cred-table .inline-form { margin-top: 4px; }
/* Staff profile tab forms */
.tab-note { margin-bottom: 12px; }
.tab-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; margin-top: 2px; border-top: 1px solid var(--line); }
.tab-panel .table-wrap + .tab-actions { border-top: 0; }
.cred-table td { vertical-align: middle; }
.cred-date input[type=date] { width: 170px; padding: 6px 8px; }
.cred-files { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cred-files .file-mini { max-width: 230px; }

/* ---------- Staff modal: step indicator and the wider credential steps ---------- */
.stepper { display: flex; gap: 6px; list-style: none; margin: 0 0 14px; padding: 0; }
.stepper li { flex: 1; min-width: 0; }
.stepper li > a, .stepper li > span { display: flex; align-items: center; gap: 8px; height: 100%; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3); font-size: .78rem; font-weight: 600; text-decoration: none; }
.stepper li > a:hover { border-color: #bcd6e0; color: var(--ink); text-decoration: none; }
.step-n { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid currentColor; font-size: .72rem; }
.step-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper li.is-current > * { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.stepper li.is-current .step-n { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper li.is-done > * { color: var(--good); }
.stepper li.is-done .step-n { background: var(--good-bg); border-color: var(--good); }
.stepper-wrap { padding: 14px 22px 0; }
.modal:has(.modal-form-wide) { width: min(900px, calc(100vw - 32px)); }
.modal-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 22px 12px; }
.modal-scroll .table-wrap { margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: none; }
@media (max-width: 640px) { .stepper .step-l { display: none; } .stepper li.is-current .step-l { display: inline; } }
.cred-table td:nth-child(3) { white-space: nowrap; }
/* Single credential modal */
.modal-sub { font-weight: 500; color: var(--ink-3); }
.file-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; }
.file-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); font-size: .88rem; }
.file-list li a { font-weight: 600; word-break: break-all; }
.file-list .check { margin-left: auto; font-size: .84rem; }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: 4px; }

/* ---------- Appointment: new medications, one card each ---------- */
.med-section { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 12px; }
.med-section > .form-heading { margin-bottom: 0; }
.med-hint { margin: -4px 0 0; font-size: .84rem; color: var(--ink-3); }
.med-blocks { display: flex; flex-direction: column; gap: 12px; }
.med-block { position: relative; margin: 0; padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.med-block-title { float: left; padding: 0; margin: 0 0 12px; font-weight: 700; font-size: .92rem; color: var(--ink); }
.med-block-actions { position: absolute; top: 8px; right: 10px; display: flex; gap: 4px; }
.med-block > .form-grid { clear: both; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; align-items: start; }
.med-block .field.wide, .med-block .med-subhead { grid-column: 1 / -1; }
.med-block input, .med-block select, .med-block textarea { background: var(--surface); }
.med-subhead { margin: 4px 0 -2px; padding-top: 10px; border-top: 1px dashed var(--line-strong); font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.med-add { align-self: flex-start; }
.med-add svg { width: 16px; height: 16px; }
@media (max-width: 640px) { .med-block > .form-grid { grid-template-columns: 1fr; } }
.yn-wide span { padding: 7px 14px; }
.qty-total { display: flex; align-items: center; min-height: 40px; padding: 0 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.supply-done { margin: 0; padding: 10px 14px 10px 30px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--good-bg, #eef7f1); font-size: .88rem; }
.supply-done li + li { margin-top: 4px; }

/* Anything under show-if control (not just fields) hides when its condition isn't met. */
[data-show-if][hidden] { display: none !important; }

/* ---------- Public background-check form (r=apply) ---------- */
.apply-page { min-height: 100vh; background: var(--surface-2); padding: 0 16px 48px; }
.apply-head { display: flex; align-items: center; gap: 10px; max-width: 780px; margin: 0 auto; padding: 22px 0 18px; font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.apply-head .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
.apply-card { max-width: 780px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow-sm); padding: 28px 32px 32px; }
.apply-card h1 { font-size: 1.55rem; letter-spacing: -.02em; margin: 0 0 8px; }
.apply-intro { font-size: 1rem; color: var(--ink-2); margin: 0 0 6px; }
.apply-privacy { margin: 0 0 18px; }
.apply-q { padding: 20px 0 4px; border-top: 1px solid var(--line); }
.apply-q h2 { display: flex; align-items: center; gap: 10px; font-size: 1.02rem; margin: 0 0 12px; }
.q-n { display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .8rem; font-weight: 700; }
.q-help { margin: -6px 0 12px 36px; font-size: .86rem; color: var(--ink-3); }
.q-opt { font-weight: 500; color: var(--ink-3); font-size: .86rem; }
.apply-q > .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; align-items: start; }
.apply-q > .form-grid + .form-grid { margin-top: 14px; }
.apply-q > .apply-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.res-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.res-row { display: grid; grid-template-columns: 110px 110px minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 10px; align-items: end; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.res-row .res-remove { margin-bottom: 4px; }
.apply-confirm { padding-top: 18px; }
.apply-confirm .check { align-items: flex-start; font-size: .94rem; }
.apply-confirm .check input { margin-top: 2px; flex: none; }
.apply-actions { display: flex; justify-content: flex-end; padding-top: 18px; border-top: 1px solid var(--line); margin-top: 18px; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.apply-done { text-align: center; padding: 48px 32px; }
.apply-done p { max-width: 52ch; margin: 10px auto 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 640px) {
  .apply-card { padding: 20px 16px 24px; }
  .apply-q > .form-grid, .apply-q > .apply-grid-3 { grid-template-columns: 1fr; }
  .q-help { margin-left: 0; }
  .res-row { grid-template-columns: 1fr 1fr; }
  .res-row .field:nth-child(3), .res-row .field:nth-child(4) { grid-column: 1 / -1; }
}

/* ---------- Applicants (staff) ---------- */
.share-panel { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.share-panel .panel-title { margin: 0 0 4px; }
.share-panel .fine { margin: 0; }
.share-row { display: flex; gap: 8px; flex: 1; min-width: min(100%, 420px); }
.share-row input { flex: 1; min-width: 0; font-size: .85rem; background: var(--surface-2); }
.applicant-kpis { margin: 16px 0; }
.applicant-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.applicant-layout aside { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 76px; }
.applicant-layout aside .panel { margin: 0; }
.detail-label { margin: 14px 0 8px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; color: var(--ink-2); }
.secret-shown { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; background: var(--warn-bg, #fff6e0); padding: 2px 6px; border-radius: 4px; }
.reveal-form { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
@media (max-width: 960px) { .applicant-layout { grid-template-columns: 1fr; } .applicant-layout aside { position: static; } }

/* ---------- File viewer (any uploaded file) ---------- */
.modal.viewer { width: min(1040px, calc(100vw - 32px)); }
.viewer .modal-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.viewer-stage { display: grid; place-items: center; min-height: 240px; max-height: calc(100vh - 140px); overflow: auto; background: #1f2d35; }
.viewer-stage img { display: block; max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; background: #fff; }
.viewer-stage.is-pdf { display: block; background: var(--surface-2); }
.viewer-stage iframe { display: block; width: 100%; height: calc(100vh - 150px); border: 0; background: #fff; }
.viewer-none { padding: 40px 24px; text-align: center; color: #fff; }
.viewer-none p { margin: 0 0 16px; }

/* ---------- Approvals ---------- */
.approval-list { display: flex; flex-direction: column; gap: 12px; }
.approval { margin: 0; }
.approval-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; }
.approval-head h2 { font-size: 1.05rem; margin: 0 0 2px; }
.approval-head p { margin: 0; }
.approval-when { font-size: .84rem; }
.approval-dates { margin: 12px 0; }
.approval-file { display: inline-flex; align-items: center; gap: 6px; margin: 0 8px 6px 0; }
.approval-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.reject > summary { list-style: none; cursor: pointer; }
.reject > summary::-webkit-details-marker { display: none; }
.reject[open] > summary { display: none; }
.reject-form { display: flex; gap: 8px; flex-wrap: wrap; }
.reject-form input { min-width: min(100%, 320px); }
.pending-note { margin-top: 4px; font-size: .82rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.hire-panel, .hired-panel { border-color: var(--good, #2e7d32); }
.hire-block { border-top: 1px dashed var(--line); padding-top: 12px; }

/* ---------- My documents ---------- */
.signin-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin: 0 0 12px; }
.signin-line .ic { width: 16px; height: 16px; }
.mydocs-section { margin-top: 16px; }
.mydocs-train { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }

/* ---------- Pay ---------- */
.pay-new-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.pay-new .panel-title { margin-top: 0; }
.pay-table td, .pay-table th { white-space: nowrap; }
.pay-table tfoot th, .pay-table tfoot td { border-top: 2px solid var(--line-strong); font-weight: 700; }
.modal:has(form[data-payroll]) { width: min(820px, calc(100vw - 32px)); }
.pay-form { display: flex; flex-direction: column; gap: 14px; }
.pay-form > * { flex-shrink: 0; }   /* keep the hours table whole; the modal body scrolls instead */
.pay-top { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.pay-save-rate { margin-top: 4px; font-size: .82rem; }
.pay-label { margin: 0; }
.pay-grid th small { display: block; font-weight: 500; color: var(--ink-3); font-size: .74rem; }
.pay-grid input { width: 96px; text-align: right; }
.pay-grid input.is-bad { border-color: var(--bad); }
.pay-grid tfoot th, .pay-grid tfoot td { font-weight: 700; }
.pay-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 0; }
.pay-summary > div { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.pay-summary dt { font-size: .76rem; color: var(--ink-3); }
.pay-summary dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-summary .pay-total { background: var(--brand); border-color: var(--brand); }
.pay-summary .pay-total dt, .pay-summary .pay-total dd { color: #fff; }
@media (max-width: 640px) { .pay-top { grid-template-columns: 1fr; } }

/* ---------- Payroll sheet (one house, every staff member) ---------- */
.pay-new-alt { padding-top: 12px; margin-top: 12px; border-top: 1px dashed var(--line-strong); }
.pay-or { width: 100%; margin: 0; }
.pay-house-fixed { display: block; padding: 9px 0; }
.sheet-house select { width: auto; }
.pay-sheet-wrap { overflow-x: auto; }
.pay-sheet { min-width: 860px; }
.pay-sheet th, .pay-sheet td { vertical-align: top; }
.pay-sheet thead th { white-space: nowrap; }
.pay-sheet thead th small { display: block; font-weight: 500; color: var(--ink-3); font-size: .72rem; }
.pay-sheet .sheet-group { text-align: center; border-bottom: 1px solid var(--line); }
.pay-sheet .sheet-person { min-width: 230px; max-width: 300px; text-align: left; font-weight: 400; }
.pay-sheet .sheet-person strong { display: block; font-size: .95rem; }
.sheet-info { display: block; font-size: .76rem; color: var(--ink-3); line-height: 1.35; margin-top: 2px; }
.sheet-multi { color: var(--accent); font-weight: 600; }
.pay-sheet input { width: 74px; text-align: right; padding: 6px 8px; }
.pay-sheet input.is-bad { border-color: var(--bad); background: var(--bad-bg); }
.pay-sheet td.calc { background: var(--surface-2); font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 12px; }
.calc-stack { min-width: 150px; font-size: .84rem; }
.calc-stack span { display: flex; justify-content: space-between; gap: 10px; line-height: 1.6; }
.calc-stack em { font-style: normal; color: var(--ink-3); }
.calc-stack b { font-weight: 600; font-variant-numeric: tabular-nums; }
.pay-sheet tr.has-ot .ot-line b { color: var(--bad); font-weight: 700; }
.pay-sheet .calc-total { font-size: 1rem; min-width: 96px; }
.pay-sheet tfoot th, .pay-sheet tfoot td { border-top: 2px solid var(--line-strong); font-weight: 700; white-space: nowrap; }
.sheet-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px 0 4px; border-top: 1px solid var(--line); margin-top: 8px; }

/* ---------- Templates (blank forms to download) ---------- */
.template-filters { margin-bottom: 0; }
.template-filters .field { min-width: 200px; }
.template-group { margin: 22px 0 8px; }
.template-cat { font-size: 1rem; margin: 0 0 10px; display: flex; align-items: center; gap: 4px; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.template-card { display: flex; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); scroll-margin-top: 80px; }
.template-card:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.template-icon { flex: 0 0 46px; height: 56px; display: grid; place-items: center; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: .7rem; font-weight: 800; letter-spacing: .04em; }
.template-body { min-width: 0; flex: 1; }
.template-body h3 { margin: 0 0 2px; font-size: .98rem; overflow-wrap: anywhere; }
.template-meta { margin: 0; color: var(--ink-3); font-size: .8rem; }
.template-desc { margin: 8px 0 0; font-size: .87rem; color: var(--ink-2); }
.template-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.template-manage { display: flex; flex-wrap: wrap; gap: 2px; margin: 6px 0 0 -11px; }
.template-versions { margin-top: 8px; font-size: .83rem; }
.template-versions summary { cursor: pointer; color: var(--ink-2); }
.template-versions ul { margin: 6px 0 0; padding-left: 18px; }
@media (max-width: 600px) { .template-grid { grid-template-columns: 1fr; } .template-filters .field { min-width: 0; flex: 1 1 100%; } }

/* ---------- Download PDF (the printable part of a page, made in the browser) ---------- */
body.pdf-mode .appbar, body.pdf-mode .side, body.pdf-mode .toolbar, body.pdf-mode .filters, body.pdf-mode .form-actions,
body.pdf-mode .danger-zone, body.pdf-mode .pager, body.pdf-mode .btn, body.pdf-mode .upload-row, body.pdf-mode .inline-form,
body.pdf-mode .dash-bar, body.pdf-mode .row-actions, body.pdf-mode .row-x, body.pdf-mode .save-status { display: none !important; }
body.pdf-mode .print-only { display: block; }
body.pdf-mode .print-head, .pdf-head { font-size: 9pt; color: #555; border-bottom: 1px solid #999; padding-bottom: 6px; margin-bottom: 12px; }
body.pdf-mode .table-wrap { overflow: visible; }
body.pdf-mode .print-area, body.pdf-mode main.content { background: #fff; }
body.pdf-mode .sched input { border: 0; background: none; box-shadow: none; padding: 2px 0; }

/* ---------- Staff schedule: autosave and row removal ---------- */
.save-status { font-size: .8rem; color: var(--ink-3); margin-left: 8px; }
.save-status.ok { color: var(--good); }
.save-status.bad { color: var(--bad); font-weight: 600; }
.shift-cell { display: flex; align-items: center; gap: 4px; }
.row-x { flex: 0 0 auto; width: 24px; height: 24px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.row-x:hover, .row-x:focus-visible { background: var(--bad-bg); color: var(--bad); }
@media print { .row-x, .save-status { display: none !important; } }

/* ---------- House checklist: files per item ---------- */
.check-files { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.file-chip { display: inline-flex; align-items: center; gap: 2px; }
.chip-x { width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); font-size: 1rem; line-height: 1; cursor: pointer; }
.chip-x:hover, .chip-x:focus-visible { background: var(--bad-bg); color: var(--bad); }
.attach-btn { cursor: pointer; }
.attach-btn.is-busy { opacity: .6; pointer-events: none; }
.attach-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
@media print { .chip-x, .attach-btn { display: none !important; } }
body.pdf-mode .chip-x, body.pdf-mode .attach-btn { display: none !important; }

/* ---------- Calendar: colour key, click a day to add ---------- */
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: -4px 0 12px; }
.cal-legend .cal-ev { display: inline-block; cursor: default; }
.cal-legend .fine { margin-left: 4px; }
.cal-day-head { display: flex; align-items: center; justify-content: space-between; }
.cal-add { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-3); font-size: 1.05rem; font-weight: 600; text-decoration: none; opacity: 0; transition: opacity .12s; }
.cal-day.can-add { cursor: pointer; }
.cal-day.can-add:hover { background: var(--surface-2); }
.cal-day.can-add:hover .cal-add, .cal-add:focus-visible { opacity: 1; background: var(--accent-soft); color: var(--accent); text-decoration: none; }
@media (hover: none) { .cal-add { opacity: 1; } }
@media print { .cal-add, .cal-legend .fine { display: none !important; } }
body.pdf-mode .cal-add { display: none !important; }

/* Reports: red rows (psychotropic/sleep medications, overdue items), as in the original tracker. */
.report .table tr.tone-bad td { background: rgba(192, 57, 43, .08); -webkit-print-color-adjust: exact; print-color-adjust: exact; }

/* Settings: rename a list entry in place */
.chip { position: relative; }
.chip-edit > summary { list-style: none; display: inline-grid; place-items: center; font-size: .85rem; }
.chip-edit > summary::-webkit-details-marker { display: none; }
.chip-edit[open] > summary { background: var(--accent-soft); color: var(--accent); }
.chip-edit-form { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 260px; display: grid; gap: 8px; padding: 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 8px 24px rgba(15, 35, 50, .14); }
.chip-edit-form .check { display: flex; gap: 6px; align-items: flex-start; font-size: .82rem; color: var(--ink-2); }
.chip-edit-form .btn { justify-self: start; }
.row-edit { display: inline-block; position: relative; text-align: left; }
.row-edit > summary { list-style: none; cursor: pointer; }
.row-edit > summary::-webkit-details-marker { display: none; }
.row-edit-form { left: auto; right: 0; white-space: normal; }
.table-wrap.table-pop { overflow: visible; }
/* Closed pop-ups take no room (they pushed the Settings page wider than a phone screen). */
.chip-edit:not([open]) > .chip-edit-form, .row-edit:not([open]) > .chip-edit-form { display: none; }
@media (max-width: 700px) {
  .table-wrap.table-pop { overflow-x: auto; }
  .chip-edit[open] > .chip-edit-form, .row-edit[open] > .chip-edit-form { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; min-width: 0; max-height: 80vh; overflow-y: auto; z-index: 60; }
}

/* Sortable list headers */
.table th.th-sort a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.table th.th-sort a:hover { color: var(--accent); }
.table th .sort-ind { font-size: .7em; opacity: .35; }
.table th.is-sorted .sort-ind { opacity: 1; color: var(--accent); }
@media print { .table th .sort-ind { display: none; } }
body.pdf-mode .table th .sort-ind { display: none; }

/* Dev mailbox (local development only) */
.devmail { max-width: 860px; margin: 32px auto; padding: 0 16px; }
.devmail-body { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Resident file tab */
.rfile-h { font-size: .95rem; margin: 22px 0 8px; color: var(--ink-2); }
.rfile-h:first-of-type { margin-top: 8px; }
.rfile-table td:first-child { min-width: 220px; }
.rdoc-add { flex-wrap: wrap; }
.row-edit-form .filter { min-width: 0; }
.rfile-sub td { border-top-style: dashed; }
.rfile-sub-name { padding-left: 18px; position: relative; color: var(--ink-2); }
.rfile-sub-name::before { content: "↳"; position: absolute; left: 2px; color: var(--ink-3); }

/* Monthly tracking grid */
.tracking-grid th[scope="row"] { white-space: nowrap; }
.tracking-grid thead th { white-space: normal; min-width: 110px; }
.tracking-cell { vertical-align: top; }
.tracking-cell .btn { margin-top: 4px; }
.tracking-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.tracking-item:last-child { border-bottom: 0; }
.tracking-name { font-size: .8rem; color: var(--ink-2); min-width: 0; }
.tracking-item .btn { margin-top: 0; }
.panel-subhead { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- House notes and logins ---------- */
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.note-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); scroll-margin-top: 80px; min-width: 0; }
.note-card:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.note-head { display: flex; align-items: center; gap: 8px; }
.note-head h3 { flex: 1; margin: 0; font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
.note-fields { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: .9rem; }
.note-fields dt { color: var(--ink-3); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding-top: 4px; }
.note-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.secret-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.secret-row code { font-size: .88rem; background: var(--surface-2); padding: 3px 7px; border-radius: 6px; overflow-wrap: anywhere; }
.note-body { font-size: .88rem; color: var(--ink-2); white-space: normal; overflow-wrap: anywhere; padding-top: 8px; border-top: 1px solid var(--line); }
.note-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.note-foot .fine { flex: 1; }
.pw-row { display: flex; gap: 6px; align-items: center; }
.pw-row input { flex: 1; min-width: 0; }
@media (max-width: 480px) { .note-grid { grid-template-columns: 1fr; } }

/* ---------- Archived items (files, trainings, Settings entries, roles) ---------- */
.archived-files { margin: 10px 0 0; font-size: .86rem; }
.archived-files > summary { cursor: pointer; color: var(--ink-3); font-weight: 600; width: fit-content; }
.archived-files > summary:hover { color: var(--ink); }
.archived-files ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.archived-files li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }
.archived-files li .archived-name { flex: 1 1 260px; min-width: 0; }
.archived-files li .inline-form { margin-left: 0; flex: none; }
.archived-files li .btn { white-space: nowrap; }
.checklist .archived-files { grid-column: 1 / -1; margin-top: 0; }

/* Long forms in steps (app.js initSteps): the staff stepper's look; each step's heading is shown by the stepper */
.form-step { display: contents; }
.form-step[hidden] { display: none; }
.form-step > .form-heading:first-child { display: none; }
.form-step > .step-hint { grid-column: 1 / -1; margin: 0; }
.form-panel > .stepper-wrap { padding: 0 0 4px; }
.modal-form > .stepper-wrap { padding: 14px 22px 0; }
.modal-form > .stepper-wrap .stepper { margin-bottom: 0; }
.stepper li > button { width: 100%; font: inherit; font-size: .78rem; font-weight: 600; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 8px; height: 100%; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3); }
.stepper li > button:hover { border-color: #bcd6e0; color: var(--ink); }
.stepper li > button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Lists grouped by resident (m.php) */
.table-grouped .group-row th { background: var(--surface-2); text-align: left; padding: 8px 14px; border-top: 2px solid var(--line-strong); }
.group-toggle { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; }
.group-name { font-weight: 700; font-size: .98rem; }
.group-house, .group-count { color: var(--ink-2); font-weight: 400; font-size: .84rem; text-transform: none; letter-spacing: 0; }
.group-caret { display: inline-block; transition: transform .15s; }
.group-toggle[aria-expanded="false"] .group-caret { transform: rotate(-90deg); }
.group-link { float: right; font-size: .82rem; font-weight: 500; text-transform: none; letter-spacing: 0; }
@media print { .group-toggle .group-caret, .group-link { display: none; } }

/* Resident file parts and shorter profile tabs */
.subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.subtabs[hidden] { display: none; } /* only one part: no tab bar */
.subtab { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .86rem; color: var(--ink-2); cursor: pointer; }
.subtab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.subtab .count-bad { background: var(--bad); color: #fff; }
.subtabs:not([hidden]) ~ .rfile-sec .rfile-h { display: none; }
.check-inline { display: inline-flex; gap: 6px; align-items: center; font-size: .86rem; color: var(--ink-2); margin-right: 8px; }

@media print { .subtabs, .show-more, .check-inline { display: none !important; } .rfile-sec[hidden], tr[hidden] { display: revert !important; } }
.btn[hidden], .form-actions [hidden] { display: none !important; }

/* Risk documents on one line (risk_docs_summary) */
.doc-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 220px; }
.doc-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.doc-good { background: #e6f3ea; color: #1f6b35; }
.doc-bad { background: #fbe9e5; color: var(--bad); }
.pager-local { margin: 10px 0 4px; }
.pager-size select { padding: 3px 6px; font: inherit; font-size: .85rem; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
@media (max-width: 640px) { .stepper li.is-current { flex: 3; } }

/* Dashboard "Needs attention": tabs per kind of work, one folded line per person */
.attn-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.attn-tab { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: .82rem; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.attn-tab:hover { border-color: #bcd6e0; color: var(--ink); }
.attn-tab[aria-selected="true"] { background: #d6f2e6; border-color: #9fd8bf; color: var(--ink); }
.attn-n { font-size: .74rem; font-weight: 500; color: var(--ink-3); }
.attn-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-left: 3px; vertical-align: super; }
.attn-dot-bad { background: var(--bad); }
.attn-dot-warn { background: var(--warn-dot); }
.attn-panel { margin: 0 -22px -20px; max-height: min(60vh, 600px); overflow-y: auto; }
.attn-group { border-top: 1px solid var(--line); }
.attn-group > summary { display: flex; align-items: center; gap: 10px; padding: 11px 22px; cursor: pointer; list-style: none; }
.attn-group > summary::-webkit-details-marker { display: none; }
.attn-group > summary:hover { background: #f4f9fb; }
.attn-icon { flex: none; display: grid; place-items: center; width: 20px; height: 18px; clip-path: polygon(50% 0, 100% 100%, 0 100%); background: var(--bad); color: #fff; font-size: .7rem; font-weight: 800; padding-top: 4px; }
.attn-warn > summary .attn-icon { background: var(--warn-dot); }
.attn-line { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.attn-who { font-weight: 700; font-size: .9rem; white-space: nowrap; }
.attn-sum { font-size: .86rem; font-weight: 600; color: var(--bad); }
.attn-where { font-size: .76rem; color: var(--ink-3); }
.attn-warn > summary .attn-sum { color: #9a6700; }
.attn-caret { flex: none; width: 8px; height: 8px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); margin: -4px 4px 0 6px; transition: transform .15s; }
.attn-group[open] > summary .attn-caret { transform: rotate(-135deg); margin-top: 4px; }
.attn-group .attn-list { margin: 0; background: var(--surface-2); }
.attn-group .attn a { padding-left: 52px; }
.attn-group .attn a::before { left: 36px; }
@media print { .attn-panel[hidden] { display: block !important; } .attn-group > .attn-list { display: block; } }

/* Row "⋯" menu (lists and resident tabs): Edit, Discharge / Discontinue / No longer involved, Archive */
.row-menu { position: relative; display: inline-block; vertical-align: middle; }
.row-menu > summary { list-style: none; cursor: pointer; width: 30px; height: 28px; display: grid; place-items: center; border-radius: 6px; color: var(--ink-2); font-size: 1.1rem; line-height: 1; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu > summary:hover, .row-menu[open] > summary { background: var(--surface-2); color: var(--ink); }
.row-menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(16, 41, 58, .14); text-align: left; }
.row-menu-list a, .row-menu-list button { display: block; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 6px; font: inherit; font-size: .88rem; color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; white-space: nowrap; }
.row-menu-list a:hover, .row-menu-list button:hover { background: var(--surface-2); text-decoration: none; }
.row-menu-list form { margin: 0; border-top: 1px solid var(--line); padding-top: 4px; margin-top: 4px; }
.row-menu-danger { color: var(--bad) !important; }
.btn-danger-text { color: var(--bad); }
@media print { .row-menu { display: none; } }

/* Folded groups on a page of their own (staff training): one line per person, opened to see the rows. */
.fold-list { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.fold-list > .fold-group:first-child { border-top: 0; }
.fold-group[open] > summary { background: var(--surface-2); }
.fold-group[open] > summary .attn-caret { transform: rotate(225deg); margin-top: 4px; }
.fold-ok > summary .attn-icon { background: var(--good, #2e8b57); clip-path: none; border-radius: 50%; width: 18px; padding-top: 0; }
.fold-ok > summary .attn-sum { color: var(--ink-3); }
.fold-body { padding: 10px 22px 16px; }
.fold-body .table-wrap { margin: 0; }
.fold-link { margin: 0 0 8px; font-size: .84rem; }
@media print { .fold-group > summary .attn-caret, .fold-link, [data-fold-all] { display: none; } }

/* A tick box that is one of several choices (medication schedule: Morning, Day, Night). */
.check-chip { display: inline-flex; align-items: center; gap: 9px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; font-weight: 600; font-size: .9rem; cursor: pointer; width: fit-content; }
.check-chip input { width: 17px; height: 17px; margin: 0; accent-color: var(--good); }
.check-chip:has(input:checked) { background: var(--good-bg); border-color: #9fd8bf; }

/* Search / Show / sort above in-page lists (staff trainings, documents). */
.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 10px; }
.table-search { flex: 1 1 220px; max-width: 360px; padding: 7px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; font-size: .9rem; background: #fff; }
.table-filter { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; color: var(--ink-2); }
.table-filter select { padding: 6px 8px; font: inherit; font-size: .86rem; }
.table-tools-info { font-size: .84rem; }
.table-none { margin: 6px 0 12px; }
.table th .th-btn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.table th .th-btn:hover { color: var(--accent); }
@media print { .table-tools { display: none; } }

/* Super administrator: select several rows and act on them together. */
.bulk-cell { width: 34px; padding-right: 0 !important; }
.bulk-cb { width: 17px; height: 17px; margin: 0 8px 0 0; vertical-align: middle; accent-color: var(--accent); cursor: pointer; }
.bulk-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 8px 10px; max-width: calc(100vw - 32px); padding: 10px 16px; background: #fff8e6; border: 1px solid #f0d58c; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.bulk-bar[hidden] { display: none; }
.bulk-bar strong { margin-right: 6px; font-size: .9rem; }
.archived-files li .bulk-cb { margin-right: 6px; }
@media print { .bulk-cell, .bulk-bar, .bulk-cb { display: none !important; } }

/* Long text in reports: four lines, then "See more". Printing and PDFs show it all. */
.clamp { display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.clamp.clamp-open, body.clamp-off .clamp { display: block; -webkit-line-clamp: unset; line-clamp: unset; overflow: visible; }
.clamp-btn { margin-top: 4px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.clamp-btn:hover { text-decoration: underline; }
body.clamp-off .clamp-btn { display: none; }
@media print { .clamp { display: block !important; -webkit-line-clamp: unset !important; overflow: visible !important; } .clamp-btn, .pager-local { display: none !important; } }

/* Reports: one part per tab; the part's own heading is shown only when printing or in a PDF. */
.report-tabs .subtabs { margin-top: 14px; }
.template-tabs .subtabs { margin: 18px 0 4px; }
.subtab-empty { color: var(--ink-3, var(--ink-2)); }
.subtab-empty .count { opacity: .6; }
.empty-tab { padding: 28px 16px; }
.template-print { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin: 0 0 10px; }
@media print { .template-print, .template-manage, .template-versions, .template-actions { display: none !important; } body.print-one .template-tabs .template-group[data-subtab-panel]:not(.print-this) { display: none !important; } }
.empty-tab p { margin: 0 0 12px; }
@media print { .template-tabs .template-group.template-group-empty[data-subtab-panel]:not(.print-this) { display: none !important; } .empty-tab .btn { display: none !important; } }
.template-tabs .subtabs:not([hidden]) ~ .template-group .template-cat { display: none; }
@media print { .template-tabs .template-group[hidden] { display: block !important; } .template-tabs .template-cat { display: block !important; } }
.subtab .count-alert { background: var(--bad); color: #fff; }
.report-tabs .subtabs:not([hidden]) ~ .report-sec .report-h { display: none; }
body.clamp-off .report-tabs .subtabs { display: none; }
body.clamp-off .report-tabs .report-sec .report-h { display: block; }
@media print { .report-tabs .report-sec[hidden] { display: block !important; } .report-tabs .report-sec .report-h { display: block !important; } }

/* Mark done by client (staff trainings) */
.client-marking { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 12px; }
.client-marking-l { font-size: .85rem; color: var(--ink-2); margin-right: 2px; }
.client-items { border: 0; padding: 0; margin: 0 0 14px; max-height: 46vh; overflow: auto; }
.modal-form > .client-items { margin: 14px 22px 0; }
.modal-form > .client-items legend { padding: 0; }
.modal-form > .client-items + .form-grid { padding-top: 12px; }
.client-item, .check-all { display: flex; gap: 8px; align-items: flex-start; padding: 6px 2px; border-bottom: 1px solid var(--line); font-size: .9rem; }
.check-all { font-weight: 600; }
@media print { .client-marking { display: none !important; } }

/* Cards that open what they count (Meti, 11-02) */
a.kpi { color: inherit; text-decoration: none; }
a.kpi:hover, .hero-stats > a:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.hero-stats > a:hover { background: rgba(255, 255, 255, .14); }
.only-chip { margin: 0 0 8px; font-size: .9rem; }
.kpi-btn { font: inherit; text-align: left; cursor: pointer; }
.kpi-btn[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.list-status-tabs { margin: 0 0 12px; }
.list-status-tabs a.subtab { text-decoration: none; }
