:root {
  --bg: #0a0e17;
  --bg2: #111827;
  --bg3: #1a2235;
  --border: #1e2d44;
  --text: #c9d1d9;
  --text-dim: #6b7b8d;
  --text-bright: #e6edf3;
  --green: #00d68f;
  --green-dim: rgba(0,214,143,0.12);
  --red: #ff6b6b;
  --red-dim: rgba(255,107,107,0.1);
  --orange: #f0a030;
  --orange-dim: rgba(240,160,48,0.1);
  --blue: #58a6ff;
  --blue-dim: rgba(88,166,255,0.1);
  --purple: #bc8cff;
  --purple-dim: rgba(188,140,255,0.1);
  --cyan: #39d2c0;
  --cyan-dim: rgba(57,210,192,0.12);
  --yellow: #ffd43b;
  --yellow-dim: rgba(255,212,59,0.12);
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 24px;
}

h1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

h1 span { color: var(--green); }

.subtitle {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 32px;
  font-family: 'JetBrains Mono', monospace;
}

/* ===== CONFIG PANEL ===== */
.config-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
  margin-bottom: 32px;
}

.config-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 18px;
  font-weight: 600;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.3s;
  min-width: 0;
}

.config-item:hover { border-color: #2a3a5a; }

.config-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex-shrink: 1;
}

.config-label .label-main {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
}

.config-label .label-sub {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.3;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: #2a3040;
  border-radius: 12px;
  transition: background 0.3s;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch.on { background: var(--green); }

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.3s;
}

.toggle-switch.on::after { transform: translateX(20px); }

/* Segmented selector for multi-option toggles */
.seg-control {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  flex-shrink: 0;
}

.seg-btn {
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
  transition: all 0.25s;
  border: none;
  background: transparent;
  white-space: nowrap;
}

.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--bg3);
  color: var(--text-bright);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Tab switcher */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
  border: 1px solid var(--border);
}

.tab {
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
  transition: all 0.25s;
  border: none;
  background: transparent;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }
.tab.active {
  background: var(--bg3);
  color: var(--text-bright);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Flow sections */
.flow-section { display: none; }
.flow-section.active { display: block; }

.flow-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.flow-title .icon { font-size: 22px; }

/* ===== FLOWCHART ===== */
.flowchart-container {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 24px;
  margin-bottom: 28px;
  overflow-x: auto;
}

.flow-pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: fit-content;
  justify-content: center;
}

.flow-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 100px;
  max-width: 130px;
  text-align: center;
  position: relative;
  transition: all 0.3s ease;
}

.flow-stage.hidden-stage {
  display: none;
}

.stage-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border: 2px solid var(--border);
  background: var(--bg3);
  transition: all 0.3s;
  position: relative;
}

.stage-icon.protected {
  border-color: var(--green);
  box-shadow: 0 0 16px rgba(0,214,143,0.15);
}

.stage-icon.vulnerable {
  border-color: var(--red);
  box-shadow: 0 0 16px rgba(255,107,107,0.15);
}

.stage-icon.neutral {
  border-color: var(--border);
}

.stage-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-bright);
}

.stage-detail {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.3;
}

/* Connection arrows */
.flow-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  min-width: 50px;
  flex-shrink: 1;
  transition: all 0.3s ease;
}

.flow-arrow.hidden-stage {
  display: none;
}

.arrow-line {
  width: 100%;
  height: 2px;
  position: relative;
  display: flex;
  align-items: center;
}

.arrow-line::before {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
  transition: background 0.3s;
}

.arrow-line.encrypted::before {
  background: var(--green);
  box-shadow: 0 0 6px rgba(0,214,143,0.3);
}

.arrow-line.cleartext::before {
  background: var(--red);
  box-shadow: 0 0 6px rgba(255,107,107,0.3);
}

.arrow-line::after {
  content: '\25B8';
  color: var(--text-dim);
  font-size: 12px;
  margin-left: -2px;
}

.arrow-line.encrypted::after { color: var(--green); }
.arrow-line.cleartext::after { color: var(--red); }

.arrow-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text-dim);
  white-space: nowrap;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
}

.arrow-label.encrypted { color: var(--green); background: var(--green-dim); }
.arrow-label.cleartext { color: var(--red); background: var(--red-dim); }

/* Shield badge on flow stage */
.shield-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  z-index: 1;
}

