/* Surity design system (PLAN P10 §M10.2). Custom CSS, no framework.

   Brand: Surity forest green (#004000 → #4B8434 gradient) with the lime
   accent (#C5F388), Poppins headings (as on surity.co.za), Inter body text,
   pill-shaped controls, soft glass surfaces, subtle borders.

   Colour tokens are defined once per theme and nowhere else — components only
   ever use var(--…). Every text/background pair the components use is checked
   against WCAG AA by tests/Design/DesignTokenContrastTest.php, which reads
   this file; if you add a token pair, add it to that test. The dark palette is
   recomputed, not inverted: lime (not dark green) carries links and active
   states on dark surfaces, the sample theme's failure we deliberately avoid.

   Theme resolution (PLAN M0.4): data-theme on <html> wins; with no attribute
   (JS disabled + THEME_DEFAULT=auto) the prefers-color-scheme block applies.
   The two dark blocks must stay identical — the contrast test enforces it. */

/* ------------------------------------------------------------------ tokens */

:root {
  --bg: #f2f5f0;
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.82);
  --surface-alt: #edf2ea;
  --surface-sunken: #e5ece2;
  --text: #142019;
  --text-muted: #546158;
  --border: #d5dfd1;
  --border-input: #7d937a;
  --primary: #004000;
  --primary-end: #4b8434;
  --primary-hover: #003300;
  --primary-hover-end: #3f7230;
  --on-primary: #ffffff;
  --primary-soft: #e2edde;
  --on-primary-soft: #0d3f0d;
  --link: #2a6a1e;
  --accent: #c5f388;
  --on-accent: #142a00;
  --whatsapp: #25d366;
  --on-whatsapp: #062814;
  --success: #1d6b38;
  --success-soft: #dcefe1;
  --warning: #5e2ca5;
  --warning-soft: #efe6fb;
  --danger: #b3263c;
  --danger-soft: #fbe4e7;
  --info: #1d5b86;
  --info-soft: #e0eef8;
  --topbar-start: #002a00;
  --topbar-end: #1d4f1d;
  --on-topbar: #f1f7ee;
  --on-topbar-muted: #bcd2b6;
  --focus-ring: 0 0 0 3px rgba(0, 64, 0, 0.25);
  --shadow-sm: 0 1px 2px rgba(16, 40, 16, 0.06);
  --shadow: 0 1px 2px rgba(16, 40, 16, 0.05), 0 8px 24px -12px rgba(16, 40, 16, 0.18);
  --shadow-lg: 0 24px 48px -16px rgba(16, 40, 16, 0.28);
  --page-glow: radial-gradient(1200px 520px at 8% -10%, rgba(75, 132, 52, 0.14), transparent 60%),
               radial-gradient(900px 420px at 100% 0%, rgba(197, 243, 136, 0.18), transparent 55%);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23142019' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0c130e;
  --surface: #131c16;
  --surface-glass: rgba(19, 28, 22, 0.84);
  --surface-alt: #1a261d;
  --surface-sunken: #0f1711;
  --text: #e4ece5;
  --text-muted: #9aab9e;
  --border: #263529;
  --border-input: #5a725e;
  --primary: #1f5c1f;
  --primary-end: #4b8434;
  --primary-hover: #2a6a2a;
  --primary-hover-end: #3f7230;
  --on-primary: #ffffff;
  --primary-soft: #1e3322;
  --on-primary-soft: #c5f388;
  --link: #b0e27a;
  --accent: #c5f388;
  --on-accent: #142a00;
  --whatsapp: #25d366;
  --on-whatsapp: #062814;
  --success: #74d394;
  --success-soft: #173022;
  --warning: #c9a7ff;
  --warning-soft: #2a1d40;
  --danger: #ff8b9b;
  --danger-soft: #3a1a20;
  --info: #8ac6f0;
  --info-soft: #142a3a;
  --topbar-start: #071209;
  --topbar-end: #133a16;
  --on-topbar: #f1f7ee;
  --on-topbar-muted: #b2c8ad;
  --focus-ring: 0 0 0 3px rgba(197, 243, 136, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, 0.7);
  --page-glow: radial-gradient(1200px 520px at 8% -10%, rgba(75, 132, 52, 0.20), transparent 60%),
               radial-gradient(900px 420px at 100% 0%, rgba(197, 243, 136, 0.06), transparent 55%);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23e4ece5' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0c130e;
    --surface: #131c16;
    --surface-glass: rgba(19, 28, 22, 0.84);
    --surface-alt: #1a261d;
    --surface-sunken: #0f1711;
    --text: #e4ece5;
    --text-muted: #9aab9e;
    --border: #263529;
    --border-input: #5a725e;
    --primary: #1f5c1f;
    --primary-end: #4b8434;
    --primary-hover: #2a6a2a;
    --primary-hover-end: #3f7230;
    --on-primary: #ffffff;
    --primary-soft: #1e3322;
    --on-primary-soft: #c5f388;
    --link: #b0e27a;
    --accent: #c5f388;
    --on-accent: #142a00;
    --whatsapp: #25d366;
    --on-whatsapp: #062814;
    --success: #74d394;
    --success-soft: #173022;
    --warning: #c9a7ff;
    --warning-soft: #2a1d40;
    --danger: #ff8b9b;
    --danger-soft: #3a1a20;
    --info: #8ac6f0;
    --info-soft: #142a3a;
    --topbar-start: #071209;
    --topbar-end: #133a16;
    --on-topbar: #f1f7ee;
    --on-topbar-muted: #b2c8ad;
    --focus-ring: 0 0 0 3px rgba(197, 243, 136, 0.35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, 0.7);
    --page-glow: radial-gradient(1200px 520px at 8% -10%, rgba(75, 132, 52, 0.20), transparent 60%),
                 radial-gradient(900px 420px at 100% 0%, rgba(197, 243, 136, 0.06), transparent 55%);
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23e4ece5' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

/* Theme-independent scales. */
:root {
  --font-body: "Inter Variable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: "Poppins", var(--font-body);
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 1.25rem;
  --radius-sm: 0.75rem;
  --radius-pill: 999px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-end));
  --gradient-primary-hover: linear-gradient(135deg, var(--primary-hover), var(--primary-hover-end));
  --sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 62%);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* -------------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  background: var(--page-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }

