/* ==========================================================================
   Q&Done design system
   Light and dark themes via Bootstrap 5.3 color modes (data-bs-theme on <html>).
   Pages are built from: .page-header, .panel (+ .panel-header/.panel-body),
   .stat-tile, .badge-soft-*, .callout. Tokens below drive both themes.
   ========================================================================== */

:root,
[data-bs-theme="light"] {
  --cq-bg: #f3f5f9;
  --cq-surface: #ffffff;
  --cq-surface-2: #f7f9fc;
  --cq-surface-hover: #f0f4fa;
  --cq-border: #dfe4ec;
  --cq-border-strong: #c9d1de;
  --cq-text: #172033;
  --cq-muted: #5d6a80;
  --cq-accent: #2563eb;
  --cq-accent-hover: #1d4fd7;
  --cq-accent-soft: #e7eefe;
  --cq-accent-border: #b9cdfb;
  --cq-hero: linear-gradient(135deg, #eef3ff 0%, #f7f9ff 100%);
  /* Section (panel) headers: a light tint of the accent, so they stand out from the white panels and follow tenant branding. */
  --cq-header-bg: color-mix(in srgb, var(--cq-accent) 9%, #f2f5fa);
  --cq-header-border: #d3dcea;
  --cq-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);

  --cq-success: #15803d; --cq-success-soft: #e6f6ec;
  --cq-warning: #a16207; --cq-warning-soft: #fdf4dc;
  --cq-danger: #b91c1c;  --cq-danger-soft: #fdeaea;
  --cq-info: #0e7490;    --cq-info-soft: #e3f5f9;
  --cq-neutral: #475569; --cq-neutral-soft: #eef1f5;
}

[data-bs-theme="dark"] {
  --cq-bg: #0a0d14;
  --cq-surface: #111722;
  --cq-surface-2: #0d121b;
  --cq-surface-hover: #172031;
  --cq-border: #232c3d;
  --cq-border-strong: #33405a;
  --cq-text: #e6eaf2;
  --cq-muted: #93a0b6;
  --cq-accent: #3b82f6;
  --cq-accent-hover: #5b96f8;
  --cq-accent-soft: rgba(59, 130, 246, .14);
  --cq-accent-border: rgba(59, 130, 246, .45);
  --cq-hero: linear-gradient(135deg, #12204a 0%, #0f1830 100%);
  --cq-header-bg: var(--cq-surface-2);
  --cq-header-border: var(--cq-border);
  --cq-shadow: none;

  --cq-success: #4ade80; --cq-success-soft: rgba(74, 222, 128, .12);
  --cq-warning: #fbbf24; --cq-warning-soft: rgba(251, 191, 36, .13);
  --cq-danger: #f87171;  --cq-danger-soft: rgba(248, 113, 113, .13);
  --cq-info: #38bdf8;    --cq-info-soft: rgba(56, 189, 248, .13);
  --cq-neutral: #a3afc2; --cq-neutral-soft: rgba(163, 175, 194, .12);
}

/* Map tokens onto Bootstrap so its components follow the theme. */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --bs-body-bg: var(--cq-bg);
  --bs-body-color: var(--cq-text);
  --bs-emphasis-color: var(--cq-text);
  --bs-secondary-color: var(--cq-muted);
  --bs-secondary-bg: var(--cq-surface-2);
  --bs-tertiary-bg: var(--cq-surface-2);
  --bs-border-color: var(--cq-border);
  --bs-link-color: var(--cq-accent);
  --bs-link-color-rgb: 37, 99, 235;
  --bs-link-hover-color: var(--cq-accent-hover);
  --bs-heading-color: var(--cq-text);
  --bs-border-radius: .5rem;
  --bs-border-radius-lg: .75rem;
  --bs-font-sans-serif: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-bs-theme="dark"] { --bs-link-color-rgb: 59, 130, 246; color-scheme: dark; }

/* ---------- Base ---------------------------------------------------------- */

html { font-size: 15px; position: relative; min-height: 100%; }

body {
  background: var(--cq-bg);
  color: var(--cq-text);
  margin-bottom: 64px;
  -webkit-font-smoothing: antialiased;
}

.text-muted, .form-text { color: var(--cq-muted) !important; }

a { text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--cq-accent); outline-offset: 2px; }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
  box-shadow: 0 0 0 .2rem var(--cq-accent-soft);
  border-color: var(--cq-accent);
}

/* ---------- App navigation ------------------------------------------------ */

.app-navbar {
  background: var(--cq-surface);
  border-bottom: 1px solid var(--cq-border);
  padding-top: .4rem;
  padding-bottom: .4rem;
}

