/* ============================================================================
   Tribastion Reach — design system
   Brand: matches Tribastion PentestPro (demo-pentestpro.tribastiontechnologies.com)
   — magenta #EC008C primary, indigo secondary accent, Space Grotesk display type.
   Light is the default; dark via toggle / system.
   ============================================================================ */

:root {
  /* Brand (magenta — matches the Tribastion product family) */
  --brand: #EC008C;
  --brand-600: #D4007E;
  --brand-700: #A3238E;
  --brand-tint: rgba(236, 0, 140, 0.10);
  --brand-tint-2: rgba(236, 0, 140, 0.16);

  /* Secondary accent (indigo) — used sparingly for specific badges/tags */
  --secondary: #6366F1;
  --secondary-tint: rgba(99, 102, 241, 0.14);

  /* Light theme surfaces */
  --bg: #F5F6F8;
  --bg-2: #EEF1F5;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --elev: #FFFFFF;
  --border: #E3E8EF;
  --border-strong: #D2D9E3;

  /* Text */
  --text: #1B2430;
  --text-dim: #5A6675;
  --text-faint: #8993A2;
  --on-brand: #FFFFFF;

  /* Semantic */
  --crit: #DC2626;
  --high: #EA580C;
  --med: #EAB308;
  --low: #0EA5E9;
  --info: #0EA5E9;
  --ok: #16A34A;
  --warn: #EA580C;
  --bad: #DC2626;

  /* Chart/heat cell fills (light) */
  --cell-prevented: #dff4e8; --cell-prevented-bd: #9fe0bd; --cell-prevented-fg: #146c43;
  --cell-detected:  #dcecfd; --cell-detected-bd: #a8ccf7; --cell-detected-fg: #1d4ed8;
  --cell-succeeded: #fde0e2; --cell-succeeded-bd: #f4b2b6; --cell-succeeded-fg: #b42318;
  --cell-none:      #f1f4f8; --cell-none-bd: #e3e8ef; --cell-none-fg: #8993a2;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow: 0 4px 14px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --ring: 0 0 0 3px rgba(236, 0, 140, 0.28);

  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', var(--sans);

  color-scheme: light;
}

