/* ==========================================================================
   Safety Investigator – Task Management
   1. Tokens   2. Base   3. Controls   4. Layout   5. Components   6. Overlays
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  color-scheme: light;

  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: oklch(0.968 0.005 255);
  --surface: oklch(1 0 0);
  --sunken: oklch(0.955 0.006 255);
  --border: oklch(0.9 0.008 255);
  --border-strong: oklch(0.82 0.012 255);

  --text: oklch(0.24 0.02 260);
  --muted: oklch(0.48 0.02 260);
  --faint: oklch(0.62 0.015 260);

  --accent: oklch(0.5 0.19 264);
  --accent-hover: oklch(0.44 0.19 264);
  --accent-soft: oklch(0.95 0.03 264);
  --accent-strong: oklch(0.4 0.17 264);
  --on-accent: oklch(1 0 0);

  --ok-soft: oklch(0.95 0.045 155);
  --ok-text: oklch(0.4 0.11 155);
  --warn-soft: oklch(0.955 0.055 85);
  --warn-text: oklch(0.45 0.11 65);
  --danger: oklch(0.55 0.21 27);
  --danger-soft: oklch(0.955 0.03 27);
  --danger-text: oklch(0.46 0.18 27);

  --radius: 12px;
  --radius-sm: 8px;
  --control-h: 36px;
  --shadow-card: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-pop: 0 18px 48px -12px rgb(16 24 40 / 0.28), 0 4px 12px rgb(16 24 40 / 0.08);
}

/* Dark tokens: once for the OS setting, once for the manual toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: oklch(0.17 0.012 260);
    --surface: oklch(0.215 0.014 260);
    --sunken: oklch(0.25 0.014 260);
    --border: oklch(0.3 0.015 260);
    --border-strong: oklch(0.39 0.018 260);
    --text: oklch(0.93 0.008 260);
    --muted: oklch(0.73 0.015 260);
    --faint: oklch(0.58 0.015 260);
    --accent: oklch(0.7 0.14 264);
    --accent-hover: oklch(0.76 0.13 264);
    --accent-soft: oklch(0.3 0.07 264);
    --accent-strong: oklch(0.84 0.09 264);
    --on-accent: oklch(0.17 0.03 264);
    --ok-soft: oklch(0.29 0.05 155);
    --ok-text: oklch(0.85 0.12 155);
    --warn-soft: oklch(0.31 0.05 80);
    --warn-text: oklch(0.86 0.11 85);
    --danger: oklch(0.68 0.19 27);
    --danger-soft: oklch(0.29 0.07 27);
    --danger-text: oklch(0.82 0.11 27);
    --shadow-card: none;
    --shadow-pop: 0 18px 48px -12px rgb(0 0 0 / 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(0.17 0.012 260);
  --surface: oklch(0.215 0.014 260);
  --sunken: oklch(0.25 0.014 260);
  --border: oklch(0.3 0.015 260);
  --border-strong: oklch(0.39 0.018 260);
  --text: oklch(0.93 0.008 260);
  --muted: oklch(0.73 0.015 260);
  --faint: oklch(0.58 0.015 260);
  --accent: oklch(0.7 0.14 264);
  --accent-hover: oklch(0.76 0.13 264);
  --accent-soft: oklch(0.3 0.07 264);
  --accent-strong: oklch(0.84 0.09 264);
  --on-accent: oklch(0.17 0.03 264);
  --ok-soft: oklch(0.29 0.05 155);
  --ok-text: oklch(0.85 0.12 155);
  --warn-soft: oklch(0.31 0.05 80);
  --warn-text: oklch(0.86 0.11 85);
  --danger: oklch(0.68 0.19 27);
  --danger-soft: oklch(0.29 0.07 27);
  --danger-text: oklch(0.82 0.11 27);
  --shadow-card: none;
  --shadow-pop: 0 18px 48px -12px rgb(0 0 0 / 0.6);
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
b { font-weight: 600; }
.mono { font-family: var(--mono); font-size: 0.93em; letter-spacing: -0.01em; }

.icon {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

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

/* 3. Controls -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--control-h); padding: 0 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-weight: 550; white-space: nowrap; cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--sunken); }
a.btn { text-decoration: none; }
.btn:active { translate: 0 1px; }
.btn .icon { color: var(--muted); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary .icon { color: inherit; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.btn-danger:hover { background: var(--danger); filter: brightness(0.93); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }

.control {
  width: 100%; min-width: 0; height: var(--control-h); padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.control::placeholder { color: var(--faint); }
.control:hover { border-color: var(--faint); }
.control:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 22%, transparent);
}
.control[readonly] { background: var(--sunken); border-color: var(--border); color: var(--muted); }
.control[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in oklch, var(--danger) 18%, transparent); }
.control-lg { height: 42px; font-size: 16px; font-weight: 550; }

select.control, .pill-select {
  appearance: none; cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d8696' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.textarea { height: auto; min-height: 300px; padding: 10px 12px; line-height: 1.55; resize: vertical; }

.control-group { display: flex; gap: 6px; }

/* Compact status select used inside tables */
.pill-select {
  height: 26px; padding: 0 24px 0 10px;
  border: 1px solid transparent; border-radius: 999px;
  background-color: var(--sunken); background-size: 13px; background-position: right 7px center;
  font-size: 12px; font-weight: 650; letter-spacing: 0.03em;
}
.pill-select[data-value="OPEN"] { background-color: var(--accent-soft); color: var(--accent-strong); }
.pill-select[data-value="CLOSED"] { background-color: var(--ok-soft); color: var(--ok-text); }
.pill-select[data-value="ONGOING"], .pill-select[data-value="DELAYED"] { background-color: var(--warn-soft); color: var(--warn-text); }
.pill-select[data-value="REJECTED"] { background-color: var(--danger-soft); color: var(--danger-text); }
.pill-select.is-plain { min-width: 68px; font-weight: 500; letter-spacing: 0; }
.pill-select option { background: var(--surface); color: var(--text); }

