/*
 * Copyright © 2025–2026 The Polymath (Pty) Ltd. All rights reserved.
 * PolyTrack is proprietary software. Unauthorised copying or distribution
 * is strictly prohibited.
 */

:root {
  --navy: #1B2A4A;
  --navy-light: #2E4470;
  --cream: #F5F1E8;
  --cream-dark: #EAE3D3;
  --bronze: #A87C4F;
  --bronze-dark: #8A6238;
  --ink: #2B2B28;
  --muted: #6B6760;
  --white: #FFFFFF;
  --border: #DDD6C4;
  --low: #5B8A5A;
  --medium: #C99A2E;
  --high: #C9702E;
  --critical: #B23A3A;
  --radius: 8px;
}

/* ── BREAKPOINTS (Feature 1.2) ──────────────────────────────────────────── */
/* Mobile first — base styles apply to all sizes */
/* sm:  ≥576px  (landscape phone) */
/* md:  ≥768px  (tablet) */
/* lg:  ≥992px  (desktop) */
/* xl:  ≥1200px (large desktop) */
/* A hamburger nav, 480px mobile-card breakpoint, and touch-target rules
   already existed before this feature (see "PWA / Mobile optimisations"
   and "Mobile hamburger navigation" further down this file) — this feature
   extends that existing foundation with the pieces that were genuinely
   missing (responsive tables, form grids, chart sizing) rather than
   duplicating a second parallel responsive system. See the dedicated
   "Feature 1.2 — Responsive design overhaul" section near the end of this
   file for the additions themselves. */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  background: var(--cream);
  color: var(--ink);
}

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

.topbar { background: var(--navy); color: var(--white); }
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.brand { color: var(--white); font-weight: 700; font-size: 1.25rem; letter-spacing: 0.02em; }
.topnav { display: flex; gap: 20px; }
.topnav a, .topbar-user a, .topbar-user span { color: var(--cream); font-weight: 500; font-size: 0.92rem; }
.topbar-user { display: flex; gap: 16px; align-items: center; }

.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }

h1, h2, h3 { font-weight: 600; color: var(--navy); }
h1 { font-size: 1.6rem; margin-bottom: 4px; }
h2 { font-size: 1.2rem; }

.subtitle { color: var(--muted); margin-top: 0; margin-bottom: 24px; }
.muted { color: var(--muted); font-size: 0.82rem; }

.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 20px; }

/* ── Collapsible dashboard cards (accordions) ─────────────────────────
   Applied to dashboard .card sections so they're collapsed by default —
   only the header (title + any action buttons/help button) is visible
   until clicked. Clicking anywhere on the header toggles it, EXCEPT on an
   interactive control inside the header (a button/link/select/etc, e.g.
   the "?" help button or a "View all" action link) — see
   polyriskToggleCard() in base.html, which checks event.target before
   toggling so those controls keep working normally instead of being
   swallowed by the toggle click. */
.card-accordion-header { cursor: pointer; display: flex !important; align-items: center; flex-wrap: wrap; gap: 8px; }
/* margin-left:auto pulls the chevron to the far right regardless of how
   many sibling elements (title, help button, action buttons) sit before
   it in the header — works whether the header uses .section-header's
   flex/space-between layout, a plain flex row, or is just an <h2> with
   inline children, without needing to touch each card's existing markup. */
.accordion-chevron { display: inline-block; color: var(--muted); font-size: 0.85rem; flex-shrink: 0; margin-left: auto; padding-left: 12px; transition: transform 0.15s; }
.card-accordion.is-collapsed .accordion-chevron { transform: rotate(-90deg); }
.card-accordion-body { margin-top: 16px; }
.card-accordion.is-collapsed .card-accordion-body { display: none; }

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
@media (min-width: 768px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  background: var(--white); border: 1px solid var(--border); border-left: 4px solid var(--bronze);
  border-radius: var(--radius); padding: 16px 20px;
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; color: var(--navy); }
.stat-card .stat-label { color: var(--muted); font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.92rem; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: var(--cream); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; color: var(--white); white-space: nowrap; }
.badge-low { background: var(--low); }
.badge-medium { background: var(--medium); }
.badge-high { background: var(--high); }
.badge-critical { background: var(--critical); }
.badge-open { background: var(--bronze); }
.badge-progress { background: var(--navy-light); }
.badge-completed { background: var(--low); }
.badge-overdue { background: var(--critical); }
.badge-info { background: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; background: var(--navy); color: var(--white);
  padding: 10px 18px; min-height: 44px; border-radius: var(--radius); border: none;
  font-family: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--navy-light); text-decoration: none; }
.btn-secondary { background: var(--white); color: var(--navy); border: 1px solid var(--navy); }
.btn-secondary:hover { background: var(--cream-dark); }
.btn-bronze { background: var(--bronze); }
.btn-bronze:hover { background: var(--bronze-dark); }
.btn-sm { padding: 6px 12px; min-height: 36px; font-size: 0.82rem; }

.actions-row { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }

form .field { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 6px; color: var(--navy); }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 16px; background: var(--white); color: var(--ink);
}
input, select { min-height: 44px; }
textarea { min-height: 80px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 160px; }
.hint { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }

.flash-stack { margin-bottom: 20px; }
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 8px; font-size: 0.9rem; }
.flash-success { background: #E5EEDB; color: #3E5A2E; border: 1px solid #C7D9B4; }
.flash-error { background: #F6E2DE; color: #8A3324; border: 1px solid #E9C2B9; }

.empty-state { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }

.login-wrap { max-width: 380px; margin: 80px auto; }
.login-card { background: var(--white); border-radius: var(--radius); padding: 32px; border: 1px solid var(--border); }
.login-card h1 { text-align: center; }
.login-card .subtitle { text-align: center; }

.note-list { list-style: none; padding: 0; margin: 12px 0 0; }
.note-list li { padding: 8px 0; border-top: 1px solid var(--border); font-size: 0.88rem; }
.note-list li .note-meta { color: var(--muted); font-size: 0.78rem; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }

details.update-toggle summary { cursor: pointer; color: var(--navy); font-weight: 600; font-size: 0.85rem; }
.inline-form { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; flex-wrap: wrap; }
.inline-form select { width: auto; }
.inline-form textarea { min-height: 40px; width: 220px; }

.breadcrumb { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }

.prewrap { white-space: pre-wrap; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 4px; }
.info-grid .field p { margin: 0; font-size: 0.92rem; }

.is-hidden { display: none; }
.action-row td { background: var(--cream); padding: 18px 20px; border-bottom: 1px solid var(--border); }
.action-panel { padding: 2px 0; }
.action-panel + .action-panel { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
.action-panel-header { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.action-panel p { margin: 0 0 12px; font-size: 0.92rem; }

/* ---- Days remaining ---- */
.days-ok { color: var(--low); font-weight: 600; }
.days-warning { color: var(--medium); font-weight: 600; }
.days-critical { color: var(--high); font-weight: 600; }
.days-overdue { color: var(--critical); font-weight: 600; }

/* ---- Charts ---- */
.chart-row { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.chart-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; flex: 1; min-width: 220px; }
.chart-card h3 { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 12px; }
.chart-card canvas { max-height: 180px; }

/* ---- Tasks ---- */
.task-row td { font-size: 0.9rem; }
.reminder-banner { background: #FFF8E1; border: 1px solid #FFD54F; border-radius: var(--radius); padding: 10px 16px; margin-bottom: 16px; font-size: 0.88rem; }
.reminder-banner strong { color: var(--navy); }

/* ---- External verification widgets (VAT / FSP / CIPC registration) ---- */
.verify-result { margin-top: 6px; font-size: 0.85rem; }
.verify-result.verify-ok { color: var(--low); }
.verify-result.verify-bad { color: var(--critical); }
.verify-result.verify-warn { color: var(--medium); }
.verify-result.verify-checking { color: var(--muted); }
.verify-field-row { display: flex; gap: 8px; align-items: flex-start; }
.verify-field-row input { flex: 1; }
.integration-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.integration-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.integration-status-dot.status-active { background: var(--low); }
.integration-status-dot.status-not-configured { background: var(--medium); }
.integration-status-dot.status-error { background: var(--critical); }
.integration-status-dot.status-pending { background: var(--muted); }

/* ---- Section icons ─────────────────────────────────────────── */
.section-icon {
    object-fit: contain;
    vertical-align: middle;
    flex-shrink: 0;
}
.section-icon-lg  { width: 64px;  height: 64px;  }
.section-icon-md  { width: 48px;  height: 48px;  }
.section-icon-sm  { width: 32px;  height: 32px;  }
.section-icon-xs  { width: 24px;  height: 24px;  }
.icon-fallback    { font-size: 1.5rem; display: inline-block;
                    text-align: center; }

/* Onboarding card icon */
.onboarding-card-icon {
    width: 64px; height: 64px;
    object-fit: contain;
    margin-bottom: 8px;
}

/* Dashboard card icon in header */
.card-header-icon {
    width: 36px; height: 36px;
    object-fit: contain;
    margin-right: 10px;
    vertical-align: middle;
}

/* Nav icon */
.nav-section-icon {
    width: 20px; height: 20px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 6px;
}

/* ---- Simple filter tabs (e.g. admin registrations page) ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab-link { padding: 8px 16px; color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 500; border-bottom: 2px solid transparent; }
.tab-link:hover { color: var(--navy); }
.tab-link.is-active { color: var(--navy); border-bottom-color: var(--bronze); }

/* ---- Personal profile completion prompt (existing-client nudge) ---- */
.profile-prompt-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--cream); border: 1px solid var(--bronze); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; }
.profile-prompt-banner .profile-prompt-text { font-size: 0.9rem; color: var(--navy); }
.profile-prompt-banner .profile-prompt-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.profile-prompt-banner form { display: inline; margin: 0; }

/* ---- Drag & drop upload ---- */
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px 20px; text-align: center; color: var(--muted); cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.drop-zone.drag-over { background: var(--cream); border-color: var(--navy); }
.drop-zone input[type="file"] { display: none; }
.drop-zone label { color: var(--navy); font-weight: 600; cursor: pointer; text-decoration: underline; }
.drop-zone p { margin: 0 0 6px; }

/* ---- Barcode / QR scan sections ---- */
/* Mobile-first: camera option shown first and more prominently. */
.scan-options { display: flex; flex-direction: column; gap: 20px; }
.scan-option { flex: 1; }
.scan-option-camera { order: 1; }
.scan-option-upload { order: 2; }
@media (min-width: 768px) {
  /* Desktop: upload option shown first. */
  .scan-options { flex-direction: row; }
  .scan-option-camera { order: 2; }
  .scan-option-upload { order: 1; }
}

/* ---- Document list ---- */
.doc-list { list-style: none; padding: 0; margin: 12px 0 0; }
.doc-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.doc-list li:last-child { border-bottom: none; }
.doc-list .doc-name { flex: 1; }
.doc-list .doc-meta { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }

/* ---- Procurement ---- */
.proc-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--cream-dark); color: var(--navy); }
.proc-status-awarded { background: var(--low); color: var(--white); }
.proc-status-completed { background: var(--navy); color: var(--white); }
.proc-status-cancelled { background: var(--muted); color: var(--white); }

/* ---- Claims register ---- */
.claim-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; color: var(--white); background: var(--bronze); }
.claim-status-closed { background: var(--low); }
.claim-status-disputed { background: var(--critical); }

/* ---- Compliance tracker ---- */
.compliance-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; color: var(--white); background: var(--low); }
.compliance-status-expiring-soon { background: var(--medium); }
.compliance-status-expired { background: var(--critical); }
.compliance-status-not-applicable { background: var(--muted); }

