/* ---------- themes ----------
   Every colour used by the app lives in a variable so the five themes
   (iaea, light, dark, cyber, pastel) can swap the whole palette. Severity
   colours (--sev-*) drive the findings panel AND canvas highlights, so
   keep them visible against --canvas-bg in every theme. */
:root {
  color-scheme: light;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --ui-font-increase: 0px;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #d8dee4;
  --text: #1d2733;
  --muted: #68737f;
  --accent: #1f6feb;
  --accent-dark: #175bc4;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(31, 111, 235, 0.06);
  --hover: #eef1f4;
  --item-bg: #fbfcfd;
  --item-hover: #f0f6ff;
  --code-bg: #eef1f4;
  --input-bg: #ffffff;
  --canvas-bg: #fbfcfd;
  --glyph-bg: #2c3e50;
  --glyph-fg: #ffffff;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --danger-soft-border: #f5c6c0;
  --login-grad-a: #10304d;
  --login-grad-b: #1f6feb;
  --modal-backdrop: rgba(10, 20, 30, 0.55);

  /* canvas drawing */
  --node-fill: #ffffff;
  --node-stroke: #44546a;
  --node-glyph: #33415c;
  --node-internet-fill: #eef4fb;
  --node-firewall-fill: #fbe9e7;
  --node-firewall-stroke: #c0392b;
  --node-diode-fill: #ede7f6;
  --node-diode-stroke: #5e35b1;
  --decor: #90a0b4;
  --edge: #44546a;
  --badge-none: #98a2ad;
  --badge-ring: #ffffff;
  --badge-text: #ffffff;

  /* findings: violation / warning / correctly implemented / note */
  --sev-error: #c0392b;
  --sev-warning: #e6a817;
  --sev-pass: #27ae60;
  --sev-info: #90a0b4;
  --sev-text: #ffffff;
  --verdict-pass-bg: #e8f5e9; --verdict-pass-fg: #1b5e20;
  --verdict-warn-bg: #fff8e1; --verdict-warn-fg: #8d6e00;
  --verdict-fail-bg: #fdecea; --verdict-fail-fg: #c0392b;

  /* security level chips / zones / badges */
  --sl1: #c0392b;
  --sl2: #e67e22;
  --sl3: #d4a017;
  --sl4: #2980b9;
  --sl5: #27ae60;
  --zone-tint: 10%;
}

:root[data-text-size="large"] { --ui-font-increase: 1.5px; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10151c;
  --panel: #1a212b;
  --border: #2d3846;
  --text: #dce3ea;
  --muted: #8b98a5;
  --accent: #4c8dff;
  --accent-dark: #6da2ff;
  --accent-contrast: #0b1220;
  --accent-soft: rgba(76, 141, 255, 0.1);
  --hover: #242e3b;
  --item-bg: #1f2833;
  --item-hover: #263344;
  --code-bg: #242e3b;
  --input-bg: #121820;
  --canvas-bg: #0d1117;
  --glyph-bg: #33455c;
  --glyph-fg: #e6edf5;
  --danger: #e0564a;
  --danger-soft: rgba(224, 86, 74, 0.14);
  --danger-soft-border: rgba(224, 86, 74, 0.4);
  --login-grad-a: #0b1622;
  --login-grad-b: #16325a;
  --modal-backdrop: rgba(0, 0, 0, 0.65);

  --node-fill: #1e2733;
  --node-stroke: #9fb0c3;
  --node-glyph: #d7e0ea;
  --node-internet-fill: #16273b;
  --node-firewall-fill: #3a2320;
  --node-firewall-stroke: #e0564a;
  --node-diode-fill: #2a2340;
  --node-diode-stroke: #a78bfa;
  --decor: #7b8b9d;
  --edge: #9fb0c3;
  --badge-none: #5c6875;
  --badge-ring: #10151c;
  --badge-text: #ffffff;

  --sev-error: #f26257;
  --sev-warning: #f0b429;
  --sev-pass: #3ddc84;
  --sev-info: #8b98a5;
  --sev-text: #0b1220;
  --verdict-pass-bg: rgba(61, 220, 132, 0.12); --verdict-pass-fg: #6ee7a0;
  --verdict-warn-bg: rgba(240, 180, 41, 0.12); --verdict-warn-fg: #f5c95e;
  --verdict-fail-bg: rgba(242, 98, 87, 0.12);  --verdict-fail-fg: #f58e86;

  --sl1: #e05545;
  --sl2: #f08c3a;
  --sl3: #e3b52f;
  --sl4: #4a9fd8;
  --sl5: #37c871;
  --zone-tint: 14%;
}