.app-navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--cq-text);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.brand-mark {
  width: 1.6rem; height: 1.6rem;
  border-radius: .45rem;
  display: inline-grid; place-items: center;
  background: var(--cq-brand, var(--cq-accent));
  color: #fff;
  font-size: .8rem; font-weight: 800;
}

/* Product logo (files in wwwroot/brand). The wordmark has a light and a dark version. */
.app-icon { width: 1.75rem; height: 1.75rem; display: block; flex: none; }
.wordmark-heading { margin: 0 auto 1rem; }
.wordmark { display: block; width: 100%; max-width: 18rem; height: auto; margin: 0 auto; }
[data-bs-theme="dark"] .wordmark-light, [data-bs-theme="light"] .wordmark-dark { display: none; }

.app-navbar .nav-link {
  color: var(--cq-muted);
  font-weight: 500;
  font-size: .925rem;
  padding: .45rem .7rem !important;
  border-radius: .45rem;
}

.app-navbar .nav-link:hover { color: var(--cq-text); background: var(--cq-surface-hover); text-decoration: none; }
.app-navbar .nav-link.active { color: var(--cq-accent); background: var(--cq-accent-soft); }

.theme-toggle {
  border: 1px solid var(--cq-border);
  background: var(--cq-surface-2);
  color: var(--cq-muted);
  border-radius: .45rem;
  padding: .3rem .55rem;
  line-height: 1;
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .85rem;
}
.theme-toggle:hover { color: var(--cq-text); border-color: var(--cq-border-strong); }
.theme-toggle svg { width: 1rem; height: 1rem; }

.app-main { padding-top: 1.5rem; padding-bottom: 1.5rem; }

.footer {
  position: absolute; bottom: 0; width: 100%;
  line-height: 56px;
  font-size: .85rem;
  color: var(--cq-muted);
  background: var(--cq-surface);
  border-top: 1px solid var(--cq-border);
}

/* ---------- Page header --------------------------------------------------- */

.page-header {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: .75rem 1.5rem;
  margin-bottom: 1.25rem;
}

.page-header h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-header .page-subtitle { color: var(--cq-muted); margin: .25rem 0 0; font-size: .95rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.breadcrumb { font-size: .85rem; margin-bottom: .5rem; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--cq-muted); }
.breadcrumb-item.active { color: var(--cq-muted); }

/* ---------- Panels: the primary way sections are delineated -------------- */

.panel {
  background: var(--cq-surface);
  border: 1px solid var(--cq-border);
  border-radius: .75rem;
  box-shadow: var(--cq-shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.panel-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem 1rem;
  padding: .85rem 1.15rem;
  border-bottom: 1px solid var(--cq-header-border);
  background: var(--cq-header-bg);
}

.panel-title { font-size: 1rem; font-weight: 650; margin: 0; letter-spacing: -.005em; }
.panel-subtitle { color: var(--cq-muted); font-size: .85rem; margin: .15rem 0 0; }
.panel-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }

.panel-body { padding: 1.1rem 1.15rem; }
.panel-body > :last-child { margin-bottom: 0; }

/* Flush content (tables, list groups) sits edge to edge inside the panel. */
.panel-flush { padding: 0; }
.panel-flush > .table, .panel-flush > .table-responsive > .table { margin: 0; }
.panel-flush > .list-group { border-radius: 0; }
.panel-flush > .list-group > .list-group-item { border-left: 0; border-right: 0; }
.panel-flush > .list-group > .list-group-item:first-child { border-top: 0; }
.panel-flush > .list-group > .list-group-item:last-child { border-bottom: 0; }

.panel-footer {
  padding: .75rem 1.15rem;
  border-top: 1px solid var(--cq-border);
  background: var(--cq-surface-2);
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
}

.panel-accent { border-color: var(--cq-accent-border); }
.panel-accent > .panel-header { background: var(--cq-accent-soft); border-bottom-color: var(--cq-accent-border); }

.panel-danger { border-color: var(--cq-danger); }
.panel-danger > .panel-header { background: var(--cq-danger-soft); }

/* Small uppercase label used for field captions and section kickers. */
.eyebrow {
  font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--cq-muted);
}

/* ---------- Stat tiles ---------------------------------------------------- */

.stat-grid {
  display: grid;
  gap: .9rem;
  grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
  margin-bottom: 1.25rem;
}

.stat-tile {
  background: var(--cq-surface);
  border: 1px solid var(--cq-border);
  border-radius: .75rem;
  padding: .85rem 1rem;
  box-shadow: var(--cq-shadow);
  min-width: 0;
}
a.stat-tile { display: block; color: inherit; }
a.stat-tile:hover { text-decoration: none; border-color: var(--cq-accent-border); background: var(--cq-surface-hover); }

