/* Firevyzer — Claude-inspired design system
   Display: Source Serif 4  ·  UI: IBM Plex Sans  ·  Data: IBM Plex Mono */

:root {
  /* warm paper palette */
  --paper: #F3F1EA;
  --paper-2: #ECE9E0;
  --panel: #FDFCF9;
  --panel-edge: #E7E3D8;
  --hairline: #E2DED2;
  --ink: #211F1A;
  --ink-2: #4A463E;
  --muted: #837D70;
  --faint: #A39C8C;

  /* terracotta accent (Claude) */
  --accent: #C2613D;
  --accent-strong: #A94E2E;
  --accent-wash: #F6E9E1;
  --accent-edge: #E6C7B5;

  /* neutral selection — cool steel-blue, deliberately NOT red/terracotta
     so it never reads as "deny" or "error" */
  --select: #4C6E93;
  --select-strong: #3A5878;
  --select-soft: #D7DFEA;
  --select-wash: #E9EDF2;
  --select-edge: #C3D1DF;

  /* verdict semantics, warm-leaning */
  --allow: #4F7A52;
  --allow-wash: #E6EDDF;
  --allow-edge: #CBD9BC;
  --deny: #B14A3C;
  --deny-wash: #F3E0DA;
  --deny-edge: #E5C3B8;

  /* caution / over-broad — amber, deliberately NOT red so it never reads as
     "deny" in the Allowed section; flags an over-broad "any … except …" class. */
  --warn: #B0863C;
  --warn-strong: #8A6626;
  --warn-wash: #F6EDD8;
  --warn-edge: #E4D3A6;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(40,34,26,.05), 0 1px 1px rgba(40,34,26,.04);
  --shadow-md: 0 4px 16px rgba(40,34,26,.07), 0 1px 3px rgba(40,34,26,.05);
  --shadow-lg: 0 18px 48px rgba(40,34,26,.13), 0 4px 12px rgba(40,34,26,.07);

  --serif: "Source Serif 4", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --pad: 20px;
  --row-pad: 11px;
  --gap: 16px;
}

[data-density="compact"] {
  --pad: 14px;
  --row-pad: 7px;
  --gap: 11px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-wash); }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; letter-spacing: -.01em; }
.mono { font-family: var(--mono); font-variant-ligatures: none; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 13px; }

/* ---- app shell ---- */
.app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px;
  background: var(--panel);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mark {
  width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: var(--shadow-sm);
}
.brand .mark svg { display: block; }
.brand .name { font-family: var(--serif); font-size: 19px; font-weight: 500; letter-spacing: -.02em; }
.brand .tag {
  font-size: 11px; color: var(--muted); margin-left: 2px;
  border-left: 1px solid var(--hairline); padding-left: 12px; line-height: 1.25;
}
.topbar .spacer { flex: 1; }
.topbar-div { width: 1px; height: 22px; background: var(--hairline); margin: 0 5px; flex: none; }
.acct-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: #fff; letter-spacing: .02em;
  background: linear-gradient(150deg, var(--select) 0%, var(--select-strong) 100%);
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--panel-edge); background: var(--panel);
  color: var(--ink); padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, transform .04s;
}
.btn:hover { background: #fff; border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent); border-color: var(--accent-strong); color: #fff;
}
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--paper-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; display: grid; place-items: center; color: var(--muted);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }

/* ---- two-pane workspace ---- */
.workspace {
  flex: 1; display: grid;
  grid-template-columns: minmax(0,1.5fr) minmax(0,1fr);
  gap: 0; align-items: stretch;
}
.workspace.stacked { grid-template-columns: 1fr; }
.pane { padding: 22px 26px 40px; min-width: 0; }
.pane.left { border-right: 1px solid var(--hairline); }
.pane.right { background: var(--paper-2); }

.pane-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.pane-head h2 { font-size: 17px; }
.pane-head .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.pane-toolbar { display: flex; align-items: center; gap: 8px; margin: 16px 0 12px; flex-wrap: wrap; }
.pane-toolbar .spacer { flex: 1; }
.overlap-bar { display: flex; align-items: center; gap: 9px 11px; flex-wrap: wrap; width: 100%; }
.overlap-lead { font-size: 12.5px; color: var(--ink-2); flex: none; }
.overlap-lead b { font-weight: 600; color: var(--accent-strong); font-family: var(--mono); }
.overlap-refs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.overlap-clear { margin-left: auto; flex: none; }