p { margin: 0 0 0.75em; }

a { color: var(--link); text-decoration: none; text-underline-offset: 0.18em; }
a:hover { text-decoration: underline; }
/* A link inside running text needs more than colour to stand out (WCAG
   1.4.1, axe link-in-text-block) — PLAN P10 §M10.6. */
:where(p, dd, .alert, .help-text, .auth-footer) a:not(.btn):not(.chip):not(.nav-link) { text-decoration: underline; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-5) 0; }

code, kbd { font-size: 0.9em; background: var(--surface-alt); border-radius: 0.4rem; padding: 0.1em 0.35em; }

.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ layout shell */
/* PLAN P10 §M10.3. .has-shell: dark-green sidebar (fixed on desktop, a
   slide-in drawer under 960px) + light topbar with breadcrumbs.
   .no-shell (login, sign-up, share links, 2FA challenge): one dark bar. */

:root { --sidebar-width: 252px; --topbar-height: 60px; }

.skip-link { position: absolute; left: -999px; top: 0.5rem; z-index: 100; background: var(--surface); color: var(--text); padding: 0.5rem 1rem; border-radius: var(--radius-pill); }
.skip-link:focus { left: 0.5rem; }

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--topbar-start), var(--topbar-end));
  color: var(--on-topbar);
  z-index: 40;
  overflow-y: auto;
}
.app-sidebar .app-brand { padding: 1.1rem 1.25rem 0.9rem; }
.app-brand { display: inline-flex; align-items: center; flex: none; }
.app-brand img { height: 32px; width: auto; display: block; }

.side-nav { flex: 1; padding: 0.25rem 0.75rem 1rem; }
.nav-group + .nav-group { margin-top: 0.35rem; }
.nav-group ul, ul.nav-group { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.1rem; }
ul.nav-group-plain { margin-bottom: 0.5rem; }
/* PLAN P31 §M31.2 (Surity, 2026-11-10): a section's items sit indented under its heading, on a faint guide line. */
details.nav-group > ul { padding: 0.15rem 0 0.4rem 0.6rem; margin-left: 1.1rem; border-left: 1px solid rgba(255, 255, 255, 0.14); }

/* Accordion section headings (owner feedback on M10.3): icon at 1.5x in the
   brand accent, chevron turns when open. <summary> is natively a button. */
.nav-group-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-topbar-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.nav-group-label::-webkit-details-marker { display: none; }
.nav-group-label:hover { color: var(--on-topbar); background: rgba(255, 255, 255, 0.06); }
.nav-group-label:focus-visible { box-shadow: 0 0 0 3px rgba(197, 243, 136, 0.45); }
.nav-group-icon { font-size: 1.5em; width: 1.6rem; text-align: center; color: var(--accent); }
.nav-group-chevron { margin-left: auto; font-size: 0.7rem; transition: transform 0.2s var(--ease); }
details[open] > .nav-group-label { color: var(--on-topbar); }
details[open] > .nav-group-label .nav-group-chevron { transform: rotate(180deg); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-pill);
  color: var(--on-topbar-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.app-sidebar .nav-link { color: var(--on-topbar-muted); }
.nav-link i { width: 1.1rem; text-align: center; opacity: 0.9; }
.app-sidebar .nav-link:hover { background: rgba(255, 255, 255, 0.08); color: var(--on-topbar); text-decoration: none; }
.app-sidebar .nav-link.active { background: var(--accent); color: var(--on-accent); }
.app-sidebar .nav-link:focus-visible { box-shadow: 0 0 0 3px rgba(197, 243, 136, 0.45); border-radius: var(--radius-pill); }
/* PLAN P21 §M21.5: "Customise menu" under the menu, and the eye toggles on the profile page. */
.nav-customise { display: flex; align-items: center; gap: 0.5rem; margin-top: var(--space-3); padding: 0.4rem 0.75rem; border-radius: var(--radius-pill); font-size: 0.78rem; color: var(--on-topbar-muted); }
.nav-customise:hover { color: var(--on-topbar); background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.nav-customise:focus-visible { box-shadow: 0 0 0 3px rgba(197, 243, 136, 0.45); }
.eye-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: var(--space-2); }
.eye-toggle { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-pill); cursor: pointer; }
.eye-toggle.is-fixed { cursor: default; }
.eye-toggle:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.eye-toggle .eye-off { display: none; }
.eye-toggle:has(input:not(:checked)) { color: var(--text-muted); border-style: dashed; }
.eye-toggle:has(input:not(:checked)) .eye-on { display: none; }
.eye-toggle:has(input:not(:checked)) .eye-off { display: inline-block; }

.sidebar-footer { padding: 0.75rem; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.sidebar-user { display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem; border-radius: var(--radius-sm); color: var(--on-topbar); min-width: 0; }
.app-sidebar .sidebar-user { color: var(--on-topbar); }
.app-sidebar .sidebar-user:hover { background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.avatar { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 0.85rem; }
.sidebar-user-text { display: grid; min-width: 0; line-height: 1.3; }
.sidebar-user-email { font-size: 0.82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 0.74rem; color: var(--on-topbar-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.has-shell .app-main { margin-left: var(--sidebar-width); min-height: 100vh; }

.app-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--topbar-height);
  padding: 0.5rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid var(--border);
}
.no-shell .app-topbar {
  justify-content: space-between;
  background: linear-gradient(120deg, var(--topbar-start), var(--topbar-end));
  border-bottom: 0;
  color: var(--on-topbar);
}
.no-shell .app-topbar .muted { color: var(--on-topbar-muted); }
.no-shell .app-topbar .btn, .no-shell .app-topbar .icon-btn { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.28); color: var(--on-topbar); }
.no-shell .app-topbar .btn:hover, .no-shell .app-topbar .icon-btn:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.5); color: var(--on-topbar); }

.app-topbar-actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