.stat-label { font-size: .78rem; color: var(--cq-muted); margin-bottom: .2rem; }
.stat-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.stat-value.stat-value-sm { font-size: 1rem; font-weight: 600; letter-spacing: 0; }
.stat-note { font-size: .75rem; color: var(--cq-muted); margin-top: .2rem; font-weight: 600; }
.stat-tile.is-danger .stat-value { color: var(--cq-danger); }
.stat-tile.is-success .stat-value { color: var(--cq-success); }
.stat-tile.is-accent { border-color: var(--cq-accent-border); box-shadow: inset 3px 0 0 var(--cq-accent), var(--cq-shadow); }
.stat-tile.is-accent .stat-value { color: var(--cq-accent); }
.stat-grid-6 { grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); }

/* Hero band (e.g. top of a dashboard) */
.hero-panel {
  background: var(--cq-hero);
  border: 1px solid var(--cq-accent-border);
  border-radius: .9rem;
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
}

/* ---------- Callouts ------------------------------------------------------ */

.callout {
  display: flex; align-items: center; gap: .75rem;
  border: 1px solid var(--cq-accent-border);
  background: var(--cq-accent-soft);
  border-radius: .6rem;
  padding: .6rem .9rem;
  font-size: .9rem;
  margin-bottom: 1.25rem;
}
.callout-tag {
  font-size: .68rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: .2rem .55rem; border-radius: 999px;
  background: var(--cq-accent); color: #fff; white-space: nowrap;
}
.callout-warning { border-color: var(--cq-warning); background: var(--cq-warning-soft); }
.callout-warning .callout-tag { background: var(--cq-warning); color: #111; }
.callout-success { border-color: var(--cq-success); background: var(--cq-success-soft); }
.callout-danger { border-color: var(--cq-danger); background: var(--cq-danger-soft); }

/* ---------- Badges -------------------------------------------------------- */

.badge { font-weight: 600; letter-spacing: .01em; border-radius: 999px; padding: .32em .65em; }
.badge-soft-primary { color: var(--cq-accent); background: var(--cq-accent-soft); }
.badge-soft-success { color: var(--cq-success); background: var(--cq-success-soft); }
.badge-soft-warning { color: var(--cq-warning); background: var(--cq-warning-soft); }
.badge-soft-danger  { color: var(--cq-danger);  background: var(--cq-danger-soft); }
.badge-soft-info    { color: var(--cq-info);    background: var(--cq-info-soft); }
.badge-soft-neutral { color: var(--cq-neutral); background: var(--cq-neutral-soft); }

/* Neutral outline badge used for "Required", question types, etc. */
.badge-outline { color: var(--cq-muted); background: transparent; border: 1px solid var(--cq-border-strong); font-weight: 600; }

/* ---------- Tables -------------------------------------------------------- */

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--cq-text);
  --bs-table-border-color: var(--cq-border);
  --bs-table-hover-bg: var(--cq-surface-hover);
  --bs-table-hover-color: var(--cq-text);
  font-size: .925rem;
}
.table > :not(caption) > * > * { padding: .6rem 1.15rem; }
.table > thead th {
  font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--cq-muted);
  background: var(--cq-surface-2);
  border-bottom-width: 1px;
  white-space: nowrap;
}
.table > tbody > tr:last-child > * { border-bottom: 0; }
.table .cell-sub { display: block; font-size: .8rem; color: var(--cq-muted); }

/* ---------- Forms --------------------------------------------------------- */

.form-label { font-weight: 600; font-size: .875rem; margin-bottom: .3rem; }
.form-control, .form-select {
  background-color: var(--cq-surface-2);
  border-color: var(--cq-border-strong);
  color: var(--cq-text);
}
.form-control:focus, .form-select:focus { background-color: var(--cq-surface); color: var(--cq-text); }
.form-control::placeholder { color: var(--cq-muted); opacity: .75; }
.form-control[readonly] { background-color: var(--cq-surface-2); }
.input-group-text { background: var(--cq-surface-2); border-color: var(--cq-border-strong); color: var(--cq-muted); }
.form-check-input { border-color: var(--cq-border-strong); background-color: var(--cq-surface-2); }

/* Grouped form sections inside a panel */
.form-section + .form-section { border-top: 1px solid var(--cq-border); margin-top: 1.1rem; padding-top: 1.1rem; }
.form-section-title { font-size: .9rem; font-weight: 650; margin-bottom: .75rem; }

/* ---------- Buttons ------------------------------------------------------- */