input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }

/* 4. Layout ---------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  height: 54px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 650; letter-spacing: -0.01em; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent); }
.brand-mark .icon { stroke-width: 3; }
.topbar-section { padding-left: 14px; border-left: 1px solid var(--border); color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.avatar {
  display: grid; place-items: center; min-width: 32px; height: 32px; margin-left: 8px; padding: 0 8px;
  border: 0; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; cursor: pointer;
}
.avatar:hover, .avatar[aria-expanded="true"] { background: color-mix(in oklch, var(--accent) 22%, var(--surface)); }
.theme-moon { display: none; }
:root[data-theme="dark"] .theme-sun { display: none; }
:root[data-theme="dark"] .theme-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-sun { display: none; }
  :root:not([data-theme="light"]) .theme-moon { display: block; }
}

.page { max-width: 1480px; margin: 0 auto; padding: 0 24px 56px; }

.panel { display: grid; gap: 16px; padding-top: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; }

/* 5. Components ------------------------------------------------------------ */

/* Task header (sticks to the top so Save is always in reach) */
.task-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap;
  margin: 0 -24px; padding: 18px 24px 14px;
  background: color-mix(in oklch, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
}
.task-id { min-width: 0; flex: 1 1 380px; }
.task-kicker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-no { font-size: 13px; font-weight: 600; color: var(--muted); }
.task-no.is-new { padding: 1px 7px; border-radius: 5px; background: var(--accent); color: var(--on-accent); letter-spacing: 0.04em; }
.task-head h1 { margin: 6px 0 9px; font-size: 24px; line-height: 1.2; font-weight: 650; letter-spacing: -0.02em; text-wrap: balance; overflow-wrap: anywhere; }
.task-head h1.is-empty { color: var(--faint); }

