/* =========================================================
   HSEQ Platform – Clickable Prototype
   Plain CSS, no framework. Tokens first, then components.
   ========================================================= */

:root {
  /* Brand */
  --brand: #4f46e5;
  --brand-600: #4338ca;
  --brand-50: #eef0ff;
  --brand-100: #dfe2ff;
  --side: #0f1b2d;
  --side-2: #18263b;
  --side-text: #a9b4c4;

  /* Neutrals */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e6ea;
  --border-strong: #cfd4da;
  --text: #1c2430;
  --text-2: #4a5563;
  --text-3: #7a8594;

  /* Status */
  --green: #1f9d55;
  --green-50: #e8f6ee;
  --amber: #d98a00;
  --amber-50: #fff5e0;
  --orange: #e8590c;
  --orange-50: #fff0e6;
  --red: #d7263d;
  --red-50: #fdecee;
  --blue: #2463eb;
  --blue-50: #eaf0fe;
  --purple: #7048e8;
  --purple-50: #f1edfd;
  --grey-50: #eef0f3;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .18);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
svg { flex-shrink: 0; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.hidden { display: none !important; }

/* ---------- App shell: sidebar + topbar ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; padding: 16px 12px;
}
a.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: #fff; padding: 4px 8px 16px; }
a.brand:hover { text-decoration: none; }
a.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--side-text); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #22c55e); color: #fff;
}
.side-cta { margin: 4px 4px 18px; }
.side-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 12px 12px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--side-text); font-weight: 500;
}
.nav a:hover { color: #fff; text-decoration: none; background: var(--side-2); }
.nav a.active { color: #fff; background: var(--brand); }
.nav a .count { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: rgba(255,255,255,.12); color: #fff; }
.nav a.sub { padding-left: 42px; font-size: 13px; }
.side-foot { margin-top: auto; padding: 12px; border-radius: 10px; background: var(--side-2); font-size: 12px; }
.side-foot strong { color: #fff; display: block; font-size: 22px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 24px;
  background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.global-search {
  display: flex; align-items: center; gap: 8px;
  width: 380px; max-width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text-3); cursor: text;
}
.global-search input { border: 0; background: transparent; outline: 0; font: inherit; width: 100%; color: var(--text); }
.kbd { font-size: 11px; padding: 1px 6px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); color: var(--text-3); white-space: nowrap; }
.icon-btn {
  position: relative; width: 36px; height: 36px; border-radius: var(--radius);
  display: grid; place-items: center;
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid var(--surface); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer; border: 1px solid transparent; background: transparent; font: inherit; color: var(--text); }
.user-chip:hover { background: var(--surface-2); border-color: var(--border); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: #334155; color: #fff; font-size: 12px; font-weight: 600;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.c1 { background: #0f766e; } .avatar.c2 { background: #7c3aed; }
.avatar.c3 { background: #c2410c; } .avatar.c4 { background: #1d4ed8; }
.menu-toggle { display: none; }
.scrim { display: none; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; display: none; z-index: 60;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-sm); color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.dropdown-head { padding: 8px 10px; }

.notif-item { display: flex; gap: 10px; padding: 10px; border-radius: var(--radius-sm); }
.notif-item:hover { background: var(--surface-2); }
.notif-list { width: 340px; }

/* ---------- Page layout ---------- */
.page { width: 100%; max-width: 1440px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-3); margin-top: 4px; }
.breadcrumb { display: flex; gap: 6px; align-items: center; color: var(--text-3); font-size: 13px; margin-bottom: 6px; }
.breadcrumb a { color: var(--text-3); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-all { grid-column: 1 / -1; }
.layout-main-side { display: grid; grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head .desc { color: var(--text-3); font-size: 12px; font-weight: 400; margin-top: 2px; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }

/* KPI tiles */
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { color: var(--text-3); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kpi .trend { font-size: 12px; color: var(--text-3); }
.kpi .trend.up { color: var(--red); }
.kpi .trend.down { color: var(--green); }
.kpi.accent { border-left: 3px solid var(--brand); }
a.kpi:hover { text-decoration: none; background: var(--surface-2); }
a.kpi { color: inherit; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-outline { border-color: var(--brand); color: var(--brand); }
.btn-outline:hover { background: var(--brand-50); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; font-weight: 500; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--grey-50); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.green { background: var(--green-50); color: var(--green); }
.badge.amber { background: var(--amber-50); color: #a86b00; }
.badge.orange { background: var(--orange-50); color: var(--orange); }
.badge.red { background: var(--red-50); color: var(--red); }
.badge.blue { background: var(--blue-50); color: var(--blue); }
.badge.purple { background: var(--purple-50); color: var(--purple); }
.badge.brand { background: var(--brand-50); color: var(--brand); }
.badge.solid-green { background: var(--green); color: #fff; }
.badge.solid-red { background: var(--red); color: #fff; }

.risk { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 22px; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 700; color: #fff; }
.risk.low { background: var(--green); }
.risk.med { background: var(--amber); }
.risk.high { background: var(--orange); }
.risk.ext { background: var(--red); }

.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; background: var(--grey-50); color: var(--text-2); font-size: 12px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.req::after { content: " *"; color: var(--red); }
.hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; outline: 0;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8594' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.input[readonly], .textarea[readonly], .select:disabled { background: var(--surface-2); color: var(--text-2); }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 36px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 4px 0 12px; }

/* Segmented control (replaces the Yes/No split buttons in legacy UI) */
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); width: 100%; }
.segmented button {
  flex: 1; height: 36px; padding: 0 12px; border: 0; background: transparent;
  font: inherit; color: var(--text-2); cursor: pointer; border-right: 1px solid var(--border);
}
.segmented button:last-child { border-right: 0; }
.segmented button:hover { background: var(--surface-2); }
.segmented button.active { background: var(--brand); color: #fff; font-weight: 600; }
.segmented.readonly button { cursor: default; }
.segmented.readonly button:not(.active):hover { background: transparent; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }

.checkbox { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.checkbox input { accent-color: var(--brand); width: 16px; height: 16px; }

/* Choice cards (observation type picker) */
.choice-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.choice {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  padding: 16px 10px; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font: inherit; color: var(--text-2); min-height: 108px;
}
.choice:hover { border-color: var(--border-strong); background: var(--surface-2); }
.choice .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; }
.choice strong { color: var(--text); font-size: 13px; }
.choice span.small { line-height: 1.3; }
.choice.active { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 3px var(--brand-100); }

/* Upload */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 22px;
  text-align: center; color: var(--text-3); background: var(--surface-2); cursor: pointer;
}
.dropzone:hover { border-color: var(--brand); color: var(--brand); }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.thumb {
  width: 96px; height: 72px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: linear-gradient(135deg, #cbd5e1, #94a3b8); position: relative; overflow: hidden;
  display: grid; place-items: center; color: #fff;
}
.thumb .x { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; display: grid; place-items: center; cursor: pointer; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th.sortable { cursor: pointer; }
.table th.sortable::after { content: " ↕"; opacity: .5; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--brand-50); }
.table .id { font-weight: 600; color: var(--brand); white-space: nowrap; }
.table .title-cell { max-width: 360px; }
.table .title-cell .t { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table .title-cell .s { font-size: 12px; color: var(--text-3); }
.overdue { color: var(--red); font-weight: 600; }
.empty { padding: 28px; text-align: center; color: var(--text-3); }

.pagination { display: flex; gap: 4px; align-items: center; }
.pagination button { min-width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit; }
.pagination button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Filter bar */
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.filterbar .input-icon { width: 280px; }
.filterbar .select { width: auto; min-width: 150px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font: inherit; font-size: 13px; color: var(--text-2);
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--text); border-color: var(--text); color: #fff; }
.chip .n { font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: rgba(127,127,127,.18); }

/* ---------- Record header + tabs ---------- */
.record-head { background: var(--surface); border-bottom: 1px solid var(--border); }
.record-head .inner { max-width: 1440px; margin: 0 auto; padding: 18px 24px 0; }
.record-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.record-title h1 { font-size: 24px; }
.record-meta { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 8px; color: var(--text-3); font-size: 13px; }
.record-meta span strong { color: var(--text-2); font-weight: 500; }

.tabs { display: flex; gap: 2px; margin-top: 16px; overflow-x: auto; scrollbar-width: thin; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 14px; border: 0; background: none; cursor: pointer; white-space: nowrap;
  font: inherit; font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .st { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; color: #fff; }
.tab .st.done { background: var(--green); }
.tab .st.todo { background: transparent; border: 1.5px solid var(--border-strong); }
.tab .st.warn { background: var(--amber); }
.tab .n { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--grey-50); color: var(--text-2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Workflow stepper */
.stepper { display: flex; align-items: center; margin-top: 16px; }
.step { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.step .dot {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  font-size: 11px; font-weight: 700; border: 2px solid var(--border-strong); color: var(--text-3); background: var(--surface);
}
.step .lbl { font-size: 12px; font-weight: 500; color: var(--text-3); white-space: nowrap; }
.step .lbl small { display: block; font-weight: 400; font-size: 11px; }
.step .bar { flex: 1; height: 2px; background: var(--border); margin: 0 10px; min-width: 16px; }
.step:last-child { flex: 0 0 auto; }
.step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.step.done .bar { background: var(--green); }
.step.done .lbl { color: var(--text-2); }
.step.current .dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px var(--brand-100); }
.step.current .lbl { color: var(--brand); font-weight: 600; }

/* Accordions (Affected party / Evidence) */
.acc { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.acc + .acc { margin-top: 12px; }
.acc-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer; user-select: none; }
.acc-head .count {
  min-width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--grey-50); color: var(--text-3);
}
.acc-head .count.has { background: var(--green); color: #fff; }
.acc-head .chev { margin-left: auto; transition: transform .15s; color: var(--text-3); }
.acc.open .acc-head .chev { transform: rotate(180deg); }
.acc-body { display: none; padding: 0 16px 16px; }
.acc.open .acc-body { display: block; }

/* People list */
.person { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.person:first-child { border-top: 0; }
.person .info { flex: 1; min-width: 0; }
.person .info .n { font-weight: 500; }
.person .info .r { font-size: 12px; color: var(--text-3); }

/* Timeline (events) */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item .tl-dot { position: absolute; left: -28px; top: 2px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--border-strong); color: var(--text-3); }
.tl-item.green .tl-dot { border-color: var(--green); color: var(--green); }
.tl-item.blue .tl-dot { border-color: var(--blue); color: var(--blue); }
.tl-item.amber .tl-dot { border-color: var(--amber); color: var(--amber); }
.tl-item.brand .tl-dot { border-color: var(--brand); color: var(--brand); }
.tl-item .tl-title { font-weight: 600; }
.tl-item .tl-desc { color: var(--text-2); font-size: 13px; }
.tl-item .tl-meta { color: var(--text-3); font-size: 12px; margin-top: 2px; }

/* Comments */
.comment { display: flex; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.comment:first-child { border-top: 0; padding-top: 0; }
.comment .body { flex: 1; }
.comment .body .who { font-weight: 600; font-size: 13px; }
.comment .body .who span { font-weight: 400; color: var(--text-3); margin-left: 6px; }
.composer { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; }

/* ---------- Risk matrix ---------- */
.matrix { display: grid; grid-template-columns: 90px repeat(5, 1fr); gap: 3px; font-size: 11px; }
.matrix .ax { display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; color: var(--text-3); text-align: right; line-height: 1.2; }
.matrix .ax.top { justify-content: center; padding: 0 0 4px; text-align: center; align-items: flex-end; }
.matrix .cell {
  height: 38px; border-radius: 4px; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; border: 2px solid transparent; transition: transform .08s;
}
.matrix .cell:hover { transform: scale(1.05); }
.matrix .cell.low { background: #5cb87a; }
.matrix .cell.med { background: #f0b429; }
.matrix .cell.high { background: #f27a36; }
.matrix .cell.ext { background: #d7263d; }
.matrix .cell.sel { border-color: var(--text); box-shadow: 0 0 0 2px #fff inset; transform: scale(1.08); }
.risk-summary { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.risk-summary .item { flex: 1; min-width: 110px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.risk-summary .item .k { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.risk-summary .item .v { font-weight: 600; margin-top: 2px; }

/* ---------- RCA 5-Whys tree ---------- */
.rca-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.rca-canvas { display: flex; flex-direction: column; align-items: center; padding: 24px 12px; background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 18px 18px; border-radius: var(--radius); min-height: 420px; transform-origin: top center; }
.rca-node {
  position: relative; max-width: 560px; width: 100%; padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm);
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
}
.rca-node:hover { border-color: var(--brand); }
.rca-node.sel { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.rca-node .lvl { flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px; background: var(--grey-50); color: var(--text-2); }
.rca-node.problem { background: #fff7e6; border-color: #f0b429; }
.rca-node.problem .lvl { background: #f0b429; color: #fff; }
.rca-node.root { background: #eef2ff; border-color: #3b4cca; }
.rca-node.root .lvl { background: #3b4cca; color: #fff; }
.rca-link { width: 2px; height: 22px; background: var(--border-strong); position: relative; }
.rca-link::after { content: ""; position: absolute; bottom: -2px; left: -4px; border: 5px solid transparent; border-top-color: var(--border-strong); }
.rca-leaf { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.rca-leaf .pill { padding: 8px 14px; border-radius: var(--radius); color: #fff; font-weight: 600; font-size: 13px; }
.rca-leaf .pill.rc { background: #3b4cca; }
.rca-leaf .pill.fp { background: #0f8b8d; }

/* ---------- Life-saving rules ---------- */
.lsr-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.lsr {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 16px 10px; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface);
  cursor: pointer; font: inherit; color: var(--text); position: relative;
}
.lsr:hover { border-color: var(--border-strong); background: var(--surface-2); }
.lsr .ic { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: #1f3a93; color: #fff; }
.lsr .nm { font-size: 13px; font-weight: 500; }
.lsr.breached { border-color: var(--red); background: var(--red-50); }
.lsr.breached .ic { background: var(--red); }
.lsr.breached::after { content: "Breached"; position: absolute; top: 8px; right: 8px; font-size: 10px; font-weight: 700; color: #fff; background: var(--red); padding: 1px 6px; border-radius: 4px; }
.lsr-grid.disabled .lsr { opacity: .55; pointer-events: none; }

/* ---------- Info list (read-only key/value) ---------- */
.kv { display: grid; grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); gap: 10px 16px; }
.kv dt { color: var(--text-3); font-size: 13px; }
.kv dd { margin: 0; font-weight: 500; }

/* ---------- Alerts / callouts ---------- */
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; font-size: 13px; }
.callout.info { background: var(--blue-50); border-color: #c7d6fb; color: #1e3a8a; }
.callout.warn { background: var(--amber-50); border-color: #f5d48a; color: #7a4d00; }
.callout.danger { background: var(--red-50); border-color: #f5b8c1; color: #8a1224; }
.callout.success { background: var(--green-50); border-color: #a7dcbc; color: #155e36; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { width: 100%; max-width: 520px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column; }
.modal.lg { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius); background: #1c2430; color: #fff; box-shadow: var(--shadow-lg); font-size: 13px; animation: toast-in .2s ease-out; }
.toast .ok { color: #4ade80; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Wizard ---------- */
.wizard { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.wiz-steps { position: sticky; top: 80px; padding: 8px; }
.wiz-step { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: var(--radius); cursor: pointer; color: var(--text-2); }
.wiz-step:hover { background: var(--surface-2); }
.wiz-step .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; border: 2px solid var(--border-strong); color: var(--text-3); background: var(--surface); }
.wiz-step.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.wiz-step.active .n { border-color: var(--brand); background: var(--brand); color: #fff; }
.wiz-step.done .n { border-color: var(--green); background: var(--green); color: #fff; }
.wiz-pane { display: none; }
.wiz-pane.active { display: block; }
.sticky-foot { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 12px 18px; display: flex; justify-content: space-between; gap: 8px; border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- Charts (pure CSS bars) ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b .stack-bar { width: 100%; max-width: 34px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; }
.bars .b .seg { width: 100%; }
.bars .b small { color: var(--text-3); font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.hbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.hbar .nm { width: 150px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { display: block; flex: 1; height: 8px; background: var(--grey-50); border-radius: 999px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.hbar .v { width: 30px; text-align: right; font-weight: 600; }

/* Task list */
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 18px; border-top: 1px solid var(--border); }
.task:first-child { border-top: 0; }
.task:hover { background: var(--surface-2); }
.task .ti { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.task .tb { flex: 1; min-width: 0; }
.task .tb .t { font-weight: 500; color: var(--text); }
.task .tb .s { font-size: 12px; color: var(--text-3); }

/* Quick action tiles */
.qa { display: flex; gap: 14px; align-items: center; padding: 18px; color: var(--text); }
.qa:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow); }
.qa .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.qa .t { font-weight: 600; font-size: 15px; }
.qa .s { color: var(--text-3); font-size: 13px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero {
  position: relative; overflow: hidden; color: #fff; padding: 48px;
  background: radial-gradient(1200px 600px at 110% 110%, rgba(34,197,94,.35), transparent 60%), linear-gradient(150deg, #0f1b2d 0%, #1e1b4b 55%, #4f46e5 100%);
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-hero::before, .login-hero::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); }
.login-hero::before { width: 520px; height: 520px; right: -160px; bottom: -160px; }
.login-hero::after { width: 340px; height: 340px; right: -70px; bottom: -70px; }
.login-hero .brand { color: #fff; }
.login-hero h2 { font-size: 34px; font-weight: 700; line-height: 1.2; max-width: 460px; }
.login-hero p { opacity: .85; max-width: 440px; margin-top: 14px; font-size: 15px; }
.login-stats { display: flex; gap: 32px; position: relative; z-index: 1; }
.login-stats div strong { display: block; font-size: 26px; }
.login-stats div span { opacity: .8; font-size: 13px; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--surface); }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 26px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 40px; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

/* Prototype helper banner */
.proto-note { position: fixed; bottom: 16px; left: 16px; z-index: 90; background: #1c2430; color: #cbd5e1; font-size: 12px; padding: 6px 10px; border-radius: 6px; opacity: .85; }
.proto-note a { color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-main-side { grid-template-columns: minmax(0, 1fr); }
  .choice-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .global-search { width: 260px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 120; width: 264px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 110; }
  .topbar { padding: 0 16px; gap: 12px; }
  .menu-toggle { display: grid; }
  .global-search { display: none; }
  .user-chip .nm { display: none; }
  .page { padding: 16px; }
  .record-head .inner { padding: 16px 16px 0; }
  .grid-2, .grid-3, .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  .wizard { grid-template-columns: 1fr; }
  .wiz-steps { position: static; display: flex; overflow-x: auto; }
  .wiz-step .l { display: none; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .lsr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stepper .lbl { display: none; }
  .step .bar { margin: 0 4px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .filterbar .input-icon { width: 100%; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head .actions { width: 100%; }
}

@media print {
  .sidebar, .topbar, .tabs, .actions, .proto-note, .toast-wrap { display: none !important; }
  .tab-panel { display: block !important; page-break-inside: avoid; }
  body { background: #fff; }
}

/* =========================================================
   Additions: record workspace, board, AI assist, palette
   ========================================================= */

/* Record workspace: outline | content | summary */
.workspace { display: grid; grid-template-columns: 200px minmax(0, 1fr) 290px; gap: 20px; align-items: start; }
.outline { position: sticky; top: 76px; }
.outline .ol-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 0 10px 8px; }
.ol-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; border: 0; border-radius: var(--radius); background: none; cursor: pointer;
  font: inherit; color: var(--text-2);
}
.ol-item:hover { background: var(--surface); }
.ol-item.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); border-left: 3px solid var(--brand); }
.ol-item .st { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.ol-item .st.done { background: var(--green); }
.ol-item .st.todo { border: 1.5px dashed var(--border-strong); }
.ol-item .st.warn { background: var(--amber); }
.ol-item .n { margin-left: auto; font-size: 11px; padding: 0 7px; border-radius: 999px; background: var(--grey-50); color: var(--text-2); font-weight: 600; }
.ol-progress { margin: 14px 10px 0; }
.progress { height: 6px; border-radius: 999px; background: var(--grey-50); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: 999px; }

.summary { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 16px; }
.summary .kv { grid-template-columns: 110px 1fr; font-size: 13px; }

.section-anchor { scroll-margin-top: 80px; }

.status-hero { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.status-hero .ring { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--grey-50) 0); position: relative; }
.status-hero .ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); }
.status-hero .ring span { position: relative; }

/* Kanban board */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--grey-50); border-radius: 10px; padding: 10px; min-height: 300px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 600; font-size: 13px; }
.col-head .n { font-size: 11px; padding: 0 7px; border-radius: 999px; background: var(--surface); color: var(--text-2); }
.ocard { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; color: var(--text); box-shadow: var(--shadow-sm); }
.ocard:hover { text-decoration: none; border-color: var(--brand); }
.ocard .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.ocard .t { font-weight: 500; font-size: 13px; line-height: 1.4; }
.ocard .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; color: var(--text-3); }
.type-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.type-dot::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.t-unsafe-act { color: var(--orange); }
.t-unsafe-cond { color: var(--red); }
.t-near-miss { color: var(--purple); }
.t-safe { color: var(--green); }
.t-env { color: #0f8b8d; }

.view-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.view-toggle button { height: 34px; padding: 0 12px; border: 0; background: var(--surface); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font: inherit; color: var(--text-2); }
.view-toggle button + button { border-left: 1px solid var(--border); }
.view-toggle button.active { background: var(--text); color: #fff; }

/* AI assist */
.ai-card { border: 1px solid #d9d6fe; background: linear-gradient(135deg, #f5f3ff, #eef6ff); border-radius: var(--radius); padding: 14px 16px; }
.ai-card .ai-head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #4338ca; margin-bottom: 8px; }
.ai-card .sug { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.ai-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: #fff; border: 1px solid #d9d6fe; font-size: 12px; color: #3730a3; cursor: pointer; font: inherit; font-size: 12px; }
.ai-chip:hover { background: #eef0ff; }
.ai-chip.applied { background: #4338ca; color: #fff; border-color: #4338ca; }

/* Command palette */
.palette { max-width: 620px; align-self: flex-start; margin-top: 10vh; }
.palette .p-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.palette .p-input input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 16px; }
.palette .p-list { padding: 8px; max-height: 360px; overflow: auto; }
.palette .p-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 8px 10px 4px; }
.palette .p-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text); }
.palette .p-item:hover { background: var(--brand-50); text-decoration: none; }
.palette .p-item .k { margin-left: auto; }

/* Quick report page (focused, single column) */
.focus { max-width: 820px; margin: 0 auto; }
.focus-head { text-align: center; margin: 8px 0 22px; }
.focus-head h1 { font-size: 26px; }
.timer-pill { display: inline-flex; gap: 6px; align-items: center; padding: 4px 12px; border-radius: 999px; background: var(--green-50); color: var(--green); font-size: 12px; font-weight: 600; margin-bottom: 10px; }
.q-block { padding: 20px 22px; border-top: 1px solid var(--border); }
.q-block:first-child { border-top: 0; }
.q-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; margin-right: 8px; }
.q-title { font-weight: 600; font-size: 15px; display: flex; align-items: center; margin-bottom: 12px; }
.sev-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.sev { padding: 10px; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font: inherit; text-align: left; }
.sev strong { display: block; font-size: 13px; }
.sev span { font-size: 12px; color: var(--text-3); }
.sev .bar { height: 4px; border-radius: 2px; margin-bottom: 8px; }
.sev.active { border-color: var(--text); box-shadow: 0 0 0 3px var(--grey-50); }

/* Success screen */
.success-screen { text-align: center; padding: 48px 24px; }
.success-screen .big { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center; background: var(--green-50); color: var(--green); }

/* Heat strip (dashboard) */
.heat { display: grid; grid-template-columns: 92px repeat(6, minmax(0, 1fr)); gap: 4px; font-size: 12px; }
.heat .h { color: var(--text-3); display: flex; align-items: center; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.heat .h.c { justify-content: center; }
.heat .c { height: 30px; border-radius: 4px; display: grid; place-items: center; font-weight: 600; font-size: 11px; }

@media (max-width: 1280px) {
  .workspace { grid-template-columns: 200px minmax(0, 1fr); }
  .workspace .summary { grid-column: 1 / -1; position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .outline { position: static; display: flex; gap: 6px; overflow-x: auto; }
  .outline .ol-title, .ol-progress { display: none; }
  .ol-item { white-space: nowrap; width: auto; }
  .sev-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(4, 260px); }
}

/* =========================================================
   Action workflow
   ========================================================= */
.role-switch { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); }
.role-switch .segmented button { height: 30px; font-size: 13px; white-space: nowrap; }
.next-card .checkbox { display: flex; margin: 4px 0; }
.table td .row { white-space: nowrap; }
.table td > a.small { white-space: nowrap; }

.next-card { border: 1.5px solid var(--brand-100); box-shadow: var(--shadow); }
.next-head { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, var(--brand-50), transparent); border-radius: var(--radius) var(--radius) 0 0; }
.next-head.wait { background: linear-gradient(180deg, var(--amber-50), transparent); }
.next-head.green { background: linear-gradient(180deg, var(--green-50), transparent); }
.next-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: #fff; flex-shrink: 0; }
.next-head.wait .next-ico { background: var(--amber); }
.next-head.green .next-ico { background: var(--green); }
.next-k { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.next-head h2 { font-size: 17px; margin: 2px 0; }

.ext-card { border: 1px solid #f5d48a; background: var(--amber-50); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.completion { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); }
.mini { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2); display: flex; flex-direction: column; }
.mini .k { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.mini .v { font-weight: 600; margin-top: 2px; }

.hoc { display: inline-flex; gap: 2px; vertical-align: middle; margin-right: 6px; }
.hoc span { width: 10px; height: 10px; border-radius: 2px; background: var(--grey-50); border: 1px solid var(--border-strong); }
.hoc span.on { background: var(--green); border-color: var(--green); }
.req-list { display: flex; flex-wrap: wrap; gap: 8px; }
.req-list span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.dot-s { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.dot-s.ok { background: var(--green); }
.dot-s.warn { background: var(--red); }
.ev { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ev-ic { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }

.flow { display: flex; align-items: stretch; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.flow-step { flex: 1; min-width: 160px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.flow-step strong { font-size: 13px; color: var(--text); }
.flow-step em { font-style: normal; font-weight: 600; color: var(--brand); margin-top: auto; padding-top: 6px; }
.fs-n { width: 22px; height: 22px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 11px; }
.flow-arrow { display: flex; align-items: center; color: var(--text-3); font-size: 18px; }

@media (max-width: 900px) {
  .role-switch { width: 100%; flex-wrap: wrap; min-width: 0; }
  .role-switch .segmented { width: 100% !important; overflow-x: auto; }
  .role-switch .segmented button { flex: 1 0 auto; }
  .record-head .actions { min-width: 0; max-width: 100%; }
  .flow-arrow { display: none; }
}

/* =========================================================
   My tasks
   ========================================================= */
.tstats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tstat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 16px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  font: inherit; cursor: pointer; border-top: 3px solid var(--c, var(--border));
}
.tstat.static { cursor: default; border-top-color: var(--green); }
.tstat:not(.static):hover { background: var(--surface-2); }
.tstat.active { box-shadow: 0 0 0 2px var(--c); }
.tstat .n { font-size: 26px; font-weight: 700; line-height: 1.1; color: var(--c, var(--text)); }
.tstat .l { font-size: 12px; color: var(--text-3); font-weight: 500; }
.tdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.quickadd { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--border); color: var(--text-3); background: var(--surface-2); }
.quickadd input:not(.select) { flex: 1; border: 0; background: transparent; outline: 0; font: inherit; color: var(--text); height: 32px; min-width: 0; }

.tgroup-head {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 18px; border: 0; cursor: pointer;
  background: var(--surface); border-bottom: 1px solid var(--border); font: inherit; color: var(--text); text-align: left;
  position: sticky; top: 60px; z-index: 2;
}
.tgroup-head .n { font-size: 11px; font-weight: 600; padding: 0 7px; border-radius: 999px; background: var(--grey-50); color: var(--text-2); }
.tgroup-head .chev { margin-left: auto; color: var(--text-3); transition: transform .15s; }
.tgroup.collapsed .chev { transform: rotate(-90deg); }
.tgroup.collapsed .tgroup-body { display: none; }
.gdot { width: 10px; height: 10px; border-radius: 3px; }

.trow { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--border); cursor: pointer; }
.trow:hover { background: var(--surface-2); }
.trow.is-open { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand); }
.trow.is-done .ttitle { text-decoration: line-through; color: var(--text-3); }
.trow.is-done .tico { background: var(--green-50) !important; color: var(--green) !important; }
.tico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.tmain { flex: 1; min-width: 0; }
.ttitle { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tmeta { display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.ttype { font-weight: 600; }
.tdue { width: 104px; text-align: right; flex-shrink: 0; }
.tact { display: flex; align-items: center; gap: 6px; flex-shrink: 0; justify-content: flex-end; min-width: 150px; }

.drawer-scrim { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .25); z-index: 90; }
.drawer-scrim.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100%; z-index: 95;
  background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .2s ease;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; gap: 12px; align-items: flex-start; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-body { padding: 20px; overflow: auto; flex: 1; }
.drawer-foot { display: flex; gap: 8px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border); }

@media (max-width: 900px) {
  .tstats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trow { flex-wrap: wrap; gap: 10px; }
  .tmain { flex-basis: calc(100% - 50px); }
  .ttitle { white-space: normal; }
  .tdue { width: auto; text-align: left; margin-left: 46px; }
  .tact { min-width: 0; margin-left: auto; }
  .hide-sm { display: none !important; }
  .tgroup-head { top: 60px; }
  .quickadd .select { display: none; }
}

/* =========================================================
   Record workflows (observation / incident)
   ========================================================= */
.plain-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.locked .matrix, .locked .segmented { pointer-events: none; }
.locked .matrix { opacity: .85; }
.step.skipped .dot { border-style: dashed; color: var(--text-3); }
.step.skipped .lbl { color: var(--text-3); text-decoration: line-through; }
.outcomes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.outcome {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; text-align: left;
  border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font: inherit; color: var(--text);
}
.outcome:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.outcome span:last-child { font-size: 12px; color: var(--text-3); }
.oc-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 4px; }
.linked-act { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: var(--surface); }
a.linked-act:hover { text-decoration: none; border-color: var(--brand); }
.linked-act .progress { display: block; }
.feedback { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.feedback span { flex: 1; font-weight: 500; }
.gate { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 2px; }
.gate-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 13px; }
.gate-item .gi { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.gate-item.ok .gi { background: var(--green); }
.gate-item.no .gi { background: var(--red); }
.gate-item.opt .gi { background: var(--amber); }
.gate-item .link-btn { margin-left: auto; font-size: 12px; }
.approvers { display: flex; flex-direction: column; gap: 8px; }
.approver { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.approver.current { border-color: var(--brand); background: var(--brand-50); }
.approver .info { flex: 1; }
@media (max-width: 900px) { .outcomes { grid-template-columns: 1fr; } }

/* =========================================================
   Data viz (charts.js) + Analytics page
   ========================================================= */
.viz-tip { position: absolute; z-index: 300; display: none; pointer-events: none; min-width: 140px; max-width: 280px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12px; }
.viz-tip .vt-title { color: var(--text-3); font-weight: 600; margin-bottom: 4px; }
.viz-tip .vt-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: var(--text-2); }
.viz-tip .vt-row strong { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.viz-tip .vt-row span:last-child { white-space: normal; }
.viz-tip .vt-key.line { width: 12px; height: 2px; border-radius: 1px; flex-shrink: 0; }
.viz-tip .vt-key.box { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.viz-svg { display: block; overflow: visible; outline: none; }
.viz-svg:focus-visible { outline: 2px solid var(--brand); outline-offset: 4px; border-radius: 4px; }
.viz-tick { font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.viz-label { font-size: 12px; fill: var(--text-2); }
.viz-label .strong { font-weight: 700; fill: var(--text); }
.viz-label .muted, .viz-label.muted { fill: var(--text-3); }
.viz-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.viz-legend i { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: middle; margin-right: 6px; }
.viz-foot { font-size: 12px; color: var(--text-3); margin-top: 8px; }
.viz-table { overflow-x: auto; }
.viz-table .table td, .viz-table .table th { padding: 8px 12px; }

.vbars { display: flex; flex-direction: column; gap: 4px; }
.vbar { display: grid; grid-template-columns: minmax(96px, 38%) 1fr 44px; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 6px; color: var(--text); outline: none; }
a.vbar:hover, .vbar:hover, .vbar:focus-visible { background: var(--surface-2); text-decoration: none; }
.vb-label { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vb-track { display: block; height: 12px; }
.vb-fill { display: block; height: 12px; border-radius: 0 4px 4px 0; transition: width .3s ease; }
.vb-val { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }

.vheat { display: grid; gap: 2px; font-size: 12px; }
.vh-col { color: var(--text-3); text-align: center; padding-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vh-row { color: var(--text-2); display: flex; align-items: center; padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vh-cell { height: 36px; border-radius: 4px; display: grid; place-items: center; font-weight: 600; outline: none; cursor: default; }
.vh-cell:hover, .vh-cell:focus-visible { box-shadow: inset 0 0 0 2px var(--text); }
.vh-legend { display: flex; align-items: center; gap: 8px; justify-content: flex-end; font-size: 11px; color: var(--text-3); margin-top: 10px; }
.vh-swatches { display: inline-flex; gap: 2px; }
.vh-swatches i { width: 18px; height: 10px; border-radius: 2px; display: block; }

.vstack { display: flex; gap: 2px; height: 22px; }
.vs-seg { display: block; min-width: 6px; outline: none; }
.vs-seg:first-child { border-radius: 4px 0 0 4px; }
.vs-seg:last-child { border-radius: 0 4px 4px 0; }
.vs-seg:hover, .vs-seg:focus-visible { filter: brightness(1.1); box-shadow: inset 0 0 0 2px rgba(0,0,0,.25); }
.vs-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin-top: 14px; }
.vs-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.vs-item i { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.vs-item strong { color: var(--text); font-variant-numeric: tabular-nums; }
.od-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); color: var(--text); font-size: 13px; }
.od-row span:nth-child(2) { flex: 1; }
.od-row:hover { text-decoration: none; background: var(--surface-2); }
.spark { display: block; }

.viz-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.viz-filters .segmented button { white-space: nowrap; }
#vizRoot { transition: opacity .15s; }
#vizRoot.refreshing { opacity: .45; }

.insight { display: flex; gap: 24px; align-items: center; padding: 16px 20px; margin-bottom: 20px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-50), #f5fbf7); border: 1px solid var(--brand-100); }
.ins-score { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.insight .ring { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; position: relative;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--grey-50) 0); }
.insight .ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #fff; }
.insight .ring span { position: relative; }
.ins-list { list-style: none; margin: 0; padding: 0 0 0 24px; border-left: 1px solid var(--brand-100); display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--text-2); }
.ins-list li { display: flex; gap: 10px; align-items: flex-start; }
.ins-list strong { color: var(--text); }
.ins-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.ins-ic.good { background: var(--green); } .ins-ic.bad { background: var(--red); } .ins-ic.info { background: var(--brand); }

.kpi-group { margin-bottom: 20px; }
.kpi-group-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.kpi2 { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.kpi2.off { border-color: #f5b8c1; box-shadow: inset 3px 0 0 var(--red); }
.kpi2-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi2-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.kpi-help { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-3); font-size: 11px; font-weight: 700; cursor: help; flex-shrink: 0; }
.kpi-help:hover, .kpi-help:focus-visible { background: var(--brand-50); color: var(--brand); border-color: var(--brand); }
.kpi2-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.kpi2-value { font-size: 30px; font-weight: 700; line-height: 1.05; color: var(--text); }
.kpi2-foot { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 12px; }
.delta { font-weight: 600; white-space: nowrap; }
.delta.good { color: #0b7a0b; } .delta.bad { color: var(--red); } .delta.flat { color: var(--text-3); }
.delta .dl { font-weight: 400; }
.tstatus { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; }
.tstatus.good { color: #0b7a0b; } .tstatus.bad { color: var(--red); }
.tstatus .muted { font-weight: 400; }

.viz-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.viz-grid .card-head { align-items: flex-start; }
.scorecard .num { font-variant-numeric: tabular-nums; }
.scorecard tr.hl td { background: var(--brand-50); }
.scorecard th.sortable { cursor: pointer; }
.minibar { position: relative; display: inline-block; width: 80px; height: 8px; background: var(--grey-50); border-radius: 999px; vertical-align: middle; margin-right: 8px; }
.minibar span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.minibar i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); }

@media (max-width: 1200px) { .viz-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .viz-grid { grid-template-columns: minmax(0, 1fr); }
  .viz-grid .span-2 { grid-column: auto; }
  .insight { flex-direction: column; align-items: flex-start; }
  .ins-list { border-left: 0; padding-left: 0; }
  .viz-filters .segmented { width: 100% !important; display: grid; grid-template-columns: 1fr 1fr; }
  .viz-filters .segmented button { border-bottom: 1px solid var(--border); }
  .viz-filters .select { width: 100% !important; }
  .vs-legend { grid-template-columns: 1fr; }
}
a.kpi2-link { color: inherit; }
a.kpi2-link:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow); }
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi2 { padding: 12px; min-width: 0; }
  .kpi2 .spark { display: none; }
  .kpi2-value { font-size: 24px; }
  .kpi2-label { font-size: 12px; }
  .tstatus, .delta { white-space: normal; }
}
.viz-card .card-head { flex-wrap: nowrap; }
.viz-card .card-head > .actions, .viz-card .card-head > .btn { flex-shrink: 0; }
.kpi2-src { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-3); border-top: 1px dashed var(--border); padding-top: 6px; margin-top: 2px; }
.viz-src { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-3); margin-top: 10px; }
.an-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 4px 0 18px; overflow-x: auto; }
.an-tabs button { padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.an-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.an-panel { display: none; } .an-panel.active { display: block; }
.dict td:first-child { font-weight: 600; white-space: nowrap; }
.dict td { vertical-align: top; font-size: 13px; }
.dict code { font-size: 12px; background: var(--grey-50); padding: 1px 5px; border-radius: 4px; }
.hp-list .row { padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.dict { table-layout: fixed; }
.dict td, .dict th { white-space: normal; overflow-wrap: anywhere; }
.dict td:first-child { white-space: normal; }
.dict code { white-space: normal; }
.scorecard td:first-child { white-space: nowrap; }
.vbar { grid-template-columns: minmax(96px, 46%) 1fr 40px; }