/* ---- Dark theme: system default when not explicitly set to light ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1218;
    --bg-2: #0A0D12;
    --surface: #161C25;
    --surface-2: #1B222D;
    --elev: #1A212C;
    --border: #28313E;
    --border-strong: #354150;
    --text: #E7ECF3;
    --text-dim: #9AA7B8;
    --text-faint: #667081;
    --brand-tint: rgba(236, 0, 140, 0.16);
    --brand-tint-2: rgba(236, 0, 140, 0.24);
    --secondary: #818CF8; --secondary-tint: rgba(129, 140, 248, 0.18);
    --crit: #FF6B72; --high: #FBBF4D; --med: #FCD34D; --low: #6BA6FF; --ok: #3ECf8e; --warn: #FBBF4D; --bad: #FF6B72;
    --cell-prevented: rgba(62,207,142,.16); --cell-prevented-bd: rgba(62,207,142,.4); --cell-prevented-fg: #7ee7b8;
    --cell-detected:  rgba(107,166,255,.16); --cell-detected-bd: rgba(107,166,255,.42); --cell-detected-fg: #a9caff;
    --cell-succeeded: rgba(255,107,114,.18); --cell-succeeded-bd: rgba(255,107,114,.45); --cell-succeeded-fg: #ffb0b4;
    --cell-none:      #141a22; --cell-none-bd: #28313e; --cell-none-fg: #5a6675;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 6px 20px rgba(0,0,0,.45);
    --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}

/* ---- Dark theme: explicit toggle ---- */
:root[data-theme="dark"] {
  --bg: #0E1218; --bg-2: #0A0D12; --surface: #161C25; --surface-2: #1B222D; --elev: #1A212C;
  --border: #28313E; --border-strong: #354150;
  --text: #E7ECF3; --text-dim: #9AA7B8; --text-faint: #667081;
  --brand-tint: rgba(236, 0, 140, 0.16); --brand-tint-2: rgba(236, 0, 140, 0.24);
  --secondary: #818CF8; --secondary-tint: rgba(129, 140, 248, 0.18);
  --crit: #FF6B72; --high: #FBBF4D; --med: #FCD34D; --low: #6BA6FF; --ok: #3ECf8e; --warn: #FBBF4D; --bad: #FF6B72;
  --cell-prevented: rgba(62,207,142,.16); --cell-prevented-bd: rgba(62,207,142,.4); --cell-prevented-fg: #7ee7b8;
  --cell-detected:  rgba(107,166,255,.16); --cell-detected-bd: rgba(107,166,255,.42); --cell-detected-fg: #a9caff;
  --cell-succeeded: rgba(255,107,114,.18); --cell-succeeded-bd: rgba(255,107,114,.45); --cell-succeeded-fg: #ffb0b4;
  --cell-none: #141a22; --cell-none-bd: #28313e; --cell-none-fg: #5a6675;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 6px 20px rgba(0,0,0,.45); --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-600); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); font-family: var(--display); }
h1 { font-size: 1.55rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .85em; }
img { max-width: 100%; }
::selection { background: var(--brand-tint-2); }

/* ---- Layout shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 244px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; flex-direction: column; gap: .55rem; padding: 1.1rem 1.15rem .85rem; }
.brand-lockup { display: flex; align-items: center; gap: .55rem; }
.brand-logo { height: 22px; width: auto; display: block; }
/* Every Tribastion wordmark image in the app (sidebar, landing nav/footer,
   login, request-access) — not just the sidebar's .brand-logo — must invert
   in dark mode, and must do so for BOTH an explicit dark toggle AND a system
   dark preference with no explicit choice (the two cases every other themed
   rule in this file already handles). Missing either half of this used to
   leave the logo showing its light-background colours on a dark background
   outside the authenticated shell. */
:root[data-theme="dark"] .brand-logo, [data-theme="dark"] .brand-logo,
:root[data-theme="dark"] .lnav-logo, [data-theme="dark"] .lnav-logo,
:root[data-theme="dark"] .login-brand .m, [data-theme="dark"] .login-brand .m,
:root[data-theme="dark"] .lfoot-brand img, [data-theme="dark"] .lfoot-brand img {
  filter: brightness(0) invert(1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo,
  :root:not([data-theme="light"]) .lnav-logo,
  :root:not([data-theme="light"]) .login-brand .m,
  :root:not([data-theme="light"]) .lfoot-brand img {
    filter: brightness(0) invert(1);
  }
}
.brand-divider { width: 1px; align-self: stretch; min-height: 22px; background: var(--border-strong); }
.product-mark { flex-shrink: 0; display: flex; }
.product-name { font-weight: 700; font-size: .95rem; letter-spacing: -.01em; color: var(--text); }
.brand-sub { font-size: .68rem; color: var(--text-faint); letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.nav { display: flex; flex-direction: column; padding: .5rem .6rem; gap: 2px; overflow-y: auto; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 500; font-size: .89rem; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--brand-tint); color: var(--brand-600); font-weight: 600; }
.nav-ico { width: 1.4rem; display: inline-flex; align-items: center; justify-content: center; opacity: .85; }
.icon { flex: none; display: inline-block; vertical-align: middle; }
.sidebar-foot { padding: .85rem; border-top: 1px solid var(--border); }
.org-chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .75rem; }
.org-name { font-size: .82rem; font-weight: 700; }
.org-meta { font-size: .68rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-top: 2px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.75rem; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  position: sticky; top: 0; backdrop-filter: blur(10px); z-index: 20;
}
.topbar-title { font-weight: 700; font-size: 1.08rem; letter-spacing: -.02em; }
.topbar-right { display: flex; align-items: center; gap: .9rem; }
.user-badge { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.user-name { font-size: .85rem; font-weight: 600; }
.user-role { font-size: .68rem; color: var(--text-faint); }
.content { padding: 1.75rem; max-width: 1320px; width: 100%; }
.appfoot {
  margin-top: auto; padding: 1rem 1.75rem; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; color: var(--text-faint); font-size: .74rem; gap: 1rem; flex-wrap: wrap;
}

/* ---- Theme toggle ---- */
.theme-toggle {
  width: 41px; height: 41px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); cursor: pointer; display: grid; place-items: center;
  font-size: 1.2rem; transition: all .12s;
}
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); }