:root[data-theme="cyber"] {
  color-scheme: dark;
  --font: "Cascadia Code", "Fira Code", Consolas, "Courier New", monospace;
  --bg: #050a06;
  --panel: #0a130c;
  --border: #14522a;
  --text: #9dffb0;
  --muted: #4e9964;
  --accent: #00ff66;
  --accent-dark: #5cff96;
  --accent-contrast: #02180a;
  --accent-soft: rgba(0, 255, 102, 0.08);
  --hover: #0e1f12;
  --item-bg: #0c1810;
  --item-hover: #103018;
  --code-bg: #0e1f12;
  --input-bg: #060e08;
  --canvas-bg: #030704;
  --glyph-bg: #0f3d1e;
  --glyph-fg: #a8ffbe;
  --danger: #ff3860;
  --danger-soft: rgba(255, 56, 96, 0.12);
  --danger-soft-border: rgba(255, 56, 96, 0.45);
  --login-grad-a: #010703;
  --login-grad-b: #063d1c;
  --modal-backdrop: rgba(0, 5, 2, 0.75);

  --node-fill: #07130a;
  --node-stroke: #33ff77;
  --node-glyph: #ccffdd;
  --node-internet-fill: #06231b;
  --node-firewall-fill: #250910;
  --node-firewall-stroke: #ff3860;
  --node-diode-fill: #131c2e;
  --node-diode-stroke: #7aa2ff;
  --decor: #2f9954;
  --edge: #33ff77;
  --badge-none: #2f6b42;
  --badge-ring: #050a06;
  --badge-text: #031208;

  --sev-error: #ff3860;
  --sev-warning: #ffd000;
  --sev-pass: #00ff88;
  --sev-info: #58b573;
  --sev-text: #04170a;
  --verdict-pass-bg: rgba(0, 255, 136, 0.1);  --verdict-pass-fg: #6bffb4;
  --verdict-warn-bg: rgba(255, 208, 0, 0.1);  --verdict-warn-fg: #ffe14d;
  --verdict-fail-bg: rgba(255, 56, 96, 0.12); --verdict-fail-fg: #ff7a95;

  --sl1: #ff2f5e;
  --sl2: #ff8c1a;
  --sl3: #f5d90a;
  --sl4: #00c8ff;
  --sl5: #00ff88;
  --zone-tint: 12%;
}

/* Pastel: bold Wes Anderson palette (color-hex.com palette 71159) —
   powder cyan #72dfff, salmon #fa8072, marigold #fe9c1f, teal #008080
   and near-black ink #0d0d0d, on cream panels with inked outlines. */
:root[data-theme="pastel"] {
  color-scheme: light;
  --bg: #8ce4ff;
  --panel: #fff6e8;
  --border: #7cc3c3;
  --text: #0d0d0d;
  --muted: #567a80;
  --accent: #fa8072;
  --accent-dark: #f76251;
  --accent-contrast: #0d0d0d;
  --accent-soft: rgba(250, 128, 114, 0.14);
  --hover: #ffe9d1;
  --item-bg: #fffbf2;
  --item-hover: #ffe4de;
  --code-bg: #d9f4fc;
  --input-bg: #ffffff;
  --canvas-bg: #d6f4ff;
  --glyph-bg: #008080;
  --glyph-fg: #fff6e8;
  --danger: #d43d2a;
  --danger-soft: #ffe0da;
  --danger-soft-border: #f5a08f;
  --login-grad-a: #fa8072;
  --login-grad-b: #72dfff;
  --modal-backdrop: rgba(13, 13, 13, 0.5);

  --node-fill: #fffbf2;
  --node-stroke: #0d0d0d;
  --node-glyph: #0d0d0d;
  --node-internet-fill: #c9f0fd;
  --node-firewall-fill: #ffe0da;
  --node-firewall-stroke: #d43d2a;
  --node-diode-fill: #d5eaea;
  --node-diode-stroke: #008080;
  --decor: #4d9aa8;
  --edge: #0d0d0d;
  --badge-none: #8fb5bd;
  --badge-ring: #fff6e8;
  --badge-text: #ffffff;

  --sev-error: #d43d2a;
  /* marigold #fe9c1f darkened enough to carry white chip text */
  --sev-warning: #e08908;
  --sev-pass: #008080;
  --sev-info: #6fa1ad;
  --sev-text: #ffffff;
  --verdict-pass-bg: #cceaea; --verdict-pass-fg: #045f5f;
  --verdict-warn-bg: #ffe9c7; --verdict-warn-fg: #8f5a06;
  --verdict-fail-bg: #ffe0da; --verdict-fail-fg: #b83320;

  --sl1: #d43d2a;
  --sl2: #fe9c1f;
  --sl3: #d9b426;
  --sl4: #1d9ed6;
  --sl5: #008080;
  --zone-tint: 16%;
}