.task-meta { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.meta-item b { color: var(--text); }
.meta-item.is-overdue b { color: var(--danger-text); }

.task-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-actions .sep { width: 1px; height: 22px; background: var(--border-strong); margin: 0 2px; }
.unsaved { display: inline-flex; align-items: center; gap: 7px; margin-left: 4px; color: var(--warn-text); font-size: 13px; font-weight: 550; }
.unsaved::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  color: var(--muted); font-size: 12px; font-weight: 550;
}
.chip.is-empty { border-style: dashed; color: var(--faint); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; background: var(--sunken); color: var(--muted);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.05em;
}
.badge[data-tone="open"] { background: var(--accent-soft); color: var(--accent-strong); }
.badge[data-tone="closed"] { background: var(--ok-soft); color: var(--ok-text); }
.badge[data-tone="high"] { background: var(--danger-soft); color: var(--danger-text); }
.badge[data-tone="mid"] { background: var(--warn-soft); color: var(--warn-text); }
.badge[data-tone="open"]::before, .badge[data-tone="closed"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.progress { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.progress b { min-width: 34px; color: var(--text); }
.progress-track { width: 110px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress-track i { display: block; width: var(--pct, 0%); height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.3s ease; }
.progress.is-complete .progress-track i { background: var(--ok-text); }
/* Every step closed but the task itself is still open (red [%] in the old tool) */
.progress.is-attention .progress-track i { background: var(--danger); }
.progress.is-attention b { color: var(--danger-text); }

/* Tabs */
.tabs {
  position: relative; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 12px; border: 0; background: none;
  color: var(--muted); font-weight: 550; white-space: nowrap; cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab:hover { color: var(--text); background: color-mix(in oklch, var(--text) 5%, transparent); }
.tab[aria-selected="true"] { color: var(--accent-strong); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; inset: auto 8px 0; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); }
.tab:focus-visible { outline-offset: -2px; }
.tab-count {
  min-width: 20px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--sunken); color: var(--muted);
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
}
.tab[aria-selected="true"] .tab-count { background: var(--accent-soft); color: var(--accent-strong); }

/* Cards */
.card {
  display: flex; flex-direction: column; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-card);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 13.5px; font-weight: 650; white-space: nowrap; }
.card-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.card-body { padding: 14px 16px 16px; }
.card-fill { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.card-fill .textarea { flex: 1; }

/* Form */
.form-card { container-type: inline-size; padding: 4px 18px 18px; }
.form-section { margin: 0; padding: 14px 0 0; border: 0; min-width: 0; }
.form-section + .form-section { margin-top: 16px; border-top: 1px solid var(--border); }
.form-section legend { float: left; width: 100%; margin-bottom: 10px; padding: 0; color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.form-grid { clear: both; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.c2 { grid-column: span 2; }
.c3 { grid-column: span 3; }
.c12 { grid-column: span 12; }
@container (max-width: 940px) {
  .c2 { grid-column: span 4; }
  .c3 { grid-column: span 6; }
}
@container (max-width: 560px) {
  .c2, .c3 { grid-column: span 6; }
}
@container (max-width: 260px) {
  .c2, .c3 { grid-column: span 12; }
}

/* Workflow selection */
.selection-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.selection-bar .control { flex: 1 1 200px; }
.type-description {
  flex: 1; min-height: 132px; padding: 12px 14px;
  border-radius: var(--radius-sm); background: var(--sunken);
  color: var(--text); white-space: pre-wrap;
}
.type-description.is-empty { color: var(--faint); }

/* Tables */
.table-wrap { overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
.table-scroll { max-height: 304px; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th {
  position: sticky; top: 0; z-index: 1; height: 36px; padding: 0 12px;
  background: var(--surface); box-shadow: inset 0 -1px 0 var(--border);
  color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; text-align: left; white-space: nowrap;
}
.table td { height: 42px; padding: 0 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in oklch, var(--text) 3.500%, transparent); }
.table tbody tr.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.table .num { text-align: right; }
.table .pos { width: 1%; color: var(--faint); text-align: right; }
.table .fit { width: 1%; }
.table .center { width: 1%; text-align: center; }
.table .grow { width: 99%; white-space: normal; }
.table .dim { color: var(--muted); }
.table label { cursor: pointer; }
.step-name { padding: 0; border: 0; background: none; text-align: left; font-weight: 550; cursor: pointer; }
.step-name:hover { color: var(--accent-strong); }
tr.is-closed .step-name { color: var(--muted); }

/* Empty states and placeholders */
.empty { display: grid; place-items: center; align-content: center; gap: 12px; min-height: 180px; padding: 28px 20px; color: var(--muted); text-align: center; }
.empty > .icon { width: 26px; height: 26px; color: var(--faint); stroke-width: 1.6; }
.empty p { max-width: 36ch; }
.card-fill > .empty { flex: 1; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }

.stub { align-items: center; gap: 8px; padding: 72px 24px; text-align: center; border-style: dashed; box-shadow: none; }
.stub .icon { width: 30px; height: 30px; color: var(--faint); stroke-width: 1.5; }
.stub h2 { margin-top: 6px; font-size: 16px; font-weight: 650; }
.stub p { margin-bottom: 8px; color: var(--muted); }

/* 6. Overlays -------------------------------------------------------------- */
dialog { color: var(--text); }
dialog::backdrop { background: rgb(12 16 26 / 0.48); backdrop-filter: blur(2px); }

.modal {
  width: min(420px, calc(100vw - 32px)); padding: 0;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow-pop);
}
.modal[open] { animation: pop-in 0.16s ease-out; }
.modal form { padding: 22px 22px 18px; }
.modal h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.modal p { margin-top: 8px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.modal-actions .btn { min-width: 84px; }

.drawer {
  width: min(460px, 100vw); height: 100dvh; max-height: none; max-width: none;
  margin: 0 0 0 auto; padding: 0;
  border: 0; border-left: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-pop);
}
.drawer[open] { display: flex; flex-direction: column; animation: slide-in 0.2s ease-out; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 20px; }
.drawer-head h2 { font-size: 17px; font-weight: 650; }
.drawer-search { position: relative; padding: 0 20px 12px; border-bottom: 1px solid var(--border); }
.drawer-search .icon { position: absolute; left: 31px; top: 10px; color: var(--faint); pointer-events: none; }
.drawer-search .control { padding-left: 34px; }
.task-list { flex: 1; overflow: auto; margin: 0; padding: 8px; list-style: none; }
.task-item {
  display: grid; gap: 4px; width: 100%; padding: 11px 12px;
  border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer;
}
.task-item:hover { background: var(--sunken); }
.task-item[aria-current="true"] { background: var(--accent-soft); }
.task-item-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.task-item-top .badge { margin-left: auto; }
.task-item-title { font-weight: 600; overflow-wrap: anywhere; }
.task-item-sub { color: var(--muted); font-size: 12.5px; }
.task-list .empty { min-height: 120px; }

/* A popover, so messages also show above an open dialog (see toast() in core.js). */
.toasts {
  position: fixed; z-index: 100; inset: auto auto 24px 50%; translate: -50% 0; display: grid; gap: 8px; justify-items: center; pointer-events: none;
  margin: 0; padding: 0; border: 0; background: none; overflow: visible; color: inherit;
}
.toast {
  display: inline-flex; align-items: center; gap: 9px; max-width: min(480px, calc(100vw - 32px)); padding: 10px 16px;
  border-radius: 10px; background: oklch(0.26 0.02 260); color: oklch(0.97 0.005 260);
  box-shadow: var(--shadow-pop); font-weight: 550;
  opacity: 0; translate: 0 8px; transition: opacity 0.2s, translate 0.2s;
}
.toast.is-in { opacity: 1; translate: 0 0; }
.toast::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 50%; background: oklch(0.75 0.12 264); }
.toast[data-tone="ok"]::before { background: oklch(0.78 0.16 155); }
.toast[data-tone="warn"]::before { background: oklch(0.8 0.15 80); }

@keyframes pop-in { from { opacity: 0; scale: 0.96; } }
@keyframes slide-in { from { translate: 40px 0; opacity: 0; } }

/* Responsive --------------------------------------------------------------- */
@media (max-width: 1020px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .textarea { min-height: 220px; }
}
@media (max-width: 720px) {
  .topbar { padding: 0 16px; }
  .topbar-section, #btn-listing span { display: none; }
  .page { padding: 0 16px 40px; }
  .task-head { position: static; margin: 0 -16px; padding: 16px 16px 12px; }
  .task-head h1 { font-size: 21px; }
  .task-actions { width: 100%; }
  .task-actions .sep { display: none; }
  .task-actions .unsaved { width: 100%; }
  .progress-track { width: 72px; }
}

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

/* ==========================================================================
   7. Start page
   ========================================================================== */
.home { max-width: 1240px; }
.home-head { padding: 44px 0 22px; }
.eyebrow { color: var(--accent-strong); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.home-head h1 { margin-top: 6px; font-size: 32px; font-weight: 650; letter-spacing: -0.025em; }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.module-card {
  display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 18px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-card);
  color: inherit; text-decoration: none;
  transition: border-color 0.15s, translate 0.15s, box-shadow 0.15s;
}
a.module-card:hover { border-color: var(--accent); translate: 0 -2px; box-shadow: 0 10px 24px -14px color-mix(in oklch, var(--accent) 70%, transparent); }
.module-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 10px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); }
.module-icon .icon { width: 20px; height: 20px; }
.module-code { color: var(--faint); font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; }
.module-name { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.module-text { margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.module-foot { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 16px; color: var(--accent-strong); font-weight: 600; }
.module-card.is-disabled { background: transparent; box-shadow: none; border-style: dashed; }
.module-card.is-disabled .module-icon { background: var(--sunken); color: var(--faint); }
.module-card.is-disabled .module-name { color: var(--muted); }



.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 15px; font-weight: 650; }

/* ==========================================================================
   8. Task tabs (notes, attachments, references, resources, export, FSIR)
   ========================================================================== */
.split-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.split-main { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); }
.split-side { grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr); }

