/* ============================================================
   DPSIEM console: frame layout and SIEM components.
   Loads after operator.css. It adds to Operator and leaves the
   Operator primitives (panel, btn, tag, tbl, callout) untouched.
   ============================================================ */

:root {
  /* Severity is an ordered status scale. It always ships with a text
     label, and critical is the only one drawn as a solid fill.
     These four steps were run through the dataviz palette validator on
     the panel surface of each theme: neighbouring steps stay apart for
     normal vision (delta E 15.9 dark, 17.1 light) and for the common
     colour-vision deficiencies (12.8 dark, 11.2 light). Re-run it before
     changing any of them. */
  --sev-crit: #DD4A5E;
  --sev-high: #F08C3C;
  --sev-med:  #F6CE52;
  --sev-low:  #6FB1E8;
  --sev-info: #94A2AE;
  --rail-w: 200px;
}
[data-theme="light"] {
  --sev-crit: #B0202C;
  --sev-high: #DC7622;
  --sev-med:  #866200;
  --sev-low:  #2F74B5;
  --sev-info: #51606C;
}

html, body { height: 100%; }
body { overflow: hidden; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { .dot.pulse { animation: none; } }
a.btn, a.btn:hover { text-decoration: none; }

/* ---- App frame: bar on top, rail on the left, status line below ---- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: 40px minmax(0, 1fr) 22px;
  height: 100vh;
}
.app > .appbar, .app > .statusbar { grid-column: 1 / -1; }
.appbar a.brand, .appbar a.brand:hover { text-decoration: none; }
.appbar .search { width: 340px; }
.appbar .search .kbd { position: absolute; right: 5px; }
.appbar .live { display: inline-flex; align-items: center; gap: 8px; font: 500 var(--t-xs) var(--ff-mono); color: var(--teal); }
.appbar .who { display: inline-flex; align-items: center; gap: 8px; font-size: var(--t-sm); color: var(--fg-1); }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--bg-4); color: var(--fg-0); font: 600 10px/22px var(--ff-mono); text-align: center; flex: none; }
.statusbar .mock { color: var(--amber); }

.rail { background: var(--bg-1); border-right: 1px solid var(--line-1); padding: 6px 0 12px; overflow: auto; }
.rail-group { padding: 14px 14px 6px; font: 500 var(--t-xxs)/1 var(--ff-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-4); }
.rail-link {
  display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 14px 0 12px;
  color: var(--fg-2); font-size: var(--t-md); text-decoration: none; border-left: 2px solid transparent;
}
.rail-link:hover { background: var(--bg-2); color: var(--fg-0); text-decoration: none; }
.rail-link.active { background: var(--bg-2); color: var(--fg-0); border-left-color: var(--amber); }
.rail-link.active .gly { color: var(--amber); }
.rail-link .meta { margin-left: auto; font: 500 var(--t-xs)/1 var(--ff-mono); color: var(--fg-3); }
.rail-link .meta.hot { color: var(--sev-crit); }
.rail-link .meta.warn { color: var(--sev-med); }

.main { overflow: auto; padding: 20px 24px 40px; }
.main > * + * { margin-top: 12px; }

/* ---- Page furniture ---- */
.page-head { display: flex; align-items: flex-end; gap: 8px; }
.page-head h1 { margin: 0; font-size: var(--t-2xl); font-weight: 600; letter-spacing: -0.015em; color: var(--fg-0); line-height: 1.2; }
.page-head p { margin: 3px 0 0; color: var(--fg-2); font-size: var(--t-md); }
.grid { display: grid; gap: 12px; align-items: start; }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-1 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel { overflow: hidden; }
.panel-title { white-space: nowrap; flex: none; }
.panel-header .hint { color: var(--fg-3); font-size: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.panel-header .legend { flex: none; }
.panel-body { padding: 12px 14px; }
.tbl a { color: var(--fg-0); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .clip { max-width: 0; width: 46%; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 56px 24px; text-align: center; color: var(--fg-2); }
.empty b { display: block; color: var(--fg-0); font-size: var(--t-lg); font-weight: 600; margin-bottom: 4px; }

/* ---- Severity ---- */
.sev {
  --c: var(--sev-info);
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: var(--r-1);
  font: 600 var(--t-xs)/1 var(--ff-mono); letter-spacing: 0.04em; white-space: nowrap;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 42%, transparent);
}
.sev.crit { --c: var(--sev-crit); background: var(--c); border-color: transparent; color: #0B0F13; }
.sev.high { --c: var(--sev-high); }
.sev.med  { --c: var(--sev-med); }
.sev.low  { --c: var(--sev-low); }
/* On white, the mark colours are too light to read as small text, so the
   label ink is the same hue taken darker. */
[data-theme="light"] .sev { color: color-mix(in srgb, var(--c) 66%, #000); }
[data-theme="light"] .sev.crit { color: #fff; }

/* ---- "Needs you now" banner ---- */
.now-banner { display: flex; align-items: center; gap: 14px; padding: 10px 14px; }
.now-banner.callout { border-left-color: var(--sev-crit); }
.now-banner .ttl { margin: 0 0 1px; }

/* ---- Stat strip: one panel, six readings ---- */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stat { padding: 12px 14px 13px; border-right: 1px solid var(--line-1); min-width: 0; }
.stat:last-child { border-right: none; }
.stat-k { font-size: var(--t-sm); color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-v { margin-top: 4px; font-size: var(--t-2xl); font-weight: 600; letter-spacing: -0.015em; color: var(--fg-0); line-height: 1.15; }
.stat-v small { font-size: var(--t-md); font-weight: 400; color: var(--fg-2); letter-spacing: 0; }
.stat-d { margin-top: 5px; font-size: var(--t-sm); color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-d .good { color: var(--teal); }
.stat .bar { margin-top: 9px; }

/* ---- Fleet tape: one lane per tenant, 96 fifteen-minute windows ---- */
.tape-body { position: relative; padding: 12px 14px 8px; }
.tape-row {
  display: grid; grid-template-columns: 200px minmax(0, 1fr) 150px; align-items: center; gap: 12px;
  height: 22px; color: var(--fg-1); text-decoration: none; border-radius: var(--r-1);
}
a.tape-row:hover { background: var(--bg-2); text-decoration: none; }
a.tape-row:hover .tape-name { color: var(--fg-0); }
.tape-row.vol { height: 64px; margin-bottom: 8px; }
.tape-name { display: flex; align-items: baseline; gap: 8px; padding-left: 4px; font-size: var(--t-sm); white-space: nowrap; overflow: hidden; }
.tape-name span { overflow: hidden; text-overflow: ellipsis; }
.tape-name small { font: 400 var(--t-xxs) var(--ff-mono); color: var(--fg-3); flex: none; }
.tape-row.vol .tape-name { align-self: end; flex-direction: column; gap: 1px; color: var(--fg-2); }
.tape-row.vol .tape-name b { font-size: var(--t-xl); font-weight: 600; color: var(--fg-0); }
.strip { position: relative; display: grid; grid-template-columns: repeat(96, minmax(0, 1fr)); gap: 1px; height: 14px; }
.strip i { display: block; height: 100%; background: var(--bg-3); border-radius: 1px; }
.tape-row.vol .strip { height: 64px; grid-template-rows: 64px; align-items: end; }
.tape-row.vol .strip i { background: var(--fg-4); border-radius: 1px 1px 0 0; }
.tape-row.vol .strip i.over { background: var(--sev-med); }
.strip .inc { --c: var(--sev-info); position: absolute; top: -3px; bottom: -3px; border: 1.5px solid var(--c); border-radius: var(--r-2); pointer-events: none; }
.strip .inc.crit { --c: var(--sev-crit); }
.strip .inc.high { --c: var(--sev-high); }
.strip .inc.med  { --c: var(--sev-med); }
.tape-stat { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-right: 4px; font: 400 var(--t-xs) var(--ff-mono); color: var(--fg-2); white-space: nowrap; }
.tape-stat .quiet { color: var(--fg-4); }
.tape-row.vol .tape-stat { align-self: end; }
.tape-axis { display: grid; grid-template-columns: 200px minmax(0, 1fr) 150px; gap: 12px; margin-top: 8px; }
.tape-axis .ticks { position: relative; height: 18px; border-top: 1px solid var(--line-2); }
.tape-axis .ticks span { position: absolute; top: 4px; transform: translateX(-50%); font: 400 var(--t-xxs) var(--ff-mono); color: var(--fg-3); white-space: nowrap; }
.tape-axis .ticks span.first { transform: none; }
.tape-axis .ticks span.nowtick { transform: translateX(-100%); color: var(--amber); }
.tape-cross { position: absolute; top: 12px; bottom: 30px; width: 1px; background: var(--line-strong); pointer-events: none; display: none; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-family: var(--ff-sans); font-size: var(--t-xs); color: var(--fg-3); white-space: nowrap; }
.legend i { width: 10px; height: 10px; border-radius: 1px; display: inline-block; }
.legend .box { width: 16px; height: 10px; border: 1.5px solid var(--sev-crit); border-radius: var(--r-2); display: inline-block; }

.tip {
  position: fixed; z-index: 50; pointer-events: none; display: none; max-width: 300px;
  background: var(--bg-3); border: 1px solid var(--line-2); box-shadow: var(--shadow-pop); border-radius: var(--r-3);
  padding: 8px 10px; font-size: var(--t-sm); line-height: 1.5; color: var(--fg-1);
}
.tip b { color: var(--fg-0); font-weight: 600; }
.tip .sev { margin-top: 4px; }

/* ---- Incident list ---- */
.inc-row { display: block; padding: 10px 14px 11px; border-bottom: 1px solid var(--line-1); color: var(--fg-1); text-decoration: none; }
.inc-row:last-child { border-bottom: none; }
.inc-row:hover { background: var(--bg-2); text-decoration: none; }
.inc-row .top { display: flex; align-items: center; gap: 8px; font: 400 var(--t-xs) var(--ff-mono); color: var(--fg-3); }
.inc-row .ttl { margin-top: 6px; font-size: var(--t-md); font-weight: 500; color: var(--fg-0); }
.inc-row .sub { margin-top: 2px; font-size: var(--t-sm); color: var(--fg-2); }
.inc-row .foot { display: flex; gap: 12px; margin-top: 6px; font-size: var(--t-sm); color: var(--fg-3); }
.inc-row .foot b { font-weight: 400; color: var(--fg-1); }

/* ---- ATT&CK coverage rows ---- */
.mx-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 44px; gap: 10px; align-items: center; height: 19px; font-size: var(--t-sm); color: var(--fg-1); }
.mx-cells { display: flex; gap: 1px; overflow: hidden; }
.mx-cells i { flex: none; width: 7px; height: 11px; border-radius: 1px; background: var(--bg-3); }
.mx-cells i.on { background: var(--teal); }
.mx-cells i.part { background: color-mix(in srgb, var(--teal) 38%, var(--bg-3)); }
.mx-row .t-num { text-align: right; font-size: var(--t-xs); }

/* ============================================================
   Shared pieces for the other screens. Reach for these before
   writing page-specific CSS, so the screens stay one product.
   ============================================================ */

/* ---- Tabs (inside a panel or under a page head) ---- */
.tabs { display: flex; border-bottom: 1px solid var(--line-1); padding: 0 6px; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; margin-bottom: -1px;
  font: inherit; font-size: var(--t-sm); color: var(--fg-2); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.tab:hover { color: var(--fg-0); text-decoration: none; }
.tab.active { color: var(--fg-0); border-bottom-color: var(--amber); }
.tab .meta { font: 500 var(--t-xs) var(--ff-mono); color: var(--fg-3); }

/* ---- Toolbar and filter chips ---- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  font: inherit; font-size: var(--t-sm); color: var(--fg-1); background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: 12px; cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--bg-3); color: var(--fg-0); }
.chip.on { border-color: color-mix(in srgb, var(--amber) 55%, transparent); background: var(--amber-bg); color: var(--fg-0); }
.chip .x, .chip .n { font-family: var(--ff-mono); font-size: var(--t-xs); color: var(--fg-3); }

/* ---- Key and value list ---- */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: var(--t-sm); }
.kv dt { color: var(--fg-3); }
.kv dd { margin: 0; color: var(--fg-1); min-width: 0; overflow-wrap: anywhere; }

/* ---- A person, device, address or app named inline ---- */
.entity {
  display: inline-flex; align-items: center; gap: 5px; padding: 0 6px; height: 18px; border-radius: var(--r-1);
  font: 400 var(--t-sm)/1 var(--ff-mono); color: var(--fg-0); background: var(--bg-3); border: 1px solid var(--line-1);
  white-space: nowrap; text-decoration: none;
}
a.entity:hover { border-color: var(--line-3); text-decoration: none; }

/* ---- List next to a detail pane ---- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 12px; align-items: start; }
.split > .detail { position: sticky; top: 0; }

/* ---- Vertical timeline: time, point, what happened ---- */
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 56px 14px minmax(0, 1fr); gap: 10px; padding-bottom: 14px; }
.timeline li::before { content: ''; position: absolute; left: 72px; top: 14px; bottom: -4px; width: 1px; background: var(--line-2); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }
.timeline .t { padding-top: 2px; text-align: right; font: 400 var(--t-xs) var(--ff-mono); color: var(--fg-3); }
.timeline .pt { position: relative; z-index: 1; width: 9px; height: 9px; margin: 4px 0 0 2px; border-radius: 50%; background: var(--fg-3); box-shadow: 0 0 0 3px var(--bg-1); }
.timeline .pt.crit { background: var(--sev-crit); }
.timeline .pt.high { background: var(--sev-high); }
.timeline .pt.med { background: var(--sev-med); }
.timeline .pt.ok { background: var(--teal); }
.timeline .what { font-size: var(--t-md); color: var(--fg-0); }
.timeline .more { margin-top: 2px; font-size: var(--t-sm); color: var(--fg-2); }

/* ---- Query bar: a mono editor line with a run button ---- */
.qbar { display: flex; align-items: flex-start; background: var(--bg-inset); border: 1px solid var(--line-2); border-radius: var(--r-3); }
.qbar:focus-within { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-bg); }
.qbar .q { flex: 1; min-width: 0; margin: 0; padding: 9px 12px; font: 400 var(--t-md)/1.65 var(--ff-mono); color: var(--fg-0); white-space: pre-wrap; outline: none; }
.qbar .q .kw { color: var(--violet); }
.qbar .q .str { color: var(--lime); }
.qbar .q .fn { color: var(--teal); }
.qbar .q .num { color: var(--amber); }
.qbar .q .com { color: var(--fg-3); }
.qbar .run { margin: 7px; flex: none; }

/* ---- Histogram along a time axis ---- */
.hist { display: flex; align-items: flex-end; gap: 1px; height: 56px; }
.hist i { flex: 1; min-width: 0; background: var(--fg-4); border-radius: 1px 1px 0 0; }
.hist i.hot { background: var(--sev-med); }
.hist i.sel { background: var(--fg-1); }

/* ---- Inline meter: a labelled share of a whole ---- */
.meter { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 3px 10px; align-items: center; font-size: var(--t-sm); }
.meter .bar { grid-column: 1 / -1; }

/* ---- Narrow screens ---- */
@media (max-width: 1080px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail, .appbar .search, .appbar .who, .appbar .btn-group { display: none; }
  .g-2-1, .g-1-1, .g-1-2, .g-3, .split { grid-template-columns: minmax(0, 1fr); }
  .split > .detail { position: static; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-bottom: 1px solid var(--line-1); }
  .tape-row, .tape-axis { grid-template-columns: 120px minmax(0, 1fr); }
  .tape-stat, .tape-axis > :last-child { display: none; }
  .main { padding: 14px 12px 32px; }
  .now-banner { flex-wrap: wrap; }
}
