/* v0.13.2: self-hosted fonts (IBM Plex Sans / Mono, latin subset from
   @fontsource). Removes the runtime Google Fonts dependency so ordinary page
   navigation has no external network call. Relative URLs resolve against this
   stylesheet's own URL, so they remain correct behind the /fm/sdip gateway
   prefix. font-display: swap keeps text visible immediately. */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); }

:root {
  --bg: #F6F7F5;
  --surface: #FFFFFF;
  --ink: #1C2526;
  --ink-muted: #5B6664;
  --accent: #1F6F5C;
  --accent-dark: #16523F;
  --accent-soft: #E4EFEC;
  --alert: #B5651D;
  --alert-soft: #F6E7DA;
  --danger: #A23B2E;
  --danger-soft: #F5E1DD;
  --border: #E1E4E1;
  --radius: 8px;
  --font-ui: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

.mono { font-family: var(--font-mono); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2 { margin: 0 0 4px; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; margin-bottom: 12px; }

.muted { color: var(--ink-muted); margin: 0; }

/* Top navigation */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--ink); }
.brand-mark { font-family: var(--font-ui); font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; color: var(--accent-dark); }
.brand-sub { font-size: 0.8rem; color: var(--ink-muted); }
.nav { display: flex; gap: 20px; flex: 1; }
.nav a { color: var(--ink-muted); font-size: 0.92rem; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }
.nav a:hover { color: var(--ink); text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 0.9rem; color: var(--ink-muted); }
.topbar-user a { color: var(--ink-muted); }
.nav-link-btn { background: none; border: none; padding: 0; font-family: var(--font-ui); font-size: inherit; color: var(--ink-muted); cursor: pointer; }
.nav-link-btn:hover { color: var(--ink); text-decoration: underline; }

