/* ============================================================================
   CATS Design System — tokens + base components.
   Canonical reference: docs/DESIGN_SYSTEM.md
   ============================================================================ */

:root {
  /* surfaces */
  --bg: #0a0e1a;
  --bg-2: #0f1424;
  --bg-3: #131a2e;
  --line: #1e2740;
  --line-2: #2a3553;

  /* ink */
  --ink: #e7ecf5;
  --ink-2: #aab3c6;
  --ink-3: #6b7591;
  --ink-4: #44506a;

  /* semantic */
  --amber: #f5a524;
  --amber-2: #fb923c;
  --amber-soft: #f59e0b22;
  --cyan: #38bdf8;
  --cyan-2: #67e8f9;
  --cyan-soft: #38bdf81f;
  --green: #4ade80;
  --green-soft: #22c55e1f;
  --red: #ef4444;
  --red-soft: #ef44441f;
  --violet: #a78bfa;

  --grid: rgba(255, 255, 255, 0.025);

  /* spacing rhythm */
  --pad-page-y: 40px;
  --pad-page-x: 48px;

  /* sidebar */
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.005em;
  line-height: 1.5;
  min-height: 100vh;
}

/* atmospheric grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
  pointer-events: none;
  z-index: 1;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, #1a2240 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 100%, #1f1a30 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}

/* ============================================================================
   App shell — sidebar + main
   ============================================================================ */

.app-shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  display: flex;
  flex-direction: column;
  padding: 24px 0 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-3);
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11.5px;
  font-weight: 600;
}
.sidebar .brand-dot {
  width: 8px; height: 8px;
  background: var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--amber);
  animation: pulse 2.4s ease-in-out infinite;
  flex: 0 0 auto;
}
.sidebar .brand-name { line-height: 1.1; }
.sidebar .brand-sub {
  display: block;
  font-size: 9.5px;
  color: var(--ink-4);
  letter-spacing: 0.2em;
  margin-top: 4px;
  font-weight: 400;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.sidebar .nav-group {
  padding: 18px 0 6px;
  display: flex;
  flex-direction: column;
}
.sidebar .nav-group + .nav-group { border-top: 1px solid var(--line); }
.sidebar .nav-group .group-label {
  padding: 0 20px 8px;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.sidebar nav.nav-list { display: flex; flex-direction: column; }
.sidebar nav.nav-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  color: var(--ink-3);
  text-decoration: none;
  border-left: 2px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11.5px;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}
.sidebar nav.nav-list a:hover {
  color: var(--ink);
  background: rgba(255,255,255,0.02);
}
.sidebar nav.nav-list a.active {
  color: var(--amber);
  border-left-color: var(--amber);
  background: linear-gradient(90deg, var(--amber-soft) 0%, transparent 80%);
}
.sidebar nav.nav-list a .nav-ico {
  width: 14px;
  display: inline-flex;
  justify-content: center;
  color: inherit;
  opacity: 0.7;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--ink-3);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.sidebar-footer .user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-footer .user-row .user {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sidebar-footer .user-row .user .role {
  color: var(--amber);
  font-size: 9.5px;
  letter-spacing: 0.22em;
}
.sidebar-footer .user-row .user .email {
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-footer .signout {
  background: none;
  border: 1px solid var(--line-2);
  color: var(--ink-3);
  cursor: pointer;
  font: inherit;
  padding: 4px 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color 160ms ease, border-color 160ms ease;
}
.sidebar-footer .signout:hover { color: var(--ink); border-color: var(--ink-3); }
.sidebar-footer .sysmeta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 9.5px;
  color: var(--ink-4);
}
.sidebar-footer .sysmeta .row { display: flex; justify-content: space-between; }
.sidebar-footer .sysmeta .k { color: var(--ink-4); }
.sidebar-footer .sysmeta .v { color: var(--ink-2); letter-spacing: 0; font-family: 'JetBrains Mono', monospace; }
.sidebar-footer .sysmeta .v.green { color: var(--green); }
.sidebar-footer .sysmeta .v.red { color: var(--red); }
.sidebar-footer .sysmeta .v.amber { color: var(--amber); }

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

.main-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px var(--pad-page-x);
  border-bottom: 1px solid var(--line);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-4);
}
.main-top .crumbs {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--ink-3);
}
.main-top .crumbs .sep { color: var(--line-2); }
.main-top .crumbs .crumb.now { color: var(--ink); }
.main-top .sysline { display: flex; gap: 18px; }
.main-top .sysline .k { color: var(--ink-4); }
.main-top .sysline .v { color: var(--ink-2); letter-spacing: 0.14em; }

.page {
  flex: 1 1 auto;
  padding: var(--pad-page-y) var(--pad-page-x) 56px;
  min-width: 0;
}

/* ============================================================================
   Typography
   ============================================================================ */