.btn { font-weight: 600; font-size: .9rem; border-radius: .5rem; }
.btn-sm { font-size: .8rem; }
.btn-primary { --bs-btn-bg: var(--cq-accent); --bs-btn-border-color: var(--cq-accent); --bs-btn-hover-bg: var(--cq-accent-hover); --bs-btn-hover-border-color: var(--cq-accent-hover); --bs-btn-active-bg: var(--cq-accent-hover); --bs-btn-disabled-bg: var(--cq-accent); --bs-btn-disabled-border-color: var(--cq-accent); }
.btn-outline-secondary { --bs-btn-color: var(--cq-text); --bs-btn-border-color: var(--cq-border-strong); --bs-btn-hover-bg: var(--cq-surface-hover); --bs-btn-hover-color: var(--cq-text); --bs-btn-hover-border-color: var(--cq-border-strong); --bs-btn-active-bg: var(--cq-surface-hover); --bs-btn-active-color: var(--cq-text); }
.btn-outline-primary { --bs-btn-color: var(--cq-accent); --bs-btn-border-color: var(--cq-accent-border); --bs-btn-hover-bg: var(--cq-accent-soft); --bs-btn-hover-color: var(--cq-accent); --bs-btn-hover-border-color: var(--cq-accent); --bs-btn-active-bg: var(--cq-accent-soft); --bs-btn-active-color: var(--cq-accent); }
.btn-link { font-weight: 600; }

/* ---------- Lists, alerts, misc ------------------------------------------- */

.list-group { --bs-list-group-bg: var(--cq-surface); --bs-list-group-border-color: var(--cq-border); --bs-list-group-color: var(--cq-text); --bs-list-group-action-hover-bg: var(--cq-surface-hover); --bs-list-group-action-hover-color: var(--cq-text); }
.list-group-item { padding: .75rem 1.15rem; }

.alert { border-radius: .6rem; font-size: .925rem; padding: .7rem 1rem; }

.nav-tabs { --bs-nav-tabs-border-color: var(--cq-border); --bs-nav-tabs-link-active-bg: var(--cq-surface); --bs-nav-tabs-link-active-border-color: var(--cq-border) var(--cq-border) var(--cq-surface); }
.nav-tabs .nav-link { color: var(--cq-muted); font-weight: 600; font-size: .9rem; }
.nav-tabs .nav-link.active { color: var(--cq-text); }

/* Segmented control (used for panel-level filters) */
.segmented { display: inline-flex; border: 1px solid var(--cq-border-strong); border-radius: .5rem; overflow: hidden; }
.segmented a { padding: .3rem .8rem; font-size: .85rem; font-weight: 600; color: var(--cq-muted); }
.segmented a + a { border-left: 1px solid var(--cq-border-strong); }
.segmented a:hover { text-decoration: none; color: var(--cq-text); background: var(--cq-surface-hover); }
.segmented a.active { background: var(--cq-accent-soft); color: var(--cq-accent); }

/* Definition list used for record summaries */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem 1.5rem; margin: 0; }
.meta-grid dt { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--cq-muted); margin-bottom: .15rem; }
.meta-grid dd { margin: 0; font-weight: 600; }

/* Empty states */
.empty-state { text-align: center; color: var(--cq-muted); padding: 2rem 1rem; }
.empty-state strong { display: block; color: var(--cq-text); margin-bottom: .25rem; }

/* Auth / centered card pages */
.auth-wrap { max-width: 26rem; margin: 2rem auto; }
.auth-wrap .panel-body { padding: 1.5rem; }

/* Question cards (portal and staff question lists) */
.question-card { border: 1px solid var(--cq-border); border-radius: .65rem; background: var(--cq-surface); padding: 1rem 1.15rem; margin-bottom: .75rem; }
.question-card.is-conflict { border-color: var(--cq-warning); }
.question-card.is-error { border-color: var(--cq-danger); }
.question-card legend { float: none; }

.ad-hoc-marker { box-shadow: inset 3px 0 0 var(--cq-warning); }

.sticky-actions {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--cq-bg);
  border-top: 1px solid var(--cq-border);
  padding: .75rem 0;
  display: flex; align-items: center; gap: 1rem;
}

