:root {
  color-scheme: light;
  --ink: #182322;
  --muted: #5b6866;
  --line: #d9dfdc;
  --surface: #f7f8f5;
  --panel: #ffffff;
  --green: #1f7a4d;
  --blue: #2d6cdf;
  --coral: #d85d3f;
  --amber: #b7791f;
  --mint: #dff3e8;
  --sky: #e4efff;
  --shadow: 0 18px 48px rgba(18, 35, 33, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px;
  color: #f7fbf8;
  background: #12322b;
}

.brand,
.sidebar-status,
.topbar,
.actions,
.panel-heading,
.section-heading,
.range-row,
.toggle-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #12322b;
  background: #a8e8c5;
  font-weight: 800;
}

.brand strong,
.brand span,
.sidebar-status strong,
.sidebar-status span {
  display: block;
}

.brand span,
.sidebar-status span {
  color: rgba(247, 251, 248, 0.7);
  font-size: 0.82rem;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(247, 251, 248, 0.72);
  text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-status {
  gap: 10px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6ee7a8;
  box-shadow: 0 0 0 6px rgba(110, 231, 168, 0.14);
}

.main-panel {
  display: grid;
  gap: 20px;
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar,
.section-heading,
.panel-heading {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.96;
}

h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
}

.actions {
  gap: 10px;
}

.icon-button,
.primary-action,
.ghost-action {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 750;
}

.icon-button {
  width: 42px;
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}

.primary-action {
  padding: 0 16px;
  color: #ffffff;
  background: var(--green);
}

.primary-action:hover {
  background: #17623d;
}

.ghost-action {
  padding: 0 14px;
  color: var(--green);
  background: transparent;
  border-color: var(--line);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card,
.control-panel,
.deploy-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(18, 35, 33, 0.04);
}

.metric-card {
  display: grid;
  gap: 6px;
  min-height: 132px;
  padding: 18px;
}

.metric-card span,
.metric-card small,
.deploy-panel p,
.toggle-row small {
  color: var(--muted);
}

.metric-card strong {
  font-size: 2rem;
  line-height: 1;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
  gap: 20px;
  align-items: stretch;
}

.edge-map {
  position: relative;
  min-height: 440px;
  overflow: hidden;
  border: 1px solid #cdd7d4;
  border-radius: 8px;
  background: #edf5ef;
  box-shadow: var(--shadow);
}

.edge-map img {
  width: 100%;
  height: 100%;
  min-height: 440px;
  object-fit: cover;
  display: block;
}

.edge-map-copy {
  position: absolute;
  left: 24px;
  bottom: 24px;
  display: grid;
  gap: 6px;
  max-width: min(360px, calc(100% - 48px));
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
}

.edge-map-copy span,
.edge-map-copy small {
  color: var(--muted);
}

.edge-map-copy strong {
  font-size: 1.4rem;
}

.control-panel {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 20px;
}

.chip {
  padding: 5px 8px;
  border-radius: 999px;
  color: #16412e;
  background: var(--mint);
  font-size: 0.78rem;
  font-weight: 800;
}

label,
legend {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 750;
}

input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfa;
}

input[type="text"]:focus-visible,
input[type="range"]:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(45, 108, 223, 0.34);
  outline-offset: 2px;
}

.range-row {
  gap: 12px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

output {
  min-width: 74px;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: right;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ef;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  min-height: 36px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  text-align: center;
}

.segmented input:checked + span {
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(18, 35, 33, 0.12);
}

.toggle-row {
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.toggle-row span,
.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row input {
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
  accent-color: var(--green);
}

.full-width {
  width: 100%;
}

.rules-grid {
  display: grid;
  gap: 14px;
}

.rules-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.rule-card {
  display: grid;
  gap: 12px;
  min-height: 160px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: var(--panel);
}

.rule-card[data-profile="aggressive"] {
  border-left-color: var(--green);
}

.rule-card[data-profile="conservative"] {
  border-left-color: var(--amber);
}

.rule-card strong {
  overflow-wrap: anywhere;
}

.rule-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.rule-meta span {
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: #eef2ef;
  font-size: 0.76rem;
  font-weight: 700;
}

.rule-remove {
  justify-self: start;
  padding: 0;
  border: 0;
  color: var(--coral);
  background: transparent;
  font-weight: 800;
}

.deploy-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: center;
  padding: 22px;
}

pre {
  margin: 0;
  overflow-x: auto;
  padding: 16px;
  border-radius: 8px;
  color: #f6fbf8;
  background: #182322;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .nav-list {
    grid-template-columns: repeat(3, auto);
  }

  .sidebar-status {
    margin-top: 0;
    margin-left: auto;
  }

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

  .workbench,
  .deploy-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .sidebar,
  .main-panel {
    padding: 18px;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
  }

  .primary-action:not(.full-width) {
    flex: 1;
  }

  .metric-strip,
  .rules-list {
    grid-template-columns: 1fr;
  }

  .nav-list {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
  }

  .sidebar-status {
    width: 100%;
    margin-left: 0;
  }

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

  .edge-map,
  .edge-map img {
    min-height: 360px;
  }
}
