/* Ported from app/globals.css (Next.js app) — design tokens sourced from
   the KMC logo: navy for the "KMC" wordmark, red for the heart mark. Only
   the survey-wizard-relevant sections are kept for Phase 1; dashboard/login
   rules stay in the original for reference and get ported when their
   phases land. */
:root {
  --brand-navy: #1a2a6c;
  --brand-navy-dark: #101a47;
  --brand-blue: #3355a4;
  --brand-red: #e2231a;
  --brand-red-dark: #b91c1c;

  --color-bg: #f4f5fa;
  --color-surface: #ffffff;
  --color-text: #1b1d29;
  --color-text-muted: #5b6072;
  --color-border: #e1e4ec;

  --color-primary: var(--brand-navy);
  --color-primary-hover: #22378f;
  --color-danger: var(--brand-red);
  --color-danger-bg: #fdeceb;
  --color-success: #1e8a4c;
  --color-success-bg: #eaf7ef;
  --color-focus-ring: rgba(51, 85, 164, 0.35);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 26, 71, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 26, 71, 0.08);

  --background: var(--color-bg);
  --foreground: var(--color-text);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #10121a;
    --color-surface: #1a1d29;
    --color-text: #eef0f7;
    --color-text-muted: #a3a8bd;
    --color-border: #2c3040;
    --color-danger-bg: #3a1a1a;
    --color-success-bg: #123322;
    --background: var(--color-bg);
    --foreground: var(--color-text);
  }
}

html {
  height: 100%;
  color-scheme: light dark;
}

html,
body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  color: var(--foreground);
  background: var(--background);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body,
h1,
h2,
h3,
p,
fieldset,
legend,
ul {
  margin: 0;
  padding: 0;
}

fieldset {
  border: none;
}

a {
  color: inherit;
  text-decoration: none;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-primary);
}

/* ---------- Layout ---------- */

.app-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--color-surface);
  border-bottom: 3px solid var(--color-primary);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header__logo {
  height: 40px;
  width: auto;
}

.app-header__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

.app-header__subtitle {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  width: 100%;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

/* ---------- Login (Phase 2) ---------- */

.login-page {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(
    160deg,
    var(--color-bg) 0%,
    color-mix(in srgb, var(--brand-navy) 6%, var(--color-bg)) 100%
  );
}

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  padding: 2rem 1.75rem;
}

.login-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.psi-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--brand-navy) 0%, var(--brand-blue) 100%);
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow-md);
}

.login-hero__logo {
  height: 34px;
  width: auto;
}

.login-hero__title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: 0.01em;
}

.login-hero__subtitle {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: 0.35rem;
  line-height: 1.4;
}

.login-divider {
  height: 1px;
  background: var(--color-border);
  margin: 1.5rem 0;
}

.login-card .field {
  text-align: left;
}

/* ---------- Dashboard (Phase 2) ---------- */

.dashboard-shell {
  display: flex;
  min-height: calc(100vh - 61px);
}

.dashboard-nav {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.dashboard-nav__user {
  font-size: 0.85rem;
}

.dashboard-nav__role {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.dashboard-nav__links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dashboard-nav__links a {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--color-text);
}

.dashboard-nav__links a:hover {
  background: var(--color-bg);
  color: var(--color-primary);
}

.dashboard-main {
  flex: 1;
  padding: 1.75rem;
  min-width: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
}

th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- Stepper ---------- */

.stepper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.stepper__step {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.stepper__dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  border: 2px solid var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-surface);
  flex-shrink: 0;
}

.stepper__step--complete .stepper__dot {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.stepper__step--active .stepper__dot {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.stepper__label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.stepper__step--active .stepper__label {
  color: var(--color-primary);
  font-weight: 600;
}

.stepper__line {
  width: 16px;
  height: 2px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.1rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field__label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
}

.field__hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input:not([type]),
select,
textarea {
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  width: 100%;
}

textarea {
  min-height: 5rem;
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
  border-color: var(--color-primary);
}

.option-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.option-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.875rem;
  background: var(--color-surface);
  transition: border-color 0.15s, background 0.15s;
}

.option-pill:has(input:checked) {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface));
  color: var(--color-primary);
  font-weight: 600;
}

.option-pill input {
  accent-color: var(--color-primary);
}

/* ---------- Buttons ---------- */

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.25rem;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.nav-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.75rem;
}

/* ---------- Alerts ---------- */

