:root {
  --bg: #f8fafd;
  --surface: #ffffff;
  --surface-subtle: #f1f3f4;
  --surface-hover: #f6f8fa;
  --text: #202124;
  --text-muted: #5f6368;
  --text-subtle: #80868b;
  --border: #dadce0;
  --border-strong: #bdc1c6;
  --primary: #1a73e8;
  --primary-hover: #1558b0;
  --primary-soft: #e8f0fe;
  --green: #188038;
  --red: #d93025;
  --amber: #b06000;
  --blue: #1a73e8;
  --shadow-1: 0 1px 2px rgba(60, 64, 67, 0.15);
  --shadow-2: 0 1px 3px rgba(60, 64, 67, 0.18), 0 4px 8px rgba(60, 64, 67, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, Roboto, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.container {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 16px;
}

.app-header {
  position: sticky;
  top: 12px;
  z-index: 30;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.hero {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.eyebrow {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.hero h1,
.controls h2,
.metrics h2,
.chart h2 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
}

.hero h1 {
  font-size: 1.65rem;
  font-weight: 600;
}

.hero p,
.hint {
  margin: 0;
  color: var(--text-muted);
}

.header-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.github-cta {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  color: #3c4043;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
}

.github-cta svg {
  fill: currentColor;
}

.github-cta:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.guide-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.guide-strip div {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 13px 14px;
  background: var(--surface);
}

.guide-strip strong {
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}

.guide-strip span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.sidebar,
.content {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.sidebar {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding-right: 3px;
  scrollbar-gutter: stable;
  counter-reset: control-step;
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #c9cdd1;
  border-radius: 999px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.panel-heading {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.controls .panel-heading {
  align-items: flex-start;
  justify-content: flex-start;
}

.controls .panel-heading::before {
  counter-increment: control-step;
  content: counter(control-step);
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  margin-top: 1px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.panel-heading > div {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.panel-copy {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.panel-collapse-btn {
  width: auto;
  min-width: 72px;
  min-height: 30px;
  padding: 5px 10px;
  margin-left: auto;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  font-weight: 600;
}

.panel-collapse-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.panel.is-collapsed > :not(.panel-heading) {
  display: none;
}

.panel.is-collapsed .panel-heading {
  border-bottom: 0;
}

.grid,
.compact-grid {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.grid {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

#trafficPanel .grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#trafficPanel .checkbox-field {
  grid-column: 1 / -1;
}

.distribution-field {
  grid-column: 1 / -1;
}

.compact-grid {
  grid-template-columns: 1fr;
  padding-bottom: 0;
}

label {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(18px, auto) minmax(40px, auto) auto auto;
  align-content: start;
  gap: 6px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
}

label > span:first-child {
  min-height: 18px;
  display: flex;
  align-items: end;
  line-height: 1.2;
}

.field-unit {
  min-height: 17px;
  color: var(--text-subtle);
  font-size: 0.74rem;
  font-weight: 400;
  line-height: 1.25;
}

.range-input {
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  accent-color: var(--primary);
}

input,
select,
button {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  font-size: 0.92rem;
  background: var(--surface);
  color: var(--text);
}

input,
select {
  min-height: 40px;
}

input:hover,
select:hover {
  border-color: #8a9097;
}

input:focus,
select:focus,
button:focus-visible,
.github-cta:focus-visible {
  outline: 2px solid var(--primary-soft);
  outline-offset: 2px;
  border-color: var(--primary);
}

button {
  border-color: transparent;
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: var(--primary-hover);
}

.run-button {
  width: auto;
  min-width: 170px;
  min-height: 42px;
  display: inline-grid;
  gap: 1px;
  justify-items: start;
  padding: 8px 16px;
  white-space: nowrap;
}

.run-button span {
  line-height: 1.1;
}

.run-button small {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.1;
}

.run-button {
  position: relative;
  overflow: hidden;
  transition: transform 140ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.run-button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,0.18) 35%, transparent 70%);
  transform: translateX(-130%);
  pointer-events: none;
}

.run-button[data-state="stale"] {
  background: #d93025;
  box-shadow: 0 0 0 0 rgba(217, 48, 37, 0.28);
  animation: runPulse 1.6s ease-in-out infinite;
}

.run-button[data-state="stale"]:hover {
  background: #b3261e;
}

.run-button[data-state="running"] {
  background: #1558b0;
  animation: none;
}

.run-button[data-state="running"]::after {
  animation: runSweep 900ms linear infinite;
}

.run-button:disabled {
  cursor: progress;
}

.pressure-map {
  display: grid;
  gap: 14px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 16px;
  scrollbar-gutter: stable;
}

.pressure-map::-webkit-scrollbar {
  height: 10px;
}

.pressure-map::-webkit-scrollbar-thumb {
  background: #c9cdd1;
  border-radius: 999px;
}

.placement-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  color: #3c4043;
  background: #f6f8fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
}

.placement-note strong {
  flex: 0 0 auto;
  color: var(--text);
  font-weight: 600;
}

.placement-note span {
  min-width: 0;
  color: var(--text-muted);
  text-align: right;
}

.cause-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.46fr);
  gap: 12px;
  padding: 12px;
  background: #f1f8f4;
  border: 1px solid #ceead6;
  border-left: 4px solid var(--green);
  border-radius: 6px;
}

.cause-summary[data-kind="warn"] {
  background: #fff8e6;
  border-color: #fddc9c;
  border-left-color: var(--amber);
}

.cause-summary[data-kind="bad"] {
  background: #fce8e6;
  border-color: #f5c1bc;
  border-left-color: var(--red);
}

.cause-summary div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.cause-summary strong {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

.cause-summary span,
.cause-summary p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.cause-summary p {
  color: var(--text);
}

.pressure-flow {
  min-width: 1400px;
  display: grid;
  grid-template-columns: minmax(125px, 0.95fr) 64px minmax(145px, 1fr) 64px minmax(155px, 1.08fr) 64px minmax(155px, 1.08fr) 64px minmax(155px, 1.08fr) 64px minmax(135px, 0.95fr);
  gap: 8px;
  align-items: stretch;
}

.pressure-stage {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: 8px;
}

.pressure-stage[data-state="warn"] {
  border-left-color: var(--amber);
  background: #fffaf2;
}

.pressure-stage[data-state="bad"] {
  border-left-color: var(--red);
  background: #fff7f6;
}

.pressure-stage-head {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.stage-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--green);
}

.pressure-stage[data-state="warn"] .stage-dot {
  background: var(--amber);
}

.pressure-stage[data-state="bad"] .stage-dot {
  background: var(--red);
}

.pressure-stage[data-state="info"] {
  border-left-color: #7b858f;
  background: #f8fafd;
}

.pressure-stage[data-state="info"] .stage-dot {
  background: #7b858f;
}

.pressure-stage h3,
.pressure-stage p {
  margin: 0;
}

.pressure-stage h3 {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 650;
}

.pressure-stage p {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.pressure-stage-head strong {
  width: max-content;
  display: inline-flex;
  margin: 4px 0 5px;
  padding: 3px 6px;
  color: var(--green);
  background: #e6f4ea;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
}

.pressure-stage[data-state="warn"] .pressure-stage-head strong {
  color: #8a4b00;
  background: #fff0d6;
}

.pressure-stage[data-state="bad"] .pressure-stage-head strong {
  color: #b3261e;
  background: #fce8e6;
}

.pressure-stage[data-state="info"] .pressure-stage-head strong {
  color: #59636e;
  background: #eceff3;
}

.stage-meter {
  height: 7px;
  overflow: hidden;
  background: #e8eaed;
  border-radius: 999px;
}

.stage-meter span {
  display: block;
  height: 100%;
  min-width: 5px;
  max-width: 100%;
  background: var(--green);
  border-radius: inherit;
}

.pressure-stage[data-state="warn"] .stage-meter span {
  background: var(--amber);
}

.pressure-stage[data-state="bad"] .stage-meter span {
  background: var(--red);
}

.pressure-stage[data-state="info"] .stage-meter span {
  background: #7b858f;
}

.stage-pressure-level {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: #f1f8f4;
  border: 1px solid #ceead6;
  border-radius: 6px;
}

.stage-pressure-level[data-kind="warn"] {
  background: #fff8e6;
  border-color: #fddc9c;
}

.stage-pressure-level[data-kind="bad"] {
  background: #fce8e6;
  border-color: #f5c1bc;
}

.stage-pressure-level span {
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.stage-pressure-level strong {
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 750;
}

.pressure-stage dl {
  min-width: 0;
  display: grid;
  gap: 7px;
  margin: 0;
}

.pressure-stage dl div {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.pressure-stage dt,
.pressure-stage dd {
  margin: 0;
  font-size: 0.74rem;
}

.pressure-stage dt {
  color: var(--text-muted);
}

.pressure-stage dd {
  color: var(--text);
  font-weight: 650;
  text-align: right;
}

.pressure-edge {
  min-width: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 0.68rem;
  text-align: center;
}

.pressure-edge::before {
  content: "";
  display: block;
  width: 100%;
  height: 2px;
  background: var(--border-strong);
}

.pressure-edge::after {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--border-strong);
  border-right: 2px solid var(--border-strong);
  transform: rotate(45deg);
}

.pressure-edge strong {
  color: var(--text);
  font-size: 0.78rem;
}

.pressure-edge[data-kind="ok"]::before {
  background: var(--green);
}

.pressure-edge[data-kind="ok"]::after {
  border-color: var(--green);
}

.pressure-edge[data-kind="bad"]::before {
  background: var(--red);
}

.pressure-edge[data-kind="bad"]::after {
  border-color: var(--red);
}

.protection-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.protection-strip div {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  background: #f6f8fa;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.protection-strip div[data-kind="ok"] {
  background: #f1f8f4;
  border-color: #ceead6;
}

.protection-strip div[data-kind="warn"] {
  background: #fff8e6;
  border-color: #fddc9c;
}

.protection-strip div[data-kind="bad"] {
  background: #fce8e6;
  border-color: #f5c1bc;
}

.protection-strip span {
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.protection-strip strong {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: right;
}

@keyframes runPulse {
  0%, 100% { transform: translateY(0); box-shadow: 0 0 0 0 rgba(217, 48, 37, 0.08); }
  50% { transform: translateY(-1px); box-shadow: 0 6px 18px 0 rgba(217, 48, 37, 0.18); }
}

@keyframes runSweep {
  from { transform: translateX(-130%); }
  to { transform: translateX(130%); }
}

.window-stack {
  display: grid;
  gap: 10px;
  padding: 16px;
  padding-top: 12px;
}

.window-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.window-head > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.window-head strong {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
}

.window-head span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

#addWindowBtn {
  width: auto;
  min-height: 34px;
  padding: 7px 11px;
  color: var(--primary);
  background: var(--surface);
  border-color: var(--border);
}

#addWindowBtn:hover {
  background: var(--primary-soft);
  border-color: #c6dafc;
}

#windowRows {
  display: grid;
  gap: 8px;
}

.window-empty {
  margin: 0;
  padding: 12px;
  color: var(--text-muted);
  background: var(--surface-subtle);
  border-radius: var(--radius);
  font-size: 0.82rem;
}

.window-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.window-rule-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 2px;
}

.window-rule-header > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.window-rule-title {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.window-rule-summary {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.window-algorithm {
  flex: 0 0 auto;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  color: var(--text-muted);
  background: var(--surface-subtle);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 500;
  white-space: nowrap;
}

.algorithm-note {
  display: none;
}

.window-row button {
  width: auto;
  min-width: 78px;
  height: 40px;
  color: var(--red);
  background: var(--surface);
  border-color: var(--border);
}

.window-row button:hover {
  background: #fce8e6;
}

.hint {
  padding: 0 16px 16px;
  font-size: 0.82rem;
}

.mini-chart {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.mini-chart span {
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.mini-chart canvas {
  width: 150px;
  height: 38px;
  background: transparent;
  border: 0;
}

.metrics {
  box-shadow: var(--shadow-2);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 0;
  border-top: 1px solid var(--border);
}

.kpi {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.kpi .name {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.kpi .value {
  margin-top: 6px;
  color: var(--text);
  font-size: 1.12rem;
  font-weight: 600;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.kpi[data-kind="served"] {
  box-shadow: inset 3px 0 0 var(--green);
}

.kpi[data-kind="danger"] {
  box-shadow: inset 3px 0 0 var(--red);
}

.kpi[data-kind="latency"] {
  box-shadow: inset 3px 0 0 var(--blue);
}

.kpi[data-kind="queue"] {
  box-shadow: inset 3px 0 0 var(--amber);
}

.chart .panel-heading {
  border-bottom: 0;
}

.chart-frame {
  position: relative;
  padding: 0 16px 16px;
}

.chart-status-label {
  margin: 0 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  color: var(--green);
  background: #edf7ee;
  border: 1px solid #cce7d0;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}

canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

canvas:focus {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.chart canvas {
  min-height: 280px;
}

.dist-stats {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.status-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.status-stat {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.status-stat span {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.status-stat strong {
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}

.status-stat small {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.status-stat.ok {
  border-color: #cce7d0;
  background: #edf7ee;
}

.status-stat.warn {
  border-color: #f3d2ce;
  background: #fef3f2;
}

.status-stat.bad {
  border-color: #e3d3f7;
  background: #f7f1fe;
}

.dist-stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
}

.dist-stat {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.dist-stat:first-child {
  border-left: 1px solid var(--border);
  border-top-left-radius: 0;
  border-bottom-left-radius: var(--radius);
}

.dist-stat:last-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: var(--radius);
}

.dist-stat span {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.dist-stat strong {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  max-width: calc(100% - 16px);
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-1);
  font-size: 0.72rem;
  backdrop-filter: blur(8px);
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}

.tooltip-time {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-weight: 600;
}

.tooltip-chip {
  flex: 0 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.tooltip-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--chip-color);
  border-radius: 999px;
}

.tooltip-chip b {
  color: var(--text);
  font-weight: 600;
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.toggles label {
  width: auto;
  min-height: 32px;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
}

.toggles label.is-required {
  color: var(--text);
  background: var(--surface-subtle);
  border-color: var(--border-strong);
}

.toggles label::before {
  content: "";
  width: 9px;
  height: 9px;
  background: var(--legend-color, #5f6368);
  border-radius: 999px;
}

.toggles input[type="checkbox"] {
  width: 14px;
  height: 14px;
  min-height: 14px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
}

.toggles input[type="checkbox"]:disabled {
  cursor: not-allowed;
}

@media (max-width: 1320px) {
  .system-summary-strip,
  .status-stats,
  .dist-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

}

@media (max-width: 1100px) {
  .guide-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    grid-template-columns: repeat(2, minmax(320px, 1fr));
    overflow: visible;
    padding-right: 0;
  }

  .protection-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .system-summary-strip,
  .status-stats,
  .dist-stats-grid,
  .protection-strip {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 12px;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .guide-strip {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 1.38rem;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .grid,
  .window-row,
  .mini-chart {
    grid-template-columns: 1fr;
  }

  #trafficPanel .grid {
    grid-template-columns: 1fr;
  }

  .window-rule-header,
  .window-head {
    flex-direction: column;
  }

  .run-button,
  #addWindowBtn,
  .window-row button {
    width: 100%;
  }

  .panel-heading,
  .grid,
  .compact-grid,
  .window-stack,
  .chart-frame,
  .toggles,
  .pressure-map {
    padding-left: 12px;
    padding-right: 12px;
  }

  .placement-note {
    align-items: flex-start;
    flex-direction: column;
  }

  .placement-note span {
    text-align: left;
  }

  .cause-summary {
    grid-template-columns: 1fr;
  }
}

.page-footer {
  display: flex;
  justify-content: flex-end;
  padding: 4px 2px 0;
}

.about-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
}

.about-link:hover {
  color: var(--primary);
}

.checkbox-field {
  gap: 8px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 0.92rem;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}