/* Embedded preview frames stay white in both themes (email clients are light). */
.email-preview { background: #fff; border: 0; width: 100%; height: 22rem; }

/* Equal-height panels in a row keep their footers aligned at the bottom. */
.panel.h-100 { display: flex; flex-direction: column; }
.panel.h-100 > form { display: flex; flex-direction: column; flex: 1; }
.panel.h-100 > form > .panel-body,
.panel.h-100 > .panel-flush { flex: 1; }

/* ---------- Activity timeline and notes (Phase 5) ------------------------ */

.timeline-scroll { max-height: 26rem; overflow-y: auto; }
.timeline { list-style: none; margin: 0; padding: .25rem 0; }
.timeline-item {
  position: relative;
  padding: .55rem 1rem .55rem 2rem;
  border-bottom: 1px solid var(--cq-border);
  font-size: .9rem;
}
.timeline-item:last-child { border-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: .95rem; top: .95rem;
  width: .5rem; height: .5rem; border-radius: 50%;
  background: var(--cq-accent);
}
.timeline-item.is-danger::before { background: var(--cq-danger); }
.note-list li { padding: .6rem 0; border-top: 1px solid var(--cq-border); }
.note-list li:first-child { border-top: 0; padding-top: 0; }

/* ---------- Responses: question left, answer right ----------------------- */

.response-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: .35rem 1.5rem; padding-top: .6rem; padding-bottom: .6rem; }
.response-answer {
  border-left: 3px solid var(--cq-accent-border);
  padding-left: .85rem;
}
.response-value { white-space: pre-wrap; font-weight: 500; }
@media (max-width: 767.98px) {
  .response-row { grid-template-columns: 1fr; }
}

.review-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.25rem; }

/* ---------- Tenant branding (Phase 7) ------------------------------------ */

.tenant-logo { max-height: 2rem; max-width: 9rem; object-fit: contain; display: block; }
.tenant-logo-lg { max-height: 3.5rem; max-width: 14rem; object-fit: contain; }
.tenant-brand { display: flex; align-items: center; gap: .6rem; padding-left: .75rem; margin-left: .25rem; border-left: 1px solid var(--cq-border); }
.logo-preview { background: repeating-conic-gradient(var(--cq-surface-2) 0% 25%, var(--cq-surface) 0% 50%) 50% / 16px 16px; border: 1px dashed var(--cq-border-strong); border-radius: .5rem; padding: 1rem; display: grid; place-items: center; min-height: 6rem; }
.swatch { width: 2.25rem; height: 2.25rem; border-radius: .5rem; border: 1px solid var(--cq-border); display: inline-block; vertical-align: middle; }

/* ---------- Attachments (Phase 8) ---------------------------------------- */

.attachments { border-top: 1px dashed var(--cq-border); padding-top: .75rem; }
.file-list { list-style: none; padding: 0; margin: 0 0 .5rem; }
.file-list li { padding: .2rem 0; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.file-list li::before { content: "📎"; font-size: .85em; }

/* ---------- Reports (Phase 8) -------------------------------------------- */

.trend-chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: .4rem; height: 12rem; align-items: end; }
.trend-month { display: flex; flex-direction: column; height: 100%; min-width: 0; }
.trend-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--cq-border); }
.trend-bar { width: 42%; min-height: 1px; border-radius: 3px 3px 0 0; }
.bar-sent { background: var(--cq-accent-border); }
.bar-submitted { background: var(--cq-accent); }
.trend-label { font-size: .7rem; color: var(--cq-muted); text-align: center; margin-top: .3rem; }
.legend-swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; vertical-align: middle; margin-right: .2rem; }

/* Conditional display box in the question editor */
.condition-box { border: 1px solid var(--cq-accent-border); background: var(--cq-accent-soft); border-radius: .6rem; padding: .75rem .9rem; }
.condition-title { float: none; width: auto; font-size: .9rem; font-weight: 650; margin-bottom: .25rem; }

/* ---------- Question hierarchy: 4, 4.1, 4.2 ------------------------------ */

.q-number { min-width: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--cq-muted); }
.question-list .is-sub { padding-left: 2.6rem; background: var(--cq-surface-2); }
.question-list .is-sub .q-number::before { content: "↳ "; font-weight: 400; }
.question-card.is-sub { margin-left: 2rem; border-left: 3px solid var(--cq-accent-border); }
.response-row.is-sub .response-question { padding-left: 1.5rem; border-left: 2px solid var(--cq-accent-border); }
@media (max-width: 575.98px) { .question-card.is-sub { margin-left: .75rem; } }