.reminder-banner-warning { background: #FFF3E0; border-color: #FFB74D; }
.reminder-banner-critical { background: #FDECEA; border-color: #E57373; }
.reminder-banner-critical strong { color: var(--critical); }

/* ---- Collapsible compliance item rows ---- */
details.compliance-item summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
details.compliance-item summary::-webkit-details-marker { display: none; }
details.compliance-item summary .chevron { transition: transform 0.2s; font-size: 0.75rem; color: var(--muted); }
details.compliance-item[open] summary .chevron { transform: rotate(90deg); }
details.compliance-item .compliance-body { padding: 12px 0 8px; border-top: 1px solid var(--border); }
details.compliance-item + details.compliance-item { border-top: 1px solid var(--border); }
details.compliance-item summary .compliance-item-label { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---- Task outstanding stats ---- */
.task-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.task-stat { background: var(--cream); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 16px; font-size: 0.85rem; }
.task-stat span { font-weight: 700; color: var(--navy); margin-right: 4px; }

/* ---- Risk Health Score meter ---- */
.health-red { --health-color: var(--critical); }
.health-amber { --health-color: var(--medium); }
.health-green { --health-color: var(--low); }

.health-card { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.health-meter-wrap { flex: 1; min-width: 220px; }
.health-meter-score { font-size: 2.2rem; font-weight: 700; color: var(--health-color, var(--navy)); line-height: 1; }
.health-meter-label { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

/* ---- Field mode: stripped-down, large-tap-target mobile view ---- */
.field-mode-toggle { border: 1px solid var(--bronze); border-radius: 999px; padding: 4px 12px !important; }

.field-mode { font-size: 1.05rem; }
.field-mode .topbar-inner { padding: 12px 16px; }
.field-mode .page { padding: 16px 12px 48px; max-width: 100%; }
.field-mode .card { padding: 16px; }
.field-mode h1 { font-size: 1.35rem; }
.field-mode .subtitle { margin-bottom: 16px; }

.field-mode .btn, .field-mode input, .field-mode select, .field-mode textarea, .field-mode button {
  min-height: 48px;
  font-size: 1rem;
}
.field-mode .btn, .field-mode button {
  padding: 12px 20px;
}
.field-mode .btn-sm {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 0.95rem;
}
.field-mode label { font-size: 0.95rem; margin-bottom: 8px; }
.field-mode .field { margin-bottom: 20px; }

.field-mode table { font-size: 1rem; }
.field-mode th, .field-mode td { padding: 14px 10px; }

.field-mode .actions-row { gap: 12px; }
.field-mode .actions-row .btn { flex: 1; min-width: 140px; text-align: center; }

.field-mode .chart-row, .field-mode .timeline-chart-wrap { display: none; }
.health-meter-bar { position: relative; height: 14px; background: var(--cream-dark); border-radius: 999px; margin-top: 10px; overflow: hidden; }
.health-meter-fill { height: 100%; background: var(--health-color, var(--navy)); border-radius: 999px; transition: width 0.3s; }
.health-meter-bar .health-meter-bands { position: absolute; inset: 0; display: flex; pointer-events: none; }
.health-meter-bands span { flex: 1; border-right: 1px solid rgba(255,255,255,0.5); }
.health-meter-bands span:last-child { border-right: none; }
.health-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; color: var(--white); background: var(--health-color, var(--muted)); }
.health-mini { display: inline-flex; align-items: center; gap: 8px; min-width: 120px; }
.health-mini .health-meter-bar { flex: 1; margin-top: 0; height: 8px; }
.health-mini .health-mini-value { font-weight: 700; font-size: 0.85rem; color: var(--health-color, var(--navy)); min-width: 30px; text-align: right; }

.category-scores { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 16px; }
.category-score-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.category-score-card .cat-name { font-size: 0.82rem; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.category-score-card .health-meter-bar { height: 8px; margin-top: 6px; }
.category-score-card .cat-value { font-size: 0.85rem; font-weight: 700; }

.progress-stats { display: flex; gap: 16px; flex-wrap: wrap; margin: 16px 0; }
.progress-stat { flex: 1; min-width: 160px; background: var(--cream); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.progress-stat .stat-value { font-size: 1.4rem; font-weight: 700; color: var(--navy); }
.progress-stat .stat-label { color: var(--muted); font-size: 0.8rem; }

.timeline-chart-wrap { margin-top: 12px; }
.timeline-chart-wrap canvas { max-height: 200px; }

/* ---- Template library ---- */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 12px; }
.template-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; }
.template-card h2 { font-size: 1rem; margin: 0 0 6px; }
.template-card .template-columns { flex: 1; margin: 10px 0 14px; }
.template-card .btn { align-self: flex-start; }

/* ---- Feature permission system ---- */
.feature-checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 8px; }
.feature-checkbox { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; }
.feature-checkbox input { width: auto; margin-top: 3px; }
.feature-checkbox span { display: flex; flex-direction: column; gap: 2px; font-size: 0.85rem; }
.feature-checkbox strong { color: var(--navy); font-size: 0.88rem; }

.feature-locked { text-align: center; }
.feature-locked .lock-icon { font-size: 1.6rem; display: block; margin-bottom: 8px; }
.feature-locked-notice { color: var(--muted); }

/* ---- Self-onboarding portal (/register) ---- */
.onboarding-header {
  background: var(--navy); color: var(--white);
  padding: 16px 24px; display: flex; align-items: center; justify-content: space-between;
}
.onboarding-header .brand { color: var(--white); font-weight: 700; font-size: 1.25rem; letter-spacing: 0.02em; }
.onboarding-header a.login-link { color: var(--cream); font-weight: 500; font-size: 0.9rem; }
.onboarding-wrap { max-width: 720px; margin: 0 auto; padding: 32px 24px 64px; }
.onboarding-wrap.wide { max-width: 900px; }

.wizard-progress { display: flex; align-items: flex-start; margin-bottom: 32px; }
.wizard-progress-step { flex: 1; text-align: center; position: relative; }
.wizard-progress-step:not(:last-child)::after {
  content: ""; position: absolute; top: 16px; left: 50%; width: 100%; height: 2px;
  background: var(--border); z-index: 0;
}
.wizard-progress-step.is-complete:not(:last-child)::after { background: var(--low); }
.wizard-step-circle {
  position: relative; z-index: 1;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--white); border: 2px solid var(--border); color: var(--muted);
  font-weight: 700; font-size: 0.85rem; margin: 0 auto 6px;
}
.wizard-progress-step.is-current .wizard-step-circle { border-color: var(--navy); background: var(--navy); color: var(--white); }
.wizard-progress-step.is-complete .wizard-step-circle { border-color: var(--low); background: var(--low); color: var(--white); }
.wizard-step-label { font-size: 0.75rem; color: var(--muted); }
.wizard-progress-step.is-current .wizard-step-label { color: var(--navy); font-weight: 600; }

.wizard-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }

.feature-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 16px 0; }
.feature-card {
  position: relative; display: block; cursor: pointer;
  border: 2px solid var(--border); border-radius: var(--radius); padding: 16px;
  background: var(--white);
}
.feature-card.is-selected { border-color: var(--navy); background: var(--cream); }
.feature-card .feature-card-icon { font-size: 1.6rem; display: block; margin-bottom: 8px; }
.feature-card .feature-card-name { font-weight: 600; color: var(--navy); font-size: 0.92rem; display: block; margin-bottom: 4px; }
.feature-card .feature-card-desc { color: var(--muted); font-size: 0.8rem; }
.feature-card input[type="checkbox"] { position: absolute; top: 14px; right: 14px; width: 18px; height: 18px; }

.registration-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.link-btn { background: none; border: none; padding: 0; color: var(--navy); font-weight: 600; text-decoration: underline; cursor: pointer; font-size: 0.85rem; }