.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--amber);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.eyebrow::before {
  content: '';
  width: 22px; height: 1px;
  background: var(--amber);
}
.eyebrow.cy { color: var(--cyan); }
.eyebrow.cy::before { background: var(--cyan); }

h1.title, h2.title {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.08;
  color: var(--ink);
}
h1.title { font-size: 42px; }
h2.title { font-size: 28px; }
h3.title {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 18px;
  color: var(--ink);
}

.subtitle {
  font-size: 15px;
  color: var(--ink-2);
  max-width: 760px;
  margin-top: 8px;
  line-height: 1.55;
  font-weight: 300;
}

.mono { font-family: 'JetBrains Mono', monospace; }

/* ============================================================================
   Stat strip / KPI row
   ============================================================================ */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat-strip .stat {
  padding: 18px 24px;
  border-right: 1px solid var(--line);
  position: relative;
}
.stat-strip .stat:last-child { border-right: 0; }
.stat-strip .stat .label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.stat-strip .stat .num {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 36px;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.stat-strip .stat .num .unit {
  font-size: 13px;
  letter-spacing: 0;
  color: var(--ink-3);
  font-weight: 400;
}
.stat-strip .stat .num.amber { color: var(--amber); }
.stat-strip .stat .num.cyan { color: var(--cyan); }
.stat-strip .stat .num.red { color: var(--red); }
.stat-strip .stat .num.green { color: var(--green); }
.stat-strip .stat .delta {
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-3);
}
.stat-strip .stat .delta.up { color: var(--red); }
.stat-strip .stat .delta.down { color: var(--green); }

/* ============================================================================
   Panels / cards
   ============================================================================ */

.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-2) 0%, rgba(15,20,36,0.4) 100%);
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--amber);
}
.panel.cy::before { background: var(--cyan); }
.panel.vi::before { background: var(--violet); }
.panel.mix::before { background: linear-gradient(90deg, var(--amber), var(--cyan)); }

.panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.panel > header .title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink-3);
}
.panel > header .meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-4);
}
.panel > .body { padding: 18px 22px 20px; }
.panel > .body.flush { padding: 0; }

/* ============================================================================
   Tables (operator)
   ============================================================================ */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tbl th {
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--bg-3);
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-2);
}
.tbl td {
  padding: 12px 18px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td {
  background: var(--amber-soft);
}
.tbl td.mono,
.tbl th.mono,
.tbl .mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.tbl td.num { font-family: 'JetBrains Mono', monospace; text-align: right; }
.tbl td.muted { color: var(--ink-3); }

/* ============================================================================
   Status dots / pills / tags
   ============================================================================ */

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-4);
  vertical-align: middle;
  margin-right: 8px;
}
.dot.amber { background: var(--amber); box-shadow: 0 0 10px var(--amber-soft); }
.dot.amber.pulse { animation: pulse 2.4s ease-in-out infinite; }
.dot.cyan { background: var(--cyan); box-shadow: 0 0 10px var(--cyan-soft); }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); box-shadow: 0 0 10px var(--red-soft); }
.dot.violet { background: var(--violet); }

.pill {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 3px 9px;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  border-radius: 0;
}
.pill.amber { color: var(--bg); background: var(--amber); border-color: var(--amber); font-weight: 600; }
.pill.cyan  { color: var(--bg); background: var(--cyan); border-color: var(--cyan); font-weight: 600; }
.pill.red   { color: var(--red); border-color: var(--red); }
.pill.green { color: var(--green); border-color: var(--green); }
.pill.outline-amber { color: var(--amber); border-color: var(--amber); }

.sev {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: 2px 8px;
  border: 1px solid currentColor;
}
.sev.info     { color: var(--ink-3); }
.sev.low      { color: var(--cyan); }
.sev.medium   { color: var(--amber); }
.sev.high     { color: var(--amber-2); }
.sev.critical { color: var(--red); background: var(--red-soft); font-weight: 600; }

/* ============================================================================
   Buttons + links
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 10px 18px;
  background: var(--bg-2);
  color: var(--amber);
  border: 1px solid var(--amber);
  cursor: pointer;
  text-decoration: none;
  transition: background 180ms ease, color 180ms ease;
}
.btn:hover { background: var(--amber); color: var(--bg); }
.btn.ghost { color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--bg-3); border-color: var(--ink-3); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red); color: var(--bg); }
.btn .ch { color: inherit; opacity: 0.8; }

a.nav-link {
  font-family: 'JetBrains Mono', monospace;
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px dotted var(--cyan-soft);
  padding-bottom: 1px;
}
a.nav-link:hover { color: var(--cyan-2); border-bottom-color: var(--cyan-2); }
a.nav-link::after { content: ' →'; color: var(--ink-3); }

/* ============================================================================
   Grid helpers
   ============================================================================ */