/* Search-as-you-type picker (client-picker.js) */
.client-picker { position: relative; }
.client-picker .picker-status:empty { display: none; }
.picker-list {
  position: absolute; z-index: 1060; left: 0; right: 0; top: calc(100% + 2px); max-height: 20rem; overflow-y: auto;
  margin: 0; padding: .25rem 0; list-style: none; background: var(--cq-surface); border: 1px solid var(--cq-border-strong);
  border-radius: .5rem; box-shadow: 0 8px 24px rgba(16, 24, 40, .14);
}
.picker-list [role=option] { display: flex; flex-direction: column; padding: .45rem .75rem; cursor: pointer; }
.picker-list [role=option].active, .picker-list [role=option]:hover { background: var(--cq-accent-soft); }
.picker-list .picker-name { font-weight: 600; color: var(--cq-text); }
.picker-list .picker-sub { font-size: .8rem; color: var(--cq-muted); }
.picker-list .picker-empty { padding: .5rem .75rem; color: var(--cq-muted); font-size: .9rem; }

/* Confirmation dialog (site.js) */
.cq-confirm .modal-content { background: var(--cq-surface); color: var(--cq-text); border: 1px solid var(--cq-border); border-radius: .75rem; box-shadow: 0 16px 48px rgba(16, 24, 40, .22); }
.cq-confirm .modal-header, .cq-confirm .modal-footer { border-color: var(--cq-border); }
.cq-confirm .modal-title { font-weight: 700; }
.cq-confirm .modal-body { color: var(--cq-text); }

/* Reports: client time-to-submit bands and top-10 lists */
.band-chart { display: grid; gap: .45rem; }
.band-row { display: grid; grid-template-columns: 8.5rem 1fr 5.5rem; align-items: center; gap: .5rem; font-size: .85rem; }
.band-track { height: .7rem; background: var(--cq-neutral-soft); border-radius: 999px; overflow: hidden; }
.band-fill { display: block; height: 100%; background: var(--cq-accent); border-radius: 999px; }
.band-fill.band-open { background: var(--cq-warning); }
.band-value { text-align: right; white-space: nowrap; }
.highlight-list { margin: 0; padding-left: 1.25rem; }
.highlight-list li { padding: .3rem 0; border-bottom: 1px solid var(--cq-border); }
.highlight-list li:last-child { border-bottom: 0; }
.highlight-list li a { display: block; font-weight: 600; }

/* Settings > Integrations */
.integrations-nav .nav-link { padding: .3rem .75rem; font-size: .875rem; font-weight: 600; color: var(--cq-muted); border-radius: .4rem; }
.integrations-nav .nav-link.active { background: var(--cq-accent-soft); color: var(--cq-accent); }
.secret-once { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; background: var(--cq-surface-2); border: 1px dashed var(--cq-border-strong); border-radius: .4rem; padding: .5rem .75rem; }
.integration-card { display: flex; flex-direction: column; gap: .35rem; height: 100%; }
.integration-card h3 { font-size: 1rem; font-weight: 700; margin: 0; }
.api-doc pre { background: var(--cq-surface-2); border: 1px solid var(--cq-border); border-radius: .4rem; padding: .6rem .8rem; font-size: .8rem; white-space: pre-wrap; }
.api-doc h3 { font-size: 1rem; font-weight: 700; margin-top: 1.25rem; }
.api-doc code.verb { font-weight: 700; color: var(--cq-accent); }

/* Dashboard: Whole organization counts read at a glance. */
.badge.org-count { font-size: 1rem; font-weight: 700; min-width: 2.4rem; padding: .3rem .6rem; }
.badge-outline.org-count { color: var(--cq-text); }

/* Dashboard: Whole organization rows with a bar scaled to the largest count. */
.org-bar-row { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: .75rem; row-gap: .35rem; }
.org-bar-track { grid-column: 1 / -1; height: .4rem; background: var(--cq-neutral-soft); border-radius: 999px; overflow: hidden; }
.org-bar-fill { display: block; height: 100%; border-radius: 999px; min-width: 0; transition: width .3s ease; }
.org-bar-accent { background: var(--cq-accent); }
.org-bar-danger { background: var(--cq-danger); }
.org-bar-warning { background: var(--cq-warning); }
.org-bar-neutral { background: var(--cq-muted); }
@media (prefers-reduced-motion: reduce) { .org-bar-fill { transition: none; } }

/* Review follow-ups (portal and staff) */
.followup-panel { border-color: var(--cq-warning); }
.followup-item { padding: .9rem 0; border-bottom: 1px solid var(--cq-border); }
.followup-item:last-of-type { border-bottom: 0; }
.followup-item.is-error { background: var(--cq-danger-soft); }
.followup-thread { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; gap: .4rem; }
.followup-thread li { padding: .45rem .7rem; border-radius: .5rem; max-width: 46rem; }
.followup-thread li.from-staff { background: var(--cq-accent-soft); border: 1px solid var(--cq-accent-border); }
.followup-thread li.from-client { background: var(--cq-surface-2); border: 1px solid var(--cq-border); margin-left: 1.5rem; }
.followup-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.followup-box { margin-top: .6rem; padding: .6rem .75rem; border: 1px solid var(--cq-border); border-radius: .5rem; background: var(--cq-surface); }