.icon-btn {
  position: relative;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.icon-btn:hover { border-color: var(--link); color: var(--link); text-decoration: none; }
.icon-btn:focus-visible { border-radius: var(--radius-pill); }
.icon-badge {
  position: absolute;
  top: -0.3rem;
  right: -0.35rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: var(--surface);
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
}
/* PLAN P31 §M31.1 (Surity, 2026-11-10): the bell has to catch the eye — bigger,
   and red with a pulsing glow while anything is unread (steady glow with
   reduced motion: the motion block below stops the animation). */
.bell-btn { width: 2.75rem; height: 2.75rem; font-size: 1.2rem; }
.bell-btn .icon-badge { top: -0.25rem; right: -0.3rem; min-width: 1.3rem; height: 1.3rem; line-height: 1.3rem; font-size: 0.72rem; }
.bell-btn.has-unread { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); box-shadow: 0 0 0.5rem 0.1rem color-mix(in srgb, var(--danger) 45%, transparent); animation: bell-glow 1.8s ease-in-out infinite; }
.bell-btn.has-unread:hover { color: var(--danger); border-color: var(--danger); }
.bell-btn.has-unread .fa-bell { animation: bell-ring 3.6s ease-in-out infinite; transform-origin: 50% 0; }
@keyframes bell-glow {
  0%, 100% { box-shadow: 0 0 0.35rem 0.05rem color-mix(in srgb, var(--danger) 35%, transparent); }
  50% { box-shadow: 0 0 1rem 0.35rem color-mix(in srgb, var(--danger) 65%, transparent); }
}
@keyframes bell-ring {
  0%, 80%, 100% { transform: rotate(0); }
  84% { transform: rotate(14deg); }
  88% { transform: rotate(-12deg); }
  92% { transform: rotate(8deg); }
  96% { transform: rotate(-4deg); }
}
.sidebar-toggle { display: none; }
/* PLAN P31 §M31.4: the company Surity is looking at, under a list's title. */
.company-scope { margin: 0.35rem 0 0; font-size: 0.9rem; color: var(--text-muted); }
.company-scope strong { color: var(--text); }

.breadcrumbs { min-width: 0; }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; font-size: 0.87rem; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--text-muted); min-width: 0; }
.breadcrumbs li + li::before { content: "\f054"; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 0.6rem; opacity: 0.7; }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--link); }
.breadcrumbs [aria-current="page"] { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }

.sidebar-backdrop { position: fixed; inset: 0; background: rgba(6, 16, 8, 0.5); z-index: 35; }

@media (max-width: 960px) {
  .app-sidebar { transform: translateX(-100%); transition: transform 0.22s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar-open .app-sidebar { transform: none; }
  .has-shell .app-main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .app-topbar { padding: 0.5rem 1rem; }
}

.app-container { max-width: 1200px; margin: 0 auto; padding: var(--space-5) 1.5rem 3rem; }
.app-container > * + * { margin-top: var(--space-5); }
.app-container > .page-header + .tabs { margin-top: var(--space-4); }

/* Section tabs (facility workspace). Scroll sideways on a phone rather than wrap. */
.tabs { display: flex; gap: 0.25rem; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid var(--border); padding-bottom: 0; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; } /* still swipe-scrollable on a phone */
.tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--link); text-decoration: none; }
.tab.active { color: var(--link); border-bottom-color: var(--link); font-weight: 600; }

/* Page header: title (+ optional subtitle) on the left, primary actions on the right. */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-4); }
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--text-muted); margin: 0.2rem 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Small layout helpers so templates don't need inline styles. */
.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.cluster-end { justify-content: flex-end; }
.split { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.narrow { max-width: 560px; }
.narrow-sm { max-width: 420px; }
.narrow-lg { max-width: 720px; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-5);
}
.card + .card { margin-top: var(--space-5); }
.card > :last-child { margin-bottom: 0; }
.card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-header h2, .card-header h3 { margin: 0; }

/* Key/value facts on detail pages. */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: var(--space-3) var(--space-4); margin: 0; }
.facts dt { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.facts dd { margin: 0.15rem 0 0; overflow-wrap: anywhere; }
.facts dd .btn { white-space: normal; text-align: left; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid var(--border-input);
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 1.05rem;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
}
.btn:hover { text-decoration: none; border-color: var(--link); color: var(--link); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--radius-pill); }
.btn:disabled, .btn.disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary {
  background: var(--sheen), var(--gradient-primary);
  border-color: transparent;
  color: var(--on-primary);
}
.btn-primary:hover { background: var(--sheen), var(--gradient-primary-hover); border-color: transparent; color: var(--on-primary); }

.btn-accent { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn-accent:hover { background: var(--accent); border-color: transparent; color: var(--on-accent); filter: brightness(1.04); }

.btn-danger { border-color: var(--danger); color: var(--danger); background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--primary-soft); border-color: transparent; color: var(--on-primary-soft); }
/* WhatsApp's own green, for "send by WhatsApp" only (document share PIN). */
.btn-whatsapp { background: var(--whatsapp); border-color: var(--whatsapp); color: var(--on-whatsapp); }
.btn-whatsapp:hover { background: color-mix(in srgb, var(--whatsapp) 85%, var(--on-whatsapp)); border-color: transparent; color: var(--on-whatsapp); }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.82rem; }
.btn-lg { padding: 0.7rem 1.4rem; font-size: 1rem; }
.btn-block { display: flex; width: 100%; }

/* Forms posting a single button (delete/approve) sit inline with sibling buttons. */
form.inline { display: inline; }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  background: var(--surface-alt);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge-primary { background: var(--primary-soft); color: var(--on-primary-soft); }
.badge-accent  { background: var(--accent); color: var(--on-accent); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-info    { background: var(--info-soft); color: var(--info); }

/* ---------------------------------------------------------------- alerts */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--primary-soft);
  color: var(--on-primary-soft);
}
.alert > i { margin-top: 0.2rem; }
.alert p:last-child { margin-bottom: 0; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert-danger  { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-info    { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }

.flash-stack { display: grid; gap: var(--space-2); }

/* ----------------------------------------------------------------- forms */

label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: 0.88rem; }

input, select, textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-pill);
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
textarea { border-radius: var(--radius-sm); min-height: 6rem; resize: vertical; }
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 0.85rem;
  padding-right: 2.5rem;
}
select[multiple] { border-radius: var(--radius-sm); background-image: none; padding-right: 1rem; }
input[type="file"] { border-radius: var(--radius-sm); padding: 0.45rem; }
input[type="color"] { width: 5.5rem; height: 2.75rem; padding: 0.3rem; border-radius: var(--radius-sm); cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 0.45rem; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 0.45rem; }
input[type="file"]::file-selector-button {
  font: inherit; font-size: 0.85rem; border: 0; border-radius: var(--radius-pill);
  background: var(--primary-soft); color: var(--on-primary-soft); padding: 0.35rem 0.9rem; margin-right: 0.75rem; cursor: pointer;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 0.85; }

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--link); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-alt); color: var(--text-muted); cursor: not-allowed; }