.alert {
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-warning {
  background: #fff6e5;
  color: #7a5200;
  border: 1px solid #f0d68a;
}

.alert-danger {
  background: var(--color-danger-bg);
  color: var(--brand-red-dark);
  border: 1px solid var(--brand-red);
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

/* ---------- Emotion picker ---------- */

.emotion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 0.6rem;
}

.emotion-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 0.4rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--color-surface);
  transition: border-color 0.15s, transform 0.1s;
  text-align: center;
  font-size: 0.8rem;
}

.emotion-card:has(input:checked) {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface));
  font-weight: 600;
  color: var(--color-primary);
}

.emotion-card img {
  border-radius: var(--radius-sm);
}

.scale-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.scale-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  border-bottom: 3px solid var(--dot-color, var(--color-border));
  cursor: pointer;
  font-size: 0.85rem;
  background: var(--color-surface);
}

.scale-dot--wide {
  min-width: auto;
  padding: 0 0.9rem;
}

.scale-dot:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
}

.scale-dot input {
  display: none;
}

.scale-anchors {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  max-width: 26rem;
  margin-top: 0.5rem;
}

/* ---------- Likert items ---------- */

.likert-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  background: var(--color-surface);
}

.likert-item legend {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.6rem;
  padding-right: 0.5rem;
}

.likert-list {
  display: grid;
  gap: 0.75rem;
}

/* ---------- Responsive polish ---------- */

body {
  background-image:
    radial-gradient(circle at 0 0, rgba(51, 85, 164, 0.07), transparent 28rem),
    linear-gradient(180deg, var(--color-bg), color-mix(in srgb, var(--color-bg) 94%, #fff));
  background-attachment: fixed;
}

.app-header {
  min-height: 68px;
  padding: 0.7rem clamp(1rem, 4vw, 2.5rem);
  border-bottom-width: 2px;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--color-surface) 94%, transparent);
}

.app-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.app-header__copy {
  display: grid;
  min-width: 0;
}

.page {
  max-width: 760px;
  padding: clamp(1rem, 3vw, 2rem) clamp(0.85rem, 3vw, 1.5rem) 4rem;
}

.card {
  border-color: color-mix(in srgb, var(--color-border) 82%, transparent);
  box-shadow: 0 14px 40px rgba(16, 26, 71, 0.08);
}

.auth-layout {
  background:
    radial-gradient(circle at 15% 15%, rgba(51, 85, 164, 0.18), transparent 24rem),
    radial-gradient(circle at 90% 90%, rgba(226, 35, 26, 0.08), transparent 22rem),
    var(--color-bg);
}

.auth-layout .login-page {
  min-height: 100svh;
}