/* ---- Generic modal (AI narratives, help videos, etc.) ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(27,42,74,0.55); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.is-hidden { display: none; }
.modal-box {
  background: var(--white); border-radius: var(--radius); max-width: 640px; width: 100%;
  max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
.modal-box-wide { max-width: 900px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-body .prewrap { white-space: pre-wrap; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); }
.modal-loading { text-align: center; color: var(--muted); padding: 24px; }

/* ---- Bulk action toolbar ---- */
.bulk-toolbar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 900;
  background: var(--navy); color: var(--white); border-radius: var(--radius);
  padding: 12px 20px; display: flex; align-items: center; gap: 14px; box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.bulk-toolbar.is-hidden { display: none; }
.bulk-toolbar select { width: auto; margin: 0; }
.bulk-toolbar .btn-secondary { background: var(--white); }

/* ---- Search dropdown ---- */
.search-form { position: relative; }
.search-input { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--navy-light); background: var(--navy-light); color: var(--white); font-size: 0.85rem; width: 200px; }
.search-input::placeholder { color: var(--cream); opacity: 0.7; }
.search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; background: var(--white);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  max-height: 400px; overflow-y: auto; z-index: 500; color: var(--ink); text-align: left;
}
.search-dropdown.is-hidden { display: none; }
.search-dropdown .search-group-label { padding: 8px 12px 2px; font-size: 0.72rem; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.search-dropdown a.search-result { display: block; padding: 6px 12px; font-size: 0.85rem; color: var(--ink); }
.search-dropdown a.search-result:hover { background: var(--cream); text-decoration: none; }
.search-dropdown .search-see-all { display: block; padding: 8px 12px; font-size: 0.8rem; font-weight: 600; color: var(--navy); border-top: 1px solid var(--border); }
mark { background: #FFF3B0; padding: 0 2px; }
.search-toggle-btn { display: none; background: none; border: none; color: var(--cream); font-size: 1.1rem; cursor: pointer; }
@media (max-width: 720px) {
  .search-input { display: none; width: 140px; }
  .search-form.is-expanded .search-input { display: inline-block; }
  .search-toggle-btn { display: inline-block; }
}

/* ---- Help button (video guides) ---- */
.help-btn {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); background: var(--white);
  color: var(--muted); font-size: 0.75rem; font-weight: 700; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.help-btn:hover { background: var(--cream); color: var(--navy); }

/* ---- Survey annotation tools (Feature 7) ---- */
.annot-tool-btn.is-active { background: var(--navy); color: var(--white); border-color: var(--navy); }
.pdf-page-wrap canvas { border: 1px solid var(--border); display: block; }

.app-footer {
  text-align: center;
  padding: 16px 24px;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 48px;
  background: var(--cream);
}

/* ---- Admin nav standalone link (styled like a dropdown button, no chevron) ---- */
.nav-standalone-link {
  color: var(--cream);
  font-weight: 500;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.nav-standalone-link:hover { text-decoration: underline; }

/* ---- Admin nav dropdown groups ---- */
.nav-dropdown { position: relative; display: inline-block; }
.nav-dropdown-btn {
  background: none;
  border: none;
  margin: 0;
  padding: 0;
  font-family: inherit;
  color: var(--cream);
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.nav-dropdown-btn:hover { text-decoration: underline; }
.nav-dropdown-btn .chevron {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 0.7rem;
  margin-left: 4px;
}
.nav-dropdown.open .nav-dropdown-btn .chevron,
.nav-dropdown:hover .nav-dropdown-btn .chevron { transform: rotate(180deg); }
.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--navy);
  min-width: 180px;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 1000;
  display: none;
  padding: 6px 0;
}
.nav-dropdown.open .nav-dropdown-menu,
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: 10px 16px;
  color: var(--cream);
  font-size: 0.88rem;
  white-space: nowrap;
}
.nav-dropdown-menu a:hover { background: var(--bronze); color: var(--white); text-decoration: none; }
.nav-dropdown-menu a.active { background: var(--bronze-dark); color: var(--white); }

/* ---- AI privacy notice (below every AI feature button) ---- */
.ai-privacy-notice { font-size: 0.75rem; font-style: italic; margin-top: 6px; margin-bottom: 0; }
.ai-privacy-notice-external { color: var(--muted); }
.ai-privacy-notice-local { color: var(--low); }

/* ---- AI-extracted form fields (document extraction) ---- */
.ai-extracted-field { background: #FFF3D6 !important; }
.ai-extracted-label { color: var(--bronze-dark); font-size: 0.72rem; font-weight: 600; margin-left: 8px; }
.ai-extraction-banner { background: #E5F1E4; border: 1px solid var(--low); color: #33502F; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; }
.ai-confidence-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; margin-left: 8px; }
.ai-confidence-high { background: var(--low); color: var(--white); }
.ai-confidence-low { background: var(--medium); color: var(--white); }
.ai-extract-dropzone { border: 2px dashed var(--bronze); border-radius: var(--radius); padding: 24px 20px; text-align: center; color: var(--muted); cursor: pointer; margin-bottom: 14px; }
.ai-extract-dropzone.drag-over { background: var(--cream-dark); }
.ai-extract-loading { display: none; align-items: center; gap: 8px; color: var(--navy); font-weight: 600; margin-bottom: 14px; }
.ai-extract-loading.is-active { display: flex; }
.ai-extract-spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--navy); border-radius: 50%; animation: ai-spin 0.7s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* ---- Divider with centred text (e.g. "Or add a new person manually") ---- */
.divider-with-text { display: flex; align-items: center; text-align: center; color: var(--muted); font-size: 0.82rem; margin: 20px 0; }
.divider-with-text::before, .divider-with-text::after { content: ''; flex: 1; border-bottom: 1px solid var(--border); }
.divider-with-text span { padding: 0 12px; }

/* ---- "Select from existing contacts" card ---- */
.existing-contacts-card {
  border: 1px solid var(--border);
  background: var(--cream);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: opacity 0.2s ease;
}

/* ---- Show/hide password toggle ---- */
.password-field-wrapper { position: relative; }
.password-field-wrapper input[type="password"], .password-field-wrapper input[type="text"] { padding-right: 40px; width: 100%; }
.password-toggle-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 1rem; line-height: 1; padding: 6px 8px; }

/* PWA install banner */
.pwa-install-banner {
    display: none;
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--navy);
    color: var(--cream);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    z-index: 9999;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 340px;
    width: calc(100% - 32px);
    animation: slide-up 0.3s ease;
}
@keyframes slide-up {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}
.pwa-install-banner .pwa-text { flex: 1; }
.pwa-install-banner .pwa-btn {
    background: var(--bronze);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}
.pwa-install-banner .pwa-dismiss {
    background: none;
    border: none;
    color: var(--cream);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
    opacity: 0.6;
}

