/* ==========================================================================
   Cerylis — RTS 6 compliance assurance platform
   Institutional light theme: warm off-white surfaces, midnight-navy
   structure, restrained teal/cyan accents used only where they carry
   meaning. Semantic colours are reserved for workflow status.
   ========================================================================== */

:root {
  /* structural */
  --navy: #0B1623;
  --navy-2: #162435;
  --bg: #F7F8F6;
  --surface: #FFFFFF;
  --text: #111827;
  --text-muted: #5B6777;
  --border: #E5E7EB;
  --border-strong: #D6D9DE;

  /* accent — used deliberately, not as a base colour */
  --accent: #14C8B0;
  --accent-deep: #0D9488;   /* AA-safe teal for text/links on light surfaces */
  --accent-2: #48B8F0;

  /* semantic workflow colours — status meaning only */
  --success: #16A34A;
  --success-bg: rgba(22, 163, 74, 0.09);
  --success-border: rgba(22, 163, 74, 0.28);
  --warning: #D97706;
  --warning-bg: rgba(217, 119, 6, 0.10);
  --warning-border: rgba(217, 119, 6, 0.28);
  --danger: #DC2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --danger-border: rgba(220, 38, 38, 0.24);
  --info: #2563EB;
  --info-bg: rgba(37, 99, 235, 0.08);
  --info-border: rgba(37, 99, 235, 0.24);
  --neutral: #6B7280;
  --neutral-bg: rgba(107, 114, 128, 0.10);
  --neutral-border: rgba(107, 114, 128, 0.26);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

  --shadow-xs: 0 1px 2px rgba(11, 22, 35, 0.05);
  --shadow-sm: 0 2px 6px rgba(11, 22, 35, 0.08), 0 1px 2px rgba(11, 22, 35, 0.05);
  --shadow-md: 0 8px 20px -8px rgba(11, 22, 35, 0.16);
  --shadow-lg: 0 20px 44px -16px rgba(11, 22, 35, 0.22);
}

* { box-sizing: border-box; }
html { color-scheme: light; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  max-width: 1760px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 3vw, 3.5rem) 4rem;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(20, 200, 176, 0.22); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.015em; color: var(--text); margin: 1.5rem 0 0.5rem; }
h2 { font-size: 1.02rem; font-weight: 700; letter-spacing: -0.005em; color: var(--text); margin-top: 2.25rem; margin-bottom: 0.6rem; }
h3.chapter {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--text-muted); margin: 2.75rem 0 0.6rem; font-weight: 700;
}

a { color: var(--accent-deep); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--navy); text-decoration: underline; }

p.desc { color: var(--text-muted); line-height: 1.6; }
.gap { color: var(--danger); font-weight: 500; }
.narrative-locked {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}
.role-note { color: var(--text-muted); font-style: italic; font-size: 0.85rem; margin-top: 1rem; }
.venues, .desk { color: var(--text-muted); font-size: 0.85rem; }
.counts { color: var(--text-muted); font-size: 0.88rem; }
.article-ref { color: var(--text-muted); font-size: 0.82rem; }
.label {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--text-muted);
  white-space: nowrap; font-size: 0.85rem; font-weight: 600;
}
.overdue { color: var(--danger); font-weight: 700; }
.back { display: inline-block; margin-bottom: 1rem; color: var(--text-muted); font-size: 0.85rem; }
.back:hover { color: var(--accent-deep); }

.requirement-sticky-bar {
  position: sticky; top: 60px; z-index: 15;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1.25rem;
  background: var(--surface); border-bottom: 3px solid var(--accent);
  box-shadow: var(--shadow-sm); border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: 0.9rem 1.25rem; margin-bottom: 1.25rem;
}
.requirement-sticky-main { min-width: 0; }
.requirement-sticky-bar .back { margin-bottom: 0.3rem; }
.requirement-sticky-text {
  margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.005em;
  color: var(--text); line-height: 1.45;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.requirement-sticky-text .label { font-size: inherit; font-weight: 800; color: var(--navy); margin-right: 0.4rem; }
.requirement-sticky-bar .theme-badge { flex: none; margin-top: 0.15rem; }
.section { margin-top: 1.75rem; }

.assignment-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 0 2.5rem; }
.assignment-grid > div:first-child { border-right: 1px solid var(--border); padding-right: 2.5rem; }
.assignment-grid > div:last-child { padding-left: 0; }
.assignment-grid h3 {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin: 0 0 0.75rem;
}
.assignment-grid form.actions { display: flex; flex-direction: column; align-items: stretch; gap: 0.7rem; }
.assignment-grid form.actions > div { width: 100%; }
.assignment-grid form.actions button { align-self: flex-start; margin-top: 0.2rem; }
@media (max-width: 760px) {
  .assignment-grid { grid-template-columns: 1fr; }
  .assignment-grid > div:first-child { border-right: none; padding-right: 0; border-bottom: 1px solid var(--border); padding-bottom: 1.25rem; margin-bottom: 1.25rem; }
}

