/* AEGIS — SOC Playbook Console */
:root {
  --bg: #0b1120;
  --panel: #121b2e;
  --panel-2: #0e1626;
  --line: #22304d;
  --line-soft: #1a2540;
  --text: #e8eefa;
  --muted: #92a3c4;
  --faint: #5d6f93;
  --accent: #4c8dff;
  --accent-soft: rgba(76, 141, 255, 0.14);
  --crit: #ff5c5c;
  --high: #ff9f43;
  --med: #ffd166;
  --low: #4ade80;
  --done: #34d399;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
  --sans: -apple-system, "Segoe UI", "Inter", Roboto, "Helvetica Neue", sans-serif;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--panel-2);
  border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.main { flex: 1; padding: 34px 42px 80px; max-width: 1240px; }

.brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px 18px; border-bottom: 1px solid var(--line-soft); }
.brand-shield {
  width: 34px; height: 38px; flex-shrink: 0;
  background: linear-gradient(160deg, var(--accent), #2b5cd9);
  clip-path: polygon(50% 0, 100% 18%, 100% 60%, 50% 100%, 0 60%, 0 18%);
}
.brand-name { font-weight: 800; letter-spacing: 0.14em; font-size: 15px; }
.brand-tag { color: var(--faint); font-size: 11px; letter-spacing: 0.04em; }

.nav { display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; }
.nav a {
  color: var(--muted); padding: 9px 12px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500;
}
.nav a:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav a.active { color: var(--text); background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 16px 20px; color: var(--faint); font-size: 11.5px; border-top: 1px solid var(--line-soft); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.dot-ok { background: var(--done); }

/* ---------- typography blocks ---------- */
.page-head { margin-bottom: 26px; }
.eyebrow { color: var(--accent); font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; margin-bottom: 6px; }
h1 { font-size: 24px; font-weight: 750; letter-spacing: -0.01em; }
.page-sub { color: var(--muted); margin-top: 6px; max-width: 70ch; }
h2.section { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 30px 0 12px; font-weight: 650; }

/* ---------- cards / panels ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 18px 20px;
}
.grid { display: grid; gap: 14px; }
.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-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .sidebar { display: none; }
  .main { padding: 20px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.stat .stat-num { font-family: var(--mono); font-size: 30px; font-weight: 700; }
.stat .stat-label { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- severity ---------- */
.sev { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px; border: 1px solid; }
.sev-critical { color: var(--crit); border-color: rgba(255,92,92,.45); background: rgba(255,92,92,.08); }
.sev-high { color: var(--high); border-color: rgba(255,159,67,.45); background: rgba(255,159,67,.08); }
.sev-medium { color: var(--med); border-color: rgba(255,209,102,.4); background: rgba(255,209,102,.07); }
.sev-low { color: var(--low); border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.07); }

.chip { font-family: var(--mono); font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 2px 7px; }

/* ---------- playbook cards ---------- */
.pb-card { display: flex; flex-direction: column; gap: 10px; transition: border-color .15s; }
.pb-card:hover { border-color: var(--accent); }
.pb-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.pb-name { font-weight: 650; font-size: 15px; }
.pb-cat { color: var(--faint); font-size: 11.5px; font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.pb-desc { color: var(--muted); font-size: 13px; flex: 1; }
.pb-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.pb-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.pb-steps { color: var(--faint); font-size: 12px; font-family: var(--mono); }

/* ---------- buttons / inputs ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #071021; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--crit); border-color: rgba(255,92,92,.4); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
input[type=text], input[type=password], textarea, select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; font-family: inherit;
}
textarea { resize: vertical; min-height: 60px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
label.fld { display: block; color: var(--muted); font-size: 12px; margin: 12px 0 5px; letter-spacing: .04em; }

/* ---------- tables / lists ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:hover td { background: rgba(255,255,255,0.02); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.status-pill { font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .08em; padding: 3px 8px; border-radius: 20px; }
.status-open { color: var(--accent); background: var(--accent-soft); }
.status-closed { color: var(--done); background: rgba(52,211,153,.1); }

/* progress bar */
.prog { height: 5px; background: var(--line-soft); border-radius: 3px; overflow: hidden; min-width: 90px; }
.prog > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .25s; }
.prog.complete > span { background: var(--done); }

/* ---------- investigation runner ---------- */
.inv-layout { display: grid; grid-template-columns: 170px 1fr 280px; gap: 26px; align-items: start; }
@media (max-width: 1150px) { .inv-layout { grid-template-columns: 1fr; } .phase-rail { display: none; } }

.phase-rail { position: sticky; top: 30px; }
.rail-item { position: relative; padding: 0 0 26px 22px; cursor: pointer; }
.rail-item::before {
  content: ""; position: absolute; left: 5px; top: 5px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--faint);
}
.rail-item::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 2px; width: 1px; background: var(--line); }
.rail-item:last-child::after { display: none; }
.rail-item.done::before { background: var(--done); border-color: var(--done); }
.rail-item.partial::before { border-color: var(--accent); background: var(--accent-soft); }
.rail-name { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.rail-item.done .rail-name { color: var(--done); }
.rail-count { font-family: var(--mono); font-size: 11px; color: var(--faint); }

.phase-block { margin-bottom: 26px; }
.phase-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.phase-title h3 { font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--text); }
.phase-line { flex: 1; height: 1px; background: var(--line-soft); }