/* ---- rule table ---- */
.rules { display: flex; flex-direction: column; gap: 0; }
.rule-headrow, .rule-grid {
  display: grid;
  grid-template-columns: 22px 74px minmax(92px,1.5fr) minmax(92px,1.5fr) 60px 50px 52px;
  gap: 6px; align-items: center;
}
.rule-headrow {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); padding: 9px 8px; border-bottom: 1px solid var(--hairline);
}
.rule {
  padding: var(--row-pad) 8px;
  border-bottom: 1px solid var(--hairline);
  background: var(--panel);
  position: relative;
  transition: background .12s, box-shadow .12s;
  cursor: default;
}
.rule:first-of-type { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.rule:hover { background: color-mix(in srgb, var(--panel) 60%, #fff); }
.rule.dragging { box-shadow: var(--shadow-md); z-index: 5; }
.rule.selected { background: var(--select-soft); }
.rule.related { background: color-mix(in srgb, var(--select-wash) 60%, var(--panel)); }
.rule.related:hover { background: var(--select-wash); }
.rule.flash { animation: ruleflash 1.05s ease; }
@keyframes ruleflash {
  0% { background: var(--select-wash); box-shadow: inset 0 0 0 2px var(--select); }
  100% { background: var(--panel); box-shadow: inset 0 0 0 2px transparent; }
}
.rule.is-redundant .rule-grid { opacity: .62; }
.rule.is-redundant:hover .rule-grid { opacity: 1; }
.rules-wrap { border: 1px solid var(--panel-edge); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.rule .seq {
  font-family: var(--mono); font-size: 11px; color: var(--faint); text-align: center;
  cursor: grab; padding: 5px 0; border-radius: 5px; user-select: none;
}
.rule .seq:hover { background: var(--paper-2); color: var(--ink-2); }
.rule .seq:active { cursor: grabbing; }
.rule.dirty::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.rule.added::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--allow); }
/* selection-context bars (placed last so they win over dirty/added during selection) */
/* selected rule — solid bar */
.rule.selected::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--select); z-index: 2; }
/* related rule — thin solid hairline, same hue, so it reads "connected to" not "the same as" */
.rule.related::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; z-index: 1;
  background: color-mix(in srgb, var(--select) 78%, var(--panel));
}

/* trailing per-row actions */
.rule-acts { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.rule-acts .icon-btn { opacity: 0; transition: opacity .12s, background .12s, color .12s; }
.rule:hover .rule-acts .icon-btn, .rule.selected .rule-acts .icon-btn { opacity: .8; }
.rule-acts .icon-btn:hover { opacity: 1; }
.rule-acts .icon-btn.danger:hover { background: var(--deny-wash); color: var(--deny); }

/* decomposition lane marker */
.lane { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 0 2px 2px 0; }

/* inline finding annotations */
.rule-annot {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin: 7px 2px 1px 30px; font-size: 11.5px; color: var(--muted);
}
.rule-annot.loss { color: var(--deny); }
.rule-annot.shift { color: var(--muted); }
.rule-annot .up { color: var(--accent); font-weight: 700; }
.annot-badge {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 6px; border-radius: 999px; border: 1px solid;
}
.annot-badge.loss { background: var(--deny-wash); border-color: var(--deny-edge); color: var(--deny); }

.cell-input {
  width: 100%; min-width: 0; border: 1px solid transparent; background: transparent;
  padding: 5px 7px; border-radius: 6px; color: var(--ink);
  font-family: var(--mono); font-size: 12px;
}
.cell-input:hover { border-color: var(--hairline); background: var(--paper); }
.cell-input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-wash); }

.pill-select {
  appearance: none; border: 1px solid var(--hairline); border-radius: 999px;
  padding: 4px 19px 4px 9px; font-size: 11px; font-weight: 600; font-family: var(--mono);
  width: 100%; min-width: 0; text-overflow: ellipsis;
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 4l3 3 3-3' stroke='%23837D70' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  cursor: pointer; color: var(--ink-2);
}
.pill-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.verdict-allow { color: var(--allow); }
.verdict-deny { color: var(--deny); }
.tag-allow { background: var(--allow-wash); border-color: var(--allow-edge); color: var(--allow); }
.tag-deny { background: var(--deny-wash); border-color: var(--deny-edge); color: var(--deny); }
.proto-select { background-color: var(--panel); color: var(--ink-2); }