/* ---------- nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 20;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-bottom: 2rem;
  background: var(--navy);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: none; transition: box-shadow 0.2s var(--ease);
}
.topnav.is-scrolled { box-shadow: 0 4px 16px -6px rgba(11, 22, 35, 0.35); }
.topnav-inner {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 1760px; margin: 0 auto;
  padding: 0 clamp(1.25rem, 3vw, 3.5rem);
}
.nav-links { display: flex; align-items: center; }
.nav-links a.brand {
  font-weight: 700; letter-spacing: -0.01em; font-size: 1.05rem; margin-right: 2.25rem;
  color: #FFFFFF; padding: 1.05rem 0; border-bottom: none;
}
.nav-links a.brand:hover { color: var(--accent); text-decoration: none; }
.nav-links a {
  position: relative; margin-right: 1.6rem; padding: 1.15rem 0 1.05rem;
  font-weight: 500; font-size: 0.86rem; color: rgba(255, 255, 255, 0.62);
  border-bottom: 2px solid transparent; transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
  display: inline-flex; align-items: center; gap: 0.4rem;
  white-space: nowrap; flex-shrink: 0;
}
.nav-links a .icon { opacity: 0.85; }
.nav-links a.active .icon, .nav-links a:hover .icon { opacity: 1; }
.nav-links a:hover { color: #FFFFFF; text-decoration: none; }
.nav-links a.active { color: #FFFFFF; border-bottom-color: var(--accent); }
.nav-user { color: rgba(255, 255, 255, 0.7); font-size: 0.85rem; display: flex; align-items: center; gap: 0.6rem; }
.nav-user a { color: rgba(255, 255, 255, 0.7); }
.nav-user a:hover { color: #FFFFFF; }

.role-badge {
  padding: 0.24rem 0.65rem; border-radius: 4px; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; border: 1px solid transparent;
}
.role-1stline { background: #FFFFFF; color: var(--navy); border-color: var(--border); }
.role-2ndline { background: rgba(72, 184, 240, 0.16); color: #0B4A6F; border-color: rgba(72, 184, 240, 0.4); }
.role-3rdline { background: rgba(255, 255, 255, 0.12); color: #FFFFFF; border-color: rgba(255, 255, 255, 0.22); }
.role-administrator { background: var(--accent); color: var(--navy); border-color: transparent; }
/* On the navy top nav, the 2nd Line badge's dark-blue text (tuned for a
   light page background elsewhere, e.g. the audit log table) nearly
   disappears against its own translucent blue fill - keep the fill, swap
   just the text to white in that one context. */
.topnav .role-2ndline { color: #FFFFFF; }

.module-name-badge {
  font-weight: 600; font-size: 0.86rem; color: rgba(255, 255, 255, 0.75);
  margin-right: 2.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px;
}

.cycle-badge {
  padding: 0.22rem 0.6rem; border-radius: 4px; font-size: 0.74rem; font-weight: 700;
  background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18); letter-spacing: 0.02em;
}