/* IAEA brand palette, sampled from iaea.org (theme=iaea_2025):
   blue #0069b4 (primary) / #004b81 (hover), grey #f5f7fb (section bg),
   danger #b9222d, warning #fcc30a, success #46895c, Roboto type. */
:root[data-theme="iaea"] {
  color-scheme: light;
  --font: "Roboto", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --border: #dee2e6;
  --text: #212529;
  --muted: #6c757d;
  --accent: #0069b4;
  --accent-dark: #004b81;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(0, 105, 180, 0.07);
  --hover: #e9ecef;
  --item-bg: #fbfcfe;
  --item-hover: #e6f1f8;
  --code-bg: #e9ecef;
  --input-bg: #ffffff;
  --canvas-bg: #fbfcfe;
  --glyph-bg: #0069b4;
  --glyph-fg: #ffffff;
  --danger: #b9222d;
  --danger-soft: #f1d2d5;
  --danger-soft-border: #ea858f;
  --login-grad-a: #004b81;
  --login-grad-b: #0069b4;
  --modal-backdrop: rgba(0, 35, 60, 0.55);

  --node-fill: #ffffff;
  --node-stroke: #35506b;
  --node-glyph: #1d3a52;
  --node-internet-fill: #e6f1f8;
  --node-firewall-fill: #f8e6e8;
  --node-firewall-stroke: #b9222d;
  --node-diode-fill: #ede7f6;
  --node-diode-stroke: #5e35b1;
  --decor: #8ba3b8;
  --edge: #35506b;
  --badge-none: #98a6b3;
  --badge-ring: #ffffff;
  --badge-text: #ffffff;

  --sev-error: #b9222d;
  /* IAEA's warning gold (#fcc30a) is too pale to carry white chip text;
     darkened just enough to keep --sev-text readable. */
  --sev-warning: #d9a406;
  --sev-pass: #46895c;
  --sev-info: #8296a9;
  --sev-text: #ffffff;
  --verdict-pass-bg: #dae7de; --verdict-pass-fg: #2d5c3d;
  --verdict-warn-bg: #fef3ce; --verdict-warn-fg: #8a6d00;
  --verdict-fail-bg: #f1d2d5; --verdict-fail-fg: #b9222d;

  --sl1: #b9222d;
  --sl2: #d9662c;
  --sl3: #c79a08;
  --sl4: #0069b4;
  --sl5: #46895c;
  --zone-tint: 10%;
}

/* IAEA chrome: the top bar and both side panels go brand-blue, like
   iaea.org's navigation. Custom properties inherit, so re-declaring the
   palette variables on these containers restyles every control inside
   them (buttons, cards, findings) for the blue background. */
:root[data-theme="iaea"] .topbar,
:root[data-theme="iaea"] .palette,
:root[data-theme="iaea"] .sidebar {
  color: var(--text);
  --panel: #0069b4;
  --text: #ffffff;
  --muted: #c9e2f4;
  --border: rgba(255, 255, 255, 0.32);
  --hover: rgba(255, 255, 255, 0.16);
  --item-bg: rgba(255, 255, 255, 0.1);
  --item-hover: rgba(255, 255, 255, 0.2);
  --code-bg: rgba(0, 45, 78, 0.4);
  --accent: #ffffff;
  --accent-dark: #d9ebf7;
  --accent-contrast: #0069b4;
  --accent-soft: rgba(255, 255, 255, 0.12);
  --glyph-bg: #ffffff;
  --glyph-fg: #0069b4;
}
/* The side panels sit a step lighter than the pure-brand top bar so the
   three chrome surfaces don't merge into one slab of blue. */
:root[data-theme="iaea"] .palette,
:root[data-theme="iaea"] .sidebar {
  --panel: #2385cd;
}
/* Inputs keep their white --input-bg, so their text must stay dark
   rather than inherit the panel's white. The combo-toggle sits on top
   of the input's white background too, so it needs the same fix. */
:root[data-theme="iaea"] .sidebar input,
:root[data-theme="iaea"] .sidebar select,
:root[data-theme="iaea"] .sidebar .combo-toggle {
  color: #212529;
}
/* --danger stays the solid IAEA red for the filled Delete buttons; the
   ghost Clear button needs a light red to read against the blue bar. */