/* Signature on submit */
.signature-box { padding: .9rem 1rem; border: 1px solid var(--cq-accent-border); border-radius: .5rem; background: var(--cq-accent-soft); }

/* Sensitive answers */
.sensitive-mask { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; }

/* Client name in the portal's top bar */
.portal-client { max-width: 22rem; padding: .2rem .6rem; border: 1px solid var(--cq-border); border-radius: 999px; background: var(--cq-surface); }
@media (max-width: 575.98px) { .portal-client { max-width: 9rem; } .portal-client .text-muted { display: none; } }

/* Settings tabs: up to eleven sections, so they wrap into pill buttons instead of one joined bar */
.settings-tabs { display: flex; flex-wrap: wrap; gap: .35rem; border: 0; border-radius: 0; overflow: visible; }
.settings-tabs a { border: 1px solid var(--cq-border-strong); border-radius: .5rem; white-space: nowrap; }
.settings-tabs a + a { border-left: 1px solid var(--cq-border-strong); }

/* ---------- Help icons: a "?" that opens a short explanation ------------- */
.help-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.15rem; height: 1.15rem; padding: 0; margin-left: .3rem; vertical-align: .1em;
  border: 1px solid var(--cq-border-strong); border-radius: 999px;
  background: var(--cq-surface); color: var(--cq-muted);
  font-size: .72rem; font-weight: 700; line-height: 1; cursor: pointer;
}
.help-tip:hover { color: var(--cq-accent); border-color: var(--cq-accent); }
.help-tip:focus-visible { outline: 2px solid var(--cq-accent); outline-offset: 2px; }
.help-pop {
  position: fixed; inset: auto; margin: 0;
  width: min(24rem, calc(100vw - 2rem));
  padding: .85rem 1rem; border: 1px solid var(--cq-border); border-radius: .6rem;
  background: var(--cq-surface); color: var(--cq-text); box-shadow: 0 8px 24px rgba(16, 24, 40, .18);
  font-size: .85rem; font-weight: 400; line-height: 1.45; text-align: left; letter-spacing: normal; text-transform: none;
}
.help-pop:popover-open { display: block; }
.help-pop-title { display: block; font-weight: 700; margin-bottom: .4rem; }
.help-pop-body, .help-list, .help-para { display: block; }
.help-list > [role="listitem"] { display: block; padding-left: .9rem; position: relative; margin-bottom: .3rem; }
.help-list > [role="listitem"]::before { content: "•"; position: absolute; left: 0; color: var(--cq-muted); }
.help-para { margin-top: .5rem; }