.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-actions.end, .card-foot.end { justify-content: flex-end; }
.card-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); }
.card-foot .card-meta { margin-left: auto; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; margin-top: 16px; }
.chip .icon { width: 12px; height: 12px; margin-right: 5px; }
.textarea-sm { min-height: 120px; }
.table-tall { max-height: 432px; }

/* inline-editable table cells */
.table-edit td { padding: 0 6px; }
.table-edit td.pos { padding: 0 12px; }
.cell-control {
  width: 100%; min-width: 60px; height: 32px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
}
select.cell-control { min-width: 110px; padding-right: 26px; cursor: pointer; }
.cell-control:hover { border-color: var(--border-strong); background: var(--surface); }
.cell-control:focus-visible { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 22%, transparent); }
.cell-control.num { width: 76px; text-align: right; }
.row-new td { background: color-mix(in oklch, var(--sunken) 55%, transparent); }
.row-new .cell-control { color: var(--muted); font-weight: 550; }

.stat-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 0; }
.stat-list div { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--sunken); }
.stat-list dt { color: var(--muted); font-size: 12.5px; }
.stat-list dd { margin: 2px 0 0; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }

.hint-list { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; color: var(--muted); }
.hint-list li { display: flex; gap: 10px; }
.hint-list .icon { margin-top: 2px; color: var(--faint); }
.hint-list b { color: var(--text); }

/* Notes: rich text */
.rich-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.rich-toolbar .sep { width: 1px; height: 20px; margin: 0 4px; background: var(--border-strong); }
.rich-toolbar .card-meta { margin-left: auto; }
.rich { min-height: 420px; padding: 20px 24px 28px; outline: none; counter-reset: note-heading; line-height: 1.6; border-radius: 0 0 var(--radius) var(--radius); }
.rich:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in oklch, var(--accent) 45%, transparent); }
.rich h3 { margin: 18px 0 4px; font-size: 16px; font-weight: 650; counter-increment: note-heading; }
.rich h3:first-child { margin-top: 0; }
.rich h3::before { content: "1.1." counter(note-heading); display: inline-block; min-width: 58px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rich p, .rich div { margin: 0 0 6px; }
.rich ul { margin: 0 0 6px; padding-left: 22px; }
.rich img { display: block; max-width: min(100%, 640px); height: auto; margin: 10px 0; border-radius: 6px; }

/* Attachments */
.attach-preview { display: grid; place-items: center; min-height: 220px; max-height: 360px; overflow: hidden; border-radius: var(--radius-sm); background: var(--sunken); }
.attach-preview img, .attach-preview video { max-width: 100%; max-height: 360px; object-fit: contain; }
.attach-preview .empty { min-height: 0; }
.card.is-dropping { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 22%, transparent); }
.modal-wide { width: min(560px, calc(100vw - 32px)); }
.modal-body { padding: 16px 20px 20px; }
.modal-lead { margin: 0 0 12px; color: var(--muted); }
.modal .modal-body p { margin-top: 0; }
.import-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.import-kind { height: 64px; flex-direction: column; gap: 6px; white-space: normal; text-align: center; }
@media (max-width: 480px) { .import-grid { grid-template-columns: repeat(2, 1fr); } }

