:root {
  color-scheme: dark;
  --bg: #081018;
  --band: #0d1720;
  --panel: #121f2a;
  --panel-2: #162736;
  --line: rgba(226, 235, 242, 0.14);
  --line-strong: rgba(226, 235, 242, 0.26);
  --text: #edf5f7;
  --muted: #9db0bb;
  --teal: #22b8a9;
  --blue: #3f8cff;
  --amber: #e8b44f;
  --red: #f06b64;
  --green: #6fd190;
  --max: 1280px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 16, 24, 0.94);
  backdrop-filter: blur(14px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.1;
}

h2 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
}

h3 {
  font-size: 17px;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

nav a,
.command,
.file-button,
.segmented button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101c27;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

nav a:hover,
.command:hover,
.file-button:hover,
.segmented button:hover {
  border-color: var(--line-strong);
  background: #172838;
}

main {
  min-height: 100vh;
}

.band {
  padding: 42px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: var(--band);
}

.band:nth-child(even) {
  background: #0a131c;
}

.section-head {
  width: min(100%, var(--max));
  margin: 0 auto 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.section-head > .command + .file-button {
  margin-left: auto;
}

.status-pill {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--amber);
  background: rgba(232, 180, 79, 0.1);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.metrics-grid,
.workspace-grid,
.network-layout,
.scenario-grid,
.results-grid,
.handoff-grid {
  width: min(100%, var(--max));
  margin: 0 auto;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card {
  min-height: 96px;
  padding: 14px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.workspace-grid,
.results-grid,
.handoff-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.run-status {
  width: min(100%, var(--max));
  margin: 0 auto 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101c27;
  color: var(--muted);
  padding: 12px 14px;
  font-weight: 700;
}

.run-status.running {
  border-color: rgba(232, 180, 79, 0.45);
  color: var(--amber);
}

.run-status.done {
  border-color: rgba(111, 209, 144, 0.45);
  color: var(--green);
}

.run-status.error {
  border-color: rgba(240, 107, 100, 0.45);
  color: var(--red);
}

.panel {
  padding: 18px;
}

.panel h3 {
  margin-bottom: 14px;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.pipeline li {
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 13px;
  background: var(--panel-2);
}

.pipeline span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--teal);
  color: #04120f;
  font-weight: 900;
}

.pipeline strong,
.pipeline small {
  display: block;
}

.pipeline strong {
  margin: 12px 0 5px;
}

.pipeline small,
.muted,
.panel p,
.panel li {
  color: var(--muted);
  line-height: 1.5;
}

.tool-list,
.metric-list {
  display: grid;
  gap: 10px;
}

.tool-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.tool-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.badge {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.ok {
  color: var(--green);
  background: rgba(111, 209, 144, 0.12);
}

.warn {
  color: var(--amber);
  background: rgba(232, 180, 79, 0.12);
}

.network-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 480px;
  gap: 16px;
}

.schematic {
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #071018;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 100%;
}

.table-panel {
  min-width: 0;
}

.table-tools,
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

input,
select {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c1720;
  color: var(--text);
  padding: 0 11px;
}

.table-tools input {
  flex: 1;
}

.table-tools select {
  width: 110px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  min-height: 34px;
  border-color: transparent;
}

.segmented .active {
  background: var(--teal);
  color: #031715;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.scenario-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  cursor: pointer;
}

.scenario-card.active {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px rgba(34, 184, 169, 0.5);
}

.scenario-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.scenario-editor {
  width: min(100%, var(--max));
  margin: 0 auto;
}

.modelopti-editor {
  margin-top: 16px;
}

.wide-command {
  margin-top: 16px;
  width: 100%;
}

.editor-head span {
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

output {
  color: var(--text);
  font-size: 13px;
}

pre {
  margin: 16px 0 0;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #071018;
  color: #c9e8df;
  padding: 14px;
  font-size: 12px;
}

.file-button input {
  display: none;
}

code {
  display: block;
  margin-bottom: 12px;
  color: #bfeadd;
  overflow-wrap: anywhere;
}

.handoff ul {
  padding-left: 18px;
  margin: 0;
}

@media (max-width: 1040px) {
  .metrics-grid,
  .scenario-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace-grid,
  .network-layout,
.results-grid,
.handoff-grid {
    grid-template-columns: 1fr;
  }

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

.trend-panel {
  width: min(100%, var(--max));
  margin: 16px auto 0;
}

#trendCanvas {
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #071018;
}

@media (max-width: 720px) {
  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .metrics-grid,
  .scenario-grid,
  .controls-grid,
  .pipeline {
    grid-template-columns: 1fr;
  }

  .schematic {
    min-height: 330px;
  }
}