/* Checkboxes/radios sit inline with their label text, not stretched full-width. */
input[type="checkbox"], input[type="radio"] {
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  margin: 0 0.5rem 0 0;
  vertical-align: middle;
  accent-color: var(--primary-end);
  box-shadow: none;
}

[aria-invalid="true"] { border-color: var(--danger); }
[aria-invalid="true"]:focus { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }

/* Rows from the Surity form theme (templates/form/surity_layout.html.twig). */
.form-row { margin-bottom: var(--space-4); }
.form-row.form-check { display: flex; flex-wrap: wrap; align-items: center; }
.form-row.form-check > label { display: inline; margin: 0; font-weight: 500; }
.form-row.form-check > .form-errors, .form-row.form-check > .help-text { flex-basis: 100%; }
.form-row > div > input[type="radio"] + label,
.form-row > div > input[type="checkbox"] + label { display: inline; font-weight: 500; margin-right: var(--space-4); }
/* An expanded choice with one option per line (owner, 2026-11-05: the service desk priorities). */
.form-row > div.choice-stack { display: grid; grid-template-columns: auto 1fr; align-items: center; row-gap: var(--space-2); }
.form-row > div.choice-stack > input + label { margin-right: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-5); }
.help-text { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.3rem; }
.form-errors { list-style: none; margin: 0 0 0.35rem; padding: 0; color: var(--danger); font-size: 0.84rem; font-weight: 500; }
.form-errors li::before { content: "\f06a"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: 0.35rem; }

/* ---------------------------------------------------------------- tables */

table.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }

table.data-table th,
table.data-table td { padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }

table.data-table thead th {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom-color: var(--border);
}
table.data-table .text-right { text-align: right; }
table.data-table thead th:first-child { border-top-left-radius: var(--radius-sm); }
table.data-table thead th:last-child { border-top-right-radius: var(--radius-sm); }
/* A heading row between groups of rows (PLAN P21 §M21.3: documents by category). */
/* PLAN P31 §M31.13: DataTables' sort, filter and pages, in the design tokens. */
.dt-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin: 0 0 var(--space-3); }
.table-wrap + .dt-controls { margin: var(--space-3) 0 0; }
.dt-controls .dt-layout-cell { display: flex; align-items: center; gap: var(--space-2); }
.dt-controls .dt-layout-cell:empty { display: none; }
.dt-controls label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; margin: 0; }
.dt-search { display: flex; align-items: center; gap: var(--space-2); }
.dt-search input { width: 16rem; max-width: 60vw; }
.dt-length { display: flex; align-items: center; gap: var(--space-2); }
.dt-length select { width: auto; }
.dt-info { font-size: 0.85rem; color: var(--text-muted); }
.dt-paging nav { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.dt-paging .dt-paging-button {
  min-width: 2.2rem; padding: 0.35rem 0.65rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.85rem; cursor: pointer;
}
.dt-paging .dt-paging-button:hover:not(.disabled):not(.current) { border-color: var(--primary); color: var(--link); }
.dt-paging .dt-paging-button.current { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.dt-paging .dt-paging-button.disabled { opacity: 0.5; cursor: default; }
.dt-paging .ellipsis { padding: 0.35rem 0.25rem; color: var(--text-muted); }
table.data-table thead th.dt-orderable-asc, table.data-table thead th.dt-orderable-desc { cursor: pointer; }
table.data-table thead th.dt-orderable-asc:hover, table.data-table thead th.dt-orderable-desc:hover { color: var(--link); }
table.data-table thead th .dt-column-order { color: inherit; }
table.data-table td.dt-empty { color: var(--text-muted); text-align: left; }
@media (max-width: 720px) { .dt-controls { flex-direction: column; align-items: stretch; } .dt-search input { width: 100%; max-width: none; } }
table.data-table .group-row th { padding-top: var(--space-4); font-size: 0.95rem; font-weight: 600; color: var(--text); border-bottom: 2px solid var(--border); }
table.data-table tbody tr { transition: background 0.12s var(--ease); }
table.data-table tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
table.data-table tbody tr:last-child td { border-bottom: 0; }

/* Wide tables scroll inside their card instead of stretching the page on phones. */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
/* ui.js makes a wrap that actually scrolls focusable, so it can be scrolled
   from the keyboard (axe scrollable-region-focusable). */
.table-wrap:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* DataTables 2 skin — its stylesheet still loads first, this re-colours it and
   lays the controls out as one wrapping row (length left, search right). */
.dt-container { color: var(--text); font-size: 0.9rem; }
.dt-container .dt-layout-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin: var(--space-3) 0; }
.dt-container .dt-layout-row.dt-layout-table { display: block; }
.dt-container .dt-layout-cell { display: block; padding: 0; }
.dt-container .dt-search input,
.dt-container .dt-length select { width: auto; display: inline-block; padding-top: 0.35rem; padding-bottom: 0.35rem; }
.dt-container .dt-search input { margin-left: 0.5rem; min-width: 14rem; }
.dt-container .dt-length select { margin-right: 0.4rem; }
.dt-container .dt-search label, .dt-container .dt-length label { display: inline; font-weight: 500; color: var(--text-muted); }
.dt-container .dt-info { color: var(--text-muted); }
.dt-container .dt-paging .dt-paging-button {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-pill) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  margin-left: 0.25rem;
  padding: 0.3rem 0.8rem !important;
}
.dt-container .dt-paging .dt-paging-button:hover:not(.disabled) { border-color: var(--link) !important; color: var(--link) !important; }
.dt-container .dt-paging .dt-paging-button.current { background: var(--gradient-primary) !important; border-color: transparent !important; color: var(--on-primary) !important; }
.dt-container .dt-paging .dt-paging-button.disabled { opacity: 0.45; }
.dt-container .dt-buttons .dt-button {
  background: var(--surface) !important;
  border: 1px solid var(--border-input) !important;
  border-radius: var(--radius-pill) !important;
  color: var(--text) !important;
  font-size: 0.85rem;
}
.dt-container .dt-buttons .dt-button:hover:not(.disabled) { border-color: var(--link) !important; color: var(--link) !important; }
table.dataTable > thead > tr > th, table.dataTable > thead > tr > td { border-bottom: 1px solid var(--border); }
table.dataTable > tbody > tr > * { box-shadow: none !important; }
table.dataTable.no-footer { border-bottom: 0; }