/* Cyber risk assessment module */
.cyber-progress-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--navy);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.cyber-progress-header .cyber-progress-score { font-weight: 700; font-size: 1.1rem; color: var(--cream); }
.cyber-category-card { margin-bottom: 18px; }
.cyber-category-card h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.05rem;
}
.cyber-category-card .cyber-category-weight { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.cyber-question { border-top: 1px solid var(--border); padding: 16px 0; }
.cyber-question:first-of-type { border-top: none; padding-top: 8px; }
.cyber-question-text { font-weight: 600; margin-bottom: 2px; }
.cyber-question-hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 10px; }
.cyber-option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.cyber-option-card {
  display: block;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  background: var(--white);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.cyber-option-card:hover { border-color: var(--bronze); }
.cyber-option-card input[type="radio"] { margin-right: 8px; }
.cyber-option-card.selected { border-color: var(--navy); background: var(--navy); color: var(--white); }
.cyber-option-card.selected .muted { color: var(--cream); }
.cyber-score-ring {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  font-size: 2rem;
  font-weight: 700;
  color: var(--white);
}
.cyber-gap-item { border-left: 3px solid var(--critical); padding: 8px 12px; margin-bottom: 8px; background: var(--cream); }
.cyber-gap-item .cyber-gap-category { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.cyber-insurer-flag { color: var(--critical); font-weight: 600; }

/* Guided onboarding setup dashboard */
.setup-page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }
.setup-progress-bar-outer {
  position: sticky; top: 0; z-index: 15; background: var(--cream); padding: 12px 0 8px;
}
.setup-progress-bar { height: 10px; background: var(--cream-dark); border-radius: 999px; overflow: hidden; }
.setup-progress-fill { height: 100%; background: var(--bronze); border-radius: 999px; transition: width 0.4s ease; }
.setup-header { margin: 18px 0 24px; text-align: center; }
.setup-header h1 { margin-bottom: 4px; }
.setup-header .setup-subhead { color: var(--muted); }
.setup-header .setup-remaining { margin-top: 6px; font-size: 0.9rem; color: var(--bronze-dark); font-weight: 600; }

.setup-layout { display: flex; gap: 28px; align-items: flex-start; }
.setup-cards { flex: 1; min-width: 0; }
.setup-sidebar {
  width: 260px; flex-shrink: 0; position: sticky; top: 90px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
.setup-sidebar h3 { margin: 0 0 10px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.setup-sidebar-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: 6px;
  font-size: 0.86rem; color: var(--ink); text-decoration: none;
}
.setup-sidebar-item:hover { background: var(--cream); text-decoration: none; }
.setup-sidebar-item.is-locked { color: var(--muted); cursor: default; pointer-events: none; }
.setup-sidebar-item.is-active { background: var(--cream-dark); font-weight: 600; }
.setup-sidebar-icon { width: 18px; text-align: center; flex-shrink: 0; }
@media (max-width: 900px) { .setup-sidebar { display: none; } }

.setup-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 14px; overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.4s ease, border-color 0.4s ease, background 0.4s ease;
}
.setup-card.is-collapsing { opacity: 0.4; transform: translateY(-6px); }
.setup-card.is-expanding { animation: setup-card-in 0.4s ease; }
@keyframes setup-card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.setup-card-completed { border-left: 4px solid var(--low); }
.setup-card-skipped { border-left: 4px solid var(--muted); }
.setup-card-pending { border-left: 4px solid var(--border); background: var(--cream); }
.setup-card-active { border-left: 4px solid var(--navy); box-shadow: 0 2px 10px rgba(27,42,74,0.1); }

.setup-card-summary-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; min-height: 32px;
}
.setup-card-summary-row .setup-card-icon { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; }
.setup-card-summary-row .setup-card-titles { flex: 1; min-width: 0; }
.setup-card-summary-row .setup-card-title { font-weight: 600; }
.setup-card-summary-row .setup-card-subtitle { font-size: 0.82rem; color: var(--muted); }
.setup-card-summary-row .setup-card-meta { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.setup-card-tick {
  width: 26px; height: 26px; border-radius: 50%; background: var(--low); color: var(--white);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.9rem;
}
.setup-card-tick.is-animating { animation: setup-tick-pop 0.5s ease; }
@keyframes setup-tick-pop { 0% { transform: scale(0); opacity: 0; } 60% { transform: scale(1.25); opacity: 1; } 100% { transform: scale(1); } }
.setup-card-number {
  width: 26px; height: 26px; border-radius: 50%; background: var(--cream-dark); color: var(--muted);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.85rem; font-weight: 600;
}
.setup-card-edit-link { font-size: 0.82rem; }

.setup-card-header-bar {
  background: var(--bronze); color: var(--white); padding: 14px 18px; display: flex; align-items: center; gap: 12px;
}
.setup-card-header-bar .setup-card-icon { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.setup-card-header-bar h2 { margin: 0; font-size: 1.15rem; color: var(--white); }
.setup-card-header-bar .setup-time-badge {
  margin-left: auto; background: rgba(255,255,255,0.2); padding: 3px 10px; border-radius: 999px; font-size: 0.78rem;
}
.setup-card-body { padding: 18px; }
.setup-callout {
  background: var(--cream); border-left: 3px solid var(--bronze); padding: 12px 14px; border-radius: 6px;
  margin-bottom: 16px; font-size: 0.92rem;
}
.setup-callout .setup-tip { margin-top: 8px; font-size: 0.85rem; color: var(--muted); }
.setup-card-actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.setup-skip-link { color: var(--muted); font-size: 0.88rem; }
.setup-inline-error {
  background: #FBEAEA; color: var(--critical); border: 1px solid var(--critical);
  padding: 8px 12px; border-radius: 6px; font-size: 0.86rem; margin-top: 10px; display: none;
}
.setup-inline-error.is-visible { display: block; }

.setup-prompt-choice { display: flex; gap: 12px; margin-bottom: 16px; }
.setup-prompt-btn {
  flex: 1; padding: 14px; border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--white); cursor: pointer; font-weight: 600; font-family: inherit; font-size: 0.95rem;
}
.setup-prompt-btn:hover { border-color: var(--bronze); }
.setup-prompt-btn.is-yes:hover { border-color: var(--low); }
.setup-prompt-btn.is-no:hover { border-color: var(--critical); }

.setup-row { display: grid; gap: 8px; margin-bottom: 8px; align-items: end; }
.setup-row-field label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 2px; }
.setup-add-row-btn { margin-top: 4px; }
.setup-remove-row-btn {
  background: none; border: none; color: var(--critical); cursor: pointer; font-size: 1.1rem; padding: 4px 8px;
}