.report-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 1.5rem 2rem; margin-top: 1.5rem;
}
.report-card > *:first-child { margin-top: 0; }
.report-card.accent-navy::before,
.report-card.accent-teal::before,
.report-card.accent-cyan::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
}
.report-card.accent-navy::before { background: var(--navy); }
.report-card.accent-teal::before { background: var(--accent); }
.report-card.accent-cyan::before { background: var(--accent-2); }
.section-title {
  display: block; font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em;
  color: var(--accent-deep); margin: 0 0 1.25rem; padding-bottom: 0.85rem; border-bottom: 2px solid var(--border);
}
.report-card h2:not(:first-of-type) { padding-top: 1.5rem; margin-top: 1.5rem; border-top: 1px solid var(--border); }
@media print {
  .topnav, .flash, .actions, form, .back { display: none !important; }
  body { background: #fff !important; color: #000 !important; max-width: none; }
  .report-card { border: none; padding: 0; box-shadow: none; }
  table { border: 1px solid #ccc; }
  th, td { color: #000 !important; border-color: #ccc !important; }
}

/* ---------- buttons ---------- */
button, a.btn-primary, a.btn-secondary, a.btn-danger {
  font-family: inherit; font-size: 0.86rem; font-weight: 600; cursor: pointer;
  padding: 0.6rem 1.05rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease), transform 0.15s var(--ease);
  display: inline-flex; align-items: center; gap: 0.45rem; text-decoration: none;
}
button:hover, a.btn-primary:hover, a.btn-secondary:hover, a.btn-danger:hover { text-decoration: none; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
@media (prefers-reduced-motion: no-preference) {
  button:not(:disabled):hover, a.btn-primary:hover, a.btn-secondary:hover, a.btn-danger:hover { transform: translateY(-1px); }
}

button.btn-primary, a.btn-primary {
  background: var(--accent); border: 1px solid var(--accent); color: var(--navy);
  box-shadow: var(--shadow-xs);
}
button.btn-primary:hover, a.btn-primary:hover { background: #10B39D; border-color: #10B39D; color: var(--navy); box-shadow: var(--shadow-sm); }

button.btn-secondary, a.btn-secondary { background: var(--surface); border: 1.5px solid var(--navy); color: var(--navy); font-weight: 700; }
button.btn-secondary:hover, a.btn-secondary:hover { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: var(--shadow-sm); }

button.btn-danger, a.btn-danger {
  background: var(--surface); border: 1px solid var(--danger-border); color: var(--danger);
  padding: 0.42rem 0.8rem; font-size: 0.8rem;
}
button.btn-danger:hover, a.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }

/* icon() helper output - sized/positioned to sit cleanly inline with button
   and nav-link text, colored automatically via currentColor. */
.icon { display: inline-block; vertical-align: -0.125em; flex: none; }

/* inline loading spinner — used on buttons that trigger a slow server-side call (e.g. AI checks) */
.spinner {
  display: inline-block; width: 0.9em; height: 0.9em; vertical-align: -0.15em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.7s linear infinite; margin-right: 0.5em;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-note { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.5rem; }

/* subtle AI-assist action — never the focal action on a screen */
.ai-assist { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.6rem; }
button.btn-ai {
  background: transparent; border: 1px dashed var(--border-strong); color: var(--text-muted);
  font-size: 0.8rem; padding: 0.42rem 0.75rem;
}
button.btn-ai:hover { color: var(--accent-deep); border-color: var(--accent-2); background: rgba(72, 184, 240, 0.06); }
.ai-assist-note { color: var(--text-muted); font-size: 0.78rem; }

/* ---------- hub (module list / create module) ---------- */
.hub-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1.5rem; align-items: start; margin-top: 1.5rem;
}
.hub-grid > .hub-span { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .hub-grid { grid-template-columns: 1fr; }
}

.role-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.6rem; margin-top: 1.5rem; }
.hub-grid .role-buttons { grid-template-columns: 1fr; }
.role-buttons button {
  text-align: left; padding: 0.9rem 1.1rem; border: 1px solid var(--border); color: var(--text);
  background: var(--surface); border-left: 3px solid var(--border-strong);
  align-items: flex-start;
}
.role-buttons button .icon { margin-top: 0.15rem; color: var(--text-muted); }
.role-buttons button:hover { border-color: var(--border-strong); background: var(--bg); box-shadow: var(--shadow-xs); }
.role-picker { display: flex; gap: 0.5rem; align-items: stretch; }
.role-picker select { flex: none; width: 40%; }
.role-picker button { flex: 1; }
.role-buttons button.role-btn-1st { border-left-color: var(--text-muted); }
.role-buttons button.role-btn-2nd { border-left-color: var(--accent-2); }
.role-buttons button.role-btn-3rd { border-left-color: var(--neutral); }
.role-buttons button.role-btn-admin { border-left-color: var(--navy); }
.role-buttons small { display: block; font-weight: 400; color: var(--text-muted); margin-top: 0.2rem; font-size: 0.78rem; }

/* Module-type picker on the hub - same shape as the role picker above. */
.role-buttons button.role-btn-rts6 { border-left-color: var(--accent); }
.role-buttons button.role-btn-fx-global-code { border-left-color: var(--accent-2); }
.role-buttons button.role-btn-financial-promotions { border-left-color: var(--neutral); }
.role-buttons button.role-btn-regulatory-change { border-left-color: var(--text-muted); }
.role-buttons button.role-btn-consumer-duty-compliance { border-left-color: var(--accent-deep); }

/* ---------- create-module modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11, 22, 35, 0.45); display: flex;
  align-items: flex-start; justify-content: center; padding: 4rem 1rem; overflow-y: auto; z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  position: relative; width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 1.75rem; max-height: calc(100vh - 8rem); overflow-y: auto;
}
.modal-close {
  position: absolute; top: 0.9rem; right: 0.9rem; width: 28px; height: 28px; border-radius: 50%;
  border: none; background: transparent; color: var(--text-muted); font-size: 1.3rem; line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.checkbox-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.35rem 0.8rem; margin-top: 0.3rem;
}
.checkbox-grid label { display: flex; align-items: center; gap: 0.4rem; font-weight: 400; font-size: 0.9rem; }
.checkbox-grid input[type="checkbox"] { width: auto; }

/* ---------- landing / splash screen ---------- */
.landing-body {
  max-width: none; padding: 0; margin: 0; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.landing-center { display: flex; flex-direction: column; align-items: center; gap: 2rem; }
.landing-logo { width: 96px; height: auto; animation: landing-fade-in 0.6s var(--ease); }
.landing-progress {
  width: 200px; height: 4px; border-radius: 999px; background: var(--border);
  overflow: hidden;
}
.landing-progress-fill {
  height: 100%; width: 40%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  animation: landing-progress-slide 1.1s var(--ease) infinite;
}
@keyframes landing-progress-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
@keyframes landing-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- status pills / badges ---------- */
.status {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  margin: 0 0.35rem 0.35rem 0; border: 1px solid transparent;
}
/* A small status-specific glyph (check / clock / exclamation / warning
   triangle / dash) rendered via CSS mask so it inherits the badge's own
   status color through currentColor - no template changes needed, this
   upgrades every status badge across every module at once. Only the mask's
   alpha shape matters; the stroke color in each data URI is a throwaway
   placeholder. */
.status::before {
  content: ""; width: 11px; height: 11px; flex: none; background: currentColor; border-radius: 0;
  -webkit-mask-image: var(--status-icon); mask-image: var(--status-icon);
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}

/* reviewed / compliant / in-scope */
.status-reviewed, .status-in_scope {
  background: var(--success-bg); color: var(--success); border-color: var(--success-border);
  --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4.5 4.5L19 7'/%3E%3C/svg%3E");
}
/* under review — informational */
.status-under_review {
  background: var(--info-bg); color: var(--info); border-color: var(--info-border);
  --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l4 2'/%3E%3C/svg%3E");
}
/* feedback requested / attention required, descope pending */
.status-feedback_requested, .status-descope_requested {
  background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border);
  --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 5v9'/%3E%3Cpath d='M12 19h.01'/%3E%3C/svg%3E");
}
/* information required — evidence still owed; kept lighter than a true overdue flag */
.status-information_required {
  background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); font-weight: 500;
  --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l10 18H2z'/%3E%3Cpath d='M12 9v5'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
}
/* descoped / not started */
.status-descoped {
  background: var(--neutral-bg); color: var(--neutral); border-color: var(--neutral-border);
  --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
}

.gap-badge, .ok-badge, .theme-badge {
  display: inline-block; padding: 0.28rem 0.65rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.gap-badge { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.ok-badge { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
a.gap-badge { text-decoration: none; cursor: pointer; transition: background 0.15s var(--ease), color 0.15s var(--ease); }
a.gap-badge:hover { background: var(--danger); color: #fff; }
.theme-badge { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); font-weight: 600; }

.evidence-type {
  display: inline-block; padding: 0.22rem 0.6rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.evidence-type-control { background: rgba(11, 22, 35, 0.06); color: var(--navy); border-color: rgba(11, 22, 35, 0.14); }
.evidence-type-document { background: var(--neutral-bg); color: var(--neutral); border-color: var(--neutral-border); }
.evidence-type-attestation { background: rgba(20, 200, 176, 0.1); color: var(--accent-deep); border-color: rgba(20, 200, 176, 0.28); }

/* ---------- tables ---------- */
table {
  width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden; box-shadow: var(--shadow-xs);
}
th {
  text-align: left; padding: 0.75rem 1rem; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); background: var(--bg); border-bottom: 1px solid var(--border); font-weight: 700;
}
table[data-sortable] th[data-sort-key] { cursor: pointer; user-select: none; transition: color 0.15s var(--ease); }
table[data-sortable] th[data-sort-key]:hover { color: var(--text); }
table[data-sortable] th[data-sort-key]::after { content: "\2195"; margin-left: 0.4rem; opacity: 0.4; font-size: 0.75em; }
table[data-sortable] th[data-sort-key].sorted-asc::after { content: "\2191"; opacity: 1; color: var(--accent-deep); }
table[data-sortable] th[data-sort-key].sorted-desc::after { content: "\2193"; opacity: 1; color: var(--accent-deep); }

/* Fixed column widths for the dashboard table specifically - Theme's badges were
   pulling far more room than they need, leaving Algo cramped and the whole table
   feeling blocky on narrower screens. */
#dashboard-table { table-layout: fixed; }
#dashboard-table th:nth-child(1), #dashboard-table td:nth-child(1) { width: 13%; } /* Algo */
#dashboard-table th:nth-child(2), #dashboard-table td:nth-child(2) { width: 8%; }  /* Article */
#dashboard-table th:nth-child(3), #dashboard-table td:nth-child(3) { width: 31%; } /* Requirement */
#dashboard-table th:nth-child(4), #dashboard-table td:nth-child(4) { width: 9%; }  /* Theme */
#dashboard-table th:nth-child(5), #dashboard-table td:nth-child(5) { width: 10%; } /* Status */
#dashboard-table th:nth-child(6), #dashboard-table td:nth-child(6) { width: 10%; } /* 1st Line owner */
#dashboard-table th:nth-child(7), #dashboard-table td:nth-child(7) { width: 10%; } /* 2nd Line owner */
#dashboard-table th:nth-child(8), #dashboard-table td:nth-child(8) { width: 9%; }  /* Due date */
/* Theme/status badges are nowrap by default (fine when their column has room to
   fit any label on one line) - at these narrower widths the longest labels
   ("Self-Assessment & Change Management", "Information required") need to be
   able to wrap onto a second line instead of spilling into the next column. */
#dashboard-table .theme-badge, #dashboard-table .status { white-space: normal; }

.table-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-top: 1.25rem; }
.table-toolbar input[type=search] {
  max-width: 320px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0.55rem 0.9rem;
}
.table-toolbar .table-count { color: var(--text-muted); font-size: 0.82rem; }
.table-toolbar [data-clear-filters] { margin-left: auto; font-size: 0.8rem; padding: 0.45rem 0.85rem; }

.filter-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.75rem; }
.filter-row select { min-width: 150px; max-width: 240px; }

.flash {
  background: var(--info-bg); border: 1px solid var(--info-border);
  color: #1E3A8A; padding: 0.7rem 1rem; border-radius: var(--radius-sm);
  margin-top: 1rem; font-size: 0.88rem;
}
td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 0.88rem; color: var(--text); }
tbody tr { transition: background 0.12s var(--ease); }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

/* ---------- cards ---------- */
.card-row { display: flex; gap: 1rem; margin: 1.5rem 0; flex-wrap: wrap; }
.card {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.1rem 1.35rem; min-width: 150px; flex: 1;
  box-shadow: var(--shadow-xs);
}
.card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--neutral); }
.card .num { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.card .card-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }

.card.card-neutral::before { background: var(--neutral); }
.card.card-info::before { background: var(--info); }
.card.card-warning::before { background: var(--warning); }
.card.card-danger::before { background: var(--danger); }
.card.card-success::before { background: var(--success); }
.card.card-danger .num { color: var(--danger); }
.card.card-success .num { color: var(--success); }
.card.card-info .num { color: var(--info); }

.card-clickable {
  cursor: pointer; transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.card-clickable:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.card-clickable:focus-visible { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(72, 184, 240, 0.18); }
.card-clickable.active { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); }
.card-clickable.active .card-label { color: var(--text); font-weight: 600; }

/* ---------- tabs (segmented control) ---------- */
.tabs {
  display: flex; gap: 0.2rem; margin: 1.25rem 0 1.75rem; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.25rem; width: fit-content;
}
.tabs a {
  padding: 0.48rem 1.05rem; border: none; border-radius: 6px; color: var(--text-muted);
  font-size: 0.84rem; font-weight: 600; transition: all 0.15s var(--ease);
}
.tabs a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.tabs a.active { background: var(--navy); color: #FFFFFF; box-shadow: var(--shadow-xs); }

/* ---------- forms ---------- */
textarea, input[type=text], input[type=email], input[type=password], input[type=date], input[type=file], select {
  width: 100%; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; font-family: inherit; font-size: 0.88rem;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
textarea:focus, input:focus, select:focus {
  outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(72, 184, 240, 0.18);
}
textarea { min-height: 110px; resize: vertical; }
input[type=file] { padding: 0.45rem; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent-deep); flex: none; }
label.field-label {
  display: block; font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: 700; margin: 0.9rem 0 0.35rem;
}
.actions { margin-top: 0.85rem; display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

/* ---------- login ---------- */
.login-body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(20, 200, 176, 0.10), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(11, 22, 35, 0.06), transparent 55%),
    var(--bg);
}
.login-box {
  max-width: 420px; margin: 5.5rem auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2.25rem; box-shadow: var(--shadow-lg);
}
.login-eyebrow {
  display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--accent-deep); margin-bottom: 0.6rem;
}
.login-box h1 { margin-top: 0; font-size: 1.7rem; }