/* ------------------------------------------------------- SweetAlert2 skin */
/* Buttons come from the Swal mixin in js/ui.js (btn / btn-primary classes). */

.swal2-popup.surity-swal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
}
.surity-swal .swal2-title { font-family: var(--font-heading); font-weight: 600; font-size: 1.25rem; color: var(--text); }
.surity-swal .swal2-html-container { color: var(--text-muted); font-size: 0.95rem; }
.surity-swal .swal2-actions { gap: var(--space-2); }
.surity-swal .swal2-icon.swal2-warning { border-color: var(--warning); color: var(--warning); }
.surity-swal .swal2-icon.swal2-success { border-color: var(--success); color: var(--success); }
.surity-swal .swal2-icon.swal2-success [class^="swal2-success-line"] { background-color: var(--success); }
.surity-swal .swal2-icon.swal2-success .swal2-success-ring { border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.surity-swal .swal2-icon.swal2-error { border-color: var(--danger); color: var(--danger); }
.surity-swal .swal2-icon.swal2-error [class^="swal2-x-mark-line"] { background-color: var(--danger); }
.surity-swal .swal2-icon.swal2-info, .surity-swal .swal2-icon.swal2-question { border-color: var(--info); color: var(--info); }
.swal2-container.swal2-backdrop-show { background: rgba(6, 16, 8, 0.55); }
.surity-swal .swal2-success-circular-line-left,
.surity-swal .swal2-success-circular-line-right,
.surity-swal .swal2-success-fix { background-color: var(--surface) !important; }

/* ----------------------------------------------------------- empty states */

.empty-state { text-align: center; padding: var(--space-6) var(--space-4); color: var(--text-muted); }
.empty-state img { width: 160px; height: auto; margin: 0 auto var(--space-4); display: block; opacity: 0.95; }
.empty-state h3 { color: var(--text); }

/* -------------------------------------------------------------- motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .btn:hover, .btn:active { transform: none; }
}

/* ---------------------------------------------------------- small screens */

@media (max-width: 720px) {
  .app-container { padding: var(--space-4) 1rem 2.5rem; }
  .card { padding: var(--space-4); }
  h1 { font-size: 1.35rem; }
  .breadcrumbs li:not(:first-child):not(:last-child) { display: none; }
}

/* M10.3 tweaks */
.page-actions form { display: inline; }
.facts code { word-break: break-all; }

/* Home (PLAN P10 §M10.3): welcome banner + one tile per menu area. */
.welcome { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); overflow: hidden; }
.welcome > img { width: 200px; height: auto; flex: none; margin: -0.5rem -0.5rem -1.5rem 0; }
/* PLAN P31 §M31.12: a company's logo, on the same white plate as the sidebar's. */
.welcome-logo { flex: none; background: #ffffff; border-radius: var(--radius); padding: var(--space-3) var(--space-4); display: flex; align-items: center; justify-content: center; }
.welcome-logo img { display: block; max-width: 240px; max-height: 120px; width: auto; height: auto; }
.welcome h1 { font-size: 1.9rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; font-weight: 600; color: var(--link); margin-bottom: 0.3rem; }
.section-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: var(--space-3); }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-3); }
.tile {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease);
}
.tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--link); }
.tile-icon { flex: none; width: 2.5rem; height: 2.5rem; border-radius: 0.8rem; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--on-primary-soft); font-size: 1.05rem; }
.tile-text { display: grid; gap: 0.15rem; }
/* PLAN P32 §M32.4: New incident on Home. */
.tile-danger { border-color: var(--danger); }
.tile-danger:hover { border-color: var(--danger); }
.tile-danger .tile-icon { background: var(--danger-soft); color: var(--danger); }
.tile-text .muted { font-size: 0.85rem; }
@media (max-width: 720px) { .welcome > img, .welcome-logo { display: none; } }

/* Profile (PLAN P10 §M10.3a) */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-xl { width: 5rem; height: 5rem; font-size: 2rem; }
.app-sidebar .sidebar-user.active { background: rgba(255, 255, 255, 0.1); }
.sidebar-user-go { margin-left: auto; font-size: 0.7rem; color: var(--on-topbar-muted); }
.client-logo { background: #ffffff; border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; margin-bottom: 0.6rem; display: flex; justify-content: center; }
.client-logo img { max-width: 100%; max-height: 44px; display: block; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--space-5); align-items: stretch; }
.profile-grid > .card + .card { margin-top: 0; }
.media-row { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-4); }
.logo-preview { flex: none; width: 10rem; height: 5rem; display: flex; align-items: center; justify-content: center; background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem; }
.logo-preview img { max-width: 100%; max-height: 100%; }
.logo-preview .muted { color: #546158; font-size: 0.85rem; }

/* Filter bars above lists (audit log, …) */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); margin: var(--space-4) 0; }
.filter-bar > div { min-width: 10rem; }
.filter-bar label { margin-bottom: 0.25rem; }
.filter-actions { display: flex; gap: var(--space-2); min-width: 0 !important; }
.module-icon { color: var(--link); }

/* Dashboard (PLAN P10 §M10.3a): equal KPI tiles + charts */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--space-3); }
.kpi {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: var(--space-3); align-items: center;
  min-height: 6.5rem; padding: var(--space-4);
  background: var(--surface-glass); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease);
}
a.kpi:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--link); }
.kpi-icon { grid-row: 1 / 3; width: 2.75rem; height: 2.75rem; border-radius: 0.9rem; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--on-primary-soft); font-size: 1.1rem; }
.kpi-value { font-family: var(--font-heading); font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.kpi-label { font-size: 0.82rem; color: var(--text-muted); }
.kpi-danger .kpi-icon { background: var(--danger-soft); color: var(--danger); }
.kpi-warning .kpi-icon { background: var(--warning-soft); color: var(--warning); }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--space-5); }
.chart-grid > .card + .card { margin-top: 0; }
.chart-wide { grid-column: 1 / -1; }
.chart-box { position: relative; height: 260px; }