.grid { display: grid; gap: 24px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-12-7-5 { grid-template-columns: 7fr 5fr; }
.cols-12-8-4 { grid-template-columns: 8fr 4fr; }

.stack { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }

.spacer-32 { height: 32px; }
.spacer-48 { height: 48px; }

/* divider line under a section header */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 18px;
}
.section-head .actions { display: flex; gap: 10px; }

/* ============================================================================
   Quote / callout list
   ============================================================================ */

.q-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.q-list li {
  padding: 12px 16px;
  border-left: 2px solid var(--cyan);
  background: linear-gradient(90deg, var(--cyan-soft) 0%, transparent 60%);
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.5;
  font-weight: 300;
}
.q-list li .q-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 4px;
  display: block;
}
.q-list li strong { color: var(--ink); font-weight: 500; }

/* ============================================================================
   Coverage matrix (heatmap-style)
   ============================================================================ */

.coverage {
  display: grid;
  grid-template-columns: 140px repeat(6, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.coverage > div {
  background: var(--bg-2);
  padding: 10px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.coverage .rowlabel {
  justify-content: flex-start;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 10.5px;
  background: var(--bg-3);
}
.coverage .colhead {
  background: var(--bg-3);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 10.5px;
}
.cell { color: var(--ink); }
.cell.t-0 { color: var(--ink-4); background: var(--bg-2); }
.cell.t-1 { color: var(--ink-2); }
.cell.t-2 { color: var(--amber); background: rgba(245,165,36,0.06); }
.cell.t-3 { color: var(--amber); background: rgba(245,165,36,0.14); }
.cell.t-4 { color: var(--red); background: rgba(239,68,68,0.18); font-weight: 600; }

/* ============================================================================
   Event log (live stream)
   ============================================================================ */

.eventlog {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  display: flex;
  flex-direction: column;
}
.eventlog .row {
  display: grid;
  grid-template-columns: 88px 100px 1fr 90px;
  align-items: center;
  gap: 16px;
  padding: 9px 22px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
}
.eventlog .row:last-child { border-bottom: 0; }
.eventlog .row.fresh {
  background: var(--amber-soft);
  border-bottom-color: var(--amber);
  animation: fadefresh 1.5s ease-out forwards;
}
@keyframes fadefresh {
  to { background: transparent; border-bottom-color: var(--line); }
}
.eventlog .ts { color: var(--ink-4); }
.eventlog .kind { color: var(--cyan); text-transform: uppercase; letter-spacing: 0.14em; font-size: 10.5px; }
.eventlog .kind.attack { color: var(--amber); }
.eventlog .kind.verdict.pass { color: var(--red); }      /* attack passed = defense failed */
.eventlog .kind.verdict.fail { color: var(--green); }    /* attack failed = defense held */
.eventlog .body { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eventlog .id { color: var(--ink-3); text-align: right; }

/* ============================================================================
   Inputs
   ============================================================================ */

label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
label.field .l {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-3);
}
input[type="text"],
input[type="url"],
input[type="search"],
select,
textarea {
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  color: var(--ink);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 0;
  outline: none;
  transition: border-color 160ms ease;
}
input.mono { font-family: 'JetBrains Mono', monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan-soft);
}

/* ============================================================================
   Empty / no-data
   ============================================================================ */

.empty {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 28px 22px;
  text-align: center;
  border: 1px dashed var(--line-2);
  background: var(--bg-2);
}
.empty .hint {
  display: block;
  color: var(--ink-4);
  margin-top: 8px;
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: 12px;
}

/* ============================================================================
   Responsive guardrails
   ============================================================================ */

@media (max-width: 1280px) {
  :root { --pad-page-x: 32px; --sidebar-w: 220px; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .stat-strip .stat:nth-child(2) { border-right: 0; }
  .cols-12-7-5, .cols-12-8-4 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --pad-page-x: 20px; --pad-page-y: 28px; --sidebar-w: 72px; }
  .app-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .sidebar .brand-name,
  .sidebar .brand-sub,
  .sidebar .nav-group .group-label,
  .sidebar nav.nav-list a span:not(.nav-ico),
  .sidebar-footer .user-row .user,
  .sidebar-footer .sysmeta { display: none; }
  .sidebar .brand { justify-content: center; padding: 0 0 16px; }
  .sidebar nav.nav-list a { justify-content: center; padding: 12px 0; }
  .sidebar-footer { align-items: center; padding: 12px 0 0; }
  .sidebar-footer .signout { padding: 4px 6px; font-size: 9px; }
  .stat-strip { grid-template-columns: 1fr; }
  .stat-strip .stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .stat-strip .stat:last-child { border-bottom: 0; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .coverage { grid-template-columns: 100px repeat(3, 1fr); }
  .main-top { padding: 14px 20px; flex-wrap: wrap; gap: 12px; }
  .main-top .sysline { font-size: 9.5px; gap: 12px; }
}