:root[data-theme="iaea"] .theme-select option { color: #212529; background: #ffffff; }
:root[data-theme="iaea"] .topbar .btn-danger-ghost { color: #ffc2c8; }
:root[data-theme="iaea"] .topbar .btn-danger-ghost:hover { background: rgba(185, 34, 45, 0.4); }
:root[data-theme="iaea"] .sidebar .flow-in { color: #93d9ad; }
/* ZonePal brand palette, sampled from static/logo/zp-icon.svg:
   ink #201E1D, green #2E9E52 (primary), orange #F3821D (secondary),
   on soft off-white panels. Default theme. */
:root[data-theme="zonepal"] {
  color-scheme: light;
  --bg: #f3f8f5;
  --panel: #f5f8f6;
  --border: #d9e2dc;
  --text: #201e1d;
  --muted: #6b7570;
  --accent: #2e9e52;
  --accent-dark: #22793e;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(46, 158, 82, 0.08);
  --hover: #eaf4ed;
  --item-bg: #fbfdfb;
  --item-hover: #eaf6ee;
  --code-bg: #eef1ee;
  --input-bg: #ffffff;
  --canvas-bg: #fbfdfb;
  --glyph-bg: #201e1d;
  --glyph-fg: #ffffff;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --danger-soft-border: #f5c6c0;
  --login-grad-a: #201e1d;
  --login-grad-b: #2e9e52;
  --modal-backdrop: rgba(32, 30, 29, 0.55);

  --node-fill: #ffffff;
  --node-stroke: #201e1d;
  --node-glyph: #201e1d;
  --node-internet-fill: #eaf6ee;
  --node-firewall-fill: #fdecea;
  --node-firewall-stroke: #c0392b;
  --node-diode-fill: #fff2e4;
  --node-diode-stroke: #f3821d;
  --decor: #9fb0a6;
  --edge: #201e1d;
  --badge-none: #98a2ad;
  --badge-ring: #ffffff;
  --badge-text: #ffffff;

  --sev-error: #c0392b;
  --sev-warning: #f3821d;
  --sev-pass: #2e9e52;
  --sev-info: #90a0b4;
  --sev-text: #ffffff;
  --verdict-pass-bg: #e8f5ea; --verdict-pass-fg: #1e7a3c;
  --verdict-warn-bg: #fdf0e3; --verdict-warn-fg: #b35e12;
  --verdict-fail-bg: #fdecea; --verdict-fail-fg: #c0392b;

  --sl1: #c0392b;
  --sl2: #f3821d;
  --sl3: #d4a017;
  --sl4: #2980b9;
  --sl5: #2e9e52;
  --zone-tint: 10%;
}
/* Top bar sits a shade darker, with a green tinge, so it reads as chrome
   rather than another white panel. */
:root[data-theme="zonepal"] .topbar {
  --panel: #dce8e0;
  --border: #c7d6cc;
}

/* cyber flourishes */
:root[data-theme="cyber"] .btn-primary,
:root[data-theme="cyber"] .login-card button[type="submit"] {
  box-shadow: 0 0 14px rgba(0, 255, 102, 0.35);
}
:root[data-theme="cyber"] .topbar-title strong,
:root[data-theme="cyber"] .login-brand h1 {
  text-shadow: 0 0 10px rgba(0, 255, 102, 0.45);
}

* { box-sizing: border-box; }
/* the hidden attribute must win over display rules like .btn's inline-flex */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: calc(14px + var(--ui-font-increase));
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

h1, h2 { margin: 0; }
button { font: inherit; cursor: pointer; }
input, select {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  background: var(--input-bg);
  color: var(--text);
}
label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: calc(12px + var(--ui-font-increase)); color: var(--muted); }
.muted { color: var(--muted); }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }

.theme-select {
  width: auto;
  padding: 5px 8px;
  font-size: calc(13px + var(--ui-font-increase));
  background: var(--panel);
}

/* ---------- login ---------- */
.login-body {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--login-grad-a), var(--login-grad-b));
}
.login-card {
  background: var(--panel);
  padding: 36px;
  border-radius: 12px;
  width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand h1 { font-size: calc(20px + var(--ui-font-increase)); margin-top: 12px; }
.login-brand p { color: var(--muted); font-size: calc(12px + var(--ui-font-increase)); margin: 6px 0 0; }
.login-logo, .topbar-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  flex-shrink: 0;
}
.login-logo img, .topbar-logo img {
  width: 100%;
  height: 100%;
  display: block;
}
.login-card form { display: flex; flex-direction: column; }
.login-card button {
  margin-top: 18px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}
.login-card button:hover { background: var(--accent-dark); }
.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-soft-border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: calc(13px + var(--ui-font-increase));
}
.login-hint { text-align: center; font-size: calc(12px + var(--ui-font-increase)); color: var(--muted); margin-top: 16px; }