/* References */
.ref-icon .icon { color: var(--muted); }
.ref-search { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; }
.ref-results { height: 190px; overflow: auto; margin: 0; padding: 4px; list-style: none; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ref-result { display: flex; gap: 12px; width: 100%; padding: 6px 8px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer; }
.ref-result .mono { flex: none; min-width: 76px; color: var(--muted); }
.ref-result:hover { background: var(--sunken); }
.ref-result.is-picked { background: var(--accent-soft); color: var(--accent-strong); }
.ref-result.is-picked .mono { color: inherit; }
.ref-results .empty { min-height: 170px; padding: 12px; }
.ref-description { flex: none; min-height: 84px; max-height: 150px; overflow: auto; }

/* Export */
.check-list { margin: 0; padding: 6px; list-style: none; max-height: 330px; overflow: auto; }
.check-list label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.check-list label:hover { background: var(--sunken); }
.check-list .mono { color: var(--faint); }
.export-status { min-height: 20px; color: var(--accent-strong); font-weight: 600; }
.modal-report { width: min(980px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: hidden; }
.modal-report[open] { display: flex; flex-direction: column; }
.report-scroll { overflow: auto; padding: 24px; background: var(--sunken); }
.report-doc { max-width: 800px; margin: 0 auto; padding: 44px 52px; background: #fff; color: #1a1a1a; box-shadow: 0 2px 12px rgb(0 0 0 / 0.12); font: 13px/1.5 Arial, Helvetica, sans-serif; }
.report-doc h1 { margin: 22px 0 16px; font-size: 21px; text-align: center; }
.report-doc h2 { margin: 20px 0 6px; font-size: 16px; }
.report-doc h3 { margin: 14px 0 4px; font-size: 14px; }
.report-doc p { margin: 0 0 8px; }
.report-doc table { width: 100%; margin: 6px 0 12px; border-collapse: collapse; }
.report-doc th, .report-doc td { padding: 4px 7px; border: 1px solid #a5a5a5; text-align: left; vertical-align: top; font-size: 12.5px; }
.report-doc thead th, .report-doc table.pos th { background: #e8e8e8; }
.report-doc table.facts th { width: 35%; background: #f3f3f3; font-weight: normal; }
.report-doc table.page-head td { width: 33%; }
.report-doc .center { text-align: center; }
.report-doc .right { text-align: right; }
.report-doc .brand { font-size: 15px; font-weight: bold; }
.report-doc .none { color: #777; }
.report-doc img { max-width: 100%; }

/* FSIR item list + editor */
.table-items { table-layout: fixed; }
.table-items th:first-child { width: 54px; }
.table-items th:last-child { width: 38%; }
.table-items.has-status th:last-child { width: 72px; }
.table-items td { white-space: normal; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap !important; }
.item-no { margin-right: 10px; color: var(--faint); }
.report-preview { max-height: 420px; overflow: auto; padding: 18px 20px; }
.report-preview section + section { margin-top: 20px; }
.report-preview h3 { margin: 0 0 4px; font-size: 15.5px; font-weight: 650; }
.report-preview p { white-space: pre-wrap; }
.report-preview .empty { min-height: 120px; }

.sequence { display: grid; gap: 14px; }
.seq-pos { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.seq-head { display: flex; align-items: center; justify-content: space-between; }
.seq-pos textarea { height: auto; padding: 8px 10px; resize: vertical; }
.seq-images { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seq-drop { display: grid; place-items: center; align-content: center; gap: 6px; min-height: 96px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; cursor: pointer; }
.seq-drop:hover { border-color: var(--accent); color: var(--accent-strong); }
.seq-image { position: relative; margin: 0; }
.seq-image img { display: block; width: 100%; border-radius: var(--radius-sm); }
.seq-image .btn { position: absolute; top: 6px; right: 6px; }

@media (max-width: 1020px) {
  .split-even, .split-main, .split-side { grid-template-columns: minmax(0, 1fr); }
  .rich-toolbar .card-meta { display: none; }
}
td.fit select.cell-control { width: auto; min-width: 0; }

/* ==========================================================================
   9. ESC / ERCS risk assessment
   ========================================================================== */
:root {
  --risk-red: oklch(0.87 0.09 25);      --risk-red-text: oklch(0.38 0.15 27);
  --risk-orange: oklch(0.89 0.1 65);    --risk-orange-text: oklch(0.4 0.11 55);
  --risk-yellow: oklch(0.95 0.12 100);  --risk-yellow-text: oklch(0.4 0.09 95);
  --risk-green: oklch(0.91 0.1 150);    --risk-green-text: oklch(0.36 0.1 150);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --risk-red: oklch(0.4 0.12 27);     --risk-red-text: oklch(0.92 0.05 27);
    --risk-orange: oklch(0.45 0.1 60);  --risk-orange-text: oklch(0.94 0.06 70);
    --risk-yellow: oklch(0.5 0.09 100); --risk-yellow-text: oklch(0.96 0.07 100);
    --risk-green: oklch(0.4 0.08 150);  --risk-green-text: oklch(0.93 0.08 150);
  }
}
:root[data-theme="dark"] {
  --risk-red: oklch(0.4 0.12 27);     --risk-red-text: oklch(0.92 0.05 27);
  --risk-orange: oklch(0.45 0.1 60);  --risk-orange-text: oklch(0.94 0.06 70);
  --risk-yellow: oklch(0.5 0.09 100); --risk-yellow-text: oklch(0.96 0.07 100);
  --risk-green: oklch(0.4 0.08 150);  --risk-green-text: oklch(0.93 0.08 150);
}
[data-tone="red"] { --tone: var(--risk-red); --tone-text: var(--risk-red-text); }
[data-tone="orange"] { --tone: var(--risk-orange); --tone-text: var(--risk-orange-text); }
[data-tone="yellow"] { --tone: var(--risk-yellow); --tone-text: var(--risk-yellow-text); }
[data-tone="green"] { --tone: var(--risk-green); --tone-text: var(--risk-green-text); }

.c4 { grid-column: span 4; }
.c6 { grid-column: span 6; }
.cq { container-type: inline-size; }
@container (max-width: 940px) { .c4 { grid-column: span 6; } .c6 { grid-column: span 12; } }
@container (max-width: 560px) { .c4 { grid-column: span 12; } }

.esc-top { margin-top: 4px; }
.tabs-card { padding: 0 8px; }
.card-panel { padding: 16px; }
.card-panel > .textarea { display: block; min-height: 260px; }
.std-search { flex: 0 1 130px; }
.bordered { border: 1px solid var(--border); border-radius: var(--radius-sm); }

.rating-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.rating-detail { display: flex; flex-direction: column; gap: 8px; }
.rating-detail .textarea { min-height: 210px; }
.field-head { display: flex; align-items: center; justify-content: space-between; min-height: 30px; }
.field-head label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.check-row { display: flex; gap: 20px; margin-top: 10px; color: var(--muted); }
.check-row label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* result summary in the page header */
.risk-result { display: inline-flex; align-items: center; gap: 10px; height: 24px; padding: 0 10px 0 4px; border-radius: 999px; background: var(--sunken); color: var(--muted); font-variant-numeric: tabular-nums; }
.risk-result[data-tone="none"] { padding-left: 10px; }
.risk-result b { display: inline-grid; place-items: center; min-width: 36px; height: 18px; padding: 0 8px; border-radius: 999px; background: var(--tone); color: var(--tone-text); font-size: 12px; }
.risk-result span + span { padding-left: 10px; border-left: 1px solid var(--border-strong); }

/* matrix */
.esc-matrix-card { margin-top: 16px; }
.matrix-wrap { overflow-x: auto; padding: 12px; }
.matrix { width: 100%; border-collapse: separate; border-spacing: 3px; font-size: 12.5px; }
.matrix th, .matrix td { border-radius: 6px; }
.matrix thead th { min-width: 58px; padding: 6px 4px; background: var(--sunken); color: var(--muted); font-weight: 500; text-align: center; vertical-align: top; line-height: 1.3; }
.matrix thead th b, .matrix tbody th b { display: block; color: var(--text); font-weight: 650; }
.matrix thead th span { display: block; font-size: 11px; }
.matrix tbody th { min-width: 250px; padding: 6px 10px; background: var(--sunken); color: var(--muted); font-weight: 500; text-align: left; line-height: 1.3; }
.matrix tbody th b { font-size: 12px; letter-spacing: 0.01em; }
.matrix tbody th span { font-size: 11.5px; }
.matrix tbody td { height: 44px; background: var(--tone, var(--sunken)); color: var(--tone-text, var(--faint)); font-weight: 600; text-align: center; white-space: nowrap; }
.matrix th.is-hit { background: var(--text); color: var(--surface); }
.matrix th.is-hit b { color: var(--surface); }
.matrix td.is-hit { position: relative; z-index: 1; outline: 3px solid var(--text); outline-offset: 0; font-size: 14px; font-weight: 750; box-shadow: 0 4px 14px rgb(0 0 0 / 0.25); }
.matrix-corner { min-width: 250px; padding: 8px 10px; background: transparent; color: var(--muted); vertical-align: middle; }
.matrix-corner span { display: block; font-variant-numeric: tabular-nums; }
.matrix-code { display: block; margin-bottom: 2px; color: var(--text); font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.matrix[data-matrix="ERCS"] thead th { min-width: 78px; }

.matrix-legend { flex-wrap: wrap; gap: 8px 24px; color: var(--muted); font-size: 13px; }
.matrix-legend span { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--tone); }

/* create dialog */
.choice-list { display: grid; gap: 8px; }
.choice { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); text-align: left; cursor: pointer; }
.choice:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.choice:disabled { opacity: 0.5; cursor: not-allowed; }
.choice span { color: var(--muted); font-size: 13px; }
.transfer-field { margin-top: 16px; }

@media (max-width: 1020px) {
  .rating-layout { grid-template-columns: minmax(0, 1fr); }
}
/* the assessment form sits in a narrower card: keep the 12-column layout longer */
@container (min-width: 700px) and (max-width: 940px) {
  .is-dense .c2 { grid-column: span 2; }
  .is-dense .c3 { grid-column: span 3; }
  .is-dense .c4 { grid-column: span 4; }
  .is-dense .c6 { grid-column: span 6; }
}

/* ==========================================================================
   10. Sign-in and user management
   ========================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.badge[data-tone="ok"] { background: var(--ok-soft); color: var(--ok-text); }
.badge[data-tone="warn"] { background: var(--warn-soft); color: var(--warn-text); }
.badge[data-tone="danger"] { background: var(--danger-soft); color: var(--danger-text); }
.badge[data-tone="ok"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* account menu in the top bar */
.user-menu { position: relative; }
.menu {
  position: absolute; z-index: 30; top: calc(100% + 8px); right: 0; min-width: 232px; padding: 6px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-pop);
  animation: pop-in 0.12s ease-out;
}
.menu-head { display: grid; gap: 1px; margin-bottom: 6px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); }
.menu-head span { color: var(--muted); font-size: 12.5px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px;
  border: 0; border-radius: var(--radius-sm); background: none; color: inherit; text-align: left; text-decoration: none; font-weight: 500; cursor: pointer;
}
.menu-item:hover { background: var(--sunken); }
.menu-item .icon { color: var(--muted); }

/* forms in dialogs and on the login page */
.form-stack { display: grid; gap: 14px; margin-top: 18px; }
.form-pairs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 16px; }
.form-pairs .span-2 { grid-column: span 2; }
.field .field-hint, .field-hint { margin: 0; color: var(--faint); font-size: 12.5px; }
.field .field-error { margin: 0; color: var(--danger-text); font-size: 12.5px; font-weight: 550; }
.form-error, .modal .form-error {
  margin-top: 14px; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger-text); font-weight: 550;
}
.check-field { display: inline-flex; align-items: center; gap: 9px; color: var(--text) !important; font-size: 14px !important; font-weight: 500 !important; cursor: pointer; }
.check-field:has(:disabled) { color: var(--muted) !important; cursor: default; }
@media (max-width: 480px) {
  .form-pairs { grid-template-columns: minmax(0, 1fr); }
  .form-pairs .span-2 { grid-column: auto; }
}

/* login page */
.auth-page { min-height: 100dvh; display: grid; }
.auth { width: min(400px, calc(100vw - 32px)); margin: auto; padding: 32px 0 64px; }
.auth-brand { justify-content: center; width: 100%; margin-bottom: 22px; font-size: 16px; }
.auth-card { padding: 28px 28px 24px; box-shadow: var(--shadow-pop); }
.auth-card h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.auth-lead { margin-top: 6px; color: var(--muted); }
.auth-card .btn-block { margin-top: 20px; }
.auth-card .btn-ghost { margin-top: 8px; color: var(--muted); }
.auth-foot { margin-top: 18px; color: var(--muted); font-size: 13px; text-align: center; }
.auth-theme { position: fixed; top: 10px; right: 16px; }

/* user management */
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 44px 0 22px; }
.admin-head h1 { margin-top: 6px; font-size: 32px; font-weight: 650; letter-spacing: -0.025em; }
.users-toolbar { justify-content: flex-start; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.users-toolbar select.control { width: auto; }
.users-toolbar .card-meta { margin-left: auto; }
.search-field { position: relative; flex: 0 1 300px; }
.search-field .icon { position: absolute; left: 11px; top: 10px; color: var(--faint); pointer-events: none; }
.search-field .control { padding-left: 34px; }
.table-users tbody tr { cursor: pointer; }
.table-users tr.is-inactive td:not(:last-child) { opacity: 0.62; }
.table-users td { height: 48px; }

.signin-box {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 18px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--sunken);
}
.signin-info { display: grid; gap: 2px; min-width: 0; }
.signin-info span { color: var(--muted); font-size: 12.5px; }
#u-new-hint { margin-top: 16px; }
#u-code { text-transform: uppercase; }

.secret {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 14px 0 12px; padding: 10px 10px 10px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--sunken);
}
.secret output { font-size: 17px; font-weight: 600; letter-spacing: 0.04em; user-select: all; overflow-wrap: anywhere; }

/* Pages that start with a record from the server stay blank until it is there. */
.is-booting main { visibility: hidden; }

/* ==========================================================================
   11. Action and recommendation tracking
   ========================================================================== */
.tracking { max-width: 1360px; }
.section-title { margin: 34px 0 12px; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }

/* one of several: scope switch */
.track-scope { margin-bottom: 14px; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--sunken); border: 1px solid var(--border); }
.segmented button {
  height: 30px; padding: 0 14px; border: 0; border-radius: 7px; background: none;
  color: var(--muted); font-weight: 550; white-space: nowrap; cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(16 24 40 / 0.14); }