/* ---- feedback panel ---- */
.fs-summary {
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: var(--gap);
}
.fs-summary .headline { font-family: var(--serif); font-size: 19px; line-height: 1.35; letter-spacing: -.01em; }
.fs-summary .headline em { font-style: normal; color: var(--accent); }
.fs-counts { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.fs-files {
  margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--hairline);
  font-size: 11.5px; color: var(--faint); display: flex; align-items: center; gap: 8px;
}
.fs-files span { color: var(--accent); }
.count-chip {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 10px;
  border-radius: 999px; border: 1px solid var(--hairline); background: var(--paper);
  font-size: 12.5px;
}
.count-chip .n { font-family: var(--mono); font-weight: 600; font-size: 15px; }
.count-chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.count-chip.gain .dot { background: var(--allow); }
.count-chip.gain .n { color: var(--allow); }
.count-chip.loss .dot { background: var(--deny); }
.count-chip.loss .n { color: var(--deny); }
.count-chip.neutral .dot { background: var(--faint); }

.fs-group { margin-bottom: 22px; }
.fs-group-title {
  display: flex; align-items: center; gap: 9px; margin: 0 0 11px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600;
}
.fs-group-title .line { flex: 1; height: 1px; background: var(--hairline); }

.flow-card {
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--radius);
  padding: 13px 15px; box-shadow: var(--shadow-sm); margin-bottom: 10px;
  border-left-width: 3px;
}
.flow-card.gain { border-left-color: var(--allow); }
.flow-card.loss { border-left-color: var(--deny); }
.flow-card.shift { border-left-color: var(--accent); }
.flow-line { display: flex; align-items: flex-start; gap: 9px; font-family: var(--mono); font-size: 13px; }
.flow-eps { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.flow-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; row-gap: 3px; line-height: 1.45; }
.flow-proto {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; padding: 3px 7px; border-radius: 5px;
  background: var(--paper-2); color: var(--ink-2); flex: none; margin-top: 1px;
}
.flow-ep { color: var(--ink); }
.ep-except { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.ep-more { color: var(--accent); font-size: 11px; background: var(--accent-wash); padding: 1px 6px; border-radius: 999px; cursor: default; }
.flow-arrow { color: var(--faint); }
.flow-port { color: var(--muted); }
.flow-port b { color: var(--ink-2); font-weight: 600; }
.flow-meta { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 12px; color: var(--muted); }
.verdict-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-family: var(--mono); font-size: 11px; font-weight: 600; border: 1px solid;
}
.verdict-badge.allow { background: var(--allow-wash); border-color: var(--allow-edge); color: var(--allow); }
.verdict-badge.deny { background: var(--deny-wash); border-color: var(--deny-edge); color: var(--deny); }
.verdict-flow { color: var(--faint); }
.flow-cause { margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--hairline); font-size: 12px; color: var(--muted); }
.flow-cause code { font-family: var(--mono); color: var(--ink-2); background: var(--paper-2); padding: 1px 5px; border-radius: 4px; }

/* ---- empty / states ---- */
.fs-empty {
  border: 1px dashed var(--panel-edge); border-radius: var(--radius);
  padding: 40px 28px; text-align: center; color: var(--muted); background: var(--panel);
}
.fs-empty h3 { font-size: 17px; color: var(--ink-2); margin-bottom: 7px; }
.fs-empty .ring { width: 46px; height: 46px; margin: 0 auto 16px; color: var(--allow); }

/* ---- upload / dropzone ---- */
.dropzone-wrap { display: grid; place-items: center; flex: 1; padding: 60px 20px; }
.dropzone {
  width: min(560px, 92vw); background: var(--panel); border: 1.5px dashed var(--accent-edge);
  border-radius: 16px; padding: 46px 40px; text-align: center; box-shadow: var(--shadow-md);
  transition: border-color .15s, background .15s, transform .15s;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-wash); transform: scale(1.008); }
.dropzone .big-mark {
  width: 60px; height: 60px; border-radius: 15px; margin: 0 auto 20px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent), var(--accent-strong));
  box-shadow: var(--shadow-md);
}
.dropzone h1 { font-size: 27px; margin-bottom: 8px; letter-spacing: -.02em; }
.dropzone p { color: var(--muted); margin: 0 auto 24px; max-width: 40ch; }
.dropzone .actions { display: flex; gap: 11px; justify-content: center; }
.dropzone .hint { margin-top: 22px; font-size: 12px; color: var(--faint); }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; box-shadow: var(--shadow-lg); z-index: 60; display: flex; gap: 9px; align-items: center;
}
.toast .x { color: var(--accent); }