/* ---------- Setup checklist (dashboard, new organizations) --------------- */
.setup-meter { flex: 0 0 9rem; height: .5rem; border-radius: 999px; background: var(--cq-accent-soft); overflow: hidden; align-self: center; }
.setup-meter > span { display: block; height: 100%; background: var(--cq-accent); }
.setup-steps { list-style: none; margin: 0; padding: 0; }
.setup-step {
  display: grid; grid-template-columns: 1.5rem minmax(0, 1fr) auto; gap: .75rem; align-items: start;
  padding: .7rem 1.25rem; border-top: 1px solid var(--cq-border);
}
.setup-mark {
  width: 1.25rem; height: 1.25rem; margin-top: .1rem; border-radius: 999px; border: 1.5px solid var(--cq-border-strong);
  display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700;
}
.setup-step.is-done .setup-mark { background: var(--cq-success); border-color: var(--cq-success); color: #fff; }
.setup-text { display: grid; gap: .1rem; min-width: 0; }
.setup-title { font-weight: 600; text-decoration: none; }
.setup-title:hover { text-decoration: underline; }
.setup-step.is-done .setup-title { color: var(--cq-muted); font-weight: 500; }
.setup-desc { font-size: .85rem; color: var(--cq-muted); }
.setup-actions { white-space: nowrap; padding-top: .1rem; }
@media (max-width: 575.98px) {
  .setup-step { grid-template-columns: 1.5rem minmax(0, 1fr); }
  .setup-actions { grid-column: 2; }
  .setup-meter { flex-basis: 100%; }
}

/* ---------- Help articles and "Learn more" links ------------------------- */
.help-article { max-width: 48rem; }
.help-article h2 { font-size: 1.1rem; font-weight: 700; margin: 1.5rem 0 .5rem; }
.help-article h2:first-child { margin-top: 0; }
.help-article p, .help-article ul, .help-article ol { max-width: 68ch; }
.help-article li { margin-bottom: .35rem; }
.learn-more { white-space: nowrap; }

.footer-version { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Platform home: System readiness, Security, To do (OPS-011) ---- */
.stat-grid-4 { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.dash-section { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 767.98px) { .dash-section { grid-template-columns: 1fr; } }
.dash-gauge-col { display: flex; flex-direction: column; align-items: center; gap: .9rem; }
.dash-main { min-width: 0; }

/* Ring gauge */
.gauge { --tone: var(--cq-success); width: 8.5rem; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
    background: conic-gradient(var(--tone) calc(var(--pct) * 1%), var(--cq-neutral-soft) 0); }
.gauge-warning { --tone: var(--cq-warning); }
.gauge-danger { --tone: var(--cq-danger); }
.gauge-inner { width: 74%; aspect-ratio: 1; border-radius: 50%; background: var(--cq-surface); display: flex; flex-direction: column;
    align-items: center; justify-content: center; text-align: center; }
.gauge-value { font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--tone); }
.gauge-total { font-size: .95rem; font-weight: 600; color: var(--cq-muted); }
.gauge-label { font-size: .72rem; color: var(--cq-muted); margin-top: .2rem; }

/* Status dots and check tiles */
.status-dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; flex: none; vertical-align: middle; }
.status-ok { background: var(--cq-success); }
.status-warning { background: var(--cq-warning); }
.status-danger { background: var(--cq-danger); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .6rem; }
.check-tile { border: 1px solid var(--cq-border); border-radius: .55rem; padding: .55rem .7rem; background: var(--cq-surface); }
.check-tile.is-warning { border-color: var(--cq-warning); background: var(--cq-warning-soft); }
.check-tile.is-danger { border-color: var(--cq-danger); background: var(--cq-danger-soft); }
.dash-freshness { display: flex; gap: .5rem; align-items: flex-start; width: 100%; }
.dash-facts { margin: 0; width: 100%; display: grid; gap: .5rem; }
.dash-facts dt { font-size: .72rem; color: var(--cq-muted); font-weight: 600; }
.dash-facts dd { margin: 0; font-size: 1.25rem; font-weight: 700; }

/* Disk meters */
.meter-row { display: grid; grid-template-columns: 6rem minmax(0, 1fr) 5.5rem; gap: .6rem; align-items: center; }
.meter-track { height: .7rem; border-radius: 999px; background: var(--cq-neutral-soft); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 999px; background: var(--cq-success); }
.meter-fill.is-warning { background: var(--cq-warning); }
.meter-fill.is-danger { background: var(--cq-danger); }
.meter-value { text-align: right; }

/* Failed sign-ins chart */
.sec-chart { width: 100%; height: auto; display: block; }
.sec-chart .bar-staff, .legend-swatch.bar-staff { fill: var(--cq-accent); background: var(--cq-accent); }
.sec-chart .bar-lock, .legend-swatch.bar-lock { fill: var(--cq-danger); background: var(--cq-danger); }
.sec-chart .bar-client, .legend-swatch.bar-client { fill: var(--cq-warning); background: var(--cq-warning); }
.sec-chart .bar-none { fill: var(--cq-border-strong); }
.sec-chart .chart-axis { stroke: var(--cq-border-strong); stroke-width: 1; }
.sec-chart .chart-label { fill: var(--cq-muted); font-size: 11px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .9rem; color: var(--cq-muted); }
.legend-swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .3rem; vertical-align: middle; }

/* To do */
.todo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.todo-item { border: 1px solid var(--cq-border); border-left-width: 4px; border-radius: .55rem; padding: .65rem .8rem; background: var(--cq-surface); }
.todo-item.is-ok { border-left-color: var(--cq-success); }
.todo-item.is-warning { border-left-color: var(--cq-warning); }
.todo-item.is-danger { border-left-color: var(--cq-danger); background: var(--cq-danger-soft); }
.todo-head { display: flex; gap: .6rem; align-items: flex-start; }
.todo-head > .badge { flex: none; min-width: 5.5rem; }
.todo-title { min-width: 0; }
.todo-meta { display: flex; flex-wrap: wrap; gap: .25rem 1.2rem; margin: .4rem 0 0; padding-left: 6.1rem; }
@media (max-width: 575.98px) { .todo-meta { padding-left: 0; } }
.todo-done { margin: .4rem 0 0; padding-left: 6.1rem; }
.todo-done > summary { list-style: none; display: inline-block; }
.todo-done > summary::-webkit-details-marker { display: none; }
@media (max-width: 575.98px) { .todo-done { padding-left: 0; } }