/* numbers at a glance */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  display: grid; gap: 1px; padding: 14px 16px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-card);
  transition: border-color 0.12s;
}
.tile:hover { border-color: var(--border-strong); }
.tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile-number { font-size: 26px; font-weight: 650; line-height: 1.15; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile-label { font-weight: 600; }
.tile-hint { color: var(--muted); font-size: 12.5px; }
.tile[data-tone="danger"] .tile-number { color: var(--danger-text); }

/* list */
.table-track tbody tr { cursor: pointer; }
.table-track td { height: 56px; padding-top: 8px; padding-bottom: 8px; }
.table-track tr.is-finished td { color: var(--muted); }
.table-track tr.is-finished .track-title { color: var(--muted); font-weight: 500; }
.track-no { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.track-kind { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 7px; background: var(--accent-soft); color: var(--accent-strong); }
.track-kind[data-kind="recommendation"] { background: var(--warn-soft); color: var(--warn-text); }
.track-title { padding: 0; border: 0; background: none; text-align: left; font-weight: 600; cursor: pointer; overflow-wrap: anywhere; }
.track-title:hover { color: var(--accent-strong); }
.track-title + .badge { margin-left: 6px; vertical-align: 1px; }
.track-sub { display: block; margin-top: 1px; color: var(--muted); font-size: 12.5px; }
.badge-status[data-tone]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.table-track { min-width: 780px; }
.table-track th:nth-child(3) { min-width: 170px; }
.chip-row { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.due.is-overdue { display: inline-flex; align-items: center; gap: 6px; color: var(--danger-text); font-weight: 600; }
.due.is-overdue .icon { width: 14px; height: 14px; }
.track-comments { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.track-comments .icon { width: 14px; height: 14px; }

/* detail dialog */
.modal-item { width: min(1060px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: hidden; }
.modal-item[open] { display: flex; flex-direction: column; }
.modal-item.is-new { width: min(620px, calc(100vw - 32px)); }
.modal-item form { padding: 0; }
.item-head { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.item-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); min-height: 0; flex: 1; overflow: hidden; }
.modal-item.is-new .item-body { grid-template-columns: minmax(0, 1fr); }
.item-form { display: grid; gap: 14px; align-content: start; padding: 18px 20px 20px !important; overflow: auto; }
.item-form .textarea { min-height: 110px; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 16px; }
.modal-item .control:disabled { background: var(--sunken); border-color: var(--border); color: var(--text); opacity: 1; cursor: default; }
.modal-item select.control:disabled { background-image: none; }
.modal-item .field-hint, .modal-item .form-error { margin-top: 0; }

.assignees { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 28px; }
.chip-lg { height: 28px; gap: 7px; padding: 0 9px; color: var(--text); font-size: 13px; font-weight: 500; }
.chip-lg span { color: var(--muted); }
.chip-lg .icon { margin-right: 0; color: var(--muted); }
.chip-remove { display: grid; place-items: center; width: 18px; height: 18px; margin-right: -4px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.chip-remove:hover { background: var(--danger-soft); color: var(--danger-text); }
.chip-remove .icon { width: 11px; height: 11px; margin: 0; }
.task-link { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; color: var(--text); font-weight: 550; text-decoration: none; overflow-wrap: anywhere; }
.task-link .mono { flex: none; color: var(--muted); }
a.task-link:hover { color: var(--accent-strong); }
a.task-link .icon { flex: none; width: 14px; height: 14px; color: var(--faint); }

.item-activity { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--border); background: color-mix(in oklch, var(--sunken) 55%, var(--surface)); }
.item-activity h3 { margin: 0; padding: 16px 18px 8px; color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.timeline { flex: 1; min-height: 120px; overflow: auto; display: grid; gap: 14px; align-content: start; margin: 0; padding: 6px 18px 16px; list-style: none; }
.tl-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
.tl-who { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-size: 10.5px; font-weight: 700; }
.tl-dot { justify-self: center; width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); }
.tl-bubble { padding: 9px 12px 10px; border: 1px solid var(--border); border-radius: 4px 12px 12px 12px; background: var(--surface); }
.tl-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.tl-head time { color: var(--faint); }
.timeline p { margin: 3px 0 0; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; }
.tl-item.is-change p { color: var(--muted); font-size: 13px; }
.comment-form { display: grid; gap: 8px; padding: 12px 18px 16px !important; border-top: 1px solid var(--border); background: var(--surface); }
.comment-form .textarea { min-height: 68px; }

.item-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.item-rights { margin-right: auto; color: var(--muted); font-size: 12.5px; }
.item-foot .btn { min-width: 84px; }

/* task tab */
.track-note { color: var(--muted); font-size: 13px; }

/* start page: what waits for the signed-in user */
.module-note { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; }

/* groups (user management) */
.groups-card { margin-top: 20px; }
.groups-card .card-head { flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.groups-card .card-meta { flex: 1; white-space: normal; }
.member-list { max-height: 220px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.member-list label span { color: var(--muted); }
.table-groups tbody tr { cursor: pointer; }
.table-groups td { height: 48px; }
.table-groups tr.is-inactive td:not(:last-child) { opacity: 0.62; }

@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-item { overflow: auto; }
  .item-body { grid-template-columns: minmax(0, 1fr); overflow: visible; }
  .item-form { overflow: visible; }
  .item-activity { border-left: 0; border-top: 1px solid var(--border); }
  .timeline { max-height: 320px; }
  .segmented { display: flex; }
  .segmented button { flex: 1; padding: 0 8px; }
}
