/* ==========================================================================
   Affinitas FP Hub
   Brand: navy #00456E, teal #348D95, taken from the company logo.
   One stylesheet, no build step, no CDN. Tokens drive both themes.
   ========================================================================== */

:root {
  --brand-navy: #00456e;
  --brand-teal: #348d95;

  --accent: var(--brand-teal);
  --accent-strong: #2a7278;
  --accent-soft: rgba(52, 141, 149, 0.12);

  --primary: var(--brand-navy);
  --primary-soft: rgba(0, 69, 110, 0.08);
  --on-primary: #ffffff;

  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --surface-3: #eef3f6;
  --border: #dfe6ec;
  --border-strong: #c6d2db;

  --text: #14222e;
  --text-muted: #5d6f7e;
  --text-faint: #8698a6;

  --ok: #1f7a4d;
  --ok-soft: rgba(31, 122, 77, 0.1);
  --warn: #a86a00;
  --warn-soft: rgba(168, 106, 0, 0.12);
  --danger: #b3261e;
  --danger-soft: rgba(179, 38, 30, 0.1);
  --info: #1f6f9c;
  --info-soft: rgba(31, 111, 156, 0.1);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 34, 48, 0.06);
  --shadow: 0 2px 8px rgba(16, 34, 48, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 34, 48, 0.14);

  --sidebar-w: 252px;
  --header-h: 60px;

  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
  --font-mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

  color-scheme: light;
}

html[data-theme="dark"] {
  --accent: #4fb3bb;
  --accent-strong: #6bc9d0;
  --accent-soft: rgba(79, 179, 187, 0.16);

  --primary: #4f9ec9;
  --primary-soft: rgba(79, 158, 201, 0.14);
  --on-primary: #05131d;

  --bg: #0c151d;
  --surface: #131f2a;
  --surface-2: #16242f;
  --surface-3: #1d2f3c;
  --border: #24384a;
  --border-strong: #365064;

  --text: #e6eef4;
  --text-muted: #9aadbc;
  --text-faint: #728798;

  --ok: #55c08a;
  --ok-soft: rgba(85, 192, 138, 0.14);
  --warn: #e5a545;
  --warn-soft: rgba(229, 165, 69, 0.15);
  --danger: #f0776d;
  --danger-soft: rgba(240, 119, 109, 0.14);
  --info: #62b3e0;
  --info-soft: rgba(98, 179, 224, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.55);

  color-scheme: dark;
}

/* ---------------------------------------------------------------- base --- */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0 0 0.4em; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.9em; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 200;
  background: var(--surface); color: var(--text);
  padding: 0.6rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow);
  transition: top 0.15s;
}
.skip-link:focus { top: 8px; }