/* Facility photos (PLAN P10 §M10.4) */
.gallery-label { font-size: 0.9rem; margin: var(--space-4) 0 var(--space-2); }
.gallery-label:first-of-type { margin-top: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-2); }
.gallery-item { display: block; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-alt); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s var(--ease); }
.gallery-item:hover img { transform: scale(1.04); }
/* PLAN P31 §M31.15: a form in a pop-up (the share form's new contact). */
.modal { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); background: var(--surface); color: var(--text); width: min(92vw, 36rem); max-height: 90vh; overflow: auto; }
.modal::backdrop { background: rgba(6, 16, 8, 0.6); }
.quick-contact-btn { margin-left: var(--space-2); vertical-align: middle; }
.lightbox { border: 0; padding: 0; background: transparent; max-width: min(92vw, 1400px); max-height: 92vh; overflow: visible; }
.lightbox::backdrop { background: rgba(6, 16, 8, 0.85); }
.lightbox img { display: block; max-width: 100%; max-height: 84vh; border-radius: var(--radius-sm); margin: 0 auto; }
.lightbox-caption { color: #f1f7ee; text-align: center; margin: var(--space-2) 0 0; }
.lightbox-close { position: absolute; top: -0.75rem; right: -0.75rem; }

/* Form sections (PLAN P10 §M10.4) */
.form-section { border: 0; margin: 0 0 var(--space-5); padding: 0; }
.form-section + .form-section { border-top: 1px solid var(--border); padding-top: var(--space-4); }
.form-section > legend { font-family: var(--font-heading); font-weight: 600; font-size: 1rem; padding: 0; margin-bottom: var(--space-3); float: left; width: 100%; }
.form-section > legend + * { clear: both; }
/* PLAN P32 §M32.3: an incident's severity as a dot after its number. */
.severity-dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-left: 0.35rem; vertical-align: 0.05em; border: 1px solid var(--border); background: var(--info); }
.severity-dot.severity-medium { background: var(--warning); }
.severity-dot.severity-high { background: var(--danger); }
.severity-dot.severity-critical { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); }
/* PLAN P32 §M32.5: a section inside a card (the incident's photos and files under Details). */
.card-section { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.card-section > .card-header { margin-bottom: var(--space-3); }
.card-section h3 { margin: 0; font-size: 1.05rem; }
.incident-ref { font-family: var(--font-mono); font-weight: 600; white-space: nowrap; }
/* Numbers and dates that should line up down a column. */
.mono { font-family: var(--font-mono); font-size: 0.9em; white-space: nowrap; }
/* PLAN P32 §M32.2: the log form's "Optional" section, closed by default. */
.form-optional { border-top: 1px solid var(--border); padding-top: var(--space-4); }
.form-optional > summary { font-family: var(--font-heading); font-weight: 600; font-size: 1rem; cursor: pointer; margin-bottom: var(--space-3); }
.form-optional[open] > summary { margin-bottom: var(--space-3); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 var(--space-4); }

/* Document share reveal page (PLAN P10 §M10.4): value + copy button. */
.facts.facts-single { grid-template-columns: 1fr; }
.copy-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.share-link { overflow-wrap: anywhere; font-size: 0.85rem; }
.share-pin { font-size: 1.4rem; letter-spacing: 0.12em; }

/* ------------------------------------------- workflow pages (PLAN P10 §M10.4) */

/* Filter chips above a list: links, the active one filled. */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.85rem; border: 1px solid var(--border-input); border-radius: 999px; color: var(--text); text-decoration: none; font-size: 0.85rem; font-weight: 500; }
.chip:hover { border-color: var(--link); color: var(--text); text-decoration: none; }
.chip.active { background: var(--primary-soft); border-color: transparent; color: var(--on-primary-soft); }
.chip-count { font-size: 0.75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chip.active .chip-count { color: inherit; }
.chips-label { align-self: center; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-right: var(--space-1); }

/* Buttons/forms side by side in a table cell or header. */
.row-actions { display: flex; flex-wrap: nowrap; gap: var(--space-2); justify-content: flex-end; }
.row-actions form, .page-actions form { margin: 0; }
/* A POST form that reads as a link (opening a notification marks it read, PLAN P20 §M20.4). */
.link-button { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--link); text-decoration: underline; cursor: pointer; text-align: left; }
.link-button:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 2px; }
/* A "Reject" that opens a reason box in place (PLAN P19 §M19.4 paperwork review). */
.row-actions details > summary { list-style: none; cursor: pointer; }
.row-actions details > summary::-webkit-details-marker { display: none; }
.row-actions:has(details[open]) { flex-wrap: wrap; }
.row-actions details[open] { flex-basis: 100%; min-width: 14rem; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Progress through a fixed workflow (assessment lifecycle). */
.steps { display: flex; flex-wrap: wrap; list-style: none; margin: 0 0 var(--space-5); padding: 0; gap: var(--space-3) var(--space-1); }
.step { flex: 1 0 7.5rem; position: relative; padding-top: var(--space-4); font-size: 0.8rem; color: var(--text-muted); }
.step::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px; border-radius: 999px; background: var(--border); }
.step.done::before { background: var(--primary-end); }
.step.current::before { background: var(--accent); }
.step.current { color: var(--text); font-weight: 600; }
.step small { display: block; font-weight: 400; color: var(--text-muted); }
.steps-off { margin: calc(-1 * var(--space-3)) 0 var(--space-5); }

/* Vertical history of what happened, newest first. */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 var(--space-4) 2.25rem; }
.timeline li::before { content: ""; position: absolute; left: 0.8rem; top: 1.6rem; bottom: 0.2rem; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline-icon { position: absolute; left: 0; top: 0; width: 1.65rem; height: 1.65rem; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; background: var(--primary-soft); color: var(--on-primary-soft); }
.timeline-when { display: block; font-size: 0.78rem; color: var(--text-muted); }

/* Comment threads. */
.comment { border-top: 1px solid var(--border); padding: var(--space-3) 0; }
.comment-meta { margin: 0; font-size: 0.82rem; color: var(--text-muted); }
.comment-body { margin: var(--space-1) 0 0; white-space: pre-line; }
.pre-line { white-space: pre-line; }
.comment-reply { margin: var(--space-2) 0 0 var(--space-5); padding-left: var(--space-3); border-left: 2px solid var(--border); }
.comment-reply-form { margin: var(--space-2) 0 0 var(--space-5); }
.comment-form { margin-top: var(--space-4); }
.comment-form textarea, .comment-reply-form textarea { width: 100%; }

/* Pick-one-of-many buttons (room picker for "Log incident"). */
.room-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--space-2); margin-bottom: var(--space-3); }
.room-picker .btn { justify-content: center; }