.setup-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.setup-chip {
  padding: 6px 14px; border-radius: 999px; border: 2px solid var(--border); background: var(--white);
  cursor: pointer; font-size: 0.85rem;
}
.setup-chip.is-selected { background: var(--navy); border-color: var(--navy); color: var(--white); }
.setup-dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 30px; text-align: center;
  color: var(--muted); margin-bottom: 14px; cursor: pointer;
}
.setup-dropzone.is-dragover { border-color: var(--bronze); background: var(--cream); }

.setup-toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.setup-toggle-row:last-child { border-bottom: none; }
.setup-switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.setup-switch input { opacity: 0; width: 0; height: 0; }
.setup-switch-slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: background 0.2s;
}
.setup-switch-slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: var(--white);
  border-radius: 50%; transition: transform 0.2s;
}
.setup-switch input:checked + .setup-switch-slider { background: var(--low); }
.setup-switch input:checked + .setup-switch-slider::before { transform: translateX(18px); }

.setup-cyber-modal-frame { width: 100%; height: 70vh; border: none; border-radius: var(--radius); }

.setup-celebration-overlay {
  position: fixed; inset: 0; background: rgba(27,42,74,0.92); z-index: 999; display: flex;
  align-items: center; justify-content: center; padding: 20px;
}
.setup-celebration-card {
  background: var(--white); border-radius: 12px; padding: 40px; max-width: 480px; width: 100%; text-align: center;
}
.setup-celebration-tick {
  width: 80px; height: 80px; border-radius: 50%; background: var(--low); color: var(--white);
  display: flex; align-items: center; justify-content: center; font-size: 2.4rem; margin: 0 auto 18px;
  animation: setup-celebration-pop 0.6s ease;
}
@keyframes setup-celebration-pop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); }
}
.setup-celebration-summary { color: var(--muted); margin: 14px 0 22px; text-align: left; }
.setup-celebration-summary li { margin-bottom: 4px; }