/* ---- Cards & grid ---- */
.grid { display: grid; gap: 1.1rem; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2,1fr); } .grid-3 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 720px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } .sidebar { display:none; } }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem 1.3rem; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; }
.card-head h3 { margin: 0; }
.card-sub { color: var(--text-faint); font-size: .78rem; }

/* ---- KPI stat ---- */
.stat { display: flex; flex-direction: column; gap: .25rem; position: relative; overflow: hidden; }
.stat-label { color: var(--text-dim); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-value { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-family: var(--display); }
.stat-sub { font-size: .78rem; color: var(--text-faint); }
.stat-value.ok { color: var(--ok); } .stat-value.warn { color: var(--warn); } .stat-value.bad { color: var(--bad); }
.stat-value.brand { color: var(--brand); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
thead th {
  text-align: left; padding: .7rem .9rem; color: var(--text-faint); font-weight: 700;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
tbody td { padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.t-right { text-align: right; } .t-center { text-align: center; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; padding: .16rem .55rem; border-radius: 20px; font-size: .71rem;
  font-weight: 600; text-transform: capitalize; letter-spacing: .01em; border: 1px solid transparent; white-space: nowrap;
}
.sev-critical { background: color-mix(in srgb, var(--crit) 14%, transparent); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 35%, transparent); }
.sev-high { background: color-mix(in srgb, var(--high) 16%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--high) 35%, transparent); }
.sev-medium { background: color-mix(in srgb, var(--med) 18%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--med) 35%, transparent); }
.sev-low { background: color-mix(in srgb, var(--low) 14%, transparent); color: var(--low); border-color: color-mix(in srgb, var(--low) 35%, transparent); }
.sev-info { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.outcome-prevented { background: var(--cell-prevented); color: var(--cell-prevented-fg); }
.outcome-detected { background: var(--cell-detected); color: var(--cell-detected-fg); }
.outcome-succeeded { background: var(--cell-succeeded); color: var(--cell-succeeded-fg); }
.outcome-refused { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }
.outcome-error, .outcome-skipped { background: var(--surface-2); color: var(--text-faint); }
.status-active, .status-completed, .status-closed, .status-effective, .status-reported, .status-connected { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.status-running, .status-scheduled, .status-in-remediation, .status-partial { background: var(--brand-tint-2); color: var(--brand-600); }
.status-draft, .status-paused, .status-not-tested, .status-queued, .status-unknown { background: var(--surface-2); color: var(--text-dim); border-color: var(--border); }
.status-blocked, .status-failed, .status-open, .status-ineffective, .status-suspended, .status-revoked, .status-retest-failed, .status-error { background: color-mix(in srgb, var(--crit) 15%, transparent); color: var(--crit); }
.status-triaged, .status-awaiting-retest, .status-pending-authorization, .status-risk-accepted { background: color-mix(in srgb, var(--med) 18%, transparent); color: var(--warn); }
.chip { display:inline-block; padding:.12rem .55rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; font-size:.73rem; color: var(--text-dim); font-weight: 500; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; padding: .52rem .95rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-weight: 600; font-size: .85rem; cursor: pointer; font-family: inherit;
  transition: all .12s; box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: 0 2px 8px rgba(236,0,140,.28); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-danger { background: color-mix(in srgb, var(--crit) 12%, transparent); border-color: color-mix(in srgb, var(--crit) 40%, transparent); color: var(--crit); box-shadow: none; }
.btn-danger:hover { background: color-mix(in srgb, var(--crit) 20%, transparent); color: var(--crit); border-color: var(--crit); }
.btn-ghost { background: transparent; box-shadow: none; border-color: var(--border); }
.btn-sm { padding: .34rem .7rem; font-size: .78rem; }
.inline { display: inline; }
.actions { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }

/* ---- Forms ---- */
.form { max-width: 780px; }
.field { margin-bottom: 1.05rem; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .35rem; color: var(--text-dim); }
.field .hint { font-size: .74rem; color: var(--text-faint); margin-top: .28rem; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], input[type=date],
input[type=number], select, textarea {
  width: 100%; padding: .58rem .75rem; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: .88rem; transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 96px; resize: vertical; font-family: var(--mono); font-size: .82rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.field-error { color: var(--crit); font-size: .76rem; margin-top: .28rem; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .86rem; }
.check input { width: auto; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; } .row > * { flex: 1; min-width: 160px; }
.checklist { display: grid; grid-template-columns: repeat(2,1fr); gap: .4rem; max-height: 320px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem; background: var(--surface-2); }

/* ---- Alerts ---- */
.alert { padding: .8rem 1.05rem; border-radius: var(--radius-sm); margin-bottom: 1.1rem; font-size: .86rem; border: 1px solid; display: flex; gap: .5rem; align-items: flex-start; }
.alert-info { background: var(--brand-tint); border-color: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--text); }
.alert-warn { background: color-mix(in srgb, var(--med) 12%, transparent); border-color: color-mix(in srgb, var(--med) 35%, transparent); color: var(--text); }
.alert-bad { background: color-mix(in srgb, var(--crit) 10%, transparent); border-color: color-mix(in srgb, var(--crit) 32%, transparent); color: var(--text); }
.alert-ok { background: color-mix(in srgb, var(--ok) 10%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--text); }

/* ---- Page header ---- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.4rem; gap: 1rem; flex-wrap: wrap; }
.page-head .sub { color: var(--text-dim); font-size: .88rem; margin-top: .25rem; max-width: 760px; }
.section { margin-bottom: 1.6rem; }
.muted { color: var(--text-faint); }
.dim { color: var(--text-dim); }
.empty { padding: 2.5rem; text-align: center; color: var(--text-faint); }

/* ---- Bars / meters ---- */
.mini-bar { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.mini-bar span { display: block; height: 100%; border-radius: 4px; }
.mini-bar .ok { background: var(--ok); } .mini-bar .warn { background: var(--warn); } .mini-bar .bad { background: var(--bad); }
.mini-bar .accent { background: var(--brand); }
.stack { display: flex; height: 9px; border-radius: 5px; overflow: hidden; background: var(--surface-2); min-width: 120px; }
.stack .s-prevented { background: var(--ok); } .stack .s-detected { background: var(--low); } .stack .s-succeeded { background: var(--crit); }

/* ---- Resilience ring ---- */
.ring-wrap { display: flex; align-items: center; gap: 1.3rem; }
.ring { --p: 0; width: 116px; height: 116px; border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--p)*1%), var(--surface-2) 0);
  display: grid; place-items: center; position: relative; }
.ring::after { content: ''; position: absolute; inset: 11px; border-radius: 50%; background: var(--surface); }
.ring-inner { position: relative; z-index: 1; text-align: center; }
.ring-inner .n { font-size: 1.8rem; font-weight: 700; letter-spacing: -.03em; font-family: var(--display); }
.ring-inner .l { font-size: .64rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* ---- Sparkline ---- */
.spark { display: flex; align-items: flex-end; gap: 4px; height: 60px; }
.spark .b { flex: 1; background: linear-gradient(180deg, var(--brand), var(--brand-tint-2)); border-radius: 3px 3px 0 0; min-height: 4px; transition: height .3s; }

/* ---- Heat tiles (dashboard tactic summary) ---- */
.heat { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.heat-cell { padding: .6rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.heat-cell .t { font-size: .7rem; color: var(--text-dim); text-transform: capitalize; font-weight: 600; }
.heat-cell .v { font-size: 1.1rem; font-weight: 800; }

/* ============================================================================
   ATT&CK MATRIX HEATMAP
   ============================================================================ */
.attack-wrap { overflow-x: auto; padding-bottom: 10px; }
.attack { display: flex; gap: 10px; min-width: max-content; }
.attack-col { min-width: 164px; flex: 0 0 164px; display: flex; flex-direction: column; }
.attack-col-head {
  font-size: .7rem; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: .02em;
  padding: .5rem .5rem; border-radius: var(--radius-xs); background: var(--surface-2); border: 1px solid var(--border);
  margin-bottom: 6px; text-align: center; position: sticky; top: 0;
}
.attack-col-head .c { display: block; font-weight: 600; color: var(--text-faint); font-size: .64rem; margin-top: 2px; text-transform: none; }
.tcell {
  display: block; padding: .45rem .55rem; border-radius: var(--radius-xs); margin-bottom: 5px;
  border: 1px solid var(--cell-none-bd); background: var(--cell-none); color: var(--cell-none-fg);
  font-size: .73rem; line-height: 1.28; transition: transform .1s, box-shadow .1s; cursor: default;
}
.tcell:hover { transform: translateY(-1px); box-shadow: var(--shadow); z-index: 2; position: relative; }
.tcell .tid { font-family: var(--mono); font-size: .64rem; opacity: .8; display: block; }
.tcell .tn { display: block; font-weight: 600; color: var(--text); }
.tcell.st-prevented { background: var(--cell-prevented); border-color: var(--cell-prevented-bd); }
.tcell.st-prevented .tn { color: var(--cell-prevented-fg); }
.tcell.st-detected { background: var(--cell-detected); border-color: var(--cell-detected-bd); }
.tcell.st-detected .tn { color: var(--cell-detected-fg); }
.tcell.st-succeeded { background: var(--cell-succeeded); border-color: var(--cell-succeeded-bd); }
.tcell.st-succeeded .tn { color: var(--cell-succeeded-fg); }
.tcell.st-not_tested { opacity: .72; }
.tcell.st-not_tested .tn { color: var(--text-faint); font-weight: 500; }
.legend { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: .78rem; align-items: center; color: var(--text-dim); }
.legend .sw { display: inline-block; width: 13px; height: 13px; border-radius: 4px; margin-right: 5px; vertical-align: middle; border: 1px solid var(--border-strong); }

/* ---- Misc ---- */
.kv { display: grid; grid-template-columns: 190px 1fr; gap: .45rem 1rem; font-size: .86rem; }
.kv dt { color: var(--text-faint); font-weight: 500; } .kv dd { margin: 0; }
.tag-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 1.3rem 0; }
.list-reset { list-style: none; padding: 0; margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.timeline li { padding: .3rem 0 .8rem 1.1rem; position: relative; font-size: .84rem; }
.timeline li::before { content:''; position:absolute; left:-5px; top:.55rem; width:8px; height:8px; border-radius:50%; background: var(--brand); }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }
.countdown.overdue { color: var(--crit); }
.countdown.soon { color: var(--warn); }

.g-recaptcha { margin: 1rem 0; }

/* ---- Login / public ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(1200px 500px at 50% -10%, var(--brand-tint), transparent), var(--bg); }
.login-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.2rem; box-shadow: var(--shadow-lg); }
.login-brand { text-align: center; margin-bottom: 1.6rem; }
.login-brand .m { height: 32px; margin: 0 auto .9rem; }
.login-brand h1 { font-size: 1.35rem; margin-top: .2rem; font-family: var(--display); }
.login-brand .s { color: var(--text-faint); font-size: .82rem; }
.login-product { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-bottom: .3rem; }
/* ---- RBAC matrix (Roles & Access) ---- */
.matrix { width: 100%; border-collapse: collapse; font-size: .84rem; }
.matrix th, .matrix td { padding: .5rem .7rem; border-bottom: 1px solid var(--border); }
.matrix thead th { position: sticky; top: 0; background: var(--surface); text-align: center; font-weight: 600;
  color: var(--text-dim); border-bottom: 2px solid var(--border-strong); white-space: nowrap; }
.matrix thead th:first-child { text-align: left; }
.matrix tbody tr:hover { background: var(--brand-tint); }
.matrix .matrix-group td { background: var(--bg); font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; font-size: .72rem; color: var(--text-faint); border-bottom: 1px solid var(--border-strong); }
.matrix .matrix-perm { white-space: nowrap; }
.matrix .matrix-res { color: var(--text); font-weight: 500; }
.matrix input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.chip.act-create { background: rgba(59,130,246,.14); color: #3b82f6; }
.chip.act-read   { background: var(--brand-tint); color: var(--text-dim); }
.chip.act-update { background: rgba(234,179,8,.16); color: #b7860b; }
.chip.act-delete { background: rgba(239,68,68,.14); color: var(--bad); }
.chip.act-approve, .chip.act-publish, .chip.act-decide, .chip.act-fulfill, .chip.act-import, .chip.act-push {
  background: rgba(16,185,129,.14); color: #0d9488; }

/* ---- Toggle switch ---- */
.switch { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; user-select: none; font-size: .88rem; }
.switch input { width: 40px; height: 22px; appearance: none; background: var(--border-strong); border-radius: 999px;
  position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch input:checked { background: var(--brand); }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked::after { transform: translateX(18px); }

/* ---- Posture bars (client portal) ---- */
.posture { display: flex; flex-direction: column; gap: .55rem; }
.posture-row { display: flex; align-items: center; gap: .6rem; }
.posture-row .lbl { width: 84px; }
.posture-row .val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---- Search / dropdown trigger buttons ---- */
kbd {
  display: inline-block; font-family: var(--mono); font-size: .68rem; padding: .05rem .35rem;
  border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-dim);
  margin-left: .2rem; line-height: 1.4;
}

/* ---- Notification bell + dropdown ---- */
.dropdown { position: relative; }
.bell-btn { position: relative; }
.bell-badge {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 999px; background: var(--crit); color: #fff; font-size: .62rem; font-weight: 700;
  display: grid; place-items: center; line-height: 1; border: 2px solid var(--surface);
}
.dropdown-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-width: 90vw;
  background: var(--elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 40; overflow: hidden;
}
.dropdown-head { display: flex; align-items: center; justify-content: space-between; padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
.dropdown-head strong { font-size: .85rem; }
.dropdown-list { max-height: 320px; overflow-y: auto; }
.dropdown-item { display: flex; flex-direction: column; gap: .15rem; padding: .65rem .9rem; border-bottom: 1px solid var(--border); color: var(--text); }
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-item-title { font-size: .82rem; font-weight: 600; }
.dropdown-item-time { font-size: .7rem; }
.dropdown-item.is-unread { background: var(--brand-tint); }
.dropdown-item.is-unread .dropdown-item-title::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); margin-right: .4rem; vertical-align: middle; }
.dropdown-empty { padding: 1.4rem; text-align: center; font-size: .82rem; }
.dropdown-foot { display: block; text-align: center; padding: .6rem; font-size: .78rem; font-weight: 600; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ---- Quick search (Ctrl+K) ---- */
.qs-overlay {
  position: fixed; inset: 0; background: rgba(14, 18, 24, .5); z-index: 100;
  align-items: flex-start; justify-content: center; padding: 12vh 1rem 1rem;
}
/* [hidden] must win when present — a bare `display:flex` above would out-rank the
   browser's own `[hidden]{display:none}` and the overlay could never be closed. */
.qs-overlay:not([hidden]) { display: flex; }
.qs-box { width: 100%; max-width: 560px; background: var(--elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
.qs-head { display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.qs-input { flex: 1; border: none; border-bottom: none; border-radius: 0; font-size: 1rem; padding: 1rem 1.2rem; }
.qs-input:focus { box-shadow: none; border-color: var(--border); }
.qs-close {
  flex: none; width: 34px; height: 34px; margin-right: .7rem; border-radius: 8px; border: none;
  background: var(--surface-2); color: var(--text-dim); cursor: pointer; font-size: 1rem; line-height: 1;
  display: grid; place-items: center;
}
.qs-close:hover { background: var(--brand-tint); color: var(--brand-600); }
.qs-results { max-height: 50vh; overflow-y: auto; }
.qs-item { display: flex; align-items: center; gap: .6rem; padding: .7rem 1.2rem; border-bottom: 1px solid var(--border); color: var(--text); }
.qs-item:last-child { border-bottom: none; }
.qs-item:hover { background: var(--surface-2); text-decoration: none; }
.qs-type { flex: none; font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--brand); background: var(--brand-tint); border-radius: 5px; padding: .15rem .4rem; }
.qs-label { flex: 1; font-size: .87rem; font-weight: 600; }
.qs-sub { font-size: .76rem; }
.qs-empty { padding: 1.5rem; text-align: center; color: var(--text-faint); font-size: .85rem; }
.qs-hint { padding: .55rem 1.2rem; border-top: 1px solid var(--border); font-size: .72rem; background: var(--surface-2); }

/* ---- Accordion (Training & Help) ---- */
.accordion { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.accordion-item + .accordion-item { border-top: 1px solid var(--border); }
.accordion-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .95rem 1.15rem; background: none; border: none; text-align: left; cursor: pointer;
  font-family: inherit; font-size: .92rem; font-weight: 600; color: var(--text);
}
.accordion-trigger:hover { background: var(--surface-2); }
.accordion-trigger .n { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-600); font-size: .89rem; font-weight: 700; margin-right: .6rem; flex: none; }
.accordion-trigger .chev { transition: transform .15s; color: var(--text-faint); flex: none; }
.accordion-trigger.is-open .chev { transform: rotate(90deg); }
.accordion-body { padding: 0 1.15rem 1.1rem 2.75rem; font-size: .85rem; color: var(--text-dim); }
.accordion-body p { margin: 0 0 .6rem; }

/* ---- Findings board (drag-and-drop) ---- */
.board-wrap { overflow-x: auto; padding-bottom: 10px; }
.board { display: flex; gap: 12px; min-width: max-content; align-items: flex-start; }
.board-col { width: 240px; flex: 0 0 240px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem; transition: background .12s, border-color .12s; }
.board-col.is-dragover { background: var(--brand-tint); border-color: var(--brand); }
.board-col-head { display: flex; align-items: center; justify-content: space-between; padding: .3rem .4rem .7rem; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-dim); }
.board-col-count { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .05rem .5rem; font-size: .7rem; color: var(--text-faint); }
.board-col-body { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.board-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .7rem .8rem; box-shadow: var(--shadow-sm); cursor: grab; display: flex; flex-direction: column;
}
.board-card[draggable="true"]:active { cursor: grabbing; }
.board-card.is-dragging { opacity: .4; }
.board-card-title { font-size: .82rem; font-weight: 600; color: var(--text); margin: .1rem 0 .3rem; }
.board-card-title:hover { color: var(--brand); text-decoration: none; }
.board-card-meta { font-size: .68rem; color: var(--text-faint); }

/* ---- Flip cards (front summary / back detail, hover or click) ---- */
.flip-card { perspective: 1200px; }
.flip-card-inner {
  position: relative; width: 100%; height: 100%; min-height: inherit;
  transition: transform .5s cubic-bezier(.4,.2,.2,1); transform-style: preserve-3d;
}
.flip-card:hover .flip-card-inner, .flip-card.is-flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-card-front, .flip-card-back {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 14px; border: 1px solid var(--border); padding: 1.3rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.flip-card-front { background: var(--surface); }
.flip-card-back { background: var(--brand); border-color: var(--brand); color: #fff; transform: rotateY(180deg); }
.flip-card-back h4, .flip-card-back p, .flip-card-back b { color: #fff; }
.flip-card-hint { position: absolute; bottom: .6rem; right: .7rem; font-size: .64rem; color: var(--text-faint); }

/* ---- Onboarding checklist (dashboard) ---- */
.onboard-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
@media (max-width: 900px) { .onboard-list { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .onboard-list { grid-template-columns: 1fr; } }
.onboard-item {
  display: flex; align-items: flex-start; gap: .6rem; padding: .75rem .85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.onboard-item:hover { border-color: var(--brand); text-decoration: none; }
.onboard-item.is-done { background: color-mix(in srgb, var(--ok) 8%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.onboard-mark {
  flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: .74rem; font-weight: 700; border: 1.5px solid var(--border-strong); color: transparent;
}
.onboard-item.is-done .onboard-mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.onboard-text { display: flex; flex-direction: column; gap: .1rem; font-size: .83rem; }
.onboard-text .muted { font-size: .74rem; }
.onboard-item.is-done .onboard-text b { text-decoration: line-through; text-decoration-color: var(--text-faint); }

/* ---- Tabs ---- */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); }
.tabs .tab { padding: .5rem .9rem; text-transform: capitalize; color: var(--text-dim); text-decoration: none;
  border-bottom: 2px solid transparent; font-size: .88rem; font-weight: 500; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