/* Units of a commercial property (PLAN P16): logo tiles, the unit-scope
   banner above the facility tabs, and the unit grid on the Units tab.
   Brand logos sit on the plain surface so their own colours read in both
   themes. */
.unit-logo { display: block; max-width: 100%; height: 5rem; object-fit: contain; }
.unit-logo-sm { height: 2rem; width: 4.5rem; }
.unit-logo-lg { height: 5rem; width: 12rem; }
.unit-badge { display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--on-primary-soft); flex: none; }
.unit-scope { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-4); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.unit-scope-all { margin-left: auto; font-weight: 600; white-space: nowrap; }
.app-container > .page-header + .unit-scope + .tabs { margin-top: var(--space-3); }
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: var(--space-3); list-style: none; margin: 0; padding: 0; }
.unit-card { position: relative; display: flex; flex-direction: column; gap: var(--space-2); height: 100%; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease); }
.unit-card:hover, .unit-card:focus-visible { border-color: var(--link); box-shadow: var(--shadow); }
.unit-card-logo { display: flex; align-items: center; justify-content: center; height: 5.5rem; border-radius: var(--radius-sm); background: var(--surface-alt); overflow: hidden; }
.unit-card-logo .unit-badge { width: 2.75rem; height: 2.75rem; font-size: 1.2rem; }
.unit-card-name { font-weight: 600; line-height: 1.25; }
.unit-card-meta { font-size: 0.82rem; color: var(--text-muted); }
.unit-card .badge { align-self: flex-start; }
.unit-filter { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.unit-filter select { min-width: 14rem; }

label.checkbox { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 500; }
label.checkbox input { width: auto; }

/* Low-key destructive action at the foot of a detail page. */
.danger-zone { margin-top: var(--space-5); display: flex; justify-content: flex-end; }
.danger-zone .btn:hover { color: var(--danger); background: var(--danger-soft); }

.inline-form { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.inline-form select { width: auto; min-width: 16rem; }

/* Two cards side by side (comments + history), stacked on narrow screens. */
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: var(--space-5); align-items: start; margin-top: var(--space-5); }
.two-col > .card + .card { margin-top: 0; }

/* Filter bar extras: a search box that takes the spare width, an inline checkbox. */
.filter-bar .filter-grow { flex: 1 1 14rem; }
.filter-bar .filter-check { min-width: 0; align-self: flex-end; padding-bottom: 0.55rem; }
.list-count { font-size: 0.85rem; margin: calc(-1 * var(--space-2)) 0 var(--space-3); }
.share-selected { margin-bottom: var(--space-3); } /* PLAN P31 §M31.17 */
.icon-btn-danger:hover { border-color: var(--danger); color: var(--danger); }

/* Budget used bar: green → purple near the limit → red over it. */
.meter { display: block; width: 100%; min-width: 4.5rem; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: var(--space-1); }
.meter > span { display: block; height: 100%; width: var(--pct); background: var(--primary-end); border-radius: inherit; }
.meter-near > span { background: var(--warning); }
.meter-over > span { background: var(--danger); }
.row-over td { background: color-mix(in srgb, var(--danger-soft) 45%, transparent); }
.text-danger { color: var(--danger); }
.budget-summary { margin-bottom: var(--space-5); }
.kpi-over .kpi-value { color: var(--danger); }
.kpi.kpi-plain { grid-template-columns: 1fr; min-height: 0; row-gap: var(--space-1); }
.stars { color: var(--warning); white-space: nowrap; font-size: 0.85rem; }

/* Spacing utilities — tokens only, for the odd gap a component doesn't give. */
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
label.checkbox-block { display: flex; margin-bottom: var(--space-1); }
.row-unread td { font-weight: 600; }

/* ------------------------------------------- signed-out screens (P10 §M10.5) */

.auth {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  max-width: 1040px; margin: var(--space-5) auto; min-height: min(640px, calc(100vh - 9rem));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.auth-art {
  position: relative; display: flex; align-items: flex-end; padding: var(--space-6);
  color: var(--on-topbar);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--topbar-end) 10%, transparent) 30%, color-mix(in srgb, var(--topbar-end) 92%, transparent)),
    var(--auth-image) center / cover no-repeat,
    var(--topbar-end);
}
.auth-art-hero { --auth-image: url('../images/brand/hero-building-800.webp'); }
.auth-art-fingerprint { --auth-image: url('../images/brand/fingerprint-building.webp'); }
.auth-art-maintenance { --auth-image: url('../images/brand/maintenance-circle.webp'); }
.auth-kicker { margin: 0 0 var(--space-1); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); }
.auth-tagline { margin: 0; font-family: var(--font-heading); font-size: 1.45rem; font-weight: 600; line-height: 1.3; max-width: 22ch; }
.auth-panel { padding: var(--space-6); display: flex; flex-direction: column; justify-content: center; }
.auth-panel h1 { margin-bottom: var(--space-2); }
.auth-intro { color: var(--text-muted); margin: 0 0 var(--space-5); }
.auth-panel form > div, .auth-panel .form-row { margin-bottom: var(--space-4); }
.auth-panel .btn-block { width: 100%; justify-content: center; }
.auth-footer { margin-top: var(--space-5); text-align: center; color: var(--text-muted); font-size: 0.92rem; }
.auth-footer p { margin: var(--space-1) 0; }
/* The legal links stand apart from the help lines above them (owner, 2026-11-05). */
.auth-footer p.auth-legal { margin-top: var(--space-6); }
.auth-panel .alert { margin-bottom: var(--space-4); }
.pin-input { font-size: 1.5rem; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }

@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; margin: var(--space-3) auto; min-height: 0; }
  .auth-art { min-height: 150px; padding: var(--space-4) var(--space-5); }
  .auth-tagline { font-size: 1.1rem; }
  .auth-panel { padding: var(--space-5); }
}