/* ---------- exercise selection landing page ---------- */
.landing-main { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; }
.landing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1080px;
  margin: 0 auto 16px;
}
.landing-toolbar h2 { font-size: calc(18px + var(--ui-font-increase)); }
.view-toggle { display: flex; gap: 6px; }
.view-toggle .btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
}
.exercise-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
a.exercise-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}
.exercise-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px; height: 56px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border);
}
.exercise-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.exercise-text { display: flex; flex-direction: column; gap: 6px; }
.exercise-text strong { font-size: calc(15px + var(--ui-font-increase)); }
.exercise-text small { color: var(--muted); font-size: calc(12px + var(--ui-font-increase)); line-height: 1.5; }
.exercise-card.coming-soon { border-style: dashed; opacity: 0.65; }
/* list view: one full-width row per exercise, icon beside the text */
.exercise-grid.list-view { grid-template-columns: 1fr; }
.exercise-grid.list-view .exercise-card { flex-direction: row; align-items: center; padding: 14px 18px; }
.exercise-grid.list-view .exercise-icon { width: 44px; height: 44px; }
.exercise-grid.list-view .exercise-icon svg { width: 24px; height: 24px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-start { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.topbar-logo { width: 34px; height: 34px; font-size: calc(13px + var(--ui-font-increase)); }
.topbar-title strong { display: block; font-size: calc(14px + var(--ui-font-increase)); }
.topbar-title small { color: var(--muted); font-size: calc(11px + var(--ui-font-increase)); }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.topbar-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.topbar-user { color: var(--muted); font-size: calc(12px + var(--ui-font-increase)); }
.menu-trigger {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 7px;
  justify-content: center;
}
.menu-trigger svg.menu-hamburger { width: 20px; height: 20px; }
.topbar-trefoil {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}
.topbar-trefoil img {
  display: block;
  width: 100%;
  height: 100%;
}

.app-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(12, 20, 28, 0.42);
}
.app-menu-backdrop[hidden] { display: none; }
.app-menu {
  width: min(310px, 88vw);
  height: 100%;
  padding: 16px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  box-shadow: 12px 0 32px rgba(0, 0, 0, 0.24);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: app-menu-enter 0.18s ease-out;
}
@keyframes app-menu-enter { from { transform: translateX(-100%); } to { transform: translateX(0); } }
.app-menu-head { display: flex; align-items: center; justify-content: space-between; }
.app-menu-head h2 { margin: 0; font-size: calc(17px + var(--ui-font-increase)); }
.menu-close {
  border: 0;
  padding: 2px 7px;
  background: transparent;
  color: var(--muted);
  font-size: calc(26px + var(--ui-font-increase));
  line-height: 1;
}
.menu-close:hover { color: var(--text); }
.app-menu-actions { display: flex; flex-direction: column; gap: 7px; }
.app-menu .btn { width: 100%; justify-content: flex-start; padding: 9px 11px; }
.app-menu-account {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.app-menu-account label { font-size: calc(11px + var(--ui-font-increase)); font-weight: 700; text-transform: uppercase; color: var(--muted); }
.app-menu-account .theme-select { width: 100%; }
.app-menu-account .topbar-user { padding: 4px 0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-size: calc(13px + var(--ui-font-increase));
}
.btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; margin-top: 14px; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }

/* ---------- layout ---------- */
.workspace { display: flex; flex: 1; min-height: 0; }

.palette {
  width: 200px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  flex-shrink: 0;
}
.palette h2, .panel h2 {
  font-size: calc(11px + var(--ui-font-increase));
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 14px 0 8px;
}
.palette h2 { font-weight: 700; color: var(--text); }
.panel h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: var(--text);
  background: var(--hover);
  margin: -12px -12px 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.panel-h2-actions { display: flex; gap: 6px; }
.panel-h2-label { display: flex; align-items: center; gap: 6px; }
.panel-toggle-btn {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.panel-toggle-btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; transition: transform 0.15s ease; }
.panel-toggle-btn.collapsed svg { transform: rotate(-90deg); }
.panel-toggle-btn:hover { color: var(--text); }
.panel-clear {
  font-size: calc(10px + var(--ui-font-increase));
  text-transform: none;
  letter-spacing: normal;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel);
  color: var(--muted);
}
.panel-clear:hover { background: var(--hover); color: var(--text); }
.panel-clear[hidden] { display: none; }
.panel-clear.is-loading { display: inline-flex; align-items: center; gap: 5px; cursor: wait; }
.export-spinner {
  display: none;
  width: 11px;
  height: 11px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: export-spin 0.7s linear infinite;
}
.is-loading .export-spinner { display: inline-block; }
@keyframes export-spin { to { transform: rotate(360deg); } }
.palette h2:first-child { margin-top: 0; }
.palette-hint { font-size: calc(11px + var(--ui-font-increase)); color: var(--muted); }
.tool-row { display: flex; gap: 4px; }
.tool-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: calc(12px + var(--ui-font-increase));
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}
.tool-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--item-bg);
  cursor: grab;
  font-size: calc(12px + var(--ui-font-increase));
  user-select: none;
}
.palette-item:hover { border-color: var(--accent); background: var(--item-hover); }
.palette-glyph {
  flex-shrink: 0;
  width: 46px;
  text-align: center;
  font-size: calc(10px + var(--ui-font-increase));
  font-weight: 700;
  padding: 4px 0;
  border-radius: 4px;
  background: var(--glyph-bg);
  color: var(--glyph-fg);
}