/* scrollbars */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #d8d3c6; border-radius: 999px; border: 3px solid var(--paper); }
.pane.right ::-webkit-scrollbar-thumb { border-color: var(--paper-2); }

.fade-in { animation: fade .35s ease; }
@keyframes fade { from { transform: translateY(5px); } to { transform: none; } }

/* ============================================================ *
 *  Four-workflow workspace — added in v18
 * ============================================================ */

.app { height: 100vh; }

/* three columns: Trace · Rules · Analysis (data flows left → right) */
.workspace3 {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(440px, 1.55fr) minmax(358px, 430px);
}
.workspace3 > .pane { overflow-y: auto; overflow-x: hidden; padding: 18px 20px 40px; }
.pane.trace-col { background: var(--paper-2); border-right: 1px solid var(--hairline); }
.pane.center { background: var(--paper); }
.pane.right { background: var(--paper-2); border-left: 1px solid var(--hairline); padding-top: 0; }

@media (max-width: 1240px) {
  .workspace3 { grid-template-columns: minmax(248px,1fr) minmax(340px,1.5fr) minmax(310px,1fr); }
}
@media (max-width: 1040px) {
  .app { height: auto; min-height: 100vh; }
  .workspace3 { display: flex; flex-direction: column; }
  .workspace3 > .pane { overflow: visible; }
  .pane.trace-col, .pane.right { border: none; border-bottom: 1px solid var(--hairline); }
  .slideover { width: min(440px, 96vw); }
}

/* right-panel header (single, auto-switching: Allowed traffic ⇄ Changes) */
.analysis-head {
  display: flex; align-items: baseline; gap: 10px;
  position: sticky; top: 0; z-index: 6;
  background: var(--paper-2); padding: 18px 0 12px; margin-bottom: 2px;
  border-bottom: 1px solid var(--hairline);
}
.analysis-head h2 { font-size: 17px; }
.analysis-head .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.analysis-head .atab-badge { margin-left: auto; align-self: center; }

/* analysis tabs */
.analysis-tabs {
  display: flex; gap: 6px; position: sticky; top: 0; z-index: 6;
  background: var(--paper-2); padding: 16px 0 12px; margin-bottom: 2px;
}
.atab {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid transparent; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 600; position: relative;
}
.atab:hover { color: var(--ink); background: color-mix(in srgb, var(--panel) 70%, transparent); }
.atab.on { background: var(--panel); color: var(--ink); border-color: var(--panel-edge); box-shadow: var(--shadow-sm); }
.atab-badge { font-family: var(--mono); font-size: 11px; font-weight: 700; background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 7px; }
.atab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.analysis-body { padding-bottom: 20px; }

/* ---- RuleRef ---- */
.ruleref {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 3px 9px 3px 6px; border-radius: 999px; border: 1px solid var(--panel-edge);
  background: var(--panel); color: var(--ink-2); font-size: 12px; font-weight: 500;
  box-shadow: var(--shadow-sm); cursor: pointer; vertical-align: middle;
  font-family: var(--sans); transition: background .12s, border-color .12s, transform .04s;
}
.ruleref:hover { background: #fff; border-color: var(--faint); }
.ruleref:active { transform: translateY(1px); }
.ruleref.selected { border-color: var(--select); box-shadow: 0 0 0 2px var(--select-wash); }
.ruleref.dim { background: transparent; box-shadow: none; color: var(--muted); }
.ruleref.dim:hover { background: var(--panel); color: var(--ink-2); }
.rr-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.rr-dot.allow { background: var(--allow); }
.rr-dot.drop { background: var(--deny); }
.rr-idx { font-size: 10.5px; color: var(--faint); font-weight: 600; }
.rr-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-acl { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 5px; border-radius: 999px; }
.rr-acl.old { background: var(--paper-2); color: var(--muted); }
.rr-acl.new { background: var(--accent-wash); color: var(--accent-strong); }
.ruleref.is-default { background: transparent; border: 1px dashed var(--panel-edge); box-shadow: none; color: var(--muted); cursor: default; }

/* ---- verdict badge ---- */
.vbadge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-family: var(--mono); font-size: 11px; font-weight: 600; border: 1px solid; }
.vbadge.allow { background: var(--allow-wash); border-color: var(--allow-edge); color: var(--allow); }
.vbadge.drop { background: var(--deny-wash); border-color: var(--deny-edge); color: var(--deny); }