.step {
  border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--panel);
  padding: 14px 16px; margin-bottom: 10px; transition: border-color .15s, opacity .15s;
}
.step.checked { border-color: rgba(52,211,153,.35); }
.step.checked .step-title { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(146,163,196,.5); }
.step.na { opacity: .55; }
.step-row { display: flex; gap: 12px; align-items: flex-start; }
.step-check {
  appearance: none; width: 19px; height: 19px; flex-shrink: 0; margin-top: 2px; cursor: pointer;
  border: 1.5px solid var(--faint); border-radius: 5px; background: var(--panel-2); position: relative;
}
.step-check:checked { background: var(--done); border-color: var(--done); }
.step-check:checked::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: #06251a; font-size: 13px; font-weight: 800; }
.step-check:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.step-body { flex: 1; }
.step-title { font-weight: 600; font-size: 14px; cursor: pointer; }
.step-detail { color: var(--muted); font-size: 13px; margin-top: 3px; }
.step-tools { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.step-toggle { background: none; border: none; color: var(--faint); font-size: 12px; cursor: pointer; padding: 2px 4px; }
.step-toggle:hover { color: var(--accent); }
.step-extra { margin-top: 10px; display: grid; gap: 8px; }
.step-extra input, .step-extra textarea { font-size: 12.5px; }
.step-ts { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.na-label { display: flex; gap: 6px; align-items: center; color: var(--faint); font-size: 12px; cursor: pointer; }
.na-label input { accent-color: var(--faint); }

/* context panel */
.ctx { position: sticky; top: 30px; display: grid; gap: 14px; }
.ctx .card { padding: 14px 16px; }
.ctx h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 9px; }
.ctx ul { list-style: none; }
.ctx li { font-size: 12.5px; color: var(--muted); padding: 4px 0 4px 14px; position: relative; }
.ctx li::before { content: "›"; position: absolute; left: 0; color: var(--accent); }
.ctx-esc li::before { content: "!"; color: var(--crit); font-weight: 800; }

/* inv header */
.inv-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.inv-fields { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 10px; margin: 14px 0 22px; }
@media (max-width: 900px) { .inv-fields { grid-template-columns: 1fr 1fr; } }
.inv-progress-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.inv-progress-wrap .prog { flex: 1; height: 7px; }
.prog-label { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

/* AI + enrich panel */
.tool-panel textarea { min-height: 46px; }
.ai-answer { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 12px; font-size: 12.5px; color: var(--muted); white-space: pre-wrap; max-height: 320px; overflow: auto; margin-top: 8px; }

/* report */
.report-md {
  background: #ffffff; color: #16202e; border-radius: var(--radius);
  padding: 44px 52px; font-size: 14px; line-height: 1.6; max-width: 880px;
}
.report-md h1 { font-size: 21px; border-bottom: 3px solid #16202e; padding-bottom: 10px; margin-bottom: 18px; letter-spacing: .02em; }
.report-md h2 { font-size: 15px; margin: 24px 0 10px; color: #0d1622; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid #d8dee8; padding-bottom: 5px;}
.report-md h3 { font-size: 13.5px; margin: 16px 0 6px; color: #2b3a52; }
.report-md table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13px; }
.report-md th, .report-md td { border: 1px solid #cfd7e3; padding: 7px 10px; text-align: left; }
.report-md th { background: #eef2f8; }
.report-md ul { margin: 8px 0 8px 22px; }
.report-md li { margin: 4px 0; }
.report-md code { background: #eef2f8; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.report-md em { color: #5a6b85; }
.report-md strong { color: #0d1622; }
.report-actions { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }

@media print {
  .sidebar, .report-actions, .toast, .page-head .btn { display: none !important; }
  body, .main { background: #fff; padding: 0; }
  .report-md { padding: 0; border-radius: 0; }
}

/* toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 50;
  background: var(--panel); border: 1px solid var(--accent); color: var(--text);
  border-radius: 8px; padding: 11px 16px; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.err { border-color: var(--crit); }

/* login */
.login-gate { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; }
.login-card { width: 320px; display: grid; gap: 12px; text-align: center; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 12px; padding: 34px 28px; }
.brand-mark { font-weight: 800; letter-spacing: .2em; font-size: 20px; color: var(--accent); }
.login-sub { color: var(--faint); font-size: 12.5px; margin-bottom: 6px; }
.login-error { color: var(--crit); font-size: 12.5px; min-height: 16px; }

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