.canvas-wrap { flex: 1; position: relative; overflow: hidden; background: var(--canvas-bg); }
.canvas-scroll { width: 100%; height: 100%; overflow: auto; }
.canvas-actions {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 8px;
  z-index: 10;
}
.zoom-controls {
  position: absolute;
  top: 14px;
  right: 18px;
  display: flex;
  gap: 6px;
  z-index: 10;
}
.zoom-controls .btn {
  padding: 5px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
#zoom-reset { min-width: 56px; justify-content: center; }
.canvas-actions .btn {
  padding: 9px 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.check-count {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 0.85em;
  color: var(--muted);
  background: var(--panel);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.check-history {
  padding: 8px 14px 0;
  font-size: 0.9em;
}
.check-history h3 {
  margin: 0 0 4px;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.check-history ul {
  margin: 0 0 8px;
  padding-left: 18px;
  color: var(--muted);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--panel); }
#canvas { display: block; }

.sidebar {
  width: 320px;
  min-width: 280px;
  max-width: min(650px, 55vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
  position: relative;
}
.sidebar-resizer {
  position: absolute;
  z-index: 20;
  top: 0;
  bottom: 0;
  left: -5px;
  width: 10px;
  cursor: ew-resize;
  touch-action: none;
}
.sidebar-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 2px;
  background: transparent;
}
.sidebar-resizer:hover::after, .sidebar-resizer.dragging::after { background: var(--accent); }
body.resizing-sidebar { cursor: ew-resize; user-select: none; }
.panel { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
#properties-panel { flex: 1 1 auto; overflow: hidden; }
#properties-body { flex: 1 1 auto; min-height: 0; }
#results-panel {
  flex: 0 0 var(--results-height, clamp(180px, 36%, 360px));
  overflow: hidden;
  border-bottom: 0;
  border-top: 1px solid var(--border);
}
#results-body { flex: 1 1 auto; min-height: 0; }
#properties-panel.panel-collapsed,
#results-panel.panel-collapsed { flex: 0 0 auto; }
.sidebar:has(#properties-panel.panel-collapsed) #results-panel:not(.panel-collapsed) { flex: 1 1 auto; }
/* Drag handle between Properties and Architecture check, mirroring
   .sidebar-resizer. Hidden when either panel is collapsed — nothing to
   split vertically once one side has no body. */
.panel-resizer {
  flex: 0 0 9px;
  position: relative;
  cursor: ns-resize;
  touch-action: none;
}
.panel-resizer::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 4px;
  height: 2px;
  background: transparent;
}
.panel-resizer:hover::after, .panel-resizer.dragging::after { background: var(--accent); }
.sidebar:has(#properties-panel.panel-collapsed) .panel-resizer,
.sidebar:has(#results-panel.panel-collapsed) .panel-resizer { display: none; }
body.resizing-panels { cursor: ns-resize; user-select: none; }
.panel-body { overflow-y: auto; font-size: calc(13px + var(--ui-font-increase)); }
.prop-type { font-weight: 700; margin-bottom: 4px; }
.prop-hint { font-size: calc(12px + var(--ui-font-increase)); color: var(--muted); margin: 4px 0 8px; }
.prop-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prop-label-row label { margin: 0; }
.prop-input-action { display: flex; align-items: stretch; gap: 5px; }
.prop-input-action input { flex: 1; min-width: 0; }
.prop-combo { position: relative; flex: 1; min-width: 0; display: flex; }
.prop-combo input { flex: 1; min-width: 0; padding-right: 28px; }
.combo-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.combo-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.combo-toggle:hover { color: #0069b4; }
.combo-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 160px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.combo-option { padding: 6px 8px; font-size: calc(13px + var(--ui-font-increase)); cursor: pointer; }
.combo-option:hover { background: var(--item-hover); }
.prop-highlight-all {
  flex: 0 0 34px;
  width: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  background: var(--item-bg);
  color: inherit;
}
.prop-highlight-all svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; }
.prop-highlight-all:hover { border-color: #0069b4; color: #0069b4; }
.prop-highlight-all.active { background: #0069b4; border-color: #0069b4; color: #fff; }
.function-filters {
  flex: 0 0 var(--functions-height, clamp(80px, 28%, 240px));
  order: 99;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding: 10px 12px 12px;
}
.function-filters.function-filters-collapsed { flex: 0 0 auto; }
.function-filters[hidden] { display: none; }
#functions-resizer { order: 98; }
.sidebar:has(#function-filters[hidden]) #functions-resizer,
.sidebar:has(#function-filters.function-filters-collapsed) #functions-resizer { display: none; }
.function-filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--hover);
  margin: -10px -12px 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.function-filters-title { font-size: calc(11px + var(--ui-font-increase)); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.function-clear {
  border: 0;
  padding: 2px 4px;
  background: transparent;
  color: var(--muted);
  font-size: calc(10px + var(--ui-font-increase));
}
.function-clear:hover:not(:disabled) { color: var(--text); text-decoration: underline; }
.function-clear:disabled { opacity: 0.45; cursor: default; }
.function-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.function-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--item-bg);
  color: var(--text);
  font-size: calc(10.5px + var(--ui-font-increase));
  white-space: nowrap;
}
.function-pill:hover { border-color: #0069b4; }
.function-pill.active { background: #0069b4; border-color: #0069b4; color: #fff; }
.prop-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.prop-flows { margin-top: 2px; }
.prop-flow {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 5px 7px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: calc(12px + var(--ui-font-increase));
  cursor: pointer;
}
.prop-flow:hover { background: var(--item-hover); border-color: var(--accent); }
.flow-dir { font-weight: 700; flex-shrink: 0; }
.flow-out { color: var(--accent); }
.flow-in { color: var(--sev-pass); }
.flow-two { color: var(--muted); }

.palette-icon { flex-shrink: 0; }

/* ---------- SVG elements ---------- */
.node { cursor: move; }
.node-hit { fill: transparent; }
.node-outline { fill: none; stroke: none; }
.node.selected .node-outline,
.node.pending .node-outline {
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-dasharray: 7 4;
}
.flash .node-outline { stroke-width: 3 !important; stroke-dasharray: none !important; }
.node-shape {
  fill: var(--node-fill);
  stroke: var(--node-stroke);
  stroke-width: 1.6;
}
.node-shape-internet { fill: var(--node-internet-fill); }
.node-shape-firewall { fill: var(--node-firewall-fill); stroke: var(--node-firewall-stroke); }
.node-shape-diode { fill: var(--node-diode-fill); stroke: var(--node-diode-stroke); }
.node-decor { stroke: var(--decor); stroke-width: 1.2; }
.node-decor-dot { fill: var(--decor); }
.node-decor-fill { fill: var(--node-diode-stroke); }
.node-glyph {
  font-size: calc(12px + var(--ui-font-increase));
  font-weight: 700;
  text-anchor: middle;
  fill: var(--node-glyph);
  pointer-events: none;
}
.node-name {
  font-size: calc(11px + var(--ui-font-increase));
  text-anchor: middle;
  fill: var(--muted);
  pointer-events: none;
}
.node-ip {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: calc(9.5px + var(--ui-font-increase));
  text-anchor: middle;
  fill: var(--muted);
  opacity: 0.85;
  pointer-events: none;
}
.node.selected .node-shape { stroke: var(--accent); stroke-width: 2.5; }
.node.pending .node-shape { stroke: var(--accent); stroke-dasharray: 5 3; stroke-width: 2.5; }
.sl-badge { stroke: var(--badge-ring); stroke-width: 1.5; }
.sl-badge-none { fill: var(--badge-none); }
.sl-badge-text {
  font-size: calc(10px + var(--ui-font-increase));
  font-weight: 700;
  fill: var(--badge-text);
  text-anchor: middle;
  pointer-events: none;
}

.edge-line { stroke: var(--edge); stroke-width: 1.8; fill: none; }
.edge-hit { stroke: transparent; stroke-width: 14; cursor: pointer; fill: none; }
.edge.selected .edge-line { stroke: var(--accent); stroke-width: 2.6; }
.arrow-head { fill: var(--edge); }
.arrow-head-sel { fill: var(--accent); }
.edge-label {
  font-size: calc(10.5px + var(--ui-font-increase));
  fill: var(--muted);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--canvas-bg);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.edge.selected .edge-label { fill: var(--accent); }
.edge-preview, .zone-preview, .band-preview {
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-dasharray: 6 4;
  fill: var(--accent-soft);
  pointer-events: none;
}
.band-preview { stroke-dasharray: 4 3; stroke-width: 1.2; }

.zone-rect { stroke-width: 1.8; stroke-dasharray: 8 5; cursor: move; }
.zone-label { font-size: calc(12px + var(--ui-font-increase)); font-weight: 700; pointer-events: none; }
.zone.selected .zone-rect { stroke-dasharray: none; stroke-width: 2.6; }
.zone-handle { fill: var(--accent); cursor: nwse-resize; }

.flash .node-shape, .flash .zone-rect { stroke-width: 3 !important; }
.flash .edge-line { stroke-width: 3 !important; }

/* Highlight colour follows the finding severity (same palette as the
   findings panel: violation red, warning amber, compliant green, note grey). */
.flash-error .node-outline, .flash-error .node-shape,
.flash-error .zone-rect, .flash-error .edge-line { stroke: var(--sev-error) !important; }
.flash-error .arrow-head { fill: var(--sev-error); }
.flash-warning .node-outline, .flash-warning .node-shape,
.flash-warning .zone-rect, .flash-warning .edge-line { stroke: var(--sev-warning) !important; }
.flash-warning .arrow-head { fill: var(--sev-warning); }
.flash-pass .node-outline, .flash-pass .node-shape,
.flash-pass .zone-rect, .flash-pass .edge-line { stroke: var(--sev-pass) !important; }
.flash-pass .arrow-head { fill: var(--sev-pass); }
.flash-info .node-outline, .flash-info .node-shape,
.flash-info .zone-rect, .flash-info .edge-line { stroke: var(--sev-info) !important; }
.flash-info .arrow-head { fill: var(--sev-info); }

/* Facility-function highlights are deliberately distinct from findings. */
.function-highlight .node-outline, .function-highlight .node-shape {
  stroke: #0069b4 !important;
  stroke-width: 3 !important;
  stroke-dasharray: 7 4 !important;
}

/* ---------- findings ---------- */
.verdict { padding: 8px 10px; border-radius: 6px; font-weight: 600; margin-bottom: 10px; font-size: calc(13px + var(--ui-font-increase)); }
.verdict-pass { background: var(--verdict-pass-bg); color: var(--verdict-pass-fg); }
.verdict-warn { background: var(--verdict-warn-bg); color: var(--verdict-warn-fg); }
.verdict-fail { background: var(--verdict-fail-bg); color: var(--verdict-fail-fg); }
.finding {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
}
.finding:hover, .finding-active { background: var(--item-hover); }
.finding-error { border-left-color: var(--sev-error); }
.finding-warning { border-left-color: var(--sev-warning); }
.finding-pass { border-left-color: var(--sev-pass); }
.finding-info { border-left-color: var(--sev-info); }
.finding-head { font-weight: 600; font-size: calc(12.5px + var(--ui-font-increase)); }
.finding-sev {
  display: inline-block;
  font-size: calc(10px + var(--ui-font-increase));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 4px;
  color: var(--sev-text);
  background: var(--sev-info);
}
.finding-error .finding-sev { background: var(--sev-error); }
.finding-warning .finding-sev { background: var(--sev-warning); }
.finding-pass .finding-sev { background: var(--sev-pass); }
.finding-detail { font-size: calc(12px + var(--ui-font-increase)); color: var(--muted); margin-top: 4px; }

/* ---------- guidance modal ---------- */
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--panel);
  border-radius: 12px;
  width: min(900px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}
.modal-small { width: min(480px, 92vw); }

/* file save/load dialogs — inherit the theme via the palette variables */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}
.file-list-section + .file-list-section { margin-top: 14px; }
.file-list-heading {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: calc(10px + var(--ui-font-increase));
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--item-bg);
  color: var(--text);
  text-align: left;
}
.file-item:hover { background: var(--item-hover); border-color: var(--accent); }
.file-item-name { font-weight: 600; overflow-wrap: anywhere; }
.file-item-date { color: var(--muted); font-size: calc(11px + var(--ui-font-increase)); flex-shrink: 0; }
#file-modal .modal-actions { margin-top: 16px; }
.report-format {
  display: flex;
  gap: 18px;
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.report-format[hidden] { display: none; }
.report-format legend { padding: 0 5px; font-weight: 600; }
.report-format label { display: flex; align-items: center; gap: 6px; margin: 0; }
.report-format input { width: auto; margin: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: calc(16px + var(--ui-font-increase)); }
.modal-close {
  border: none;
  background: none;
  font-size: calc(24px + var(--ui-font-increase));
  line-height: 1;
  color: var(--muted);
}
.modal-body { padding: 18px; overflow-y: auto; font-size: calc(13px + var(--ui-font-increase)); }
.sl-table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: calc(12.5px + var(--ui-font-increase)); }
.sl-table th, .sl-table td {
  border: 1px solid var(--border);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
}
.sl-table th { background: var(--hover); }
.sl-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--badge-text);
  font-weight: 700;
  font-size: calc(11px + var(--ui-font-increase));
}
.sl-chip.sl-1 { background: var(--sl1); }
.sl-chip.sl-2 { background: var(--sl2); }
.sl-chip.sl-3 { background: var(--sl3); }
.sl-chip.sl-4 { background: var(--sl4); }
.sl-chip.sl-5 { background: var(--sl5); }