/* Shared-documents page: one row per file. */
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--border); }
.file-list li:first-child { border-top: 0; }
.file-list li > div { flex: 1; min-width: 0; }
.file-list-icon { font-size: 1.3rem; color: var(--link); }

/* Standalone error page (no app shell — see error.html.twig). */
.error-page { padding: var(--space-4); }
.error-page .auth-art-copy .auth-kicker { margin: 0; }

/* Account security screens. The QR code keeps a white quiet zone in dark mode so phones can read it. */
.field-narrow { max-width: 20rem; margin-bottom: var(--space-3); }
.qr-code { display: block; background: #fff; padding: var(--space-2); border-radius: var(--radius-sm); margin: var(--space-3) 0; } /* white is functional here, not a theme colour */
.totp-secret { font-size: 1.05rem; letter-spacing: 0.05em; overflow-wrap: anywhere; }
.backup-codes { columns: 2; list-style: none; padding: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.05rem; }
.backup-codes li { padding: var(--space-1) 0; }
.auth-panel form > .form-grid { margin-bottom: 0; }

/* Compliance register (PLAN P22 §M22.1). */
.section-heading { margin: var(--space-5) 0 var(--space-2); font-size: 1.05rem; }
.section-heading:first-of-type { margin-top: var(--space-4); }
.compliance-due { display: flex; align-items: center; gap: var(--space-2); }
.compliance-due input[type=date] { width: auto; }
.plain-list { list-style: none; margin: var(--space-3) 0 0; padding: 0; }
.inline-heading { display: inline; font-size: 1.05rem; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }

/* New share link: the ticked, filterable document list (OAT 2026-11-06). */
.share-picker { border: 0; padding: 0; margin: 0 0 var(--space-4); min-width: 0; }
.share-picker-legend { font-weight: 600; font-size: 0.88rem; margin-bottom: 0.35rem; padding: 0; }
.share-picker-filters { margin-bottom: var(--space-2); }
.share-picker-list { max-height: 22rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); background: var(--surface-alt); }
.share-picker-item { display: flex; align-items: flex-start; gap: var(--space-2); padding: 0.35rem 0; }
.share-picker-item[hidden] { display: none; }
.share-picker-item input { width: auto; margin-top: 0.2rem; flex: none; }
.share-picker-item label { display: inline; margin: 0; font-weight: 500; }
/* PLAN P12 §M12.7: address-book recipients on the share form. */
.address-book-picker { border: 0; padding: 0; margin: 0 0 var(--space-4); min-width: 0; }
.address-book-picker[hidden] { display: none; }
.address-book-picker [data-address-book-search] { margin-bottom: var(--space-2); }
.address-book-list[hidden], .address-book-list li[hidden] { display: none; }
.address-book-list { list-style: none; margin: 0; max-height: 16rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); background: var(--surface-alt); }
.address-book-list li { padding: 0.35rem 0; flex-wrap: nowrap; }
.address-book-list li > span { min-width: 0; overflow-wrap: anywhere; }
.visit-notice-list { list-style: none; margin: 0; padding: 0; }
.visit-notice-list li > span { min-width: 0; overflow-wrap: anywhere; }

/* Incident photos (PLAN P30 §M30.2): the file inputs stay focusable but are
   drawn as their buttons; previews before upload. */
.photo-button { position: relative; display: inline-block; }
.photo-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.photo-button:focus-within .btn { box-shadow: var(--focus-ring); }
.photo-previews { list-style: none; padding: 0; margin: var(--space-2) 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--space-2); }
.photo-previews li { display: flex; flex-direction: column; gap: 0.25rem; align-items: stretch; }
.photo-previews img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-alt); }
.gallery-figure { margin: 0; display: flex; flex-direction: column; gap: 0.25rem; }

/* ------------------------------------------- company colours (PLAN P28) */
/* Each panel carries one theme's tokens inline (BrandPalette::previewStyle);
   the gradients are re-declared here because :root resolves them once. */
.brand-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: var(--space-3); margin: var(--space-3) 0 var(--space-4); }
.brand-preview-panel {
  --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-end));
  --gradient-primary-hover: linear-gradient(135deg, var(--primary-hover), var(--primary-hover-end));
  display: flex; min-height: 9rem; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--page-glow), var(--bg); color: var(--text);
}
.brand-preview-side { flex: none; width: 6.5rem; display: flex; flex-direction: column; gap: 0.3rem; padding: 0.6rem 0.45rem; background: linear-gradient(180deg, var(--topbar-start), var(--topbar-end)); }
.brand-preview-item { padding: 0.25rem 0.55rem; border-radius: var(--radius-pill); font-size: 0.78rem; color: var(--on-topbar-muted); }
.brand-preview-item.active { background: var(--accent); color: var(--on-accent); }
.brand-preview-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0.45rem; padding: 0.7rem 0.8rem; background: var(--surface); font-size: 0.85rem; }
.brand-preview-link { color: var(--link); text-decoration: underline; text-underline-offset: 0.18em; }
.brand-preview-button { pointer-events: none; }

/* --------------------------------------------------------- reports (P29) */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: var(--space-4); align-items: start; }
.report-grid > .card + .card { margin-top: 0; }
.report-tile-head { display: flex; gap: var(--space-3); align-items: flex-start; margin-bottom: var(--space-3); }
.report-tile-head h2 { margin: 0; font-size: 1.1rem; }
.report-tile-head p { margin: 0.15rem 0 0; font-size: 0.88rem; }
.report-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.report-menu-item { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); color: var(--text); font-size: 0.88rem; line-height: 1.35; }
.report-menu-item:hover, .report-menu-item:focus-visible { background: var(--primary-soft); color: var(--on-primary-soft); text-decoration: none; }
.report-menu-item:hover .muted, .report-menu-item:focus-visible .muted { color: var(--on-primary-soft); }
.report-menu-item > i { width: 1.1rem; margin-top: 0.15rem; text-align: center; color: var(--link); }
.report-menu-item:hover > i { color: var(--on-primary-soft); }
.report-footnote { margin-top: var(--space-4); font-size: 0.85rem; }
.report-menu { position: relative; display: inline-block; }
.report-menu > summary { list-style: none; }
.report-menu > summary::-webkit-details-marker { display: none; }
.report-menu-panel { position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 30; width: min(20rem, 85vw); padding: 0.4rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