/* ------------------------------------------------------------- layout --- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.1rem 1.15rem 0.9rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
/* Sizes are set per-hub from Admin settings; these are the fallbacks. */
.sidebar-brand img {
  width: var(--icon-size, 40px);
  height: var(--icon-size, 40px);
  object-fit: contain;
  flex: none;
}
html[data-theme="dark"] .sidebar-brand img { filter: brightness(1.25) saturate(1.1); }
/* An uploaded logo is somebody else's artwork — leave its colours alone. */
html[data-theme="dark"] .sidebar-brand img.custom-logo,
html[data-theme="dark"] .auth-logo img.custom-logo { filter: none; }
.logo-preview {
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.8rem; display: inline-block;
  max-width: 100%;
}
.logo-preview img { max-width: 260px; max-height: 90px; display: block; }
.sidebar-brand .brand-text { min-width: 0; }
.sidebar-brand .brand-name {
  font-family: var(--font-display);
  font-size: 1.02rem; font-weight: 700; letter-spacing: 0.04em;
  color: var(--text); line-height: 1.1; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand .brand-sub {
  font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-top: 2px;
}

.nav { padding: 0.8rem 0.65rem; flex: 1; }
.nav-label {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.11em;
  color: var(--text-faint); font-weight: 700;
  padding: 0.9rem 0.6rem 0.35rem;
}
.nav a {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 0.65rem; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 550; font-size: 0.9rem;
  text-decoration: none; margin-bottom: 1px;
}
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
html[data-theme="dark"] .nav a.active { color: var(--accent-strong); }
.nav a .ico { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.nav a .count {
  margin-left: auto; font-size: 0.72rem; font-weight: 700;
  background: var(--danger-soft); color: var(--danger);
  padding: 0.05rem 0.4rem; border-radius: 20px;
}

.sidebar-foot { padding: 0.7rem 0.8rem 1rem; border-top: 1px solid var(--border); }

.user-chip {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.5rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none;
}
.user-chip:hover { background: var(--surface-3); text-decoration: none; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
}
.user-chip .who { min-width: 0; }
.user-chip .who b { display: block; font-size: 0.85rem; font-weight: 620;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { font-size: 0.72rem; color: var(--text-faint); }

/* --------------------------------------------------------------- main --- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0 1.3rem;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { margin: 0; font-size: 1.08rem; font-weight: 650; }
.topbar .spacer { flex: 1; }

.menu-toggle {
  display: none; background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); width: 36px; height: 36px;
  color: var(--text); cursor: pointer; align-items: center; justify-content: center;
}

.content { padding: 1.4rem 1.6rem 3rem; max-width: 1500px; width: 100%; }

.page-head {
  display: flex; align-items: flex-start; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.2rem;
}
.page-head .lede { color: var(--text-muted); margin: 0; font-size: 0.92rem; }
.page-head .actions { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* -------------------------------------------------------------- cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.1rem;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card-head h2, .card-head h3 { margin: 0; font-size: 0.98rem; }
.card-head .spacer { flex: 1; }
.card-body { padding: 1.1rem; }
.card-body.tight { padding: 0.7rem 1.1rem; }
.card.collapsible .card-head { cursor: pointer; user-select: none; }
.card.collapsible .card-head:hover { background: var(--surface-3); }
.card.collapsed .card-body { display: none; }
.chev { transition: transform 0.18s ease; color: var(--text-faint); flex: none; }
.card.collapsed .chev { transform: rotate(-90deg); }

.grid { display: grid; gap: 1.1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); }

/* -------------------------------------------------------------- stats --- */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: 0.2rem;
}
.stat .value { font-size: 1.85rem; font-weight: 680; letter-spacing: -0.02em; line-height: 1.1; }
.stat .label { font-size: 0.8rem; color: var(--text-muted); font-weight: 550; }
.stat .hint { font-size: 0.75rem; color: var(--text-faint); }
.stat.danger .value { color: var(--danger); }
.stat.warn .value { color: var(--warn); }
.stat.ok .value { color: var(--ok); }
.stat.accent .value { color: var(--accent-strong); }

/* ----------------------------------------------------------- progress --- */
.progress {
  height: 7px; background: var(--surface-3); border-radius: 20px;
  overflow: hidden; position: relative;
}
.progress > span {
  display: block; height: 100%; border-radius: 20px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.35s ease;
}
.progress.thin { height: 5px; }
.progress-row { display: flex; align-items: center; gap: 0.7rem; }
.progress-row .progress { flex: 1; }
.progress-row .pct {
  font-size: 0.8rem; font-weight: 650; color: var(--text-muted);
  min-width: 3.1rem; text-align: right; font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-size: 0.875rem; font-weight: 600;
  padding: 0.47rem 0.95rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  background: var(--surface-3); color: var(--text);
  text-decoration: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover { text-decoration: none; background: var(--border); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--brand-navy); filter: brightness(1.12); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
html[data-theme="dark"] .btn-accent { color: #05131d; }
.btn-accent:hover { filter: brightness(1.08); }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--surface-3); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { font-size: 0.8rem; padding: 0.3rem 0.62rem; }
.btn-icon { padding: 0.4rem; width: 32px; height: 32px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* -------------------------------------------------------------- forms --- */
label { display: block; font-size: 0.82rem; font-weight: 620; margin-bottom: 0.28rem; color: var(--text); }
.field { margin-bottom: 1rem; }
.field-help { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }
.field-error { font-size: 0.8rem; color: var(--danger); margin-top: 0.3rem; font-weight: 550; }

.field-input, input[type="text"], input[type="password"], input[type="email"],
input[type="date"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; font: inherit; font-size: 0.9rem;
  padding: 0.47rem 0.65rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { resize: vertical; min-height: 78px; line-height: 1.5; }
.field-input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="color"] { padding: 2px; height: 38px; cursor: pointer; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
select { cursor: pointer; }

.check-row { display: flex; align-items: flex-start; gap: 0.55rem; margin-bottom: 0.9rem; }
.check-row label { margin: 0; font-weight: 550; }

.code-input {
  font-family: var(--font-mono); font-size: 1.5rem !important;
  letter-spacing: 0.5em; text-align: center; padding: 0.6rem !important;
  text-indent: 0.5em;
}

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: flex-end;
  padding: 0.9rem 1.1rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 1.1rem;
}
.filter-bar .field { margin: 0; min-width: 140px; flex: 1 1 140px; }
.filter-bar .field label { font-size: 0.74rem; color: var(--text-muted); }
.filter-bar .btn-row { display: flex; gap: 0.5rem; }

/* ------------------------------------------------------------- tables --- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data th {
  text-align: left; font-weight: 650; font-size: 0.73rem;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint);
  padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
table.data td { padding: 0.62rem 0.85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.nowrap, table.data th.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------- badges --- */
.badge {
  display: inline-flex; align-items: center; gap: 0.28rem;
  font-size: 0.72rem; font-weight: 650; padding: 0.12rem 0.5rem;
  border-radius: 20px; white-space: nowrap;
  background: var(--surface-3); color: var(--text-muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge.admin { background: var(--primary-soft); color: var(--primary); }

/* ----------------------------------------------------------- messages --- */
.messages { margin-bottom: 1.1rem; display: flex; flex-direction: column; gap: 0.55rem; }
.alert {
  display: flex; gap: 0.65rem; align-items: flex-start;
  padding: 0.75rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  font-size: 0.88rem; box-shadow: var(--shadow-sm);
}
.alert .ico { flex: none; margin-top: 1px; }
.alert.success { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.alert.error, .alert.danger { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.alert.warning { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.alert.info { border-color: var(--info); background: var(--info-soft); color: var(--info); }
.alert strong { font-weight: 680; }

.announcement {
  background: var(--primary); color: var(--on-primary);
  padding: 0.6rem 1.6rem; font-size: 0.88rem; font-weight: 550;
}

/* --------------------------------------------------------------- task --- */
.task {
  display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.55rem 0.3rem; border-bottom: 1px solid var(--border);
}
.task:last-child { border-bottom: none; }
.task > input[type="checkbox"] { margin-top: 0.25rem; flex: none; }
.task .task-main { flex: 1; min-width: 0; }
.task .task-text { font-size: 0.9rem; line-height: 1.45; }
.task.done .task-text { color: var(--text-faint); text-decoration: line-through; }
.task .task-meta {
  display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem;
  margin-top: 0.3rem; font-size: 0.76rem; color: var(--text-faint);
  align-items: center;
}
.task .task-controls { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.task .task-controls select, .task .task-controls input[type="date"] {
  font-size: 0.78rem; padding: 0.2rem 0.4rem; width: auto; min-width: 118px;
}
/* Feedback for controls that save themselves as soon as they change. Kept
   empty until something happens, so it takes no room in the normal case. */
.save-state {
  font-size: 0.72rem; font-weight: 600; white-space: nowrap;
  transition: opacity 0.15s ease;
}
.save-state.saving { color: var(--text-muted); }
.save-state.saved { color: var(--ok); }
.save-state.failed { color: var(--danger); }

/* Reorderable lists: a grip to drag by and two arrows, in a narrow column at
   the left of each row. Kept faint until the row is hovered so a long
   checklist does not read as a wall of controls. */
.reorder {
  display: flex; flex-direction: column; align-items: center; gap: 0.05rem;
  flex: none; padding-top: 0.1rem; margin-right: 0.15rem;
  opacity: 0.35; transition: opacity 0.12s ease;
}
.task:hover .reorder, .task:focus-within .reorder, .reorder:hover { opacity: 1; }
.reorder-form { display: flex; flex-direction: column; gap: 0; margin: 0; }
.reorder-btn {
  background: none; border: none; padding: 0.05rem 0.2rem; margin: 0;
  color: var(--text-faint); cursor: pointer; line-height: 0;
  border-radius: var(--radius-sm);
}
.reorder-btn:hover { color: var(--text); background: var(--surface-3); }
.reorder-btn .up { transform: rotate(180deg); }
.drag-grip {
  color: var(--text-faint); cursor: grab; line-height: 0; padding: 0.1rem;
  /* Stops a touch drag scrolling the page instead of moving the row. */
  touch-action: none;
}
.drag-grip:active { cursor: grabbing; }
.task.dragging { background: var(--surface-3); opacity: 0.7; }
.task-list.is-dragging { user-select: none; -webkit-user-select: none; }
.task.just-moved { background: var(--accent-soft); }
.task { transition: background 0.5s ease; }
.reorder-hint { display: flex; gap: 0.4rem; align-items: baseline; flex-wrap: wrap; }

/* Sortable table headings. The whole heading is the target, and the caret only
   appears on the column actually being sorted. */
table.data th.sortable { padding: 0; }
.sort-link {
  display: flex; align-items: center; gap: 0.3rem;
  padding: 0.6rem 0.85rem; color: inherit; text-decoration: none;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  white-space: nowrap;
}
table.data th.num .sort-link { justify-content: flex-end; }
.sort-link:hover { color: var(--accent-strong); text-decoration: none; }
.sort-link.active { color: var(--accent-strong); }
.sort-caret { flex: none; }
.sort-caret.up { transform: rotate(180deg); }

/* A yes/no question, drawn as a two-button segment. The radios themselves are
   hidden but still focusable, so the keyboard and screen readers get a real
   radio group while everyone else sees a switch. */
.yesno { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.yesno-label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); }
.yesno-options {
  display: inline-flex; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); overflow: hidden; background: var(--surface);
}
.yesno-options input { position: absolute; opacity: 0; pointer-events: none; }
.yesno-options label {
  margin: 0; padding: 0.22rem 0.7rem; font-size: 0.78rem; font-weight: 600;
  color: var(--text-muted); cursor: pointer; user-select: none;
}
.yesno-options label + input + label { border-left: 1px solid var(--border-strong); }
.yesno-options input:checked + label { background: var(--accent); color: #fff; }
.yesno-options input:focus-visible + label { outline: 2px solid var(--accent-strong); outline-offset: -2px; }

.section-question {
  padding: 0.7rem 0.3rem; margin-bottom: 0.4rem;
  border-bottom: 1px dashed var(--border);
}
.section-question .yesno { margin-bottom: 0.3rem; }

/* ------------------------------------------------------ staff channel --- */
.nav-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 0.68rem; font-weight: 700; line-height: 1;
  padding: 0.18rem 0.4rem; border-radius: 999px; min-width: 1.2rem;
  text-align: center;
}
.chat-card { display: flex; flex-direction: column; overflow: hidden; }
.chat-log {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1rem; overflow-y: auto;
  /* Tall enough to feel like a conversation, short enough that the box to
     type in is always on screen without scrolling. */
  height: min(60vh, 560px);
}
.chat-message {
  align-self: flex-start; max-width: min(46rem, 88%);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.5rem 0.7rem;
}
.chat-message.mine {
  align-self: flex-end; background: var(--accent-soft);
  border-color: transparent;
}
.chat-meta {
  display: flex; gap: 0.5rem; align-items: baseline;
  font-size: 0.72rem; margin-bottom: 0.2rem;
}
.chat-meta strong { font-weight: 650; }
.chat-body { font-size: 0.88rem; line-height: 1.45; overflow-wrap: anywhere; }
.chat-divider {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.7rem; font-weight: 650; color: var(--danger);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 0.3rem 0;
}
.chat-divider::before, .chat-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--danger); opacity: 0.35;
}
.chat-form {
  display: flex; gap: 0.5rem; align-items: flex-end;
  padding: 0.7rem 1rem 1rem; border-top: 1px solid var(--border);
}
.chat-form textarea { flex: 1; resize: vertical; min-height: 2.6rem; }
@media (max-width: 720px) {
  .chat-log { height: min(52vh, 420px); }
}

/* ----------------------------------------------------------- priority --- */
/* A stripe down the left of the row, not a badge on every task. Medium is the
   default and gets no stripe at all: if every task were marked, the marks
   would stop carrying information and High would stop standing out. */
.task[data-priority="3"] { border-left: 3px solid var(--danger); padding-left: 0.55rem; }
.task[data-priority="1"] { border-left: 3px solid var(--border-strong); padding-left: 0.55rem; }
tr.task[data-priority="3"] > td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.task[data-priority="1"] > td:first-child { box-shadow: inset 3px 0 0 var(--border-strong); }

/* The dropdown itself is tinted so the setting reads without opening it. */
.priority-select { font-weight: 600; min-width: 84px; }
.priority-select:has(option[value="3"]:checked) { color: var(--danger); }
.priority-select:has(option[value="2"]:checked) { color: var(--text-muted); }
.priority-select:has(option[value="1"]:checked) { color: var(--text-faint); }

.task-notes { display: flex; align-items: flex-start; gap: 0.4rem; margin-top: 0.35rem; }
.task-notes textarea {
  font-size: 0.8rem; min-height: 1.9rem; resize: vertical;
  background: var(--surface-2);
}
.task.done .task-notes { opacity: 0.6; }

.text-danger { color: var(--danger); font-weight: 600; }
.card.alert-card { border-color: var(--danger); }

/* Rows picked out for a bulk action. */
table.data tr.selected > td { background: var(--accent-soft); }
.bulk-bar .section-tools { align-items: flex-end; }

.task .due.overdue { color: var(--danger); font-weight: 650; }
.task .due.soon { color: var(--warn); font-weight: 600; }

.section-tools {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end;
  padding: 0.7rem 0; margin-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
}
.section-tools .field { margin: 0; }

/* --------------------------------------------------------------- tabs --- */
.tabs {
  display: flex; gap: 0.2rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); margin-bottom: 1.2rem;
}
.tab {
  padding: 0.6rem 0.95rem; font-size: 0.88rem; font-weight: 600;
  color: var(--text-muted); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.45rem;
  margin-bottom: -1px; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--accent); }
html[data-theme="dark"] .tab.active { color: var(--accent-strong); }
.tab .mini-pct {
  font-size: 0.7rem; font-weight: 700; padding: 0.05rem 0.38rem;
  border-radius: 20px; background: var(--surface-3); color: var(--text-muted);
}
.tab.active .mini-pct { background: var(--accent-soft); color: var(--accent-strong); }
.panel { display: none; }
.panel.active { display: block; }

/* ---------------------------------------------------------- code block --- */
pre.report {
  font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.55;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.9rem 1rem; overflow: auto; max-height: 420px;
  white-space: pre-wrap; word-break: break-word; margin: 0;
}
code.inline {
  font-family: var(--font-mono); font-size: 0.83em;
  background: var(--surface-3); padding: 0.1rem 0.35rem; border-radius: 4px;
}

/* ------------------------------------------------------------- checks --- */
.check-item {
  display: flex; gap: 0.7rem; padding: 0.7rem 0;
  border-bottom: 1px solid var(--border); align-items: flex-start;
}
.check-item:last-child { border-bottom: none; }
.check-item .dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none; margin-top: 0.42rem;
}
.check-item.ok .dot { background: var(--ok); }
.check-item.warning .dot { background: var(--warn); }
.check-item.error .dot { background: var(--danger); }
.check-item .check-label { font-weight: 600; font-size: 0.89rem; }
.check-item .check-detail { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15rem; }

.vuln {
  border: 1px solid var(--border); border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm); padding: 0.8rem 1rem; margin-bottom: 0.7rem;
  background: var(--surface-2);
}
.vuln.CRITICAL, .vuln.HIGH { border-left-color: var(--danger); }
.vuln.LOW, .vuln.UNKNOWN { border-left-color: var(--info); }
.vuln h4 { margin: 0 0 0.25rem; font-size: 0.9rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.vuln p { margin: 0.25rem 0 0; font-size: 0.83rem; color: var(--text-muted); }

/* --------------------------------------------------------------- misc --- */
.empty {
  text-align: center; padding: 2.6rem 1rem; color: var(--text-muted);
}
.empty .big { font-size: 1.03rem; font-weight: 600; color: var(--text); margin-bottom: 0.3rem; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 0.82rem; }
.mono { font-family: var(--font-mono); }
.right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 0.5rem; } .mb-1 { margin-bottom: 0.5rem; }
.mt-2 { margin-top: 1rem; } .mb-2 { margin-bottom: 1rem; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 0.55rem; }
.divider { height: 1px; background: var(--border); margin: 1.1rem 0; border: none; }

.theme-toggle {
  display: inline-flex; background: var(--surface-3);
  border: 1px solid var(--border); border-radius: 20px; padding: 2px;
}
.theme-toggle button {
  background: none; border: none; cursor: pointer; font: inherit;
  padding: 0.24rem 0.6rem; border-radius: 20px; font-size: 0.76rem;
  color: var(--text-muted); font-weight: 600; display: inline-flex;
  align-items: center; gap: 0.3rem;
}
.theme-toggle button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------------------------------------------------------------- auth --- */
.auth-shell {
  min-height: 100vh; display: grid; place-items: center;
  padding: 1.5rem; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 2rem 1.9rem;
}
.auth-card.wide { max-width: 560px; }
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo img {
  height: var(--logo-height, 72px);
  max-width: 100%;
  object-fit: contain;
}
/* The no-logo-uploaded fallback: the plain mark with the firm's own name
   underneath. The mark is square, so it is sized smaller than an uploaded
   wide logo would be — at the full logo height it would tower over the
   sign-in card. */
.auth-logo .auth-mark {
  height: calc(var(--logo-height, 72px) * 0.72);
  display: block;
  margin: 0 auto;
  border-radius: 22%;
}
.auth-wordmark {
  font-family: var(--font-display);
  margin-top: 0.6rem;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1.2;
}
html[data-theme="dark"] .auth-logo img { filter: brightness(1.35) saturate(1.05); }
.auth-card h1 { font-size: 1.24rem; text-align: center; margin-bottom: 0.3rem; }
.auth-card .sub { text-align: center; color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.5rem; }
.auth-foot { margin-top: 1.4rem; text-align: center; font-size: 0.8rem; color: var(--text-faint); }

.qr-box {
  display: grid; place-items: center; padding: 1rem;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); margin: 0 auto 1rem; width: fit-content;
}
.qr-box svg { display: block; width: 200px; height: 200px; }
.qr-box svg rect { fill: var(--brand-navy); }

.codes-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem;
  font-family: var(--font-mono); font-size: 0.95rem;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; margin-bottom: 1.2rem;
}
.codes-grid span { text-align: center; letter-spacing: 0.04em; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 1.2rem; }
.steps li {
  counter-increment: step; position: relative;
  padding-left: 2rem; margin-bottom: 0.7rem; font-size: 0.89rem;
}
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong);
  display: grid; place-items: center; font-size: 0.74rem; font-weight: 700;
}

/* --------------------------------------------------------- responsive --- */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 60;
    transform: translateX(-100%); transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(8, 20, 30, 0.45); z-index: 50;
  }
  .menu-toggle { display: inline-flex; }
  .content { padding: 1.1rem 1rem 2.5rem; }
  .topbar { padding: 0 1rem; }
}

@media (max-width: 620px) {
  .codes-grid { grid-template-columns: 1fr; }
  .page-head .actions { width: 100%; }
  .task .task-controls { width: 100%; }
  .auth-card { padding: 1.5rem 1.25rem; }
}

@media print {
  .sidebar, .topbar, .filter-bar, .btn, .actions { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
  body { background: #fff; font-size: 11pt; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