/* ---- TrafficClass chip ---- */
.tc {
  display: flex; align-items: flex-start; gap: 9px; font-family: var(--mono);
  font-size: 12.5px; line-height: 1.5; padding: 9px 11px; border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm); background: var(--panel);
}
.tc.tone-allow { border-left: 2.5px solid var(--allow-edge); }
.tc.tone-drop { border-left: 2.5px solid var(--deny-edge); }
/* Over-broad class ("any … except …"): amber caution, NOT red — red would read
   as "deny" in the Allowed section. The <TrafficClass> also renders a small
   "BROAD" badge (.tc-broad) so the meaning is explicit, not just color-coded. */
.tc.alarm { border-color: var(--warn-edge); background: var(--warn-wash); border-left: 2.5px solid var(--warn); }
.tc-proto { flex: none; font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 3px 7px; border-radius: 5px; background: var(--paper-2); color: var(--ink-2); margin-top: 1px; }
.tc.alarm .tc-proto { background: transparent; border: 1px solid var(--warn-edge); color: var(--warn-strong); }
.tc-broad {
  flex: none; margin-top: 1px; margin-left: auto;
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 9px; font-weight: 700; letter-spacing: .06em;
  padding: 2px 6px; border-radius: 999px;
  background: var(--warn-wash); border: 1px solid var(--warn-edge); color: var(--warn-strong);
}
.tc-flow { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; min-width: 0; color: var(--ink); }
.tc-arrow { color: var(--faint); }
.tc-from { color: var(--muted); }
.m-ep { color: var(--ink); }
.m-any { color: var(--muted); }
/* No white-space:nowrap here: a long exception list (e.g. "any port except
   80 (http), 443 (https), 3389 (rdp)") must wrap inside the card instead of
   overflowing its right edge. overflow-wrap breaks an over-long single token as
   a fallback; min-width:0 on the .m-port flex child lets it shrink so .tc-flow's
   flex-wrap can break the line. */
.m-neq, .m-except { color: var(--accent-strong); font-weight: 600; overflow-wrap: anywhere; }
.m-port { color: var(--muted); min-width: 0; }
.m-port b { color: var(--ink-2); font-weight: 600; }
.m-more { color: var(--accent); font-size: 11px; background: var(--accent-wash); padding: 0 6px; border-radius: 999px; }
.tc-list { display: flex; flex-direction: column; gap: 7px; }
.tc-empty { font-size: 12.5px; color: var(--muted); padding: 8px 11px; border: 1px dashed var(--panel-edge); border-radius: var(--radius-sm); }

/* ---- Allowed-traffic (Output) tab ---- */
.out-summary {
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: var(--gap);
}
.out-summary .headline { font-family: var(--serif); font-size: 19px; line-height: 1.35; letter-spacing: -.01em; }

.out-sec { margin-bottom: 22px; }
.out-sec-head {
  display: flex; align-items: center; gap: 8px; margin: 0 0 5px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted);
}
.out-sec-head .out-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.out-sec-head.allow { color: var(--allow); }
.out-sec-head.drop { color: var(--deny); }
.out-sec-head.allow .out-dot { background: var(--allow); }
.out-sec-head.drop .out-dot { background: var(--deny); }
.out-n {
  margin-left: 1px; font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--faint);
  background: var(--paper-2); border: 1px solid var(--hairline); border-radius: 999px; padding: 1px 8px;
}
.out-lead { font-size: 12px; color: var(--muted); margin: 0 0 11px; }

.oseg { margin-bottom: 14px; border-radius: var(--radius-sm); transition: opacity .2s ease; }
.oseg-head { margin-bottom: 7px; }
.oseg.sel { outline: 2px solid var(--select-edge); outline-offset: 5px; }
.oseg.dim { opacity: .4; }