/* ── Service schedule: per-row provider display + inline assign ─────── */
.provider-linked  { color: #1B2A4A; font-weight: 500; }
.provider-text    { color: #666; }
.provider-none    { color: #aaa; font-style: italic; }
.unlinked-badge {
    display: inline-block;
    background: #FFF8E1;
    color: #7A5C00;
    border: 1px solid #9E8A63;
    border-radius: 3px;
    font-size: 0.7rem;
    padding: 1px 5px;
    margin-left: 4px;
    vertical-align: middle;
}
.provider-inline-select {
    display: block;
    margin-top: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.85rem;
    color: #1B2A4A;
    background: white;
    cursor: pointer;
    max-width: 200px;
}
.provider-inline-select:hover {
    border-color: #9E8A63;
}

/* ── Premium benchmarking ─────────────────────────────────────────────── */
.chart-subtitle {
    color: #666;
    font-size: 0.85rem;
    margin: 0 0 20px 0;
}

.benchmark-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 16px;
    flex-wrap: wrap;
}

.industry-filter-select {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.9rem;
    color: #1B2A4A;
    background: white;
    cursor: pointer;
    min-width: 200px;
}
.industry-filter-select:focus {
    outline: none;
    border-color: #9E8A63;
}

.benchmark-table,
.benchmark-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.benchmark-table th,
.benchmark-detail-table th {
    background: #1B2A4A;
    color: #FFFFFF;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
}
.benchmark-table td,
.benchmark-detail-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #F0EDE6;
    color: #1A1A1A;
}
.benchmark-table tbody tr:hover td,
.benchmark-detail-table tbody tr:hover td {
    background: #F9F7F4;
}
.num-col { text-align: right; font-variant-numeric: tabular-nums; }
.avg-col  { font-weight: 600; color: #1B2A4A; }
.low-col  { color: #2D5A2D; }
.high-col { color: #8B0000; }
.cob-cell { font-weight: 500; }

/* Variance badge + position indicator */
.variance-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
}
.variance-badge.positive { background: #FDECEA; color: #8B0000; }
.variance-badge.negative { background: #EDF5ED; color: #2D5A2D; }
.variance-badge.neutral  { background: #F5F1E8; color: #7A5C00; }

.position-indicator {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}
.position-well_below { background: #EDF5ED; color: #2D5A2D; }
.position-below      { background: #F1F8E9; color: #3A6B3A; }
.position-at_market  { background: #F5F1E8; color: #7A5C00; }
.position-above       { background: #FFF3E0; color: #7A3A00; }
.position-well_above  { background: #FDECEA; color: #8B0000; }
.position-unknown     { background: #F5F5F5; color: #666; }

/* Heatmap */
.heatmap-scroll { overflow-x: auto; }
.heatmap-table {
    border-collapse: collapse;
    font-size: 0.78rem;
    min-width: 100%;
}
.heatmap-row-header,
.heatmap-col-header {
    background: #1B2A4A;
    color: #FFFFFF;
    padding: 8px 10px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}
.heatmap-row-header { position: sticky; left: 0; z-index: 2; }
.heatmap-col-header { text-align: center; }
.heatmap-row-label {
    background: #F5F1E8;
    color: #1B2A4A;
    font-weight: 600;
    padding: 8px 10px;
    white-space: nowrap;
    position: sticky;
    left: 0;
}
.heatmap-cell {
    text-align: center;
    padding: 8px 10px;
    border: 1px solid #FFFFFF;
    white-space: nowrap;
    min-width: 90px;
}
.heatmap-cell.no-data { background: #F0EDE6; color: #aaa; }
.heatmap-cell.has-data { display: table-cell; }
.heatmap-value { display: block; font-weight: 600; font-size: 0.82rem; }
.heatmap-count { display: block; font-size: 0.68rem; opacity: 0.8; }

/* Range chart (P25–P75 band with client marker) */
.range-chart-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}
.range-label {
    width: 200px;
    flex: 0 0 200px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #1B2A4A;
}
.range-track-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.range-min, .range-max {
    font-size: 0.75rem;
    color: #666;
    white-space: nowrap;
    flex: 0 0 auto;
}
.range-track {
    position: relative;
    flex: 1;
    height: 10px;
    background: #F0EDE6;
    border-radius: 5px;
    margin: 20px 0;
}
.range-iqr {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(158, 138, 99, 0.45);
    border-radius: 5px;
}
.range-median {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 18px;
    background: #1B2A4A;
    transform: translateX(-1px);
}
.range-your-dot {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #9E8A63;
    border: 2px solid #FFFFFF;
    box-shadow: 0 0 0 1px #9E8A63;
    transform: translate(-50%, -50%);
}
.range-your-dot.well_below,
.range-your-dot.below  { background: #2D5A2D; box-shadow: 0 0 0 1px #2D5A2D; }
.range-your-dot.above,
.range-your-dot.well_above { background: #8B0000; box-shadow: 0 0 0 1px #8B0000; }
.range-dot-label {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.68rem;
    font-weight: 600;
    color: #1B2A4A;
    white-space: nowrap;
}

/* ── PWA / Mobile optimisations ────────────────────────────── */
@media (max-width: 480px) {
    .topnav { display: none; }
    .topbar { flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
    .topbar-user { font-size: 0.8rem; }
    .card { padding: 12px; margin-bottom: 12px; }
    .btn { padding: 10px 16px; font-size: 0.9rem; min-height: 44px; }
    .stat-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 1.6rem; }
    table { font-size: 0.8rem; }
    th, td { padding: 6px 4px; }
    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.1rem; }
    .field-row { flex-direction: column; }
    .chart-row { flex-direction: column; }
    .section-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .actions-row { flex-wrap: wrap; gap: 6px; }
}

/* Safe area insets for iPhone notch */
@supports (padding: max(0px)) {
    .topbar {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Improve touch targets throughout */
@media (hover: none) and (pointer: coarse) {
    .btn, button, select, input[type="checkbox"], input[type="radio"] {
        min-height: 44px;
    }
    a { min-height: 44px; display: inline-flex; align-items: center; }
    .nav-dropdown-btn { min-height: 44px; }
    details summary { min-height: 44px; display: flex; align-items: center; }
}

/* ── Mobile hamburger navigation ────────────────────────────── */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--cream);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    min-height: 44px;
}
@media (max-width: 480px) {
    .mobile-menu-btn { display: block; }
    .topnav { display: none !important; }
    .mobile-nav {
        background: var(--navy);
        border-top: 1px solid rgba(255,255,255,0.1);
        padding: 8px 0;
    }
    .mobile-nav a {
        display: block;
        padding: 12px 20px;
        color: var(--cream);
        font-size: 0.95rem;
        border-bottom: 1px solid rgba(255,255,255,0.06);
        text-decoration: none;
        min-height: 44px;
    }
    .mobile-nav a:active { background: rgba(255,255,255,0.08); }
}

/* ── Admin dashboard collapsible sections ──────────────────── */
details.dashboard-section {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
details.dashboard-section summary.dashboard-section-header {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--cream);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--navy);
  user-select: none;
}
details.dashboard-section summary::-webkit-details-marker { display: none; }
details.dashboard-section .chevron {
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.2s;
}
details.dashboard-section[open] .chevron { transform: rotate(90deg); }
details.dashboard-section .dashboard-section-body {
  padding: 12px 16px 16px;
}

/* ── Compliance calendar (Feature 1.4) ─────────────────────── */
.calendar-category-filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; font-size: 0.82rem; color: var(--muted); }
.calendar-cat-toggle { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.calendar-grid-wrapper { overflow-x: auto; }
.calendar-grid { width: 100%; min-width: 700px; border-collapse: collapse; table-layout: fixed; }
.calendar-grid th { background: var(--navy); color: var(--white); padding: 8px; font-size: 0.8rem; text-align: left; }
.calendar-day { border: 1px solid var(--border); vertical-align: top; height: 96px; padding: 6px; cursor: pointer; transition: background 0.15s; }
.calendar-day:hover { background: var(--cream-dark); }
.calendar-day-out { background: #FAF8F2; color: var(--muted); }
.calendar-day-today { background: rgba(168,124,79,0.12); border: 2px solid var(--bronze); }
.calendar-day-num { font-weight: 600; font-size: 0.85rem; margin-bottom: 4px; }
.calendar-day-events { display: flex; flex-direction: column; gap: 2px; }
.calendar-pill { display: block; font-size: 0.68rem; padding: 2px 6px; border-radius: 999px; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calendar-pill-red { background: var(--critical); }
.calendar-pill-amber { background: var(--medium); }
.calendar-pill-navy { background: var(--navy); }
.calendar-pill-bronze { background: var(--bronze); }
.calendar-pill-more { font-size: 0.68rem; color: var(--muted); }
.calendar-detail-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.calendar-detail-row:last-child { border-bottom: none; }
@media (max-width: 767px) {
    .calendar-day { height: 76px; padding: 4px; }
    .calendar-pill { font-size: 0.62rem; }
}

/* ── Feature 1.2 — Responsive design overhaul ──────────────────────────── */

/* Step 1.2.5 — wide data tables: horizontal scroll with sticky first column */
.table-responsive-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-responsive-wrapper table {
    min-width: 700px;
}
.table-responsive-wrapper td:first-child,
.table-responsive-wrapper th:first-child {
    position: sticky;
    left: 0;
    background: inherit;
    z-index: 1;
}

/* Step 1.2.5 — simpler tables: card-per-row on mobile */
@media (max-width: 767px) {
    .table-card-mobile thead { display: none; }
    .table-card-mobile tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 12px;
        padding: 12px;
    }
    .table-card-mobile td {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
        border: none;
        border-bottom: 1px solid var(--cream-dark);
        font-size: 0.875rem;
        text-align: right;
    }
    .table-card-mobile td:last-child { border-bottom: none; }
    .table-card-mobile td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--navy);
        margin-right: 12px;
        flex-shrink: 0;
        text-align: left;
    }
    .table-card-mobile td:empty::before { content: none; }
}

/* Step 1.2.6 — responsive form grids (additive alongside the existing .field-row) */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 768px) {
    .form-row-2col { grid-template-columns: 1fr 1fr; }
    .form-row-3col { grid-template-columns: 1fr 1fr 1fr; }
}

/* Step 1.2.7 — the setup dashboard's data-entry rows use inline
   grid-template-columns (many differing column counts) — stack them to a
   single column on phones regardless of the inline style, since !important
   on a stylesheet rule outranks a non-!important inline style. */
@media (max-width: 767px) {
    .setup-row { grid-template-columns: 1fr !important; gap: 10px; }
}

/* Step 1.2.8 — Chart.js canvases */
canvas.chart-canvas {
    max-height: 300px !important;
    width: 100% !important;
}
@media (max-width: 767px) {
    canvas.chart-canvas { max-height: 220px !important; }
}

/* ── Inspection checklists (Feature 2.1) ───────────────────── */
.inspection-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.inspection-item:last-child { border-bottom: none; }
.inspection-item-text { font-weight: 600; margin: 0 0 8px; }
.inspection-item-results { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.inspection-result-option { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: 0.82rem; cursor: pointer; min-height: 36px; }
.inspection-result-option input { width: auto; min-height: 0; }
.inspection-result-option:has(input:checked) { border-color: var(--navy); background: var(--cream-dark); font-weight: 600; }
.inspection-item input[type="text"] { font-size: 0.88rem; }

/* ── Contractor management (Feature 2.3) ───────────────────── */
.contractor-progress-bar { width: 100%; max-width: 140px; height: 8px; background: var(--cream-dark); border-radius: 999px; overflow: hidden; margin-bottom: 3px; }
.contractor-progress-fill { height: 100%; border-radius: 999px; }
.contractor-progress-complete { background: var(--low); }
.contractor-progress-partial { background: var(--medium); }
.contractor-progress-empty { background: var(--critical); }
.site-access-banner { padding: 12px 18px; border-radius: var(--radius); font-weight: 700; font-size: 1rem; text-align: center; letter-spacing: 0.03em; }
.site-access-approved { background: #E5EEDB; color: #3E5A2E; border: 1px solid #C7D9B4; }
.site-access-denied { background: #F6E2DE; color: #8A3324; border: 1px solid #E9C2B9; }

/* ── Environmental obligations traffic light (Feature 3.2) ─── */
.env-traffic-light { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.env-traffic-red { background: var(--critical); }
.env-traffic-amber { background: var(--medium); }
.env-traffic-green { background: var(--low); }
.env-traffic-grey { background: var(--muted); }

/* ── Renewal workflow Kanban board (Feature 4.4) ───────────── */
.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kanban-column { flex: 0 0 240px; background: var(--cream-dark); border-radius: var(--radius); padding: 12px; }
.kanban-column-header { font-size: 0.85rem; color: var(--navy); margin: 0 0 10px; }
.kanban-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; font-size: 0.85rem; }
@media (max-width: 767px) {
    .kanban-column { flex: 0 0 200px; }
}

/* ── Risk 5x5 matrix (Feature 2.4) ──────────────────────────── */
.risk-matrix-wrapper { overflow-x: auto; }
.risk-matrix-grid { border-collapse: collapse; min-width: 640px; }
.risk-matrix-grid th { background: var(--navy); color: var(--white); padding: 8px; font-size: 0.78rem; text-align: center; }
.risk-matrix-corner { background: var(--white) !important; color: var(--muted) !important; font-size: 0.72rem !important; }
.risk-matrix-row-label { background: var(--navy) !important; color: var(--white) !important; text-align: right !important; padding-right: 10px !important; white-space: nowrap; }
.risk-matrix-cell { width: 110px; height: 90px; text-align: center; vertical-align: top; padding: 6px; border: 2px solid var(--white); }
.risk-matrix-band-low { background: rgba(91,138,90,0.25); }
.risk-matrix-band-medium { background: rgba(201,154,46,0.28); }
.risk-matrix-band-high { background: rgba(201,112,46,0.3); }
.risk-matrix-band-critical { background: rgba(178,58,58,0.32); }
.risk-matrix-score { font-size: 0.72rem; font-weight: 700; color: var(--ink); opacity: 0.6; margin-bottom: 4px; }
.risk-matrix-dots { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.risk-matrix-dot { color: var(--navy); font-size: 1.1rem; text-decoration: none; line-height: 1; }
.risk-matrix-dot:hover { color: var(--bronze); }
.risk-matrix-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px; font-size: 0.82rem; color: var(--muted); }
.risk-matrix-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.risk-matrix-swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.risk-matrix-swatch.risk-matrix-band-low { background: var(--low); }
.risk-matrix-swatch.risk-matrix-band-medium { background: var(--medium); }
.risk-matrix-swatch.risk-matrix-band-high { background: var(--high); }
.risk-matrix-swatch.risk-matrix-band-critical { background: var(--critical); }
@media (max-width: 767px) {
    .risk-matrix-cell { width: 80px; height: 70px; }
}

/* ── Offline field mode forms (Feature 4.6) ─────────────────────────────
   Independent of the pre-existing .field-mode session toggle (large-touch
   NAV chrome, opt-in on any page) — these classes are always-on for the
   three dedicated field forms, since they're built to be filled in on-site
   with one thumb regardless of whether the wider "field mode" nav toggle
   is on. */
.field-page { max-width: 480px; margin: 0 auto; }
.field-page h1 { font-size: 1.4rem; }
.field-page .card { padding: 18px; }
.field-page .btn-huge {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 18px; font-size: 1.15rem; font-weight: 600;
  text-align: center; border-radius: var(--radius); margin-bottom: 14px; min-height: 60px;
}
.field-page .field-icon { font-size: 1.6rem; }
.field-page label { display: block; font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.field-page input[type="text"], .field-page textarea, .field-page select {
  width: 100%; min-height: 48px; font-size: 1.05rem; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius); font-family: inherit; margin-bottom: 18px;
}
.field-page textarea { min-height: 100px; }
.field-page .field-radio-group { display: flex; gap: 8px; margin-bottom: 18px; }
.field-page .field-radio-group input { position: absolute; opacity: 0; }
.field-page .field-radio-group label {
  flex: 1; text-align: center; padding: 14px 6px; margin: 0; border: 2px solid var(--border);
  border-radius: var(--radius); font-weight: 600; cursor: pointer; user-select: none;
}
.field-page .field-radio-group input:checked + label { border-color: var(--navy); background: var(--cream-dark); }
.field-page .field-radio-group label.result-pass:has(input:checked), .field-page .field-radio-group input:checked + label.result-pass { border-color: var(--low); background: rgba(91,138,90,0.15); }
.field-page .field-radio-group input:checked + label.result-fail { border-color: var(--critical); background: rgba(178,58,58,0.15); }
.field-page .checklist-item { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 14px; }
.field-page .checklist-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.field-sync-badge {
  display: inline-block; background: var(--critical); color: var(--white); border-radius: 999px;
  padding: 2px 9px; font-size: 0.78rem; font-weight: 700; margin-left: 6px;
}
#field-offline-status {
  background: rgba(201,154,46,0.18); border: 1px solid var(--medium); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 18px; font-weight: 600;
}

/* ── Error pages ─────────────────────────────────────────────────────────── */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 2rem;
}
.error-code {
    font-size: 6rem;
    font-weight: 800;
    color: var(--navy);
    line-height: 1;
    margin-bottom: 1rem;
    opacity: 0.15;
}
.error-page h1 {
    font-size: 1.75rem;
    color: var(--navy);
    margin-bottom: 0.75rem;
}
.error-page p {
    color: #666;
    max-width: 400px;
    margin-bottom: 2rem;
}