/* Page layout */
.page { max-width: 1180px; margin: 0 auto; padding: 32px 24px 80px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.page-head-actions { display: flex; gap: 10px; }
.hint { font-size: 0.85rem; margin-top: 10px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card-head-row { display: flex; justify-content: space-between; align-items: center; }
.form-card { max-width: 640px; }

/* Stat grid */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-grid-compact { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card-alert { border-color: var(--alert); background: var(--alert-soft); }
.stat-card-alert .stat-value { color: var(--alert); }
.stat-card-link { text-decoration: none; color: inherit; cursor: pointer; transition: box-shadow 0.15s; }
.stat-card-link:hover { box-shadow: 0 2px 8px rgba(28,37,38,0.10); text-decoration: none; }
.stat-card-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stat-value { font-size: 1.6rem; font-weight: 600; color: var(--accent-dark); }
.stat-label { font-size: 0.82rem; color: var(--ink-muted); }

/* Roadmap */
.roadmap-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.roadmap-list li { padding: 8px 12px; border-radius: 6px; font-size: 0.9rem; }
.roadmap-done { background: var(--accent-soft); color: var(--accent-dark); padding: 0; transition: background 0.15s; }
.roadmap-done a { color: inherit; text-decoration: none; display: block; padding: 8px 12px; border-radius: 6px; }
.roadmap-done a:hover, .roadmap-done a:focus-visible { text-decoration: underline; }
.roadmap-done:hover { background: #DCEAE5; }
.roadmap-pending { background: var(--bg); color: var(--ink-muted); border: 1px dashed var(--border); }
.roadmap-pending::before { content: "… "; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table-compact td, .data-table-compact th { padding: 7px 10px; font-size: 0.88rem; }
.empty-row { color: var(--ink-muted); text-align: center; padding: 24px 10px !important; }
.empty-card { color: var(--ink-muted); }
.row-actions { display: flex; gap: 12px; white-space: nowrap; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 100px; font-size: 0.78rem; font-weight: 500; }
.badge-active { background: var(--accent-soft); color: var(--accent-dark); }
.badge-inactive { background: var(--bg); color: var(--ink-muted); border: 1px solid var(--border); }
.badge-status-active { background: var(--accent-soft); color: var(--accent-dark); }
.badge-status-upcoming { background: #E5EAF5; color: #34508C; }
.badge-status-inactive { background: var(--bg); color: var(--ink-muted); border: 1px solid var(--border); }
.badge-status-expired { background: var(--danger-soft); color: var(--danger); }
.badge-alert { background: var(--alert-soft); color: var(--alert); }
.badge-afterhours { background: var(--alert-soft); color: var(--alert); }

.alert-banner {
  background: var(--alert-soft);
  border: 1px solid var(--alert);
  color: var(--alert);
  font-size: 0.9rem;
  line-height: 1.5;
}

.pill {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.82rem;
  margin-bottom: 6px;
}

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-section { display: flex; flex-direction: column; gap: 14px; }
.form-section-title { margin: 6px 0 -4px; padding-top: 16px; border-top: 1px solid var(--border); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 0.86rem; color: var(--ink-muted); font-weight: 500; }
.form input, .form select, .form textarea {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.form textarea { font-family: var(--font-ui); resize: vertical; }
.checkbox-row { border: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.checkbox-row legend { font-size: 0.86rem; color: var(--ink-muted); font-weight: 500; padding: 0; margin-bottom: 2px; }
.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-direction: row !important;
  width: fit-content;
  padding: 6px 12px !important;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.85rem !important;
  color: var(--ink) !important;
  font-weight: 400 !important;
  cursor: pointer;
}
.checkbox-row { flex-direction: row; flex-wrap: wrap; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.inline-form { display: inline; }
.add-site-form { display: flex; gap: 10px; margin-top: 14px; }
.add-site-form input { flex: 1; padding: 7px 11px; border: 1px solid var(--border); border-radius: 6px; }
.add-doc-form { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-ui);
}
.link-btn:hover { text-decoration: underline; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-ui);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); text-decoration: none; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; }

/* Flash messages */
.flash-stack { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 6px; font-size: 0.9rem; }
.flash-success { background: var(--accent-soft); color: var(--accent-dark); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-warning { background: #fff3cd; color: #7a5b00; }

/* Auth */
.auth-wrap { display: flex; justify-content: center; padding-top: 10vh; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; width: 100%; max-width: 340px; text-align: center; }
/* v0.15.9: stacked brand lockup (mark above wordmark, tagline under) --
   BRAND-GUIDE.md section 4. Mark uses brand_mark('theme'), which already
   tracks --ink/--accent, so light/dark/auto all render correctly with no
   extra logic here. Clear space per the guide is approximated by the
   existing margins rather than literally reserving 25% of the mark's
   height on all sides -- this is a compact login card, not print
   stationery, and the guide itself scopes the strict clear-space rule to
   letterhead/business-card/cover contexts. */
.auth-logo { width: 64px; height: 64px; margin: 0 auto 14px; }
.auth-logo .brand-mark-svg { width: 100%; height: 100%; display: block; }
.auth-brand {
  font-family: var(--font-ui);
  font-weight: 700; /* closest self-hosted weight to the brand spec's
    Manrope ExtraBold (800) -- Manrope isn't self-hosted in this build, and
    this app deliberately makes no runtime Google Fonts call (see base.html's
    font comment), so IBM Plex Sans 700 stands in rather than adding a new
    external font dependency for one element. */
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.auth-tag {
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 24px;
}
.auth-card .form { text-align: left; }
/* v0.12.0: guarantee the login title and field labels track the ink token in
   every theme (light / dark / auto), so they can never end up light-on-light
   regardless of earlier layer order. The card itself uses --surface-raised. */
.auth-brand { color: var(--ink); }
.auth-card label { color: var(--ink); }

/* Client card */
.client-card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.client-card-identity { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.client-card-identity h2 { margin: 0; }
.client-card-email { font-size: 0.85rem; }
.client-card { padding: 16px 20px 14px; margin-bottom: 12px; }
.add-site-toggle { margin-top: 10px; background: none; border: none; padding: 0; font-family: var(--font-ui); cursor: pointer; }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 0; }
.detail-grid dt { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted); margin-bottom: 3px; }
.detail-grid dd { margin: 0; }

/* Footer */
.footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px 40px;
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* Tab bar (contract list filter) */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.tab-link {
  display: inline-block;
  padding: 7px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-muted);
  border-radius: 6px 6px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  text-decoration: none;
  position: relative;
  bottom: -1px;
  background: transparent;
  transition: color 0.1s;
}
.tab-link:hover { color: var(--ink); text-decoration: none; }
.tab-link-active {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
}

/* Tab count bubble */
.tab-count {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.72rem;
  padding: 0 6px;
  line-height: 1.6;
  margin-left: 4px;
  vertical-align: middle;
}
.tab-link-active .tab-count { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-dark); }

/* Quoted / neutral-blue status badge */
.badge-upcoming { background: #E5EAF5; color: #34508C; }

/* Bulk-action bar below time entries table */
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  margin-top: 4px;
}

/* Compact stat grid for detail pages */
.stat-grid-sm { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

/* Document count badge */
.badge-doc-count {
  background: var(--accent-soft);
  color: var(--accent-dark);
  min-width: 22px;
  text-align: center;
}

/* Expiring soon badge */
.badge-expiring { background: var(--alert-soft); color: var(--alert); }

/* Service delivery compliance badges */
.badge-delivery-ok    { background: var(--accent-soft); color: var(--accent-dark); }
.badge-delivery-under { background: var(--danger-soft); color: var(--danger); }
.badge-delivery-over  { background: var(--alert-soft);  color: var(--alert); }

/* Danger link button */
.link-btn-danger { color: var(--danger); }
.link-btn-danger:hover { color: var(--danger); text-decoration: underline; }

/* Icon action buttons (v0.15.7, corrected v0.15.8) -- compact icon-only
   row actions for dense Actions columns, replacing stacked/wrapping
   .link-btn text ("Edit", "Delete", "Deactivate"...). See
   templates/_icons.html for the glyph macros and its usage note on
   aria-label vs data-tooltip.

   v0.15.8 correction: the initial version fixed .icon-btn at 30x30px
   unconditionally, bypassing the existing global 44x44 touch-target rule
   above (.btn, .btn-sm, .link-btn, ...) and relying on a hover/focus-only
   tooltip that a touchscreen tap never reveals before the action fires.
   Fixed the same way this file already handles compact-vs-touch sizing
   for .btn (see the "(mouse/trackpad) devices only" comment further
   down): the BASE rule is the touch-safe, labelled version; a
   `@media (pointer: fine)` block shrinks to icon-only for mouse/trackpad.
   This fails toward the accessible option on any device that doesn't
   report a pointer type, rather than failing toward the cramped one. */
.icon-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  position: relative;
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.2;
}
.icon-btn .ui-icon { width: 18px; height: 18px; flex: none; }
/* Visible by default (touch/no-pointer-info) so the action is legible
   without ever needing to see a hover tooltip; hidden (sr-only, not
   display:none -- still reachable by name for assistive tech that
   doesn't honour aria-label consistently) under pointer:fine below,
   where the tooltip takes over as the discoverability mechanism. */
.icon-btn .icon-label { white-space: nowrap; }
.icon-btn:hover, .icon-btn:focus-visible { background: var(--hover); color: var(--ink); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn-danger { color: var(--danger); }
.icon-btn-danger:hover, .icon-btn-danger:focus-visible { background: var(--danger-soft); color: var(--danger); }

@media (pointer: fine) {
  .icon-actions { gap: 2px; }
  .icon-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    padding: 0;
    gap: 0;
  }
  .icon-btn .ui-icon { width: 16px; height: 16px; }
  .icon-btn .icon-label {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* Hover/focus tooltip, built from data-tooltip (aria-label carries the
   real accessible name -- this is purely the visual hint, and only
   matters at all under pointer:fine above, since coarse-pointer/touch
   already shows .icon-label permanently). A fixed dark chip regardless
   of the active theme reads clearly against both the warm-sand light
   canvas and the graphite dark one, rather than trying to flip with
   --ink/--surface (which would invert to an odd light-on-dark chip in
   dark mode).

   Known limitation (v0.15.8): where an .icon-btn sits inside a
   horizontally-scrollable ancestor (.table-wrap's overflow-x:auto --
   per the CSS spec, setting either overflow axis to a non-visible value
   forces the other axis to compute as 'auto' too, which can clip this
   absolutely-positioned tooltip for a row very close to the container's
   top edge). Mitigated, not eliminated, by the extra .table-wrap
   padding-top below; needs a real-browser check on the actual affected
   tables (Clients & Sites, Services) rather than being assumed fixed. */
.icon-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translate(-50%, 4px);
  background: rgba(20, 22, 20, 0.94);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  padding: 5px 8px;
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 30;
}
.icon-btn[data-tooltip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: rgba(20, 22, 20, 0.94);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 30;
}
.icon-btn[data-tooltip]:hover::after, .icon-btn[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}
.icon-btn[data-tooltip]:hover::before, .icon-btn[data-tooltip]:focus-visible::before { opacity: 1; }
/* Last action in a row: keep its tooltip from overflowing the table/card
   right edge. v0.15.8: generalised from .col-actions-only (the initial
   version missed every table using a plain .row-actions cell instead --
   afterhours rules, public holidays, classification rules, operational
   causes, staff, contractors, contract documents). */
.icon-btn:last-child[data-tooltip]::after,
.icon-btn:last-child[data-tooltip]::before { left: auto; right: 4px; transform: none; }
.icon-btn:last-child[data-tooltip]:hover::after,
.icon-btn:last-child[data-tooltip]:focus-visible::after { transform: translateY(0); }

/* Confirmation dialog */
.confirm-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 8px 24px rgba(28,37,38,0.14);
  max-width: 320px;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
}
.confirm-dialog::backdrop { background: rgba(28,37,38,0.25); }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 16px; }

/* ── Compliance bar (dashboard) ──────────────────────────────────────────── */
.compliance-bar-card { padding: 16px 20px; margin-bottom: 20px; }
.compliance-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.compliance-bar-title { font-size: 0.88rem; font-weight: 600; color: var(--ink); }
.compliance-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  gap: 2px;
  background: var(--bg);
}
.compliance-seg { min-width: 4px; transition: flex 0.3s; }
.compliance-seg-ok    { background: var(--accent); }
.compliance-seg-over  { background: var(--alert); }
.compliance-seg-under { background: var(--danger); }
.compliance-legend-row {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.compliance-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.compliance-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.compliance-dot-ok    { background: var(--accent); }
.compliance-dot-over  { background: var(--alert); }
.compliance-dot-under { background: var(--danger); }

/* ── Delivery progress bars (overview table) ─────────────────────────────── */
.progress-bar-cell { min-width: 110px; padding-top: 8px !important; padding-bottom: 8px !important; }
.progress-bar-track {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
  max-width: 140px;
}
.progress-bar-fill { height: 100%; border-radius: 3px; }
.pbf-on-track { background: var(--accent); }
.pbf-over     { background: var(--alert); }
.pbf-under    { background: var(--danger); }
.progress-bar-num { font-size: 0.8rem; }
.pbf-label-ok    { color: var(--accent-dark); }
.pbf-label-over  { color: var(--alert); }
.pbf-label-under { color: var(--danger); }

/* ── Chart wrap (delivery detail) ────────────────────────────────────────── */
.chart-wrap { margin-bottom: 20px; }

/* ── Revenue pipeline strip ──────────────────────────────────────────────── */
.pipeline-strip { padding: 16px 20px; margin-bottom: 16px; }
.pipeline-strip-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.pipeline-strip-title { font-size: 0.88rem; font-weight: 600; color: var(--ink); }
.pipeline-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  gap: 2px;
  background: var(--bg);
  margin-bottom: 10px;
}
.pipeline-seg { min-width: 4px; }
.pipeline-seg-open     { background: var(--accent); }
.pipeline-seg-quoted   { background: #34508C; }
.pipeline-seg-invoiced { background: #6B7280; }
.pipeline-seg-dismissed { background: var(--border); }
.pipeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.pipeline-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.pipeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.pipeline-dot-open     { background: var(--accent); }
.pipeline-dot-quoted   { background: #34508C; }
.pipeline-dot-invoiced { background: #6B7280; }
.pipeline-dot-dismissed { background: var(--border); border: 1px solid #9CA3AF; }

/* Responsive */
@media (max-width: 720px) {
  .stat-grid, .stat-grid-compact { grid-template-columns: 1fr 1fr; }
  .form-row, .detail-grid { grid-template-columns: 1fr; }
  .nav { display: none; }
  .topbar-inner { flex-wrap: wrap; }
  .tab-bar { flex-wrap: wrap; }
}

/* v0.5.4 operational foundation */
.global-banner {
  max-width: 1180px;
  margin: 14px auto 0;
  padding: 0 22px;
  display: grid;
  gap: 8px;
}
.global-note {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 14px;
  text-decoration: none;
  border: 1px solid var(--border, #dfe5e2);
  background: #fff;
  color: inherit;
  box-shadow: 0 8px 24px rgba(12, 35, 31, 0.06);
}
.global-note span { color: #5B6664; }
.global-note-critical { border-left: 5px solid #b42318; }
.global-note-warning { border-left: 5px solid #b7791f; }
.global-note-info { border-left: 5px solid #2f80ed; }
.global-note-success { border-left: 5px solid #16803c; }

.briefing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.briefing-card p { margin: 7px 0; }
.briefing-summary-head,
.page-head-row,
.filter-row,
.action-row {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.briefing-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.briefing-mini-grid span {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f6f8f7;
}
.text-danger { color: #b42318; }
.text-warn { color: #9a6700; }
.text-ok { color: #16803c; }
.badge-danger { background: #fee4e2; color: #b42318; }
.badge-warn { background: #fef0c7; color: #9a6700; }
.badge-ok { background: #dcfae6; color: #067647; }
.health-card + .health-card { margin-top: 16px; }
.filter-row label { display: grid; gap: 6px; min-width: 180px; }
.empty-state { padding: 28px; color: #5B6664; text-align: center; background: #f8faf9; border-radius: 14px; }

.two-col-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.checkbox-line { display: flex; gap: 8px; align-items: center; }
@media (max-width: 900px) { .two-col-grid { grid-template-columns: 1fr; } }

.badge-warning {
  background: #fff7ed;
  color: #9a3412;
}

/* v0.5.11 payroll review workflow refinements */
.payroll-period-card {
  max-width: 760px;
}
.compact-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}
.compact-toolbar select,
.compact-toolbar input[type="text"] {
  min-height: 34px;
}
.review-table td {
  vertical-align: top;
}
.small-context {
  font-size: 0.86rem;
  line-height: 1.35;
}
.decision-state {
  margin-bottom: 4px;
}

/* v0.5.12 Time Entries review table redesign */
.time-filter-actions {
  margin-top: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.time-filter-actions .spacer {
  flex: 1 1 auto;
}
.time-review-table {
  table-layout: fixed;
  width: 100%;
}
.time-review-table th,
.time-review-table td {
  vertical-align: top;
}
.time-select-col {
  width: 36px;
  text-align: center;
}
.time-when-col {
  width: 170px;
}
.time-description-col {
  width: auto;
}
.time-hours-col {
  width: 110px;
  text-align: right;
}
.time-alerts-col {
  width: 150px;
}
.time-staff-name {
  font-weight: 700;
  line-height: 1.3;
}
.time-meta {
  color: var(--ink-muted);
  font-size: 0.78rem;
  line-height: 1.35;
  margin-top: 4px;
}
.time-entry-description {
  font-weight: 700;
  line-height: 1.38;
  font-size: 0.98rem;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.time-context-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 7px;
  color: var(--ink-muted);
  font-size: 0.76rem;
  line-height: 1.35;
}
.time-context-line span:not(:last-child)::after {
  content: "";
}
.time-afterhours-small,
.time-alert-detail {
  color: var(--ink-muted);
  font-size: 0.75rem;
  line-height: 1.35;
  margin-top: 4px;
}
.badge-compact {
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 0.70rem;
  line-height: 1.15;
  margin: 0 3px 4px 0;
  display: inline-block;
}
.row-needs-review {
  /* v0.14.0.1 §8: base tint now derives from the semantic warning token so it
     is a warm cream in light and a muted dark amber in dark -- never the old
     near-white #fffdf8 that was invisible in light and too bright in dark. The
     full treatment (left accent, hover, readable badges/links) is in the
     dedicated block at the end of this file. */
  background: var(--warning-soft, #F1E7D2);
}
@media (max-width: 980px) {
  .time-review-table {
    min-width: 860px;
  }
  .time-review-table-wrap {
    overflow-x: auto;
  }
}

/* v0.5.13 Service Register CRUD */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 18px;
}
.service-form-card label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}
.service-form-card input,
.service-form-card select,
.service-form-card textarea {
  font: inherit;
}
.card-head-inline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.service-register-table td {
  vertical-align: top;
}

/* v0.5.17 interface organisation */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(28,37,38,0.04);
}
.topbar-inner { max-width: 1220px; gap: 24px; }
.nav-primary { flex-wrap: wrap; row-gap: 4px; column-gap: 16px; align-items: center; }
.nav-divider { width: 1px; height: 18px; background: var(--border); display: inline-block; }
.global-banner { position: sticky; top: 65px; z-index: 45; background: var(--bg); }
.global-banner .global-note { max-width: 1180px; margin-left: auto; margin-right: auto; }
.compact-filter-card { padding: 14px 20px; }
.workflow-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 14px; }
.workflow-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; color: inherit; background: var(--bg); display: flex; flex-direction: column; gap: 6px; }
.workflow-card span { color: var(--ink-muted); font-size: 0.86rem; }
.workflow-card:hover { text-decoration: none; border-color: var(--accent); background: var(--accent-soft); }
.review-centre-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; align-items: start; }
.review-panel { min-width: 0; }
.review-entry-list { display: flex; flex-direction: column; gap: 10px; max-height: 680px; overflow: auto; padding-right: 4px; }
.review-entry-card { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: pointer; background: #fff; }
.review-entry-card:hover { border-color: var(--accent); }
.review-entry-card input { grid-row: 1 / span 4; margin-top: 3px; }
.review-main-text { font-weight: 500; line-height: 1.35; }
.review-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.review-actions input { flex: 1; min-width: 180px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; }
@media (max-width: 980px) {
  .review-centre-grid { grid-template-columns: 1fr; }
  .topbar-inner { align-items: flex-start; flex-direction: column; gap: 10px; }
  .global-banner { top: 116px; }
}

/* v0.5.18 MVP interface system ------------------------------------------------
   Purpose: make the existing operational platform feel like one product without
   changing the business logic or database contract. */
:root {
  --bg: #F3F5F2;
  --surface: #FFFFFF;
  --surface-soft: #F8FAF8;
  --surface-raised: #FFFFFF;
  --ink: #182321;
  --ink-muted: #64716E;
  --ink-faint: #8A9693;
  --accent: #216D5B;
  --accent-dark: #123F34;
  --accent-soft: #E6F1EE;
  --accent-line: #BFD9D2;
  --alert: #A45B18;
  --alert-soft: #FFF2E3;
  --danger: #A33A2D;
  --danger-soft: #FBE7E3;
  --border: #DDE5E1;
  --border-strong: #C6D2CD;
  --shadow-sm: 0 1px 2px rgba(18, 63, 52, 0.05);
  --shadow-md: 0 12px 30px rgba(18, 63, 52, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
}

body {
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { font-weight: 500; }

h1 { font-size: clamp(1.65rem, 2vw, 2.15rem); line-height: 1.14; letter-spacing: -0.035em; }
h2 { font-size: 1.02rem; letter-spacing: -0.015em; }

.topbar {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(198,210,205,0.82);
  box-shadow: 0 4px 18px rgba(18,63,52,0.06);
}
.topbar-inner {
  max-width: 1360px;
  padding: 12px 28px 10px;
  gap: 22px;
}
.brand {
  min-width: 235px;
  gap: 12px;
  text-decoration: none !important;
}
.brand-icon {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.brand-copy { display: grid; gap: 0; }
.brand-mark { color: var(--ink); font-size: 1rem; letter-spacing: 0.02em; }
.brand-sub { display: block; font-size: 0.73rem; line-height: 1.2; color: var(--ink-muted); }
.nav-primary {
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-primary::-webkit-scrollbar { display: none; }
.nav-primary a,
.subnav a,
.topbar-link,
.nav-link-btn {
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  white-space: nowrap;
}
.nav-primary a {
  padding: 8px 12px;
  border-bottom: 0;
  color: #465552;
  font-weight: 600;
  font-size: 0.88rem;
}
.nav-primary a.active,
.nav-primary a:hover {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: var(--accent-line);
  text-decoration: none;
}
.topbar-user {
  gap: 8px;
  margin-left: auto;
}
.user-chip {
  padding: 7px 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--ink);
  border-radius: 999px;
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-link,
.nav-link-btn {
  padding: 7px 10px;
  color: var(--ink-muted) !important;
}
.topbar-link.active,
.topbar-link:hover,
.nav-link-btn:hover {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--ink) !important;
  text-decoration: none;
}
.subnav-wrap {
  border-top: 1px solid rgba(221,229,225,0.72);
  background: rgba(248,250,248,0.78);
}
.subnav {
  max-width: 1360px;
  margin: 0 auto;
  padding: 8px 28px;
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
}
.subnav-label {
  margin-right: 6px;
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.subnav a {
  padding: 6px 10px;
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.subnav a.active,
.subnav a:hover {
  color: var(--accent-dark);
  background: var(--surface);
  border-color: var(--border);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.page {
  max-width: 1360px;
  padding: 30px 28px 84px;
}
.page-head {
  padding: 4px 0 8px;
  margin-bottom: 20px;
  align-items: center;
}
.page-head > div:first-child { max-width: 780px; }
.page-head .muted { font-size: 0.98rem; }
.page-head-actions { flex-wrap: wrap; justify-content: flex-end; }

.card,
.stat-card,
.auth-card {
  border-color: var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}
.card { padding: 22px; }
.card:hover { box-shadow: 0 4px 18px rgba(18,63,52,0.055); }
.card-head-row,
.card-head-inline { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 14px; }

.stat-grid { gap: 14px; }
.stat-card {
  min-height: 108px;
  padding: 18px;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  inset: auto 16px 0 16px;
  height: 3px;
  background: var(--accent-soft);
  border-radius: 999px 999px 0 0;
}
.stat-card-alert { border-color: var(--warning); background: var(--warning-soft); }
.stat-card-alert::after { background: var(--alert); }
.stat-value { font-size: 2rem; letter-spacing: -0.05em; }
.stat-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.055em; font-weight: 700; }
.stat-card-link:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn { border-radius: 999px; min-height: 38px; box-shadow: none; }
.btn-primary { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-ghost,
.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}
.btn-ghost:hover,
.btn-secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-dark);
  text-decoration: none;
}
.btn-sm { min-height: 32px; }

input, select, textarea,
.add-site-form input,
.review-actions input {
  border-color: var(--border-strong) !important;
  border-radius: 10px !important;
  background: var(--surface-raised);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(33,109,91,0.14);
  border-color: var(--accent) !important;
}
.form label,
.form-grid label { color: var(--ink); font-weight: 700; }

.data-table { border-collapse: separate; border-spacing: 0; }
.data-table th {
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border-strong);
  color: #596663;
  padding: 10px 12px;
}
.data-table td { padding: 12px; }
.data-table tbody tr:hover td { background: #FAFCFB; }
.data-table th:first-child { border-top-left-radius: 10px; }
.data-table th:last-child { border-top-right-radius: 10px; }
.row-actions { align-items: center; }

.badge,
.pill {
  border: 1px solid transparent;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.badge-active, .badge-delivery-ok, .badge-ok { border-color: #B7DEC8; }
.badge-alert, .badge-warn, .badge-warning, .badge-delivery-over { border-color: #EBC28D; }
.badge-danger, .badge-delivery-under { border-color: #F0B5AE; }
.badge-inactive { background: #EEF2F0; color: #66736F; border-color: #D8E0DC; }

.global-banner {
  max-width: none;
  margin: 0;
  padding: 10px 28px;
  top: 99px;
  border-bottom: 1px solid rgba(221,229,225,0.82);
}
.global-note { border-radius: 12px; box-shadow: var(--shadow-sm); }

.briefing-summary {
  border: 1px solid rgba(191,217,210,0.95);
  background: linear-gradient(135deg, #FFFFFF 0%, #EEF7F4 100%);
}
.briefing-summary-head h2 { font-size: 1.25rem; }
.briefing-mini-grid span {
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(198,210,205,0.7);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.briefing-mini-grid strong { color: var(--accent-dark); font-size: 1.25rem; }
.workflow-card {
  background: linear-gradient(180deg, #fff, var(--surface-soft));
  border-radius: 16px;
  padding: 18px;
  min-height: 116px;
}
.workflow-card strong { font-size: 1rem; }

.compliance-bar-card,
.pipeline-strip { border-radius: 16px; }
.progress-bar-track,
.compliance-bar,
.pipeline-bar { background: #E9EFEC; }

.review-centre-grid { gap: 20px; }
.review-panel h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.08rem;
}
.review-panel h2::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
}
.review-entry-list { gap: 12px; max-height: 660px; }
.review-entry-card {
  border-radius: 14px;
  padding: 13px;
  background: linear-gradient(180deg, #fff, #FBFDFB);
  box-shadow: var(--shadow-sm);
}
.review-entry-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.review-main-text { font-weight: 700; color: var(--ink); }
.review-actions {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.footer {
  max-width: 1360px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

@media (max-width: 1120px) {
  .topbar-inner { flex-wrap: wrap; }
  .brand { min-width: auto; }
  .topbar-user { width: 100%; justify-content: flex-start; }
  .global-banner { top: 145px; }
}
@media (max-width: 720px) {
  .page { padding: 22px 16px 76px; }
  .topbar-inner, .subnav { padding-left: 16px; padding-right: 16px; }
  .brand-sub { display: none; }
  .user-chip { display: none; }
  .stat-grid, .stat-grid-compact { grid-template-columns: 1fr; }
  .footer { flex-direction: column; gap: 6px; padding-left: 16px; padding-right: 16px; }
}

/* v0.5.18 dashboard hero */
.dashboard-hero {
  min-height: 156px;
  padding: 26px 28px;
  border: 1px solid rgba(191,217,210,0.95);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(18,63,52,0.94), rgba(33,109,91,0.88)),
    radial-gradient(circle at 90% 10%, rgba(255,255,255,0.26), transparent 18rem);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.dashboard-hero h1 { color: #fff; margin-bottom: 8px; }
.dashboard-hero .muted { color: rgba(255,255,255,0.82); max-width: 760px; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-weight: 800;
  color: rgba(255,255,255,0.78);
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
/* v0.12.0: the hero is flat (no dark gradient), so its buttons use the normal
   themed button styles rather than the old white-on-gradient overrides. */
@media (max-width: 820px) {
  .dashboard-hero { align-items: flex-start; }
  .hero-actions { justify-content: flex-start; }
}

/* v0.5.19 web-platform shell and logo-aligned colour system -------------- */
:root {
  --brand-green-deep: #003F2D;
  --brand-green: #0F7A55;
  --brand-green-mid: #1E8F64;
  --brand-yellow: #F7C948;
  --brand-yellow-soft: #FFF4CC;
  --brand-yellow-line: #E9C55C;
  --sidebar-width: 268px;
}

body {
  /* v0.12.0 canvas consolidation: this is the authoritative final `body`
     background. It MUST use the semantic token so the application canvas flips
     with the theme (warm sand in light, graphite in dark) instead of the old
     hardcoded #F7F9F7, which left dark panels on a light canvas in dark mode.
     Any decorative tint must derive from theme variables; none is used here. */
  background: var(--bg);
  color: var(--ink);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background:
    radial-gradient(circle at 22px 22px, rgba(247,201,72,0.22), transparent 7rem),
    linear-gradient(180deg, #053E31 0%, #002F25 100%);
  color: #fff;
  border-right: 1px solid rgba(255,255,255,0.08);
  box-shadow: 16px 0 32px rgba(5,62,49,0.13);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 22px 18px;
  color: #fff;
  text-decoration: none !important;
}
.brand-logo {
  display: inline-flex;
  width: 52px;
  height: 52px;
  flex: none;
}
.brand-logo .brand-mark-svg { width: 100%; height: 100%; display: block; }
.side-brand .brand-copy { display: grid; gap: 2px; }
.side-brand .brand-mark {
  color: #fff;
  font-size: 1.32rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.side-brand .brand-sub { color: rgba(255,255,255,0.78); font-size: 0.78rem; }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px 24px;
}
.side-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 12px 7px;
  color: rgba(255,255,255,0.72);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.side-section::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(255,255,255,0.15);
}
.side-link {
  display: grid;
  grid-template-columns: 34px minmax(0,1fr);
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 14px;
  color: rgba(255,255,255,0.88);
  text-decoration: none !important;
  border: 1px solid transparent;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}
.side-link strong { display: block; color: inherit; font-size: 0.92rem; line-height: 1.25; }
.side-link small { display: block; color: rgba(255,255,255,0.70); font-size: 0.76rem; line-height: 1.25; margin-top: 1px; }
.side-icon {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.07);
  font-weight: 800;
}
.side-link.active {
  background: linear-gradient(135deg, rgba(247,201,72,0.22), rgba(255,255,255,0.09));
  color: #fff;
  border-color: rgba(247,201,72,0.52);
  box-shadow: inset 4px 0 0 var(--brand-yellow);
}
.side-link.active .side-icon {
  background: var(--brand-yellow);
  color: #063C2E;
  border-color: rgba(247,201,72,0.8);
}
.side-link:hover { background: rgba(255,255,255,0.10); transform: translateX(1px); }

.app-main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.app-main .topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 28px;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(212,222,218,0.95);
  box-shadow: 0 6px 26px rgba(5,62,49,0.06);
}
.app-main .nav-primary { flex: 1; gap: 12px; }
.app-main .nav-primary a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 12px;
  color: #25322F;
  font-weight: 700;
}
.app-main .nav-primary a.active {
  background: linear-gradient(135deg, var(--brand-green), var(--brand-green-mid));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(15,122,85,0.22);
}
.app-main .nav-primary a:hover:not(.active) {
  background: #F2F6F4;
  color: var(--brand-green-deep);
}

.topbar-user { margin-left: auto; gap: 12px; }
.user-avatar {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-green-deep), var(--brand-green));
  color: var(--brand-yellow);
  font-weight: 900;
  letter-spacing: -0.03em;
  border: 2px solid rgba(247,201,72,0.32);
}
.user-chip {
  display: grid;
  gap: 0;
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-weight: 800;
  color: #111B19;
}
.user-chip small { font-size: 0.74rem; color: var(--ink-muted); font-weight: 600; }

.notification-menu { position: relative; }
.bell-button {
  list-style: none;
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.bell-button::-webkit-details-marker { display: none; }
.bell-icon { font-size: 1.05rem; line-height: 1; }
.bell-badge {
  position: absolute;
  right: -3px;
  top: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--brand-yellow);
  color: #1C2526;
  font-size: 0.70rem;
  font-weight: 900;
  border: 2px solid #fff;
}
.notification-panel {
  position: absolute;
  top: 50px;
  right: 0;
  width: min(380px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(5,62,49,0.16);
  padding: 12px;
  display: none;
  z-index: 90;
}
.notification-menu[open] .notification-panel { display: block; }
.notification-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.notification-head a { font-size: 0.82rem; }
.notification-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  color: inherit;
  border-left: 4px solid var(--border-strong);
  text-decoration: none !important;
}
.notification-item:hover { background: #F7FAF8; }
.notification-item span { color: var(--ink-muted); font-size: 0.84rem; font-weight: 500; }
.notification-critical { border-left-color: var(--danger); background: #FFF8F7; }
.notification-warning { border-left-color: var(--brand-yellow); background: #FFFCF2; }
.notification-info { border-left-color: var(--brand-green); }
.notification-empty {
  padding: 18px 12px;
  color: var(--ink-muted);
  text-align: center;
  font-size: 0.9rem;
}

.global-banner { display: none !important; }

.page {
  width: 100%;
  max-width: 1320px;
  padding: 34px 30px 84px;
}
.footer { width: 100%; max-width: 1320px; }

.dashboard-hero {
  min-height: 132px;
  background:
    radial-gradient(circle at 94% 8%, rgba(247,201,72,0.34), transparent 15rem),
    linear-gradient(135deg, #053E31, #137354 72%, #1A8C63);
  border: 1px solid rgba(247,201,72,0.22);
}
.dashboard-hero .eyebrow { color: var(--accent); }
.stat-card-alert::after { background: var(--warning); }
.stat-card-alert .stat-value { color: #8B5A00; }
.badge-alert, .badge-warn, .badge-warning, .badge-delivery-over { background: var(--brand-yellow-soft); color: #855A00; border-color: var(--brand-yellow-line); }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { position: relative; height: auto; }
  .side-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
  .side-section { grid-column: 1 / -1; }
  .app-main .topbar { flex-wrap: wrap; }
  .topbar-user { width: 100%; justify-content: flex-start; }
}
@media (max-width: 760px) {
  .side-brand { padding: 16px; }
  .side-nav { grid-template-columns: 1fr; padding-left: 10px; padding-right: 10px; }
  .app-main .topbar { padding: 12px 16px; }
  .app-main .nav-primary { overflow-x: auto; flex-wrap: nowrap; }
  .page { padding: 22px 16px 76px; }
  .user-chip, .topbar-link { display: none; }
}

/* v0.6.0 Enterprise Design System and identity foundation ------------------ */
:root {
  --content-max: 1760px;
}

/* v0.13.0: the desktop sidebar-collapse control was removed (see the nav
   shell block near the end of this file). Its styles are intentionally gone. */

.app-shell { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); transition: grid-template-columns 0.18s ease; }
.side-link strong { font-weight: 600; letter-spacing: -0.01em; }
.side-link small { font-weight: 400; }
.side-icon { font-weight: 600; font-size: 1rem; }
.side-section { font-weight: 700; }

.page,
.footer,
.global-banner .global-note,
.subnav,
.topbar-inner { max-width: var(--content-max); }
.page { width: 100%; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand-green);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.section-panel {
  background: transparent;
  border-top: 1px solid var(--border);
  padding: 22px 0 26px;
  margin-bottom: 8px;
}
.section-panel-soft {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
}
/* File inputs (e.g. the Staff import panel) must theme with the rest of the
   form, not fall back to the browser's light default in Dark/Auto. */
.form input[type="file"] { padding: 6px 8px; }
.form input[type="file"]::file-selector-button {
  font: inherit; cursor: pointer;
  margin-right: 10px; padding: 6px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
}
.form input[type="file"]::file-selector-button:hover { background: var(--hover); }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}
/* v0.15.8: overflow-x:auto forces the other axis's computed overflow to
   'auto' too (per spec, when one axis is non-'visible' the other can't
   stay 'visible' either) -- so this box also clips anything that paints
   above/below its own edges, including the first row's .icon-btn hover
   tooltip (see static/style.css's icon-btn comment). A small top pad
   gives that tooltip headroom without a visible layout shift; this
   mitigates rather than eliminates the risk and still wants a real-
   browser check on Clients & Sites / Services, the two tables that use
   this wrapper. */
.table-wrap { overflow-x: auto; padding-top: 8px; margin-top: -8px; }
/* v0.7.5: reverted sticky table headers entirely. The v0.7.3 fix made
   thead sticky visually active for the first time (it was previously
   stuck at top:0, invisibly, behind the topbar) -- and that's exactly
   when reports came in of a data row appearing to render above the
   column headings on Compliance Dashboard and Time Evidence. The
   underlying template markup was verified correct in both cases
   (thead genuinely precedes tbody in the DOM), so this is a CSS/paint
   effect from position: sticky on <th>, not a real DOM-order bug --
   but it can't be reliably diagnosed or verified further without live
   browser rendering, which isn't available here. Given the risk (a
   misordered-looking table undermines trust in the data itself, per
   the report), reliability wins over the scrolling convenience: plain,
   always-correctly-ordered static headers, no position: sticky. */
.data-table thead th {
  background: var(--raise);
}
.data-table tbody tr:hover td { background: rgba(247,201,72,0.08); }
.table-input {
  width: 100%;
  min-width: 130px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 7px 9px;
  font: inherit;
}
.password-input { min-width: 145px; }
.switch-line { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--ink-muted); }
.identity-table td { vertical-align: middle; }
.spacious-form { max-width: none; }
.form-row-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }

.settings-workspace,
.settings-main-form { max-width: none !important; }
.settings-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 22px; }
.settings-wide-panel { max-width: none !important; }
.settings-wide-panel .data-table { min-width: 820px; }

@media (max-width: 1100px) {
  .form-row-3 { grid-template-columns: 1fr; }
  .app-main .nav-primary { display: none; }
}


/* v0.6.1 Design System application fixes ---------------------------------- */
.ui-icon {
  width: 20px;
  height: 20px;
  display: block;
}
.side-icon {
  font-size: 0;
  color: rgba(255,255,255,0.92);
}
.side-link.active .side-icon { color: #053E31; }
.side-link strong {
  font-weight: 600;
  font-size: 0.90rem;
}
.side-link small {
  font-weight: 400;
  opacity: 0.92;
}
.app-main .nav-primary a {
  gap: 8px;
  font-weight: 600;
}
.nav-icon {
  display: inline-grid;
  place-items: center;
  color: currentColor;
  opacity: 0.92;
}
.nav-icon .ui-icon { width: 18px; height: 18px; }
.app-main .nav-primary a.active .nav-icon { color: var(--brand-yellow); }

/* keep Settings and data-heavy workspaces full width and less boxed */
.page { max-width: var(--content-max); }
.settings-workspace,
.settings-wide-panel,
.classification-workspace { width: 100%; max-width: none !important; }
.classification-workspace {
  padding-top: 26px;
}
.classification-workspace .data-table {
  width: 100%;
  min-width: 1120px;
  border: 1px solid var(--border);
  border-radius: 14px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  background: var(--surface);
}
.classification-workspace .data-table th,
.classification-workspace .data-table td {
  padding: 16px 18px;
  color: var(--ink);
}
.classification-workspace .data-table th:nth-child(1) { width: 16%; }
.classification-workspace .data-table th:nth-child(2) { width: 16%; }
.classification-workspace .data-table th:nth-child(3) { width: 34%; }
.classification-workspace .data-table th:nth-child(4) { width: 12%; }
.classification-workspace .data-table th:nth-child(5) { width: 14%; }
.keyword-cell {
  font-family: var(--font-ui);
  color: var(--ink);
  max-width: none;
  white-space: normal;
  line-height: 1.45;
}
.category-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid rgba(15,122,85,0.14);
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.category-training { background: var(--brand-yellow-soft); border-color: var(--brand-yellow-line); color: #775300; }
.category-leave-public-holiday { background: #F0E7FF; border-color: #D7C2FF; color: #6D3BAA; }
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--ink-muted);
}
.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong, #cbd5d1);
}
.status-active::before { background: var(--brand-green); }
.status-active { color: var(--ink); }
.status-inactive::before { background: #9AA5A1; }
.classification-add-form {
  border-top: 1px solid var(--border);
  padding-top: 22px;
  margin-top: 22px;
}
.classification-add-form h2 { font-size: 1.02rem !important; margin-bottom: 14px !important; }
.form-row-4 { grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(320px, 2fr); }
@media (max-width: 1100px) {
  .form-row-4 { grid-template-columns: 1fr; }
}

/* v0.7.2 UI/IA streamlining -------------------------------------------- */

/* Topbar: replaced the duplicate workflow nav with a simple "where am I"
   title, kept flex:1 so topbar-user still sits at the far right. */
.topbar-title {
  flex: 1;
  font-weight: 600;
  color: var(--ink);
  font-size: 0.98rem;
}

/* Collapsible "Setup & admin" sidebar group -- collapsed by default so the
   daily-use links aren't competing with occasional-use configuration
   pages. See ADR: v0.7.2 UI/IA Consolidation. */
.side-section-toggle {
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  padding: 0;
}
.side-section-caret {
  display: inline-block;
  transition: transform 0.15s ease;
}
.side-section-toggle[aria-expanded="true"] .side-section-caret { transform: rotate(180deg); }
.side-section-group { display: none; flex-direction: column; gap: 4px; }
.side-section-group.side-section-group-open { display: flex; }

/* Unified dashboard "Needs attention" panel (replaces the old always-on
   Briefing mini-grid + 7-card stat grid -- quiet unless something needs
   attention, per the v0.5.19 notification-bell principle). */
.attention-all-clear {
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.9rem;
  margin-top: 4px;
}
.attention-context-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 6px 0 16px;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* ---------------------------------------------------------------------
   v0.9.0 Mobile Foundation
   ---------------------------------------------------------------------
   Building Managers are expected to use SDIP mostly by phone from
   v0.9.1 onward (see ADR: "v0.9.0 Roles, Permissions and Portfolio
   Foundation"). These are foundational, reusable rules -- applied here
   to this release's own new screens (Time Entries' scope toggle,
   Permissions, Role defaults, Site assignments) -- not yet a retrofit
   of every existing admin table. The main sidebar nav still disappears
   below 720px with no replacement (see the existing `.nav { display:
   none; }` rule above) -- that is a known, named gap, deliberately left
   for v0.9.1's own purpose-built mobile navigation (My Buildings /
   Today's Issues / My Time / Messages / All Buildings) rather than
   patched piecemeal here.

   Applies at 640px and below -- phone widths, not the 720/900/980px
   tablet-oriented breakpoints already used elsewhere in this file. */

/* Large touch targets: no control a Building Manager taps should be
   smaller than the commonly-cited 44x44px minimum. Applies globally,
   not just under the 640px query, since a touch target should never
   shrink back down just because a keyboard/mouse-oriented layout also
   fits the same viewport width (a phone in landscape, e.g.). */
.btn, .btn-sm, .link-btn, .checkbox-pill, input[type="checkbox"], input[type="radio"] {
  min-height: 44px;
}
.btn-sm { padding: 10px 14px; } /* was 6px 12px -- too small to reliably tap */
.checkbox-pill { display: inline-flex; align-items: center; padding: 10px 14px; }
input[type="checkbox"], input[type="radio"] { min-width: 22px; min-height: 22px; }

/* iOS Safari auto-zooms on focusing any input under 16px -- jarring and
   disorienting on a phone. Never go below 16px for anything typeable. */
input, select, textarea { font-size: 16px; }

@media (max-width: 640px) {
  /* No essential horizontal scrolling: form rows and detail grids that
     assume desktop width collapse to one column, same principle as the
     existing 720px/900px rules above, just carried further down. */
  .form-row, .form-row-3, .detail-grid, .two-col-grid { grid-template-columns: 1fr !important; }
  .stat-grid, .stat-grid-compact { grid-template-columns: 1fr !important; }
  .page-head, .page-head-actions, .section-head { flex-direction: column; align-items: stretch; }
  .page-head-actions .btn { width: 100%; text-align: center; }
  .row-actions { flex-wrap: wrap; }

  /* Simple sticky primary action -- opt-in via .sticky-mobile-action,
     used where a single primary action (e.g. "Save", "Add assignment")
     should stay reachable without scrolling back up on a long page. */
  .sticky-mobile-action {
    position: sticky;
    bottom: 0;
    background: var(--bg, #fff);
    padding: 10px 0;
    border-top: 1px solid var(--border, #dfe5e2);
    z-index: 5;
  }

  /* Opt-in table -> stacked-card conversion. Applied to this release's
     own new tables (Permissions, Role defaults, Site assignments) --
     see the .table-cards-mobile class on those templates. Existing
     tables with inline per-row edit forms (Users, Staff, Time Entries)
     are NOT converted here; that is deliberately deferred to v0.9.1,
     where each screen gets rebuilt for mobile on purpose rather than
     forced through one generic transform that would need per-table
     verification anyway. */
  .table-cards-mobile table,
  .table-cards-mobile thead,
  .table-cards-mobile tbody,
  .table-cards-mobile th,
  .table-cards-mobile td,
  .table-cards-mobile tr {
    display: block;
    width: 100%;
  }
  .table-cards-mobile thead tr { position: absolute; top: -9999px; left: -9999px; }
  .table-cards-mobile tr {
    margin-bottom: 12px;
    border: 1px solid var(--border, #dfe5e2);
    border-radius: 12px;
    padding: 10px 14px;
  }
  .table-cards-mobile td {
    border: none;
    padding: 6px 0;
    text-align: left;
  }
  .table-cards-mobile td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--ink-muted, #5B6664);
    margin-bottom: 2px;
  }
}

/* ---------------------------------------------------------------------
   v0.10.0 Reusable register + form patterns
   ---------------------------------------------------------------------
   One set of patterns for Clients & Sites, the Service Register, and any
   future register page -- built once here rather than as one-off CSS per
   page, per the release directive's explicit "establish reusable UI
   patterns" requirement. Applies register toolbars, compact tables
   (reuses .data-table/.data-table-compact above), status badges (reuse
   .badge-active/.badge-inactive above), row actions, empty states,
   pagination, modal/drawer forms (native <dialog>), collapsible sections
   (native <details>), and validation messaging.
   ------------------------------------------------------------------ */

/* Register toolbar: search + filters + primary actions in one compact
   row that wraps sensibly, never requiring horizontal scroll on its own. */
.register-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.register-toolbar .toolbar-search {
  flex: 1 1 220px;
  min-width: 160px;
}
.register-toolbar select,
.register-toolbar input[type="search"],
.register-toolbar input[type="text"] {
  min-height: 40px;
}
.register-toolbar .toolbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}
.register-toolbar .toolbar-spacer { flex: 1 1 auto; }

/* Register table: sortable column headers, sticky-feeling compact rows. */
.register-table th a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.register-table th a:hover { text-decoration: underline; }
.register-table th.sorted::after { content: ""; }
.register-table td.col-actions { white-space: nowrap; text-align: right; }
.register-table th.col-actions { text-align: right; }
/* text-align on the <td> only affects inline content -- .row-actions is a
   flex container, which ignores it for its own box position, so the
   actual fix is justify-content on the flex row itself. */
.register-table td.col-actions .row-actions { justify-content: flex-end; }
.register-table .row-additional-note {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

/* Empty state: one consistent look everywhere a register has zero rows,
   whether from no data at all or from filters matching nothing. */
.register-empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-muted);
}
.register-empty-state .empty-icon { font-size: 2rem; margin-bottom: 8px; opacity: 0.6; }
.register-empty-state .btn { margin-top: 12px; }

/* Pagination */
.register-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 4px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.register-pagination .pagination-controls { display: flex; gap: 6px; }

/* Modal / drawer forms: native <dialog>, styled consistently. Works with
   zero required JS beyond .showModal()/.close() -- see static/register.js.
   Fits small screens per the responsive-foundations requirement: no fixed
   px width beyond a max, and full-width margin below a breakpoint. */
dialog.modal-dialog {
  border: none;
  border-radius: var(--radius, 10px);
  padding: 0;
  width: min(640px, 92vw);
  max-height: 88vh;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
dialog.modal-dialog::backdrop { background: rgba(20, 24, 22, 0.45); }
dialog.modal-dialog .modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
dialog.modal-dialog .modal-head h2 { margin: 0; font-size: 1.05rem; }
dialog.modal-dialog .modal-close {
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; font-size: 1.3rem; cursor: pointer; color: var(--ink-muted);
}
dialog.modal-dialog .modal-body { padding: 18px 20px; overflow-y: auto; max-height: calc(88vh - 130px); }
dialog.modal-dialog .modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: var(--surface);
}
@media (max-width: 640px) {
  dialog.modal-dialog { width: 100vw; max-width: 100vw; height: 100%; max-height: 100%; border-radius: 0; margin: 0; }
  dialog.modal-dialog .modal-body { max-height: calc(100vh - 130px); }
}

/* Collapsible sections: native <details>/<summary>, used both for
   Settings sections and compact secondary areas (import/export, postal
   address, additional sites). Zero custom JS required for open/close;
   keyboard and screen-reader accessible by default. */
details.collapsible-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
details.collapsible-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  font-weight: 600;
}
details.collapsible-section > summary::-webkit-details-marker { display: none; }
details.collapsible-section > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 10px;
  transition: transform 0.15s ease;
  color: var(--ink-muted);
}
details.collapsible-section[open] > summary::before { transform: rotate(90deg); }
details.collapsible-section > summary .section-summary-text {
  font-weight: 400;
  color: var(--ink-muted);
  font-size: 0.85rem;
  margin-left: auto;
  text-align: right;
}
details.collapsible-section .collapsible-body { padding: 4px 18px 18px; border-top: 1px solid var(--border); }
details.collapsible-compact > summary { padding: 8px 12px; font-weight: 500; font-size: 0.9rem; min-height: 40px; }
details.collapsible-compact .collapsible-body,
details.collapsible-compact > .form-row { padding: 4px 12px 12px; }

/* Form layout helpers reused by Client/Site/Service forms */
.form-subheading { font-size: 0.95rem; margin: 0 0 8px; padding-top: 4px; border-top: 1px solid var(--border); padding-top: 14px; }
.form-section:first-child .form-subheading { border-top: none; padding-top: 0; }

/* ---------------------------------------------------------------------
   v0.10.1 platform-wide full-page form standard.

   Substantial create/edit/review/configuration workflows use a dedicated
   page (.form-page) with normal browser-page scrolling -- not a <dialog>
   modal. Modals (dialog.modal-dialog, above) remain available, but only
   for genuinely brief, self-contained interactions (confirmations, a
   one-field quick update, a short check-in) -- see docs/DESIGN_SYSTEM.md
   "Form and Modal Standard".
------------------------------------------------------------------------ */
.form-page { max-width: 980px; }
.form-page-wide { max-width: 1180px; }
/* v0.10.2 defect fix: templates apply both classes to ONE element
   (<div class="card form-page">), so the old descendant selector
   `.form-page .card` (a .card *inside* a .form-page) never matched and
   this padding was dead. Corrected to the compound selector, and the
   width caps above are superseded by the compact layer at end of file
   so a dedicated form uses the same content column as its register
   instead of leaving a large unused region. */
.form-page.card,
.card.form-page { padding: 24px 28px; }
.form-page .form-section + .form-section { margin-top: 4px; }
.form-page .form-row-2,
.form-page .form-row-3 { gap: 16px; }

/* Validation summary: shown once at the top of a redisplayed form,
   listing every field-level error so the Bookkeeper sees the whole
   picture instead of hunting through a long page. Errors are also
   repeated inline (.field-error) next to the offending field. */
.validation-summary {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius, 6px);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.validation-summary h2 { font-size: 0.95rem; margin: 0 0 6px; }
.validation-summary ul { margin: 0; padding-left: 20px; }
.validation-summary a { color: inherit; text-decoration: underline; }
.field-error {
  color: var(--danger, #dc2626);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: -2px;
}
.form-page .has-error input,
.form-page .has-error select,
.form-page .has-error textarea {
  border-color: var(--danger, #dc2626);
}

/* Bottom action bar: normal in-flow on desktop, sticky on narrow/touch
   viewports so Save/Cancel stay reachable without hunting back up a long
   page -- part of the deliberate (not squeezed-desktop) mobile/iPad
   standard. */
.form-page-actions { display: flex; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
@media (max-width: 760px) {
  .form-page-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    margin: 20px -20px 0;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 8px rgba(18,63,52,0.06);
  }
}

/* Additional-buildings compact sub-table inside the Edit Client page --
   the exceptional multi-site case, deliberately lower-emphasis than the
   primary Client/Default-site sections above it. */
.additional-sites-panel { margin-top: 8px; }
.additional-sites-panel .data-table { margin-bottom: 12px; }
.required { color: var(--danger, #dc2626); }
/* v0.13.1: the label caption (text + required marker + optional hint) is one
   flex item, so the marker never drops onto its own row under a column-flex
   `.form label`, and the input below is never shifted. */
.fld-cap { display: inline-flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.fld-cap .fld-hint { font-weight: 400; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 640px) {
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
}

/* Confirmation dialogs: no custom framework -- native confirm() wired via
   data-confirm on any form, see static/register.js. */

/* Validation message shown inline within the relevant (and, for
   Settings, automatically-expanded) section. */
.field-error { color: var(--danger, #dc2626); font-size: 0.8rem; margin-top: 4px; display: block; }

/* Secondary/lower-emphasis action -- used for "Add additional building/
   site", deliberately less prominent than the primary "Add" action. */
.btn-tertiary {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--ink-muted);
}
.btn-tertiary:hover { color: var(--ink); border-color: var(--ink-muted); }

/* v0.10.0 Settings collapsible sections (JS-driven, see register.js
   initSettingsCollapsibleSections). Applied to existing .card/.section-panel
   elements via a data-collapsible attribute -- the toggle button and
   category label are inserted by JS, this only styles them. */
[data-collapsible] .section-collapse-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  min-width: 32px;
  min-height: 32px;
  font-size: 1rem;
  color: var(--ink-muted);
  margin-right: 8px;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
}
[data-collapsible] .section-collapse-toggle::before { content: "▸"; }
[data-collapsible].settings-section-open .section-collapse-toggle { transform: rotate(90deg); }
[data-collapsible] h2,
[data-collapsible] .card-head-row,
[data-collapsible] .card-head-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
[data-collapsible] .section-summary-text {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-left: auto;
  text-transform: none;
  letter-spacing: normal;
}
.collapsible-body-js[hidden] { display: none; }

/* v0.10.1: Settings quick-index -- a compact single-line "jump to a
   section" control built by register.js from whichever
   [data-collapsible] sections actually rendered for this user, so a long
   collapsible-section page (currently only Settings) doesn't require
   scanning/scrolling to find a section. Hidden by default and only
   revealed once JS has populated it, so a no-JS visit never shows an
   empty control. A native <select> keeps this to one compact line
   regardless of how many sections exist. */
.quick-index-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.quick-index-inline label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  white-space: nowrap;
}
.quick-index-inline select {
  flex: 0 1 320px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
}
.quick-index-inline select:focus-visible {
  outline: 2px solid var(--accent, #2f6d55);
  outline-offset: 1px;
}
@media (max-width: 640px) {
  .quick-index-inline { flex-wrap: wrap; }
  .quick-index-inline select { flex-basis: 100%; }
}

/* ======================================================================
   v0.10.2 COMPACT ADMINISTRATIVE FOUNDATION
   ----------------------------------------------------------------------
   This is the authoritative, final design-system layer. It is loaded
   last on purpose: earlier files/blocks in this stylesheet accumulated
   over many versions (see the "v0.6.0 Enterprise Design System" block
   above ~line 890), which layered a consumer-dashboard treatment --
   108px KPI tiles with a decorative accent bar and hover-lift, 2rem stat
   values, uppercase-bold labels, and a 999px fully-rounded pill default
   on every .btn -- on top of an already-compact base.

   Rather than surgically delete from six interleaved historical layers
   (high regression risk on pages outside this release's scope), this
   single documented layer supersedes the bulk with equal-specificity,
   later-position rules. Removing the now-dead historical layers is
   recorded as deferred architecture debt in RELEASE_NOTES_v0_10_2.md.

   Nothing here touches the test-guarded .register-table col-actions
   rules, the settings quick-index markup, badges/.checkbox-pill (which
   remain legitimately pill-shaped), or any business logic.
   ====================================================================== */

:root {
  --radius-sm: 6px;      /* controls: inputs, buttons */
  --radius-pill: 999px;  /* reserved for genuine status badges/tags only */
}

/* --- Page shell: less top padding, tighter header, content appears
       higher on the page (acceptance criteria 11, 12). ----------------- */
.page { padding-top: 20px; }
.page-head { margin-bottom: 14px; padding: 0 0 4px; align-items: flex-start; }
.page-head h1 { font-size: 1.35rem; line-height: 1.2; margin: 0; }
.page-head .muted { font-size: 0.88rem; margin-top: 2px; }
.eyebrow { margin-bottom: 2px; }

/* --- Cards: restrained. No hover-lift, no ambient shadow as the default;
       a card is a light container, not a floating tile. ---------------- */
.card { padding: 16px 18px; margin-bottom: 14px; box-shadow: none; }
.card:hover { box-shadow: none; }
.card-head-row, .card-head-inline { padding-bottom: 10px; margin-bottom: 12px; }
.card h2 { font-size: 1.02rem; margin: 0 0 4px; }

/* --- Buttons: modest corner radius, not capsules. (criteria 9, 10.)
       Radius is global. Compact HEIGHTS are scoped to fine-pointer
       (mouse/trackpad) devices only, so the deliberate global 44px
       touch-target minimum defined earlier in this file is preserved on
       phones and tablets -- a compact desktop must not shrink tap
       targets on touch. */
.btn { border-radius: var(--radius-sm); }
.btn-tertiary { border-radius: var(--radius-sm); }
@media (pointer: fine) {
  .btn { min-height: 34px; }
  .btn-sm { min-height: 30px; padding: 5px 11px; font-size: 0.82rem; }
}

/* --- KPI / stat tiles: sized to the information, not the fashion.
       Removes the 108px min-height, decorative ::after bar and the
       hover translate. (acceptance criteria 6, 7, 9.) ------------------ */
.stat-grid { gap: 10px; margin-bottom: 14px; }
.stat-card {
  min-height: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  gap: 2px;
}
.stat-card::after { content: none; display: none; }
.stat-card:hover, .stat-card-link:hover { transform: none; box-shadow: none; }
.stat-value { font-size: 1.35rem; letter-spacing: -0.01em; }
.stat-label { font-size: 0.72rem; letter-spacing: 0.04em; font-weight: 600; }

/* --- Reusable compact controls (replace bulky pill tab/period rows) ---
       .filter-bar: a thin toolbar strip for register/dashboard filters.
       .segmented: a small joined control for period/tab switching. ----- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.filter-bar .filter-bar-spacer { margin-left: auto; }
.filter-bar label {
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.filter-bar .period-note { font-size: 0.78rem; color: var(--ink-muted); margin: 0; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.segmented a, .segmented button {
  appearance: none;
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.82rem;
  padding: 5px 12px;
  min-height: 30px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.segmented > :last-child { border-right: none; }
.segmented a:hover, .segmented button:hover { background: var(--accent-soft); color: var(--accent-dark); text-decoration: none; }
.segmented a.is-active, .segmented button.is-active { background: var(--accent); color: #fff; font-weight: 500; }

/* Underline text-tabs: a lighter alternative to boxed tab buttons. */
.text-tabs { display: flex; gap: 16px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.text-tabs a { color: var(--ink-muted); font-size: 0.9rem; padding: 6px 2px; border-bottom: 2px solid transparent; }
.text-tabs a.is-active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }
.text-tabs a:hover { color: var(--ink); text-decoration: none; }

/* --- Dedicated form pages use the full content column (same width as
       the register they came from) so no large unused region remains.
       (acceptance criterion 4.) --------------------------------------- */
.form-page { max-width: none; }
.form-page-wide { max-width: none; }
.form-page.card, .card.form-page { padding: 18px 20px; }
.form-page .form-subheading { font-size: 0.9rem; }
.form-page-actions { margin-top: 16px; padding-top: 12px; }

/* Field grid: on wide viewports let substantial forms use 2 columns of
   real content width instead of one narrow centred column. */
@media (min-width: 1024px) {
  .form-page .form-row, .form-page .form-row-2 { gap: 14px 20px; }
}

/* --- Tables: a touch denser for administrative registers. ----------- */
.data-table th { padding: 7px 10px; }
.data-table td { padding: 8px 10px; }
.data-table-compact th, .data-table-compact td { padding: 6px 9px; }

/* --- Inputs: modest radius always; compact height only on fine-pointer
       devices (touch keeps a comfortable target height). --------------- */
.form-input-sm, .filter-bar input, .filter-bar select { border-radius: var(--radius-sm); }
@media (pointer: fine) {
  .form-input-sm, .filter-bar input, .filter-bar select { min-height: 30px; }
}

/* v0.12.0 §4 dashboard: chips row + mobile-stacking operational tables.
   Scoped to .dash-stack so only the dashboard's own tables stack into cards
   on narrow screens (brief §4.4); every other page's tables are untouched. */
.dash-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
@media (max-width: 640px) {
  .dash-stack thead { display: none; }
  .dash-stack, .dash-stack tbody, .dash-stack tr, .dash-stack td { display: block; width: 100%; }
  .dash-stack tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; padding: 6px 10px; }
  .dash-stack td { border: none; padding: 3px 0; text-align: left !important; }
  .dash-stack td::before { content: attr(data-label) ": "; font-weight: 600; color: var(--ink-muted); }
  .dash-stack td[data-label="Staff"] { font-weight: 600; font-size: 1.02rem; }
  .dash-stack td[data-label="Staff"]::before { content: ""; }
}

/* v0.12.0 theme toggle control (topbar). Two glyphs, only the one for the
   theme you can switch TO is shown, so the control reads as an action. */
.theme-toggle-form { display: inline-flex; margin: 0; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-muted); cursor: pointer;
  font-size: 1rem; line-height: 1;
}
.theme-toggle:hover { background: var(--hover); color: var(--ink); }
.theme-toggle-icon { display: none; }
/* Light theme (or unset): offer the moon (switch to dark). */
.theme-toggle-moon { display: inline; }
.theme-toggle-sun { display: none; }
/* Dark theme active: offer the sun (switch to light). */
:root[data-theme="dark"] .theme-toggle-moon { display: none; }
:root[data-theme="dark"] .theme-toggle-sun { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle-moon { display: none; }
  :root:not([data-theme]) .theme-toggle-sun { display: inline; }
}

/* ==========================================================================
   Flagged Time Entry rows (v0.14.0.1 section 8)
   --------------------------------------------------------------------------
   ONE shared base treatment for every warning condition (afterhours, unusual
   duration, review-required, weekend, missing mapping, contract mismatch)
   so a flagged row is distinguishable at a glance BEFORE the badge is read,
   but never by colour alone: the descriptive text badge in the Flags column
   is always retained, and a small restrained warning glyph reinforces it.
   Colours come from the semantic warning tokens, so the treatment flips with
   the theme automatically:
     Light: warm cream row tint + amber left accent + high-contrast dark ink.
     Dark : muted dark-amber row tint + amber left accent + readable ink,
            with no pale cream or near-white background.
   Placed ABOVE the console-foundation layer on purpose (that layer must stay
   last); the selectors here are specific enough to win regardless.
   ========================================================================== */
.time-review-table tbody tr.row-needs-review > td {
  background: var(--warning-soft);
  color: var(--ink);
}
/* 3px amber inset accent down the leading edge (inset shadow avoids reflow on
   a border-collapse table). */
.time-review-table tbody tr.row-needs-review > td:first-child {
  box-shadow: inset 3px 0 0 0 var(--warning);
}
/* Hover stays distinct from BOTH an ordinary hovered row and a resting
   flagged row. */
.time-review-table tbody tr.row-needs-review:hover > td {
  background: #EADCC0;
}
:root[data-theme="dark"] .time-review-table tbody tr.row-needs-review:hover > td {
  background: #4A3A1B;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .time-review-table tbody tr.row-needs-review:hover > td {
    background: #4A3A1B;
  }
}
/* Links (including View evidence) stay clearly readable on the tint. */
.time-review-table tbody tr.row-needs-review a,
.time-review-table tbody tr.row-needs-review .link-btn {
  color: var(--accent-dark);
}
:root[data-theme="dark"] .time-review-table tbody tr.row-needs-review a,
:root[data-theme="dark"] .time-review-table tbody tr.row-needs-review .link-btn {
  color: var(--accent);
}
/* Restrained warning glyph: reinforces the badge, never the sole signal. */
.time-flag-icon {
  color: var(--warning);
  font-weight: 700;
  margin-right: 5px;
  font-size: 0.95em;
}

/* ==========================================================================
   Communications (v0.14.0, reworked v0.14.0.2 -- brief items 3-14).
   Visual idioms adapted from the agreed 8.4 design exploration (participant
   chips with a role/context sub-line, a dashed add-person affordance opening
   a small searchable popover, status shown as a quiet dot+label, and message
   bubbles distinguishing the current user from other participants) -- kept
   consistent with the SHIPPED v0.14.0 data model (Open/Awaiting Response/
   Resolved/Closed status; participants + one responsible person; optional
   linked record) rather than that exploration's category-drilldown concept.
   All colours are semantic tokens (Light/Dark/Auto both pass contrast).
   ========================================================================== */

/* ---- Shared section card (§8 restructure) ------------------------------ */
.comm-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 980px) {
  .comm-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
}
.comm-side { display: flex; flex-direction: column; gap: 14px; }
.comm-section { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius, 8px); padding: 14px 16px; }
.comm-section h2 { font-size: 0.95rem; margin: 0 0 10px; }
.comm-section + .comm-section { margin-top: 0; }

/* ---- Status shown prominently in the header (§7/§8) --------------------- */
.comm-status-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--ink-muted); }
.comm-status-tag .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--ink-muted); }
.comm-status-tag.is-open .dot, .comm-status-tag.is-awaiting .dot { background: var(--warning); }
.comm-status-tag.is-open, .comm-status-tag.is-awaiting { color: var(--warning); }
.comm-status-tag.is-resolved .dot { background: var(--accent); }
.comm-status-tag.is-resolved { color: var(--accent-dark); }
.comm-status-tag.is-closed .dot { background: var(--ink-muted); }

/* Status section body: current value first, then context-appropriate actions. */
.comm-status-current { font-size: 1.05rem; font-weight: 700; color: var(--ink); margin: 2px 0 4px; }
.comm-status-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.comm-status-help { color: var(--ink-muted); font-size: 0.82rem; margin: 4px 0 0; }

/* ---- Responsible-person section (§6) ------------------------------------ */
.comm-responsible-current { font-size: 1.05rem; font-weight: 700; color: var(--ink); margin: 2px 0 10px; }
.comm-responsible-current.is-unassigned { color: var(--ink-muted); font-weight: 600; }

/* ---- Participant chips (§4) --------------------------------------------- */
.comm-ptags { display: flex; flex-wrap: wrap; gap: 8px; }
.comm-ptag { display: flex; flex-direction: column; gap: 1px; background: var(--raise); border: 1px solid var(--line-2, var(--border)); border-radius: 10px; padding: 6px 12px; min-height: 44px; justify-content: center; }
.comm-ptag .comm-ptag-name { font-weight: 600; font-size: 0.88rem; color: var(--ink); }
.comm-ptag .comm-ptag-role { font-size: 0.74rem; color: var(--ink-muted); display: flex; align-items: center; gap: 8px; }
.comm-ptag-remove-form { margin: 0; }
.comm-ptag-remove-btn { border: 1px solid var(--line-2, var(--border)); background: var(--surface); color: var(--ink-muted); border-radius: 6px; font-size: 0.72rem; font-weight: 600; padding: 3px 8px; cursor: pointer; min-height: 28px; }
.comm-ptag-remove-btn:hover { border-color: var(--danger); color: var(--danger); }
.comm-ptag-remove-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- Add-a-person: dashed pill + searchable popover, shared with the
   create-form multi-picker (both driven by comm_people_picker.js) --------- */
.ppl-picker { display: block; }
.ppl-picker-title { font-size: 0.95rem; margin: 0 0 8px; }
.ppl-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ppl-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--raise); border: 1px solid var(--line-2, var(--border)); border-radius: 8px; padding: 8px 12px; min-height: 44px; }
.ppl-row-fixed { background: var(--accent-soft); border-color: var(--accent-soft); }
.ppl-name { font-weight: 600; color: var(--ink); font-size: 0.9rem; }
.ppl-meta { color: var(--ink-muted); font-size: 0.78rem; margin-left: 8px; }
.ppl-remove-btn { border: 1px solid var(--line-2, var(--border)); background: var(--surface); color: var(--ink-muted); border-radius: 6px; font-size: 0.78rem; font-weight: 600; padding: 6px 10px; cursor: pointer; min-height: 36px; }
.ppl-remove-btn:hover { border-color: var(--danger); color: var(--danger); }
.ppl-remove-btn:focus-visible, .ppl-candidate-btn:focus-visible, .addp-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ppl-search-wrap { position: relative; }
.ppl-search-label { display: block; font-size: 0.82rem; font-weight: 500; color: var(--ink-muted); margin-bottom: 5px; }
.ppl-search-input { width: 100%; min-height: 44px; padding: 9px 12px; font-size: 0.92rem; border: 1px solid var(--line-2, var(--border)); border-radius: var(--radius, 8px); background: var(--surface); color: var(--ink); }
.ppl-search-input:focus-visible, .ppl-search-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.ppl-candidates { list-style: none; margin: 6px 0 0; padding: 0; max-height: 220px; overflow-y: auto; border: 1px solid var(--line-2, var(--border)); border-radius: 8px; background: var(--surface); }
.ppl-candidates:empty { display: none; }
.ppl-candidate-row { border-bottom: 1px solid var(--border); }
.ppl-candidate-row:last-child { border-bottom: 0; }
.ppl-candidate-btn { display: block; width: 100%; text-align: left; padding: 10px 12px; min-height: 44px; border: 0; background: none; font: inherit; font-size: 0.88rem; color: var(--ink); cursor: pointer; }
.ppl-candidate-btn:hover { background: var(--hover, var(--raise)); }
.ppl-empty-state { color: var(--ink-muted); font-size: 0.82rem; margin: 6px 0 0; }
.ppl-selected-name { font-weight: 600; color: var(--ink); margin: 8px 0; font-size: 0.9rem; }

/* Compact dashed "+ Add someone" affordance (adapted from the 8.4 exploration) */
.addp { position: relative; display: inline-block; }
.addp-btn { border: 1px dashed var(--line-2, var(--border)); border-radius: 999px; padding: 8px 14px; min-height: 44px; font-size: 0.82rem; color: var(--ink-muted); background: var(--surface); cursor: pointer; }
.addp-btn:hover { border-color: var(--accent); color: var(--accent-dark); }

/* ---- Conversation timeline: message bubbles + quiet system events (§9) -- */
.comm-timeline { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.comm-message { max-width: 82%; border: 1px solid var(--border); border-radius: var(--radius, 8px); padding: 10px 12px; background: var(--surface-raised); }
.comm-message-mine { margin-left: auto; background: var(--accent-soft); border-color: var(--accent-soft); }
.comm-message-other { margin-right: auto; }
.comm-message-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.comm-message-you-badge { font-size: 0.72rem; font-weight: 600; color: var(--accent-dark); text-transform: uppercase; letter-spacing: 0.03em; }
.comm-message-body { white-space: pre-wrap; word-break: break-word; color: var(--ink); }
.comm-event { display: flex; align-items: baseline; justify-content: center; gap: 8px; font-size: 0.8rem; color: var(--ink-muted); padding: 2px 2px; text-align: center; font-style: italic; }
.comm-event-dot { color: var(--faint, var(--ink-muted)); }
.comm-time { font-size: 0.78rem; color: var(--ink-muted); white-space: nowrap; }
.comm-reply { margin-top: 8px; }
.comm-participant { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-unread td { font-weight: 600; }
.row-unread .comm-unread-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.btn-tiny { padding: 1px 7px; font-size: 0.85rem; line-height: 1.4; }
.nav-unread-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px;
  font-size: 0.72rem; font-weight: 600; text-align: center; border-radius: 9px;
  background: var(--accent); color: var(--accent-on, #fff); }

/* Category tag: a separate solid axis from status, never competing visually. */
.comm-cat-tag { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 5px; font-size: 0.72rem; font-weight: 700; color: #fff; background: var(--slate, var(--ink-muted)); letter-spacing: 0.01em; }

/* Status badges used in list/table contexts (inbox, export) -- distinct from
   the header dot+label, but same semantic colour mapping. */
.badge-comm-open, .badge-comm-awaiting { background: var(--warning-soft); color: var(--warning); }
.badge-comm-resolved { background: var(--accent-soft); color: var(--accent-dark); }
.badge-comm-closed { background: var(--bg); color: var(--ink-muted); border: 1px solid var(--border); }

/* ---- Reply composer: impossible to miss (§10) --------------------------- */
.comm-reply-label { font-weight: 600; font-size: 0.9rem; color: var(--ink); display: block; margin-bottom: 6px; }
.comm-reply textarea { width: 100%; min-height: 96px; border: 2px solid var(--line-2, var(--border)); border-radius: var(--radius, 8px); padding: 10px 12px; font-size: 0.94rem; background: var(--surface); color: var(--ink); resize: vertical; }
.comm-reply textarea:focus-visible, .comm-reply textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.comm-reply-btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.comm-closed-note { background: var(--raise); border: 1px solid var(--border); border-radius: var(--radius, 8px); padding: 12px 14px; color: var(--ink-muted); font-size: 0.88rem; }

/* ---- Shared Communications form-control contrast (§11) ------------------ */
.comm-form-control, .comm-form select, .comm-form input[type="text"], .comm-form input[type="search"] {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-2, var(--border));
  border-radius: var(--radius, 8px);
  min-height: 44px;
  padding: 8px 12px;
  font-size: 0.92rem;
}
.comm-form-control:focus-visible, .comm-form select:focus-visible, .comm-form select:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
/* A selected value must never look like a faint placeholder/disabled control. */
.comm-form-control, .comm-form select { font-weight: 500; }
.comm-form-control::placeholder { color: var(--faint, var(--ink-muted)); font-weight: 400; }

/* ---- Mobile / tablet (§13): stack, keep touch targets >= ~44px --------- */
@media (max-width: 900px) {
  .comm-layout { grid-template-columns: 1fr; }
  .comm-message { max-width: 92%; }
  .ppl-row, .comm-ptag, .ppl-candidate-btn, .ppl-remove-btn, .comm-ptag-remove-btn,
  .addp-btn { min-height: 44px; }
}

/* =========================================================================
   v0.23.9 -- persistent mobile bottom navigation (brief §14/§15)
   =========================================================================

   Clocking is the most time-sensitive workflow SDIP has on a phone, and until
   v0.23.8 reaching it meant Dashboard -> Menu -> Time Clock -> Clock In / Out.
   This bar makes it a single tap from anywhere in the app for eligible staff.

   Deliberately phone-only: it appears at 820px and below, the same breakpoint
   core/device.py uses for post-login routing and the drawer uses to undock the
   sidebar, so "what the server thinks is mobile" and "what the browser renders"
   never disagree. On desktop the docked sidebar already does this job and the
   bar is display:none.

   Layout rules this must not break (brief §18): nothing here may cause
   horizontal scrolling at 360/390/430px, every target is >=44px, and the bar
   respects the iOS home-indicator inset via env(safe-area-inset-bottom). The
   matching bottom padding on .page below is what guarantees no page action is
   ever obscured by the bar itself. */

.mobile-bottom-nav { display: none; }

@media (max-width: 820px) {
  .mobile-bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 80;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
    /* Never a horizontal scroll source, whatever the item count. */
    max-width: 100%;
    overflow: hidden;
  }

  .mbn-item {
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 2px;
    border: 0;
    background: transparent;
    border-radius: 10px;
    color: var(--muted, #63706C);
    text-decoration: none;
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mbn-item .ui-icon { width: 22px; height: 22px; }

  .mbn-icon { position: relative; display: inline-flex; }

  .mbn-label {
    font-size: 11px;
    line-height: 1.1;
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mbn-item.active { color: var(--accent); background: var(--accent-soft, rgba(15, 122, 85, 0.10)); }

  /* Clocking is the prominent action, not merely another equal tab. */
  .mbn-item-primary { color: var(--accent); }
  .mbn-item-primary .ui-icon { width: 25px; height: 25px; stroke-width: 2; }

  /* Open session: called out with a live dot AND the label text ("Clock out"),
     never colour alone -- so the state is readable without relying on hue. */
  .mbn-live-dot {
    position: absolute;
    top: -3px; right: -4px;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--danger, #C2483A);
    border: 2px solid var(--surface);
  }
  .mbn-item-live { color: var(--danger, #C2483A); }
  .mbn-item-live.active { background: rgba(194, 72, 58, 0.12); }

  .mbn-badge {
    position: absolute;
    top: -6px; right: -8px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--danger, #C2483A);
    color: #fff;
    font-size: 10px; font-weight: 700; line-height: 16px;
    text-align: center;
  }

  /* Reserve the bar's own height (plus safe area) beneath page content so a
     Clock In / Clock Out button at the end of the page is never sitting
     underneath the bar (brief §18: "no action obscured by bottom navigation").
     The footer gets the same treatment for the same reason. */
  body .page { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  body .footer { margin-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
}

/* v0.23.9 -- Clock In / Out page mobile ergonomics (brief §18).
   Full-bleed card, full-width 56px+ actions, and a building list that stays
   usable with the on-screen keyboard up. */
@media (max-width: 820px) {
  .clock-card { max-width: none !important; width: 100%; }
  .clock-card .btn-lg { min-height: 56px; font-size: 1.05rem; }
  /* Cap the building list so the search field and the first few results are
     all visible above the on-screen keyboard rather than pushed off-screen. */
  .building-list { max-height: 46vh !important; }
  .building-option { min-height: 48px; display: flex !important; align-items: center; }
  /* 16px prevents iOS Safari zooming the viewport on focus, which is the usual
     cause of a sudden horizontal scrollbar on a phone. */
  #building-filter { font-size: 16px; }
}

/* The active-session summary must be readable without scrolling (brief §15). */
.clock-active-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  margin: 12px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2, rgba(0, 0, 0, 0.03));
}
.clock-active-summary .cas-site { font-weight: 700; font-size: 1.05rem; }
.clock-active-summary .cas-meta { color: var(--muted, #63706C); font-size: 0.9rem; }

@media (prefers-reduced-motion: reduce) {
  .mbn-item { transition: none; }
}

/* ======================================================================
   v0.11.0 CONSOLE FOUNDATION  —  redesign mockup 5, applied platform-wide
   ----------------------------------------------------------------------
   Purpose
   -------
   Mockup 5 ("SDIP Console") settles the visual direction: a flat, dense,
   evidence-first administrative console. This layer implements it.

   Method — deliberate, and the same one v0.10.2 used
   --------------------------------------------------
   It is appended LAST and works by (a) redefining the existing design
   tokens to the mockup's palette, which propagates through all ~2,290
   lines above without editing them, and (b) overriding the specific
   structural rules where the mockup's geometry genuinely differs.

   The alternative -- rewriting 40+ templates to the mockup's own class
   names (.panel/.tbl/.fld) -- was rejected: it would touch every module
   at once, including screens with test-guarded markup (register
   col-actions, settings quick-index, clients no-dialog), for no visual
   gain over restyling the classes those templates already use.

   Consequently NO template needs to change for a page to pick up the new
   look. Templates are updated only where the mockup adds real structure
   (a topbar search, an eyebrow, a live board). See
   docs/REDESIGN_PLAN_v0_11_0.md for the page-by-page state.

   Compatibility guarantees
   ------------------------
   - No business logic, route, permission, CSRF or audit behaviour.
   - v0.10.2's test-guarded rules are preserved, not replaced:
     `.btn { border-radius: var(--radius-sm); }` still resolves to a
     6px control (this layer only retunes padding/height), `.stat-card`
     stays de-bulked, `.filter-bar`/`.segmented` still exist, and
     `th.col-actions`/`td.col-actions .row-actions` are untouched.
   - Compact control heights remain scoped to `@media (pointer: fine)`,
     so the 44px touch-target minimum survives on phones and tablets --
     which matters more from here on, not less, because the Building
     Manager time clock (v0.12) is a touch-first screen.
   - Historical dead layers still are not deleted. That debt is unchanged
     and still recorded; this release does not make it worse, because
     everything here is additive and token-driven.

   Signature
   ---------
   Every duration, clock time, contract code and site number is set in
   IBM Plex Mono. In a platform whose entire job is time evidence, a
   duration is a data type, not prose -- it should line up in a column
   and read as a measurement. That is the one intentional flourish;
   everything else is deliberately quiet.
   ====================================================================== */

/* ----------------------------------------------------------------------
   1. Tokens
   Redefining these is what carries the new palette into every older
   rule above. Values are taken directly from mockup 5.
   ---------------------------------------------------------------------- */
:root {
  /* v0.12.0 light theme = "Sand — warm" (approved in redesign mockup 12.2).
     Warm, soft, low-contrast-but-not-flat page surfaces per brief §7.1.
     The brand green accent and the graphite sidebar are unchanged from
     v0.11.0 -- only the neutral bg/surface/text/border family warms up.
     Dark (graphite) is defined below in :root[data-theme="dark"], sharing
     these exact semantic token NAMES so there is one component structure,
     not two maintained interfaces (brief §7.3). */
  --bg: #EFEAE0;
  --surface: #F8F4EC;
  --surface-raised: #FFFFFF;     /* crisp lifted card on warm ground    */
  --raise: #F3EEE3;              /* recessed/secondary surface          */
  --ink: #2A2924;
  --ink-muted: #6D6959;
  --faint: #948F7C;              /* tertiary text, hints, captions      */
  --border: #DDD5C5;
  --line-2: #CBC2AC;             /* control borders (stronger)          */

  --accent: #12735B;             /* unchanged brand green               */
  --accent-dark: #0C5544;
  --accent-soft: #E2EEE7;

  /* --- Semantic status axis (brief §7.2) ------------------------------
     success / warning / danger / information as first-class named tokens.
     --alert is retained as the historical name for "warning" so existing
     rules keep working; --warning is the new semantic alias. */
  --success: #12735B;      --success-soft: #E2EEE7;
  --warning: #8F6516;      --warning-soft: #F1E7D2;
  --alert: #8F6516;        --alert-soft: #F1E7D2;   /* legacy alias of warning */
  --danger: #96382C;       --danger-soft: #EEDCD4;
  --info: #25708A;         --info-soft: #DDE9EC;

  /* --- Category axis (brief §7.2, redesign mockup 8.4) ----------------
     Category colour is a SEPARATE axis from status: solid filled block,
     white text, used to say "which kind of thing this is" -- never reused
     to mean severity. */
  --cat-reimbursement: #12735B;  /* green  */
  --cat-job:           #A85A28;  /* orange */
  --cat-other:         #25708A;  /* blue   */
  --cat-on: #FFFFFF;             /* text on a solid category block      */

  /* --- Interaction state tokens --------------------------------------- */
  --hover: rgba(18, 115, 91, 0.06);   /* row/control hover wash          */
  --selected: #E2EEE7;                /* selected row / active choice     */

  /* The sidebar is a flat near-black green, and STAYS graphite in both
     light and dark (brief §7 / mockup 12.2) -- it is the nav rail's own
     colour, deliberately not themed. */
  --sidebar: #12201C;
  --sidebar-ink: #C7D2CC;
  --sidebar-faint: #7E8E88;
  --sidebar-active: #183029;
  --sidebar-on: #5FCE9F;         /* active icon only -- used sparingly  */
  --sidebar-width: 236px;

  /* --- Spacing scale (brief §7.2) ------------------------------------- */
  --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-5: 24px; --space-6: 32px;

  --radius: 8px;                 /* containers                          */
  --radius-sm: 6px;              /* controls                            */
  --radius-lg: 12px;             /* large panels                        */

  /* --- Elevation: faint WARM-tinted shadow (mockup 12.2 note) --------- */
  --shadow-sm: 0 1px 2px rgba(74, 61, 32, 0.06);
  --shadow-md: 0 10px 28px rgba(74, 61, 32, 0.08);

  /* --- Table density tokens (brief §7.2) ------------------------------ */
  --table-row-h: 40px;
  --table-cell-py: 8px;
  --table-cell-px: 12px;

  /* --- Responsive breakpoint reference values (brief §7.2) ------------
     CSS @media rules can't consume custom properties, so these document
     the canonical breakpoints in one place and are mirrored by the real
     media queries below and the mobile-first component work. */
  --bp-mobile: 640px;
  --bp-tablet: 768px;
  --bp-desktop: 1024px;

  /* Brand yellow is retired as a UI accent. It stays defined so no
     older rule breaks, but it resolves to the amber warning colour --
     warm tones only ever mean "needs attention", never decoration. */
  --brand-yellow: #9A6212;
  --brand-yellow-soft: #FBF0DD;
  --brand-yellow-line: #E7D3AC;
  --brand-green: #12735B;
  --brand-green-mid: #12735B;
  --brand-green-deep: #0C5544;

  /* Categorical series for charts and share-by-site breakdowns.
     Deliberately not tints of the brand green -- these encode identity
     (which client, which category), not severity. */
  --k1: #E08A2B; --k2: #1F8FB0; --k3: #B5479A; --k4: #7C6FD6;
  --k5: #5A6570; --k6: #D0503A; --k7: #4A9E5F;

  --font-ui: "Inter", "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* ====================================================================
   v0.12.0 DARK THEME (graphite) -- redesign mockup 12.2.
   Higher specificity than :root (attribute selector) so it wins over the
   light defaults regardless of source order, which lets the console
   foundation layer remain the last component-override block. Sidebar
   tokens are intentionally NOT redefined here: the nav rail stays graphite
   in both themes. Only the page/surface/text/border/status/category
   neutrals flip. Accessible contrast preserved (ink #E9ECE8 on bg #171D1B,
   accent lightened to #28A67D for AA on dark).
   ==================================================================== */
:root[data-theme="dark"] {
  --bg: #171D1B;
  --surface: #212925;
  --surface-raised: #262F2A;
  --raise: #262F2A;
  --ink: #E9ECE8;
  --ink-muted: #9CA69E;
  --faint: #6E7871;
  --border: #333D37;
  --line-2: #414C44;

  --accent: #28A67D;
  --accent-dark: #7BE0BB;
  --accent-soft: #1C3A30;

  --success: #28A67D;  --success-soft: #1C3A30;
  --warning: #E0A64B;  --warning-soft: #3A2E14;
  --alert:   #E0A64B;  --alert-soft:   #3A2E14;
  --danger:  #E08573;  --danger-soft:  #3A211D;
  --info:    #6BB6D6;  --info-soft:    #1C3038;

  --cat-reimbursement: #28A67D;
  --cat-job:           #E08A4F;
  --cat-other:         #6BB6D6;

  --hover: rgba(255, 255, 255, 0.05);
  --selected: #1C3A30;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.45);
}

/* No-flash system-preference default: a user who has NOT explicitly chosen
   a theme (no data-theme attribute rendered by the server) gets their OS
   dark preference honoured at first paint, purely in CSS -- no JavaScript,
   so there is no wrong-theme flash while scripts load (brief §7.3). Once a
   user explicitly chooses, the server renders data-theme and :not([data-theme])
   simply stops matching. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #171D1B;
    --surface: #212925;
    --surface-raised: #262F2A;
    --raise: #262F2A;
    --ink: #E9ECE8;
    --ink-muted: #9CA69E;
    --faint: #6E7871;
    --border: #333D37;
    --line-2: #414C44;
    --accent: #28A67D;
    --accent-dark: #7BE0BB;
    --accent-soft: #1C3A30;
    --success: #28A67D;  --success-soft: #1C3A30;
    --warning: #E0A64B;  --warning-soft: #3A2E14;
    --alert:   #E0A64B;  --alert-soft:   #3A2E14;
    --danger:  #E08573;  --danger-soft:  #3A211D;
    --info:    #6BB6D6;  --info-soft:    #1C3038;
    --cat-reimbursement: #28A67D;
    --cat-job:           #E08A4F;
    --cat-other:         #6BB6D6;
    --hover: rgba(255, 255, 255, 0.05);
    --selected: #1C3A30;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.45);
  }
}

/* ----------------------------------------------------------------------
   2. Typography — a console scale, not a marketing scale
   ---------------------------------------------------------------------- */
body {
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1 { font-size: 19px; letter-spacing: -0.01em; }
h2 { font-size: 13.5px; letter-spacing: 0; }
h3 { font-size: 12.5px; }
.muted { color: var(--ink-muted); }
.hint { font-size: 12px; color: var(--ink-muted); }
small { font-size: 11.5px; }

/* Numerals: tabular everywhere, so figures in a column line up even in
   the UI face. The mono class remains the explicit opt-in for durations
   and codes. */
body { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 3px;
}

/* ----------------------------------------------------------------------
   3. Sidebar — flat, quiet, one line per module
   The existing markup keeps its <small> description for every link.
   The mockup drops them: at 236px they wrap, and after a week of use
   nobody is reading "Clockify & time data" under "Time Evidence".
   Hidden rather than deleted from the template, so it is one line to
   bring back and no Jinja changes.
   ---------------------------------------------------------------------- */
.app-shell { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }

.app-sidebar {
  background: var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: none;
  color: var(--sidebar-ink);
}

.side-brand { padding: 16px 18px 14px; gap: 10px; }
.side-brand .brand-logo {
  width: 30px;
  height: 30px;
}
.side-brand .brand-mark { font-size: 14px; font-weight: 600; letter-spacing: 0; }
.side-brand .brand-sub { font-size: 11px; color: var(--sidebar-faint); }

.side-nav { gap: 1px; padding: 6px 10px 20px; }

.side-section,
.app-sidebar .side-section-toggle {
  margin: 14px 10px 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--sidebar-faint);
}
.side-section::after { display: none; }   /* drop the trailing hairline */

.side-link {
  grid-template-columns: 15px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 0;
  color: var(--sidebar-ink);
  font-size: 13px;
  transition: background 0.12s ease;
}
.side-link strong { font-size: 13px; font-weight: 400; }
.side-link small { display: none; }

.side-icon {
  width: 15px;
  height: 15px;
  border: 0;
  background: none;
  border-radius: 0;
  color: inherit;
  opacity: 0.85;
}
.side-icon .ui-icon { width: 15px; height: 15px; }

.side-link:hover { background: #182B25; transform: none; }
.side-link.active {
  background: var(--sidebar-active);
  color: #FFFFFF;
  border-color: transparent;
  box-shadow: none;
}
.side-link.active strong { font-weight: 600; }
.side-link.active .side-icon { background: none; color: var(--sidebar-on); opacity: 1; }

/* ----------------------------------------------------------------------
   4. Topbar — 52px, a real search slot, quieter identity block
   ---------------------------------------------------------------------- */
.app-main .topbar {
  min-height: 52px;
  padding: 8px 22px;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
}
.app-main .topbar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0;
}

/* Global search. Progressive: the input is a plain GET form, so it works
   with keyboard and without JavaScript. */
.topbar-search {
  flex: 1;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  color: var(--faint);
}
.topbar-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar-search input {
  border: 0;
  background: transparent;
  outline: 0;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  width: 100%;
  min-width: 0;
  padding: 0;
}
.topbar-search .ui-icon { width: 14px; height: 14px; flex: none; }

.topbar-user { gap: 10px; }
.user-avatar {
  width: 28px;
  height: 28px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent);
  color: #FFFFFF;
  border: 0;
}
.user-chip { font-size: 13px; font-weight: 600; line-height: 1.15; }
.user-chip small { font-size: 11px; font-weight: 400; color: var(--ink-muted); }
.topbar-link, .app-main .topbar .nav-link-btn { font-size: 13px; color: var(--ink-muted); font-weight: 400; }

/* ----------------------------------------------------------------------
   5. Page canvas
   ---------------------------------------------------------------------- */
.page { max-width: 1180px; padding: 20px 22px 40px; }
.page-wide, .page.wide { max-width: 1320px; }
.footer { max-width: 1180px; padding-top: 14px; font-size: 11.5px; color: var(--faint); }

.page-head { margin-bottom: 16px; gap: 16px; }
.page-head h1 { font-size: 19px; }
.page-head .muted { font-size: 12.5px; color: var(--ink-muted); }
.page-head-actions { gap: 8px; flex-shrink: 0; }

/* The gradient dashboard hero is retired. The dashboard's first element
   is now the board itself; a decorative banner above real operational
   data was pushing it below the fold. */
.dashboard-hero {
  min-height: 0;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
}
.dashboard-hero .eyebrow { color: var(--accent); }
.dashboard-hero .muted { color: var(--ink-muted); }
/* v0.12.0 fix: the hero lost its dark gradient background in the v0.11.0
   console redesign (it is now flat, `color: inherit`), but a leftover rule
   from the old gradient hero still forced the heading white -- so the title
   was white-on-light and effectively invisible (a latent v0.11.0 defect the
   test suite never checked for). Bring the heading back to normal ink. The
   whole hero is replaced by the operational dashboard in the Phase-2 rebuild;
   this keeps it readable in the meantime. */
.dashboard-hero h1 { color: var(--ink); }

/* ----------------------------------------------------------------------
   6. Buttons
   Radius stays at --radius-sm (v0.10.2's guarded rule); this only
   retunes size, weight and the hover treatment.
   ---------------------------------------------------------------------- */
.btn {
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  gap: 6px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
  line-height: 1.2;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--surface); box-shadow: none; transform: none; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #FFFFFF; }
.btn-danger { background: var(--surface); border-color: var(--line-2); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-ghost, .btn-quiet { border-color: transparent; background: transparent; color: var(--ink-muted); }
.btn-ghost:hover, .btn-quiet:hover { background: var(--bg); color: var(--ink); border-color: transparent; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (pointer: fine) {
  .btn { min-height: 32px; padding: 6px 13px; }
  .btn-sm { min-height: 28px; padding: 4px 10px; font-size: 12.5px; }
}

/* ----------------------------------------------------------------------
   7. Cards become panels
   Mockup 5's `.panel` is a bordered container with a distinct header
   strip. Rather than rename anything, `.card` is restyled to be that
   container, and `.card-head-row` becomes the header strip. Templates
   already using `.card` + `.card-head-row` get the panel treatment with
   no edit at all.
   ---------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: none;
}
.card h2 { font-size: 13.5px; font-weight: 600; margin: 0 0 4px; }
.card-head-row, .card-head-inline {
  padding: 0 0 10px;
  margin: 0 0 12px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 10px;
}
.card-head-row .muted, .card-head-inline .muted { font-size: 12px; }

/* An explicit panel primitive for new markup, matching the mockup
   exactly. Existing `.card` pages do not need it. */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; }
.panel-h {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.panel-h h2 { font-size: 13.5px; margin: 0; }
.panel-h .hint { color: var(--ink-muted); font-size: 12px; font-weight: 400; margin: 0; }
.panel-h .spacer { flex: 1; }
.panel-b { padding: 14px 16px; }
.panel-b > :last-child { margin-bottom: 0; }
.panel-foot {
  padding: 11px 16px;
  background: var(--raise);
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--ink-muted);
}
/* A panel whose body is a table sits flush -- no double padding. */
.panel > .data-table, .panel > table { margin: 0; }

/* ----------------------------------------------------------------------
   8. Metric strip
   The mockup replaces free-floating KPI tiles with one joined strip:
   hairline-separated cells in a single bordered container. It reads as
   one instrument panel rather than four competing cards, and it costs
   about a third of the vertical space.

   `.stat-grid` is restyled into that strip, so every existing page with
   a stat grid inherits it. `.stat-grid-compact` and the alert variant
   keep working.
   ---------------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}
.stat-grid-compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

.stat-card {
  background: var(--surface);
  border: 0;
  border-radius: 0;
  min-height: 0;
  padding: 12px 14px;
  box-shadow: none;
  display: block;
}
.stat-card::after { content: none; }
.stat-card:hover { box-shadow: none; transform: none; }
.stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.15;
}
.stat-label { display: block; font-size: 11.5px; color: var(--ink-muted); font-weight: 400; text-transform: none; letter-spacing: 0; margin-top: 1px; }
.stat-card small, .stat-note { display: block; color: var(--faint); font-size: 10.5px; margin-top: 3px; }

a.stat-card-link { color: inherit; text-decoration: none; }
a.stat-card-link:hover { background: var(--raise); text-decoration: none; }
a.stat-card-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Alert state: the figure carries the colour, not a decorative bar. */
.stat-card-alert { background: var(--surface); }
.stat-card-alert::after { content: none; }
.stat-card-alert .stat-value { color: var(--alert); }
.stat-card-danger .stat-value { color: var(--danger); }

/* ----------------------------------------------------------------------
   9. Attention list
   The dashboard's "needs attention" items read better as rows with a
   count chip than as tiles -- a count plus a sentence plus a
   destination is a list, not a metric.
   ---------------------------------------------------------------------- */
.att {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.att:last-of-type { border-bottom: 0; }
.att:hover { background: var(--raise); text-decoration: none; }
.att:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.att-count {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  background: var(--alert-soft);
  color: var(--alert);
}
.att-count.is-critical { background: var(--danger-soft); color: var(--danger); }
.att-text { flex: 1; min-width: 0; }
.att-text b { font-weight: 600; }
.att-text .s { color: var(--ink-muted); font-size: 12px; }
.att-go { color: var(--ink-muted); font-size: 12.5px; flex: none; }
.att-clear, .attention-all-clear {
  padding: 11px 16px;
  color: var(--ink-muted);
  font-size: 12.5px;
  background: var(--raise);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ----------------------------------------------------------------------
   10. Tables
   ---------------------------------------------------------------------- */
.data-table, .register-table, table.tbl { font-size: 12.5px; border-collapse: collapse; width: 100%; }
.data-table th, .register-table th, table.tbl th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  background: none;
}
.data-table td, .register-table td, table.tbl td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td, table.tbl tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover, .register-table tbody tr:hover { background: var(--raise); }
.data-table-compact td { padding: 6px 10px; }

/* Right-align numeric columns without an inline style on every cell --
   this replaces the residual inline `text-align:right` noted as debt in
   v0.10.2's release notes. */
.data-table th.num, .data-table td.num,
.register-table th.num, .register-table td.num,
table.tbl th.r, table.tbl td.r { text-align: right; }
td.num, .num-cell { font-family: var(--font-mono); }

.empty-row, .register-empty-state { color: var(--ink-muted); font-size: 12.5px; }

/* Row that navigates. Kept as a real anchor in the markup for keyboard
   and middle-click; this only supplies the affordance. */
.rowlink { cursor: pointer; }
.rowlink:hover { background: var(--raise); }
.rowlink:focus-within { background: var(--raise); outline: 2px solid var(--accent); outline-offset: -2px; }

/* ----------------------------------------------------------------------
   11. Badges and pills
   Pills stay pills here -- a status badge is one of the two places
   v0.10.2 explicitly reserved --radius-pill for.
   ---------------------------------------------------------------------- */
.badge, .pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.badge-active, .badge-status-active, .pill.ok { background: var(--accent-soft); color: var(--accent-dark); border: 0; }
.badge-inactive, .badge-status-inactive, .pill.off { background: var(--bg); color: var(--ink-muted); border: 1px solid var(--line-2); }
.badge-alert, .badge-warn, .badge-warning, .badge-delivery-over { background: var(--alert-soft); color: var(--alert); border: 0; }
.badge-danger, .badge-delivery-under { background: var(--danger-soft); color: var(--danger); border: 0; }

/* ----------------------------------------------------------------------
   12. Forms
   ---------------------------------------------------------------------- */
.form label, .fld label { font-size: 12px; font-weight: 600; color: var(--ink); }
.form input, .form select, .form textarea,
.fld input, .fld select, .fld textarea,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"],
input[type="search"], select, textarea {
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
/* v0.15.4: the native calendar/clock picker icon (Chrome/Edge's
   ::-webkit-calendar-picker-indicator) renders as a dark glyph by
   default, effectively invisible against the dark theme's dark input
   background. Invert it in dark mode only -- light mode's icon is
   already legible on its light input surface. */
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.4);
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-help, .fld .help { font-size: 11.5px; color: var(--faint); }
.field-error { color: var(--danger); font-size: 11.5px; }
.required-mark, .fld .req { color: var(--danger); }

/* Section-per-block dedicated forms, matching the mockup's .form-sec. */
.form-section, .form-sec {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.form-section:last-of-type, .form-sec:last-of-type { border-bottom: 0; }
.form-subheading, .form-sec .sh { font-size: 12.5px; font-weight: 600; margin: 0 0 2px; }
.form-section-note, .form-sec .sd { color: var(--ink-muted); font-size: 12px; margin: 0 0 13px; }

/* Action bar pinned to the bottom of a dedicated form. */
.form-page-actions, .action-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  background: var(--raise);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}
.form-page-actions .spacer, .action-bar .spacer { flex: 1; }

@media (pointer: fine) {
  input, select, textarea { min-height: 34px; }
  textarea { min-height: 64px; }
}

/* ----------------------------------------------------------------------
   13. Filter bar / segmented / text tabs — retuned to the console scale
   ---------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 12px;
  border: 0;
  background: none;
}
.filter-bar-spacer { flex: 1; }
.filter-bar label { font-size: 12px; color: var(--ink-muted); font-weight: 500; }

.segmented, .seg2 {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.segmented > *, .seg2 > * {
  appearance: none;
  background: var(--surface);
  border: 0;
  border-right: 1px solid var(--line-2);
  color: var(--ink-muted);
  font: inherit;
  font-size: 12.5px;
  padding: 5px 12px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}
.segmented > :last-child, .seg2 > :last-child { border-right: 0; }
.segmented > :hover, .seg2 > :hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.segmented > .is-active, .segmented > .active, .seg2 > .is-active, .seg2 > .on {
  background: var(--accent);
  color: #FFFFFF;
}
@media (pointer: coarse) {
  .segmented > *, .seg2 > * { min-height: 44px; display: inline-flex; align-items: center; }
}

.text-tabs { border-bottom: 1px solid var(--border); gap: 16px; }
.text-tabs a { font-size: 12.5px; padding: 7px 0; color: var(--ink-muted); }
.text-tabs a.is-active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* Period stepper: ‹ Last week › */
.navbtn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  cursor: pointer;
  line-height: 1;
}
.navbtn:hover { border-color: var(--accent); color: var(--accent-dark); }
.period-label { font-size: 12.5px; color: var(--ink-muted); }

/* ----------------------------------------------------------------------
   14. Live status
   A quietly pulsing dot means "this figure is currently moving". Used
   for in-progress sessions and the sync freshness chip. It is the only
   animation in the system, and it stops under reduced-motion.
   ---------------------------------------------------------------------- */
.synced {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-muted);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  padding: 4px 11px;
}
.synced.is-stale { border-color: var(--alert); color: var(--alert); background: var(--alert-soft); }
.synced.is-failed { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }

.dot-live {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #1F9E5F;
  display: inline-block;
  animation: sdip-live-pulse 2s infinite;
}
.dot-live.is-idle { background: var(--line-2); animation: none; }
.dot-live.is-stale { background: var(--alert); animation: none; }
.dot-live.is-failed { background: var(--danger); animation: none; }
@keyframes sdip-live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(31, 158, 95, 0.45); }
  70%  { box-shadow: 0 0 0 6px rgba(31, 158, 95, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 158, 95, 0); }
}
.livecell { display: inline-flex; align-items: center; gap: 8px; }
.live-tbl td { padding: 9px 12px; }

/* ----------------------------------------------------------------------
   15. Evidence breakdown — total, stacked bars, share donut
   Used by the staff/site/service detail screens.
   ---------------------------------------------------------------------- */
.detail-total {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
}
.detail-total .big { font-size: 20px; font-weight: 600; font-family: var(--font-mono); }
.detail-total .lbl { color: var(--ink-muted); font-size: 12px; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 200px;
  padding: 20px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.bcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; height: 100%; }
.btot { font-size: 10.5px; color: var(--ink-muted); font-weight: 600; font-family: var(--font-mono); }
.bar { width: 62%; max-width: 46px; display: flex; flex-direction: column; border-radius: 3px 3px 0 0; overflow: hidden; }
.bar span { display: block; width: 100%; }
.blab { font-size: 10.5px; color: var(--faint); white-space: nowrap; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 250px; }
.split > .split-main { border-right: 1px solid var(--border); min-width: 0; }

.donut-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px 16px; gap: 6px; }
.donut { width: 168px; height: 168px; border-radius: 50%; position: relative; }
.donut .hole {
  position: absolute;
  inset: 30px;
  background: var(--surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
}
.swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 8px; vertical-align: -1px; }
.seg-n {
  display: inline-flex;
  min-width: 17px;
  height: 17px;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  font-size: 10px;
  color: var(--ink-muted);
  margin-right: 9px;
  font-family: var(--font-mono);
}

/* ----------------------------------------------------------------------
   16. Collapsible disclosure (optional form sections, import panels)
   ---------------------------------------------------------------------- */
details.coll, details.collapsible-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 10px;
}
details.coll > summary, details.collapsible-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
details.coll > summary::-webkit-details-marker,
details.collapsible-section > summary::-webkit-details-marker { display: none; }
details.coll > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
details.coll > summary .chev { color: var(--ink-muted); transition: transform 0.15s ease; }
details.coll[open] > summary .chev { transform: rotate(90deg); }
details.coll > summary .opt { margin-left: auto; color: var(--faint); font-weight: 400; font-size: 11.5px; }
details.coll .cbody { padding: 4px 12px 14px; }

/* ----------------------------------------------------------------------
   17. Flash messages — narrower, quieter
   ---------------------------------------------------------------------- */
.flash {
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  box-shadow: none;
}
.flash-success { background: var(--accent-soft); color: var(--accent-dark); border-color: transparent; }
.flash-error, .flash-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.flash-warning { background: var(--alert-soft); color: var(--alert); border-color: transparent; }

/* ----------------------------------------------------------------------
   18. Time clock (v0.12 forward-compatibility)
   These classes are defined here so the clock screens ship into an
   existing design system rather than inventing one. Nothing renders
   them until the feature is built; they add ~1.5KB and no coupling.

   Sizing is deliberately touch-first: the clock is used one-handed, on
   site, sometimes in gloves. Targets are 48px+ and NOT reduced under
   `pointer: fine`, because a supervisor on a laptop pressing the same
   button benefits from the same certainty.
   ---------------------------------------------------------------------- */
.clock-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 16px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.clock-elapsed {
  font-family: var(--font-mono);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.clock-elapsed.is-idle { color: var(--faint); }
.clock-context { font-size: 13px; color: var(--ink-muted); text-align: center; }
.clock-context strong { color: var(--ink); font-weight: 600; }

.clock-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #FFFFFF;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.clock-action:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.clock-action[data-state="running"] { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.clock-action[data-state="running"]:hover { background: var(--danger-soft); }
.clock-action:disabled { background: var(--bg); color: var(--faint); border-color: var(--border); cursor: not-allowed; }

/* Offline / queued state. The clock must work with no signal in a
   basement plant room, so a queued punch is a first-class state with
   its own visible treatment -- never a silent failure. */
.clock-queued {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  background: var(--alert-soft);
  color: var(--alert);
  font-size: 12.5px;
}

/* Site picker: large, thumb-reachable rows, most-likely site first. */
.site-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  margin-bottom: 8px;
}
.site-choice:hover, .site-choice:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.site-choice .code { font-family: var(--font-mono); color: var(--ink-muted); font-size: 12.5px; }
.site-choice .why { margin-left: auto; font-size: 11.5px; color: var(--faint); }

/* Timesheet correction row: what was clocked vs what it was changed to,
   always both, because a correction is evidence too (Article I). */
.correction-row { display: grid; gap: 2px; }
.correction-row .was { font-size: 11.5px; color: var(--faint); text-decoration: line-through; font-family: var(--font-mono); }
.correction-row .now { font-family: var(--font-mono); }
.correction-flag { font-size: 11px; color: var(--alert); }

/* ----------------------------------------------------------------------
   19. Responsive
   ---------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .split > .split-main { border-right: 0; border-bottom: 1px solid var(--border); }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { position: relative; height: auto; }
  .app-main .topbar { flex-wrap: wrap; padding: 8px 16px; }
  .topbar-search { order: 3; max-width: none; flex-basis: 100%; }
  .page { padding: 16px; }
  .chart { height: 150px; }
}

@media (max-width: 640px) {
  .stat-grid, .stat-grid-compact { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .page-head-actions { width: 100%; }
  .user-chip { display: none; }
  .clock-elapsed { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .dot-live { animation: none; }
}

/* Print: strip the shell, keep the evidence. Bookkeepers do print
   payroll cases and delivery reports. */
@media print {
  .app-sidebar, .topbar, .footer, .filter-bar, .page-head-actions, .btn { display: none !important; }
  .app-shell { display: block; }
  .page { max-width: none; padding: 0; }
  .card, .panel { border-color: #999; break-inside: avoid; }
}

/* ==========================================================================
   Leave & replacement cover (v0.12.0 §12). Token-driven so it flips with the
   theme like every other rebuilt Phase 2 surface — no hardcoded canvas/ink.
   ========================================================================== */
.ta-right { text-align: right; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.tabs { display: flex; gap: 4px; margin: 0 0 16px; flex-wrap: wrap; }
.radio-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); cursor: pointer;
}
/* Inside a .form, `.form label { display:flex; flex-direction:column }` would
   otherwise stack the radio above the text and stretch it full width; keep the
   pill a row filling its .form-row grid cell (same technique as .checkbox-pill). */
.form-row .radio-pill { flex-direction: row; align-items: center; }
.form .radio-pill { color: var(--ink); font-weight: 500; }
/* `.form input` boxes text/select/file controls; a radio inside a pill must
   stay a native control, not a bordered box. */
.form .radio-pill input[type="radio"] {
  padding: 0; border: 0; background: transparent;
  min-width: 0; width: auto; outline: none;
}
.radio-pill:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft);
}

.leave-cert {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin: 12px 0;
}
.leave-cert legend { padding: 0 6px; color: var(--ink-muted); font-size: 0.85rem; }
.leave-action-forms, .leave-backup-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.leave-backup-form select, .leave-backup-form input { min-width: 0; }

.leave-cal-controls { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 0 14px; }
.leave-cal-scroll { overflow-x: auto; }
.leave-cal { table-layout: fixed; }
.leave-cal-name { text-align: left; white-space: nowrap; }
.leave-cal-day { width: 34px; text-align: center; font-size: 0.72rem; color: var(--ink-muted); line-height: 1.1; }
.leave-cell { height: 26px; padding: 2px !important; border: 1px solid var(--border); }
/* Colour = leave type; solid fill = backup confirmed. */
.leave-annual   { background: var(--success-soft); border-left: 3px solid var(--success); }
.leave-sick     { background: var(--warning-soft); border-left: 3px solid var(--warning); }
.leave-other    { background: var(--info-soft);    border-left: 3px solid var(--info); }
/* tinted + dashed = cover not yet confirmed. */
.leave-uncovered { border: 1px dashed var(--border-strong) !important; opacity: 0.55; }

.leave-legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 12px 0 0; color: var(--ink-muted); font-size: 0.82rem; }
.leave-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.leave-swatch { width: 16px; height: 16px; border-radius: 3px; display: inline-block; border: 1px solid var(--border); }
.leave-swatch.leave-annual { background: var(--success-soft); border-left: 3px solid var(--success); }
.leave-swatch.leave-sick   { background: var(--warning-soft); border-left: 3px solid var(--warning); }
.leave-swatch.leave-other  { background: var(--info-soft);    border-left: 3px solid var(--info); }
.leave-swatch.leave-uncovered { background: transparent; border: 1px dashed var(--border-strong); opacity: 0.7; }

/* v0.16.0 Leave Executive Planning View ------------------------------- */
.leave-view-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.leave-filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 12px 16px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 14px; }
.leave-filter-bar .fld { display: flex; flex-direction: column; gap: 4px; }
.leave-filter-bar label.fld-label { font-size: 0.76rem; color: var(--ink-muted); font-weight: 500; }
.leave-filter-bar .fld-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.leave-cal-day.leave-holiday, .leave-cal-name.leave-holiday { background: var(--warning-soft); }

.leave-month-grid { display: flex; flex-direction: column; gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.leave-month-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); }
.leave-month-dow > div { background: var(--bg); text-align: center; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted); padding: 6px 0; }
.leave-month-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); }
.leave-month-day { background: var(--surface); min-height: 96px; padding: 6px; position: relative; }
.leave-month-day.leave-outside { background: var(--bg); }
.leave-month-day.leave-holiday { background: var(--warning-soft); }
.leave-month-daynum { font-size: 0.78rem; font-weight: 600; color: var(--ink-muted); margin-bottom: 3px; }
.leave-month-holiday-label { font-size: 0.68rem; color: var(--warning); font-weight: 600; margin-bottom: 3px; }
.leave-month-chip { display: block; font-size: 0.7rem; padding: 1px 5px; border-radius: 3px;
  margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leave-month-chip.leave-annual { background: var(--success-soft); color: var(--success); border-left: 2px solid var(--success); }
.leave-month-chip.leave-sick   { background: var(--warning-soft); color: var(--warning); border-left: 2px solid var(--warning); }
.leave-month-chip.leave-other  { background: var(--info-soft);    color: var(--info);    border-left: 2px solid var(--info); }
.leave-month-chip.leave-uncovered { border-style: dashed; opacity: 0.8; }
.leave-month-more { font-size: 0.68rem; color: var(--ink-muted); }

/* ==========================================================================
   Navigation shell (v0.13.0). The desktop/laptop sidebar is always expanded
   and stable -- there is no desktop collapse control (removed as a customer-
   side correction). A conventional menu button appears only at tablet/mobile
   widths, in the standard top-left of the top bar (never over the brand), and
   opens the sidebar as an off-canvas drawer.
   ========================================================================== */
.nav-drawer-toggle {
  display: none;                       /* desktop: no menu control at all */
  align-items: center; justify-content: center;
  width: 36px; height: 36px; flex: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm, 8px);
  background: var(--bg); color: var(--ink); cursor: pointer;
}
.nav-drawer-toggle:hover { background: var(--hover); }
.nav-drawer-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-drawer-toggle svg { width: 18px; height: 18px; }
.nav-drawer-backdrop { display: none; }
.drawer-account { display: none; }

/* Deterministic mobile/tablet header height so the drawer can sit cleanly
   below it. Row 1 (controls) + row 2 (search). */
:root { --mobile-header-h: 98px; }

@media (max-width: 1180px) {
  /* --- Fixed two-row header: [menu | title | compact actions] then [search].
     Nothing wraps into or above the drawer any more. --- */
  .app-main .topbar {
    position: sticky; top: 0; z-index: 70;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "menu title actions" "search search search";
    align-items: center;
    column-gap: 10px; row-gap: 8px;
    min-height: var(--mobile-header-h);
    padding: 8px 14px;
    background: var(--surface);
    flex-wrap: nowrap;
  }
  .nav-drawer-toggle { display: inline-flex; grid-area: menu; }
  .app-main .topbar-title {
    grid-area: title; align-self: center;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .topbar-user { grid-area: actions; gap: 8px; flex-wrap: nowrap; width: auto; justify-content: flex-end; }
  .topbar-search {
    grid-area: search; order: 0;
    max-width: none; width: 100%; flex: none; margin: 0;
  }
  /* Essential compact actions only in the header; identity, Help and logout
     move into the drawer's account block. */
  .topbar-user .user-avatar,
  .topbar-user .user-chip,
  .topbar-user .topbar-link,
  .topbar-user > form.inline-form:last-child { display: none; }

  /* --- Drawer sits BELOW the fixed header, full remaining height --- */
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed; top: var(--mobile-header-h); left: 0; z-index: 60;
    height: calc(100dvh - var(--mobile-header-h));
    width: var(--sidebar-width); max-width: 86vw;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  body.nav-open .app-sidebar { transform: translateX(0); box-shadow: 0 18px 50px rgba(0,0,0,0.35); }
  .side-nav { display: flex; flex-direction: column; }
  .side-section { grid-column: auto; }

  /* Complete page backdrop below the header while open, and lock body scroll. */
  body.nav-open { overflow: hidden; }
  body.nav-open .nav-drawer-backdrop {
    display: block; position: fixed;
    top: var(--mobile-header-h); left: 0; right: 0; bottom: 0; z-index: 55;
    background: rgba(10, 20, 17, 0.5);
  }

  /* Account block visible only inside the drawer at this width. */
  .drawer-account {
    display: block; margin-top: auto;
    padding: 14px; border-top: 1px solid var(--border);
  }
  .drawer-account-id { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
  .drawer-account-name { display: flex; flex-direction: column; font-size: 0.9rem; color: var(--sidebar-ink, var(--ink)); }
  .drawer-account-name small { color: var(--sidebar-faint, var(--ink-muted)); }
}

@media print {
  .nav-drawer-toggle, .nav-drawer-backdrop { display: none !important; }
}


/* ============================================================================
   v0.18.0 -- Responsive Register Foundation
   First controlled phase of the SDIP responsive interface refresh (brief
   section 5). Restrained, reusable component set for register-style pages,
   used initially by the Work Orders and Messages registers only. Built
   entirely on the existing v0.12.0 Sand/Graphite design tokens: the
   bg/surface/ink/border/accent/success/warning/danger/info colour tokens,
   the space scale, and the radius and shadow tokens. No new colours, no
   remote fonts, no page-specific hardcoded values. Nothing here redefines
   a selector any non-redesigned page depends on; this is purely additive.
   ============================================================================ */

.page-heading-group { display: flex; flex-direction: column; gap: 6px; min-width: 280px; flex: 1; }
.page-heading { margin: 0; font-size: clamp(1.35rem, 2vw, 1.75rem); font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.page-description { margin: 0; font-size: 0.92rem; color: var(--ink-muted); }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-heading-row { display: flex; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 18px; }

.register-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.register-toolbar-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.register-toolbar-spacer { flex: 1 1 auto; min-width: 8px; }
.register-toolbar-search { display: flex; align-items: center; gap: 8px; }
.register-search-input {
  height: 34px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 0.86rem; min-width: 220px; font-family: var(--font-ui);
}
.register-search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--radius-pill, 1000px); border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); font-size: 0.82rem; font-weight: 600; text-decoration: none;
  white-space: nowrap; transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.filter-chip:hover { border-color: var(--accent); text-decoration: none; color: var(--ink); }
.filter-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.filter-chip .filter-count { color: var(--ink-muted); font-weight: 700; }
.filter-chip--active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-chip--active:hover { color: #fff; }
.filter-chip--active .filter-count { color: rgba(255, 255, 255, 0.78); }
.filter-chip--warning { border-color: var(--warning); color: var(--warning); background: var(--warning-soft); }
.filter-chip--warning .filter-count { color: var(--warning); }

.advanced-filter-panel { position: relative; }
.advanced-filter-panel > summary { list-style: none; cursor: pointer; }
.advanced-filter-panel > summary::-webkit-details-marker { display: none; }
.advanced-filter-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 260px;
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.advanced-filter-body label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; font-weight: 600; color: var(--ink-muted); }
.advanced-filter-body select { padding: 7px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font-family: var(--font-ui); min-height: 36px; }
.advanced-filter-body .page-actions { justify-content: flex-end; }

.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill, 1000px); font-size: 0.78rem; font-weight: 800; white-space: nowrap; }
.status-badge--open { background: var(--warning-soft); color: var(--warning); }
.status-badge--progress { background: var(--info-soft); color: var(--info); }
.status-badge--done { background: var(--bg); color: var(--ink-muted); border: 1px solid var(--border); }
.status-badge--danger { background: var(--danger-soft); color: var(--danger); }
.status-badge--neutral { background: var(--accent-soft); color: var(--accent-dark); }

.priority-indicator { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; font-weight: 700; color: var(--ink); white-space: nowrap; }
.priority-indicator .priority-dot { width: 8px; height: 8px; border-radius: var(--radius-pill, 1000px); display: inline-block; flex: none; }
.priority-indicator--high { color: var(--danger); }
.priority-indicator--high .priority-dot { background: var(--danger); }
.priority-indicator--normal .priority-dot { background: var(--info); }
.priority-indicator--low { color: var(--ink-muted); font-weight: 600; }
.priority-indicator--low .priority-dot { background: var(--faint); }

.responsive-register { border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); overflow: hidden; }
.responsive-register table { width: 100%; border-collapse: collapse; }
.register-header th { text-align: left; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); padding: 11px 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
.register-row td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.register-row:last-child td { border-bottom: none; }
.register-row:hover td { background: var(--hover); }
.register-row:focus-within td { background: var(--hover); }
.register-row-link { color: inherit; text-decoration: none; display: block; }
.register-row-link:hover { text-decoration: none; color: inherit; }
.register-row-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.record-primary { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.record-primary-title { font-size: 0.92rem; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.record-secondary { font-size: 0.78rem; color: var(--ink-muted); }
.record-meta { font-size: 0.72rem; color: var(--faint); }
.record-tablet-only { display: none; }

.monospace-reference { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 700; color: var(--accent-dark); }

/* Mobile card list -- hidden by default (desktop/tablet show the table
   instead); shown only below --bp-tablet (see media query below). Rendered
   from the SAME data as the table (no separate query, no separate
   permission check) so mobile never shows more or less than desktop. */
.mobile-register-list { display: none; list-style: none; margin: 0; padding: 0; flex-direction: column; gap: 10px; }
.mobile-record-card { display: flex; flex-direction: column; gap: 9px; padding: 13px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.mobile-record-card-top { display: flex; align-items: center; gap: 8px; }
.mobile-record-card-title { font-size: 0.94rem; font-weight: 800; color: var(--ink); line-height: 1.3; }
.mobile-record-card-sub { font-size: 0.76rem; font-weight: 600; color: var(--ink-muted); }
.mobile-record-card-foot { display: flex; align-items: center; gap: 10px; padding-top: 9px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.mobile-record-card-link { color: inherit; text-decoration: none; display: block; }
.mobile-record-card-link:hover { text-decoration: none; color: inherit; }
.mobile-record-card-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.mobile-record-card-open { font-size: 0.78rem; font-weight: 700; color: var(--accent-dark); }

.empty-state, .no-results-state {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 48px 24px; color: var(--ink-muted); border: 1px dashed var(--border);
  border-radius: var(--radius-lg); background: var(--surface);
}
.empty-state-title, .no-results-state-title { font-size: 1rem; font-weight: 700; color: var(--ink); }

.pagination-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--bg); font-size: 0.82rem; color: var(--ink-muted); flex-wrap: wrap; }

.primary-action, .secondary-action {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm); font-size: 0.86rem; font-weight: 700; text-decoration: none;
  border: 1px solid transparent; min-height: 38px;
}
.primary-action { background: var(--accent); color: #fff; }
.primary-action:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }
.primary-action:focus-visible, .secondary-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.secondary-action { background: var(--surface); border-color: var(--border); color: var(--ink); }
.secondary-action:hover { border-color: var(--accent); text-decoration: none; color: var(--ink); }

/* ---- Responsive breakpoints (mirrors --bp-tablet / --bp-desktop) ---------- */
@media (max-width: 1023px) {
  .register-col-tablet-hide { display: none; }
  .record-tablet-only { display: block; }
}
@media (max-width: 767px) {
  .responsive-register { display: none; }
  .mobile-register-list { display: flex; }
  .register-toolbar { align-items: stretch; }
  .register-toolbar-search { width: 100%; }
  .register-search-input { width: 100%; min-width: 0; }
  .advanced-filter-body { left: 0; right: auto; min-width: 0; width: 100%; }
  .filter-chip, .primary-action, .secondary-action { min-height: 44px; }
  .page-heading-row { align-items: flex-start; }
}
@media (min-width: 768px) {
  .mobile-register-list { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .filter-chip, .primary-action, .secondary-action, .register-row-link, .mobile-record-card-link { transition: none; }
}

/* v0.23.10 -- Users register (brief §12).
   The register is read-only now, so it no longer has to accommodate inputs in
   cells. These rules keep Edit reachable without horizontal scrolling at a
   normal desktop width, which was one of the two host findings. */
.users-register td, .users-register th { vertical-align: middle; }
.users-register .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.users-register .nowrap { white-space: nowrap; }
.users-register .btn-sm + .btn-sm { margin-left: 6px; }

/* v0.23.11 -- reversal reason (brief §24). The administrator states why, not
   just that a reversal happened, so the history answers the one question it
   cannot reconstruct later. */
.reverse-form { display: flex; gap: 6px; align-items: center; }
.reverse-reason-input { min-width: 190px; font: inherit; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ------------------------------------------------------------------ */
/* v0.23.15 — Contract delivery progress (brief §8, §9)                */
/*                                                                     */
/* Every colour here is an existing semantic token. Nothing is a raw    */
/* hex value copied from the mock-up, and no state is communicated by   */
/* colour alone — each has a glyph and a word beside it in the markup.  */
/* Both themes are inherited automatically because the tokens are.      */
/* ------------------------------------------------------------------ */
.delivery-progress-card { padding: 20px; margin-bottom: 20px; }

.delivery-progress-head {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.delivery-progress-head h2 { margin: 0; }
.delivery-period-state { font-size: 0.85rem; }

.delivery-progress-figures {
  display: grid;
  grid-template-columns: minmax(140px, auto) 1fr auto;
  gap: 18px; align-items: center; margin-bottom: 16px;
}
.delivery-pct-value { display: block; font-size: 2.4rem; line-height: 1.1; font-weight: 600; }
.delivery-pct-label { display: block; font-size: 0.8rem; color: var(--ink-muted); }
.delivery-headline { margin: 0; font-size: 1.05rem; font-weight: 600; }
.delivery-subline { margin: 4px 0 0; font-size: 0.9rem; }
.delivery-status-note { margin: 6px 0 0; font-size: 0.82rem; max-width: 34ch; }

.delivery-progress-track {
  position: relative; height: 22px; border-radius: 11px;
  background: var(--bg-alt, var(--bg)); border: 1px solid var(--border);
  overflow: hidden;   /* brief §8.8: the fill can never escape the track */
}
.delivery-progress-fill { height: 100%; border-radius: 11px 0 0 11px; transition: width .2s ease; }
.delivery-progress-on-track { background: var(--accent); }
.delivery-progress-under    { background: var(--danger); }
.delivery-progress-over     { background: var(--alert); }

.delivery-progress-scale {
  display: flex; justify-content: space-between;
  font-size: 0.78rem; color: var(--ink-muted); margin-top: 6px;
}
.delivery-overage { margin: 10px 0 0; font-size: 0.85rem; }
.delivery-no-target { padding: 4px 0; }
.delivery-no-target .delivery-subline { margin-bottom: 6px; }

/* brief §9: purpose-built narrow layout, not a shrunken desktop one. The
   percentage, the actual/required figures and the remaining hours all stay
   readable, and nothing scrolls sideways. */
@media (max-width: 720px) {
  .delivery-progress-card { padding: 16px; }
  .delivery-progress-figures { grid-template-columns: 1fr; gap: 10px; }
  .delivery-pct-value { font-size: 2rem; }
  .delivery-status-note { max-width: none; }
  .delivery-progress-scale { font-size: 0.72rem; }
  .delivery-progress-scale .delivery-scale-end { text-align: right; }
}

/* ------------------------------------------------------------------
   Labour reconciliation row states (v0.23.18)

   v0.23.17 retired the "ready to reconcile" status, which left the page
   styling every row with `row-muted if not row.reconcilable` -- and since
   `reconcilable` is now always false, the rows an administrator most needs
   to act on were the ones drawn as inactive. `.row-muted` was also never
   actually defined here, so "muted" was an intention rather than a style.

   Both states are now explicit, and both use existing semantic tokens so
   they follow the light/dark theme without a second set of values.

   .row-needs-rate  an actionable row: enter the historical rate, tick, confirm
   .row-muted       genuinely nothing to do here (not hourly, voided)
   ------------------------------------------------------------------ */
tbody tr.row-needs-rate > td {
  background: var(--warning-soft);
}
tbody tr.row-needs-rate > td:first-child {
  box-shadow: inset 3px 0 0 0 var(--warning);
}
tbody tr.row-muted > td {
  color: var(--ink-muted);
  opacity: 0.72;
}