.out-default {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--muted); padding: 10px 12px; margin-top: 4px;
  border: 1px dashed var(--panel-edge); border-radius: var(--radius-sm); transition: opacity .2s ease;
}
.out-default.sel { border-style: solid; border-color: var(--select-edge); background: var(--select-wash); }
.out-default.dim { opacity: .4; }
.out-default-txt { font-weight: 500; color: var(--ink-2); }
.out-default-by { margin-left: auto; font-size: 11px; color: var(--faint); display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

/* ---- Changes tab cards ---- */
.fs-empty p { margin: 0 auto; max-width: 34ch; font-size: 13px; }
.fs-group-hint { font-size: 12px; color: var(--muted); margin: -4px 0 11px; }
.fs-group-n { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.change-card { background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--radius); padding: 12px 13px; box-shadow: var(--shadow-sm); margin-bottom: 10px; border-left-width: 3px; }
.change-card.gain { border-left-color: var(--allow); }
.change-card.loss { border-left-color: var(--deny); }
.change-card .tc { border: none; background: transparent; padding: 0; }
.change-verdict { display: flex; align-items: center; gap: 8px; margin-top: 11px; }
.change-arrow { color: var(--faint); }
.change-tag { font-size: 11px; color: var(--muted); margin-left: 2px; }
.prov { margin-top: 11px; padding-top: 10px; border-top: 1px dashed var(--hairline); display: flex; flex-direction: column; gap: 7px; }
.prov-line { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.prov-key { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); min-width: 44px; }

/* ---- Health tab ---- */
.health { display: flex; flex-direction: column; gap: 18px; }
.health-summary { display: flex; align-items: center; gap: 13px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--panel-edge); background: var(--panel); box-shadow: var(--shadow-sm); }
.health-summary.ok { border-color: var(--allow-edge); background: var(--allow-wash); }
.hsum-ring { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); }
.health-summary.ok .hsum-ring { color: var(--allow); }
.hsum-head { font-family: var(--serif); font-size: 16px; }
.hsum-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.hs-head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.hs-ico { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: var(--paper-2); color: var(--muted); flex: none; }
.hs-ico.loss { background: var(--deny-wash); color: var(--deny); }
.hs-ico.shift { background: var(--accent-wash); color: var(--accent-strong); }
.hs-title { font-size: 13px; font-weight: 600; }
.hs-count { font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--paper-2); color: var(--muted); }
.hs-count.loss { background: var(--deny-wash); color: var(--deny); }
.hs-count.shift { background: var(--accent-wash); color: var(--accent-strong); }
.hs-body { display: flex; flex-direction: column; gap: 8px; }
.hs-lead { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.hs-lead.muted-note { padding: 11px 13px; border: 1px dashed var(--panel-edge); border-radius: var(--radius-sm); color: var(--muted); }
.finding { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 9px 11px; border: 1px solid var(--panel-edge); border-radius: var(--radius-sm); background: var(--panel); box-shadow: var(--shadow-sm); flex-wrap: wrap; }
.finding-main { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; min-width: 0; }
.finding-note { font-size: 11.5px; color: var(--muted); }
.finding.redundant { border-left: 3px solid var(--deny); }
.finding.shadow { border-left: 3px solid var(--accent); flex-direction: column; align-items: flex-start; gap: 8px; }
.finding-by { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.finding-by .up { color: var(--accent); font-weight: 700; }
.finding-act { flex: none; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 11.5px; font-weight: 600; padding: 0 0 0 6px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.decomp-group { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 12px 9px 15px; border: 1px solid var(--panel-edge); border-radius: var(--radius-sm); background: var(--panel); margin-bottom: 7px; flex-wrap: wrap; box-shadow: var(--shadow-sm); }
.decomp-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 0 2px 2px 0; }
.decomp-meta { display: flex; flex-direction: column; flex: none; }
.decomp-name { font-size: 12px; font-weight: 600; }
.decomp-sub { font-size: 10.5px; color: var(--faint); }
.decomp-refs { display: flex; gap: 6px; flex-wrap: wrap; }

/* decomposition / lane palette */
.lane.g-0, .g-0 .decomp-bar { background: #C2613D; }
.lane.g-1, .g-1 .decomp-bar { background: #3F6F8F; }
.lane.g-2, .g-2 .decomp-bar { background: #6E8A4F; }
.lane.g-3, .g-3 .decomp-bar { background: #8A5A86; }
.lane.g-4, .g-4 .decomp-bar { background: #B0863C; }
.lane.g-5, .g-5 .decomp-bar { background: #3E8A82; }

/* ---- Trace column ---- */
.trace-panel { display: flex; flex-direction: column; gap: 14px; }
.tq { background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--radius); padding: 13px; box-shadow: var(--shadow-sm); }
.tq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.tq-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tq-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; }
.tq .cell-input { border: 1px solid var(--hairline); background: var(--paper); border-radius: 6px; }
.tq-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; gap: 8px; }
.tq-hint { font-size: 11px; color: var(--faint); }
.trace-sec-label { display: flex; align-items: center; gap: 9px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 2px 0 9px; }
.trace-sec-label .line { flex: 1; height: 1px; background: var(--hairline); }
.trace-allchip { text-transform: none; letter-spacing: 0; font-weight: 500; font-family: var(--mono); font-size: 10.5px; color: var(--muted); background: var(--paper-2); padding: 2px 8px; border-radius: 999px; }
.trace-allchip.drop { color: var(--deny); background: var(--deny-wash); }
.trace-bar { display: flex; height: 30px; border-radius: 7px; overflow: hidden; border: 1px solid var(--panel-edge); box-shadow: var(--shadow-sm); margin-bottom: 12px; }
.tbar-seg { border: none; padding: 0; height: 100%; position: relative; cursor: pointer; border-right: 1px solid rgba(255,255,255,.32); display: flex; align-items: center; justify-content: center; min-width: 8px; transition: filter .12s; }
.tbar-seg:last-child { border-right: none; }
.tbar-seg.allow { background: var(--allow); }
.tbar-seg.drop { background: var(--deny); }
.tbar-seg.active, .tbar-seg:hover { filter: brightness(1.13); }
.tbar-pct { color: rgba(255,255,255,.95); font-size: 10px; font-weight: 600; pointer-events: none; }
.seg-list { display: flex; flex-direction: column; gap: 9px; }
.seg-row { display: flex; border: 1px solid var(--panel-edge); border-radius: var(--radius-sm); background: var(--panel); overflow: hidden; box-shadow: var(--shadow-sm); transition: box-shadow .12s; }
.seg-row.active { box-shadow: 0 0 0 2px var(--select-wash); }
.seg-rail { width: 4px; flex: none; }
.seg-row.allow .seg-rail { background: var(--allow); }
.seg-row.drop .seg-rail { background: var(--deny); }
.seg-content { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.seg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg-by { font-size: 11px; color: var(--faint); }
.seg-content .tc, .preempt .tc { border: none; background: transparent; padding: 0; }
.seg-content .tc-list, .preempt .tc-list { gap: 5px; }
.trace-shadow { margin-top: 2px; }
.trace-shadow-lead { font-size: 12px; color: var(--muted); margin: -4px 0 10px; }
.preempt { border: 1px solid var(--panel-edge); border-radius: var(--radius-sm); background: var(--panel); padding: 10px 12px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm); }
.preempt-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.preempt-would { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* ---- single-rule slide-over ---- */
.slideover { position: fixed; top: 0; right: 0; width: min(440px, 94vw); height: 100vh; background: var(--panel); border-left: 1px solid var(--panel-edge); box-shadow: var(--shadow-lg); z-index: 40; display: flex; flex-direction: column; }
.fade-slide { animation: slidein .22s cubic-bezier(.3,.7,.4,1); }
@keyframes slidein { from { transform: translateX(22px); } to { transform: none; } }
.so-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid var(--hairline); }
.so-head-l { display: flex; gap: 11px; min-width: 0; }
.so-seq { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: none; }
.so-seq.allow { background: var(--allow-wash); color: var(--allow); }
.so-seq.drop { background: var(--deny-wash); color: var(--deny); }
.so-titles { min-width: 0; }
.so-title { font-family: var(--serif); font-size: 17px; line-height: 1.3; }
.so-sub { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.so-sub-txt { font-size: 11px; color: var(--faint); }
.so-body { padding: 16px 18px 32px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.so-block { display: flex; flex-direction: column; gap: 9px; }
.so-label { display: flex; align-items: center; gap: 9px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.so-label.hero { font-size: 12px; color: var(--ink-2); }
.so-label.quiet { color: var(--faint); }
.so-count { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.so-badge { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 10.5px; padding: 2px 8px; border-radius: 999px; }
.so-badge.shift { background: var(--accent-wash); color: var(--accent-strong); }
.so-badge.loss { background: var(--deny-wash); color: var(--deny); }
.so-dead { display: flex; gap: 10px; align-items: flex-start; padding: 13px; border: 1px solid var(--deny-edge); background: var(--deny-wash); border-radius: var(--radius-sm); color: var(--ink-2); font-size: 13px; line-height: 1.55; }
.so-dead svg { color: var(--deny); flex: none; margin-top: 2px; }
.so-dead b { color: var(--ink); }
.so-callout { display: flex; gap: 9px; align-items: flex-start; padding: 11px 13px; border-radius: var(--radius-sm); }
.so-callout.shift { background: var(--accent-wash); border: 1px solid var(--accent-edge); }
.so-callout .up { color: var(--accent); font-weight: 700; margin-top: 3px; }
.so-refs { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.so-refs.wrap { flex-direction: row; flex-wrap: wrap; }
.so-foot-note { font-size: 11.5px; color: var(--faint); }
.so-outscope { display: flex; gap: 10px; align-items: flex-start; padding: 13px; border: 1px solid var(--accent-edge); background: var(--accent-wash); border-radius: var(--radius-sm); font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.so-outscope svg { color: var(--accent-strong); flex: none; margin-top: 2px; }
.so-outscope b { color: var(--ink); }

/* ---- scope lens (left column + banners) ---- */
.scope-panel { display: flex; flex-direction: column; gap: 14px; }
.scope-caption { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0; }
.scope-caption b { color: var(--ink-2); font-weight: 600; }
.scope-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.scope-active { display: flex; flex-direction: column; gap: 7px; min-width: 0; flex: 1; }
.scope-active .scope-key { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; }
.scope-allflows { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--faint); }
.scope-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }

.scope-banner { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding: 9px 11px; margin-bottom: 16px; border: 1px solid var(--accent-edge); background: var(--accent-wash); border-radius: var(--radius-sm); }
.scope-banner .scope-key { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-strong); font-weight: 700; flex: none; }
.scope-chip { min-width: 0; cursor: pointer; }
.scope-chip .tc { background: var(--panel); }
.scope-banner .link-btn { margin-left: auto; }
.health-scope-note { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--accent-strong); background: var(--accent-wash); border: 1px solid var(--accent-edge); border-radius: var(--radius-sm); padding: 8px 11px; margin-bottom: 16px; }
.health-scope-note svg { flex: none; }

/* collapse control + collapsed rail */
.trace-col .pane-head { align-items: center; }
.collapse-btn { margin-left: auto; }
.workspace3.trace-collapsed { grid-template-columns: 46px minmax(440px, 1.6fr) minmax(358px, 430px); }
.trace-rail { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 0; border: none; border-right: 1px solid var(--hairline); background: var(--paper-2); cursor: pointer; position: relative; }
.trace-rail:hover { background: var(--paper); }
.rail-ico { color: var(--muted); display: grid; place-items: center; }
.trace-rail:hover .rail-ico { color: var(--ink); }
.rail-label { writing-mode: vertical-rl; text-orientation: mixed; font-size: 10px; font-weight: 700; letter-spacing: .14em; color: var(--faint); text-transform: uppercase; }
.rail-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); position: absolute; top: 10px; right: 7px; box-shadow: 0 0 0 2px var(--paper-2); }

/* out-of-scope rule rows */
.rule.out-of-scope .rule-grid { opacity: .4; }
.rule.out-of-scope:hover .rule-grid { opacity: .78; }
.muted-annot { color: var(--faint); font-style: italic; font-size: 11px; }

@media (max-width: 1040px) {
  .workspace3.trace-collapsed { grid-template-columns: none; }
  .trace-rail { flex-direction: row; justify-content: center; border-right: none; border-bottom: 1px solid var(--hairline); padding: 10px 0; }
  .rail-label { writing-mode: horizontal-tb; }
  .rail-dot { top: 50%; right: auto; left: calc(50% + 34px); transform: translateY(-50%); }
}

/* dark mode */
[data-theme="dark"] {
  --paper: #1B1A17; --paper-2: #211F1B; --panel: #24221E; --panel-edge: #35322B;
  --hairline: #322F29; --ink: #F2EFE7; --ink-2: #CFC9BC; --muted: #948D7E; --faint: #6F695C;
  --accent-wash: #3A2A20; --accent-edge: #5A3B29;
  --allow-wash: #25301F; --allow-edge: #3C4B30; --deny-wash: #341F1B; --deny-edge: #52302A;
  --warn: #D4A657; --warn-strong: #E0B871; --warn-wash: #332812; --warn-edge: #574627;
}

/* App auth gate: hide the app until gate.js confirms a session, preventing a
   flash of UI during the Cognito round-trip. Toggled by removing the
   data-auth-pending attribute on <html>. (Moved out of an inline <style> in
   Firevyzer.html so the CSP needs no style-src 'unsafe-inline' — SECURITY_REVIEW H1.) */
html[data-auth-pending] body { visibility: hidden; }