/* ---------- error pages (404/403/500) ---------- */
.error-body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(20, 200, 176, 0.10), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(11, 22, 35, 0.06), transparent 55%),
    var(--bg);
}
.error-box {
  max-width: 460px; margin: 5rem auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2.5rem; box-shadow: var(--shadow-lg); text-align: center;
}
.error-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px;
  border-radius: 50%; background: rgba(20, 200, 176, 0.12); color: var(--accent-deep); margin: 0.4rem 0 0.9rem;
}
.error-code {
  font-size: 0.85rem; font-weight: 800; letter-spacing: 0.12em; color: var(--text-muted);
}
.error-box h1 { margin: 0.2rem 0 0.6rem; font-size: 1.5rem; }
.error-box .desc { margin: 0 auto; max-width: 360px; }

/* ---------- comments / evidence ---------- */
.comment {
  border-left: 2px solid var(--navy-2); padding: 0.6rem 0.95rem; margin: 0.6rem 0;
  background: var(--bg); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.comment .meta { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.25rem; font-weight: 700; }

.evidence-item {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  padding: 0.7rem 0.95rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 0.5rem; background: var(--surface); transition: border-color 0.15s var(--ease);
}
.evidence-item:hover { border-color: var(--border-strong); }
.evidence-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
.local-time-note { color: var(--text-muted); font-weight: 400; }
.row-descoped { color: var(--text-muted); background: var(--bg); }
.row-descoped a { color: var(--text-muted); }
.row-descoped .theme-badge, .row-descoped .status { opacity: 0.6; }
.diff-view {
  margin-top: 0.3rem; font-size: 0.82rem; line-height: 1.5; color: var(--text-muted);
}
.diff-view ins {
  text-decoration: none; background: var(--success-bg); color: var(--success);
  border-radius: 3px; padding: 0 2px;
}
.diff-view del {
  background: var(--danger-bg); color: var(--danger);
  border-radius: 3px; padding: 0 2px;
}
.diff-muted { color: var(--text-muted); font-style: italic; }
.challenge-item { flex-direction: column; align-items: stretch; gap: 0.6rem; }
.challenge-item .comment { margin: 0; }
.challenge-item form { margin-top: 0.2rem; }

.evidence-add-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem;
  margin-top: 1.25rem;
}
.evidence-add-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-xs);
}
.evidence-add-card h3 { font-size: 0.8rem; font-weight: 700; margin: 0 0 0.5rem; color: var(--text); }
.evidence-add-form { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.evidence-add-form input, .evidence-add-form select { width: 100%; }
.evidence-add-form button { align-self: flex-start; }

ul.linked { padding-left: 1.2rem; }
ul.linked li { margin-bottom: 0.3rem; }