.shield-badge.good { background: var(--green); color: #0a0e17; }
.shield-badge.bad { background: var(--red); color: white; }
.shield-badge.warn { background: var(--orange); color: #0a0e17; }

/* ===== LEGEND ===== */
.legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ===== VULNERABILITY CARDS ===== */
.vuln-layer {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.vuln-card {
  background: var(--bg2);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color 0.3s, transform 0.2s;
}

.vuln-card:hover { border-color: #2a3a5a; transform: translateY(-1px); }

.vuln-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.vuln-header .who {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
}

.vuln-header .threat-level {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.threat-high { background: var(--red-dim); color: var(--red); }
.threat-med { background: var(--orange-dim); color: var(--orange); }
.threat-low { background: var(--green-dim); color: var(--green); }
.threat-none { background: var(--blue-dim); color: var(--blue); }

.vuln-body { padding: 16px 18px; }

.vuln-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  align-items: flex-start;
}
.vuln-row:last-child { margin-bottom: 0; }

.vuln-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 2px;
}

.vuln-icon.sees { background: var(--red-dim); color: var(--red); }
.vuln-icon.blocked { background: var(--green-dim); color: var(--green); }
.vuln-icon.partial { background: var(--orange-dim); color: var(--orange); }

.vuln-text { font-size: 13px; line-height: 1.5; }
.vuln-text strong { color: var(--text-bright); font-weight: 600; }

.vuln-text .defense {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  margin-left: 4px;
  font-weight: 500;
}

.def-https { background: var(--green-dim); color: var(--green); }
.def-vpn { background: var(--blue-dim); color: var(--blue); }
.def-brave { background: var(--orange-dim); color: var(--orange); }
.def-chrome { background: var(--yellow-dim); color: var(--yellow); }
.def-ddg { background: var(--purple-dim); color: var(--purple); }
.def-google { background: var(--purple-dim); color: var(--purple); }
.def-none { background: var(--red-dim); color: var(--red); }
.def-dns { background: var(--cyan-dim); color: var(--cyan); }

/* ===== MATRIX ===== */
.matrix-section { margin-top: 48px; }

.matrix-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 20px;
}

.matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  font-size: 13px;
}

.matrix th {
  background: var(--bg3);
  padding: 12px 16px;
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.matrix td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  vertical-align: top;
}

.matrix tr:last-child td { border-bottom: none; }

.matrix .entity {
  font-weight: 600;
  color: var(--text-bright);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  white-space: nowrap;
}

.cell-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  text-align: center;
  line-height: 18px;
  font-size: 10px;
  margin-right: 6px;
  vertical-align: middle;
}

.ci-yes { background: var(--red-dim); color: var(--red); }
.ci-no { background: var(--green-dim); color: var(--green); }
.ci-partial { background: var(--orange-dim); color: var(--orange); }

/* ===== GAPS ===== */
.gaps-section { margin-top: 48px; }

.gap-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 14px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: border-color 0.3s;
}

.gap-card:hover { border-color: #2a3a5a; }

.gap-severity {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 56px;
  text-align: center;
}

.severity-high { background: var(--red-dim); color: var(--red); }
.severity-med { background: var(--orange-dim); color: var(--orange); }
.severity-low { background: var(--green-dim); color: var(--green); }
.severity-info { background: var(--blue-dim); color: var(--blue); }

/* Risk level legend */
.risk-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
}

.risk-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.risk-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gap-content h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 4px;
}

.gap-content p {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
}

.gap-content .fix {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--green-dim);
  color: var(--green);
  margin-top: 6px;
  font-weight: 500;
}

/* Score bar */
.score-section {
  margin-bottom: 32px;
}

.score-bar-container {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
}

.score-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.score-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
}

.score-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 700;
}

.score-track {
  width: 100%;
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 12px;
}

.score-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease, background 0.5s ease;
}

.score-breakdown {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Note box */
.note-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 20px;
  line-height: 1.6;
  transition: border-left-color 0.3s;
}

.note-box .summary-phrase { font-weight: 700; transition: color 0.3s; }

/* Section dividers */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0 32px;
}

/* Active stack summary */
.active-stack {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.stack-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid var(--border);
  background: var(--bg2);
  transition: all 0.3s;
}

.stack-chip.active-on { border-color: var(--green); color: var(--green); }
.stack-chip.active-off { border-color: var(--red); color: var(--red); opacity: 0.6; }
.stack-chip.active-choice { border-color: var(--blue); color: var(--blue); }

/* ===== RESPONSIVE ===== */

/* Large tablets / small desktops */
@media (max-width: 1100px) {
  .config-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tablets */
@media (max-width: 900px) {
  .config-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .vuln-layer {
    grid-template-columns: 1fr;
  }
  .score-breakdown {
    flex-direction: column;
    gap: 8px;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .container {
    padding: 20px 12px;
  }
  h1 {
    font-size: 22px;
  }
  .config-panel {
    padding: 16px 14px;
  }
  .config-grid {
    grid-template-columns: 1fr;
  }
  .config-item {
    flex-wrap: wrap;
    gap: 8px;
  }
  .seg-control {
    width: 100%;
    justify-content: stretch;
  }
  .seg-btn {
    flex: 1;
    text-align: center;
  }
  .tabs {
    width: 100%;
  }
  .tab {
    flex: 1;
    text-align: center;
    padding: 10px 12px;
    font-size: 12px;
  }
  .flow-pipeline {
    justify-content: flex-start;
  }
  .flowchart-container {
    padding: 20px 12px;
  }
  .score-bar-container {
    padding: 16px 14px;
  }
  .score-value {
    font-size: 22px;
  }
  .vuln-layer {
    grid-template-columns: 1fr;
  }
  .gap-card {
    flex-direction: column;
    gap: 10px;
  }
}