.login-card {
  max-width: 430px;
  padding: clamp(1.5rem, 5vw, 2.5rem);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input:not([type]),
select,
textarea {
  min-height: 46px;
  border-radius: 9px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

button,
.btn-secondary {
  min-height: 44px;
  border-radius: 9px;
}

.btn-primary {
  box-shadow: 0 6px 16px rgba(26, 42, 108, 0.18);
}

.dashboard-nav__links a[aria-current="page"] {
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 9%, var(--color-surface));
  font-weight: 700;
}

.dashboard-main {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

@media (max-width: 760px) {
  .app-header {
    min-height: 60px;
    padding: 0.55rem 0.85rem;
  }

  .app-header__logo {
    height: 34px;
  }

  .app-header__title {
    font-size: 0.92rem;
  }

  .app-header__subtitle {
    max-width: 15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page {
    padding: 0.9rem 0.7rem 2.5rem;
  }

  .card {
    padding: 1.1rem;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(16, 26, 71, 0.07);
  }

  .stepper {
    margin: 0 -0.7rem 1rem;
    padding: 0.2rem 0.7rem 0.65rem;
    scrollbar-width: none;
  }

  .stepper::-webkit-scrollbar {
    display: none;
  }

  .stepper__label {
    display: none;
  }

  .stepper__step--active .stepper__label {
    display: inline;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .option-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option-pill {
    min-height: 44px;
    justify-content: flex-start;
    border-radius: 10px;
  }

  .emotion-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .scale-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .scale-dot {
    width: 100%;
    min-width: 0;
    padding: 0;
  }

  .nav-buttons {
    gap: 0.7rem;
  }

  .nav-buttons > * {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  .dashboard-shell {
    display: block;
    min-height: calc(100svh - 60px);
  }

  .dashboard-nav {
    width: 100%;
    padding: 0.75rem;
    gap: 0.75rem;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .dashboard-nav__user {
    padding: 0 0.25rem;
  }

  .dashboard-nav__links {
    flex-direction: row;
    overflow-x: auto;
    gap: 0.4rem;
    padding-bottom: 0.2rem;
    scrollbar-width: none;
  }

  .dashboard-nav__links::-webkit-scrollbar {
    display: none;
  }

  .dashboard-nav__links li {
    flex: 0 0 auto;
  }

  .dashboard-nav__links a {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    white-space: nowrap;
  }

  .dashboard-nav form {
    max-width: 12rem;
  }

  .dashboard-main {
    padding: 1.1rem 0.85rem 2rem;
  }

  .dashboard-main .card {
    overflow-x: auto;
  }

  table {
    min-width: 620px;
  }
}

@media (max-width: 420px) {
  .login-page {
    padding: 0.75rem;
    align-items: flex-start;
  }

  .login-card {
    margin-top: 4vh;
    padding: 1.35rem 1.1rem;
  }

  .psi-badge {
    width: 52px;
    height: 52px;
    font-size: 1.7rem;
  }

  .emotion-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option-group {
    grid-template-columns: 1fr;
  }
}

/* ---------- Clinical workspaces ---------- */
.privacy-chip { display:inline-flex;padding:.4rem .7rem;border:1px solid var(--color-border);border-radius:999px;color:var(--color-text-muted);background:var(--color-surface);font-size:.72rem;font-weight:700;white-space:nowrap; }
.triage-kpis { margin:0 0 1rem; }
.kpi-row { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.85rem; }
.stat-tile { position:relative;min-width:0;padding:1rem 1.1rem;border:1px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);box-shadow:var(--shadow-sm);overflow:hidden; }
.stat-tile::before { content:"";position:absolute;inset:0 auto 0 0;width:4px;background:var(--metric-accent,var(--brand-blue)); }
.stat-tile__label { color:var(--color-text-muted);font-size:.72rem;font-weight:750;letter-spacing:.03em;text-transform:uppercase; }
.stat-tile__value { margin-top:.35rem;color:var(--color-text);font-size:clamp(1.65rem,3vw,2.15rem);font-weight:800;line-height:1;font-variant-numeric:tabular-nums; }
.stat-tile__value--good { color:var(--color-success); }
.stat-tile__value--critical { color:var(--color-danger); }
.metric-card--primary { --metric-accent:var(--brand-blue); }
.metric-card--danger { --metric-accent:var(--brand-red); }
.metric-card--warning { --metric-accent:#d69e00; }
.metric-card--success { --metric-accent:var(--color-success); }
.metric-card:hover { transform:translateY(-1px);box-shadow:0 8px 24px rgba(16,26,71,.09); }
.workspace-filter { display:grid;grid-template-columns:minmax(220px,2fr) minmax(150px,1fr) minmax(130px,.8fr) auto auto;align-items:end;gap:.65rem;margin-bottom:1rem;padding:1rem;border:1px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface); }
.workspace-filter > div { display:grid;gap:.3rem; }
.workspace-filter label { color:var(--color-text-muted);font-size:.7rem;font-weight:700;text-transform:uppercase; }
.workspace-filter input,.workspace-filter select { min-height:42px; }
.priority-badge { display:inline-flex;min-width:4.6rem;justify-content:center;padding:.3rem .55rem;border-radius:999px;font-size:.68rem;font-weight:800;text-transform:uppercase; }
.priority-urgent { color:#991b1b;background:#fee2e2; }
.priority-review { color:#854d0e;background:#fef3c7; }
.priority-routine { color:#166534;background:#dcfce7; }
.clinical-score { color:var(--color-primary);font-size:1.25rem;font-weight:800; }
.clinical-table tbody tr:has(.priority-urgent) { background:color-mix(in srgb,var(--color-danger) 3%,var(--color-surface)); }
.workflow-form { display:grid;gap:.75rem; }
.workflow-form .field { margin-bottom:0; }
@media (max-width:1000px) { .workspace-filter { grid-template-columns:repeat(2,minmax(0,1fr)); }.workspace-filter .filter-search { grid-column:1/-1; } }
@media (max-width:900px) { .kpi-row { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width:600px) { .workspace-filter { grid-template-columns:1fr; }.workspace-filter .filter-search { grid-column:auto; }.workspace-filter .btn-secondary,.workspace-filter button { justify-content:center;text-align:center; }.kpi-row { gap:.6rem; }.stat-tile { padding:.85rem .9rem; }.stat-tile__value { font-size:1.7rem; } }


/* Horizontal emotion thermometer */
.emotion-strength-scale {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
}

.emotion-strength-scale .scale-dot {
  min-width: 0;
  width: 100%;
  min-height: 48px;
  height: auto;
  padding: 0.5rem;
  text-align: center;
}

.thermometer-horizontal {
  position: relative;
  display: flex;
  align-items: center;
  width: min(100%, 620px);
  height: 72px;
  margin: 0.65rem 0 0.25rem;
  padding-left: 42px;
}

.thermometer-horizontal__tube {
  display: block;
  width: 100%;
  height: 30px;
  border: 5px solid var(--color-surface);
  border-radius: 0 999px 999px 0;
  background: linear-gradient(90deg, #2aa85c 0%, #b8bd37 38%, #f0a51c 68%, #e2231a 100%);
  box-shadow: 0 0 0 2px var(--color-border), inset 0 2px 5px rgba(0, 0, 0, 0.16);
}

.thermometer-horizontal__bulb {
  position: absolute;
  z-index: 1;
  left: 0;
  width: 58px;
  height: 58px;
  border: 5px solid var(--color-surface);
  border-radius: 50%;
  background: #2aa85c;
  box-shadow: 0 0 0 2px var(--color-border), inset 0 2px 5px rgba(0, 0, 0, 0.14);
}

@media (max-width: 560px) {
  .emotion-strength-scale {
    grid-template-columns: 1fr;
  }

  .emotion-strength-scale .scale-dot {
    justify-content: flex-start;
  }

  .thermometer-horizontal {
    height: 62px;
    padding-left: 36px;
  }

  .thermometer-horizontal__bulb {
    width: 50px;
    height: 50px;
  }

  .thermometer-horizontal__tube {
    height: 26px;
  }
}
.report-chart-card {
  margin-top: 1.5rem;
}

.report-section-heading {
  margin: 1.75rem 0 0.85rem;
}

.report-section-heading p,
.report-footnote {
  margin-top: 0.35rem;
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.report-footnote {
  margin-top: 1.5rem;
}

.report-filter,
.report-actions,
.chart-heading,
.chart-legend,
.timeline-axis,
.workflow-list > div {
  display: flex;
  align-items: center;
}

.report-filter {
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: 0.8rem;
}

.report-filter label { font-weight: 700; }

.report-actions { gap: 0.5rem; flex-wrap: wrap; }
.report-filter select { width: auto; min-height: 38px; }
.report-filter span { margin-left: auto; color: var(--color-text-muted); }
.stat-tile__delta { margin-top: 0.35rem; color: var(--color-text-muted); font-size: 0.7rem; }
.chart-heading { justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.chart-heading p, .privacy-note { color: var(--color-text-muted); font-size: 0.75rem; }
.chart-legend { gap: 0.35rem; color: var(--color-text-muted); font-size: 0.7rem; }
.chart-legend i { width: 9px; height: 9px; border-radius: 2px; background: var(--brand-blue); }
.chart-legend i.risk { margin-left: 0.4rem; background: var(--brand-red); }
.timeline-chart { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding-top: 1rem; border-bottom: 1px solid var(--color-border); }
.timeline-column { position: relative; flex: 1; height: 100%; min-width: 3px; }
.timeline-bar, .timeline-risk { position: absolute; bottom: 0; left: 12%; width: 76%; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--brand-blue); }
.timeline-risk { z-index: 1; left: 32%; width: 36%; background: var(--brand-red); }
.timeline-axis { justify-content: space-between; margin-top: 0.4rem; color: var(--color-text-muted); font-size: 0.68rem; }
.severity-row__value { width: 3.4rem; }
.severity-row__value small { color: var(--color-text-muted); font-size: 0.65rem; font-weight: 500; }
.report-lower-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.workflow-list { display: grid; gap: 0.55rem; margin-top: 0.85rem; }
.workflow-list > div { justify-content: space-between; gap: 1rem; padding-bottom: 0.45rem; border-bottom: 1px solid var(--color-border); font-size: 0.82rem; }
.mini-heading { margin-top: 1rem; color: var(--color-text-muted); font-size: 0.75rem; text-transform: uppercase; }
.method-note { margin-top: 1.25rem; padding: 1rem; border-left: 4px solid var(--brand-blue); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--brand-blue) 6%, var(--color-surface)); font-size: 0.8rem; }
.method-note p { margin-top: 0.3rem; color: var(--color-text-muted); }

@media (max-width: 520px) {
  .report-filter { align-items: stretch; flex-direction: column; }
  .report-filter select { width: 100%; }
  .report-filter span { margin-left: 0; }
  .report-lower-grid { grid-template-columns: 1fr; }
  .chart-heading { align-items: flex-start; flex-direction: column; }
  .severity-row {
    grid-template-columns: 6.5rem 1fr 1.5rem;
    gap: 0.4rem;
  }

  .severity-row__label {
    font-size: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Occupational health ---------- */

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.eyebrow {
  margin-bottom: 0.25rem;
  color: var(--brand-blue);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.section-subtitle,
.muted {
  color: var(--color-text-muted);
}

.section-subtitle {
  margin-top: 0.35rem;
  font-size: 0.9rem;
}

.count-badge,
.status-badge,
.risk-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 0.32rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.count-badge,
.status-badge {
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 9%, var(--color-surface));
}

.risk-badge {
  color: var(--brand-red-dark);
  background: var(--color-danger-bg);
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.table-card th,
.table-card td {
  padding: 0.85rem 1rem;
}

.table-card tbody tr:hover {
  background: color-mix(in srgb, var(--color-primary) 3%, var(--color-surface));
}

.table-action,
.back-link {
  color: var(--color-primary);
  font-weight: 700;
}

.table-action:hover,
.back-link:hover {
  text-decoration: underline;
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
}

.empty-state p {
  margin-top: 0.4rem;
  color: var(--color-text-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.detail-page {
  max-width: 980px;
}

.detail-page .back-link {
  display: inline-flex;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.escalation-link {
  display: block;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.detail-card h2 {
  margin-bottom: 0.85rem;
}

.detail-card--wide {
  grid-column: 1 / -1;
}

.data-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.data-list dt {
  color: var(--color-text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.data-list dd {
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.score-value {
  color: var(--color-primary);
  font-size: 2.25rem;
  font-weight: 800;
}

.score-list {
  display: grid;
  gap: 0.6rem;
  list-style: none;
}

.score-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.5rem;
}

.answer-grid span {
  display: grid;
  gap: 0.15rem;
  padding: 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  text-align: center;
}

.answer-grid strong {
  color: var(--color-text);
  font-size: 1rem;
}

@media (max-width: 760px) {
  .section-heading {
    flex-direction: column;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-card--wide {
    grid-column: auto;
  }

  .data-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .answer-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .data-list {
    grid-template-columns: 1fr;
  }

  .answer-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------- Questionnaire CMS ---------- */

.btn-danger {
  background: transparent;
  border-color: var(--color-danger);
  color: var(--brand-red-dark);
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-bg);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  min-height: 36px;
  font-size: 0.82rem;
}

.add-card {
  border: 2px dashed color-mix(in srgb, var(--color-primary) 35%, var(--color-border));
  background: color-mix(in srgb, var(--color-primary) 4%, var(--color-surface));
}

.add-card > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: var(--color-primary);
}

.add-card > summary::-webkit-details-marker {
  display: none;
}

.add-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.add-card > form {
  margin-top: 1rem;
}

.version-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--color-surface);
  color: var(--color-text);
}

.version-pill:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.version-pill--active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}

.version-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d69e00;
  flex-shrink: 0;
}

.version-pill--published .version-pill__dot {
  background: var(--color-success);
}

.version-pill--active .version-pill__dot {
  background: #fff;
}

.locked-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-text-muted) 6%, var(--color-surface));
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.qcard {
  margin-bottom: 1rem;
}

.qcard--locked {
  background: color-mix(in srgb, var(--color-text-muted) 3%, var(--color-surface));
}

.qcard__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.qcard__title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.qcard__index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-primary) 10%, var(--color-surface));
  color: var(--color-primary);
  font-size: 0.8rem;
  font-weight: 800;
  flex-shrink: 0;
}

.type-chip,
.required-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.type-chip {
  background: color-mix(in srgb, var(--brand-blue) 10%, var(--color-surface));
  color: var(--brand-blue);
}

.required-chip {
  background: var(--color-danger-bg);
  color: var(--brand-red-dark);
}

.qcard__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.qcard__fields > .field {
  min-width: 0;
}

.qcard__fields > .field:nth-child(1) {
  flex: 0 1 6.5rem;
}

.qcard__fields > .field:nth-child(2) {
  flex: 4 1 220px;
}

.qcard__fields > .field:nth-child(3) {
  flex: 1 1 170px;
}

.qcard__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.options-block {
  margin-top: 1.1rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-bg) 60%, var(--color-surface));
  border: 1px solid var(--color-border);
}

.options-block h4 {
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.6rem 0.75rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--color-border);
}

.option-row:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.option-row__field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 120px;
  min-width: 0;
}

.option-row__actions {
  display: flex;
  gap: 0.4rem;
  flex: 0 0 auto;
  align-self: end;
}

@media (max-width: 480px) {
  .qcard__fields > .field:nth-child(1) {
    flex-basis: 100%;
  }

  .option-row {
    align-items: stretch;
  }

  .option-row__actions {
    flex-basis: 100%;
    justify-content: flex-end;
  }
}
