:root {
  color-scheme: light;
  --ink: #151b23;
  --muted: #5f6b7a;
  --line: #dde4ec;
  --paper: #f5f7fa;
  --panel: #ffffff;
  --soft-panel: #f9fbfd;
  --teal: #136f63;
  --teal-dark: #0e584f;
  --blue: #2f66b1;
  --blue-dark: #244f8c;
  --amber: #a96d16;
  --red: #b73535;
  --green: #297a43;
  --shadow: 0 10px 28px rgba(29, 42, 57, 0.07);
  --shadow-soft: 0 1px 2px rgba(29, 42, 57, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 30px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(29, 42, 57, 0.03);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(25px, 2.6vw, 34px);
  line-height: 1.08;
  font-weight: 780;
}

h2 {
  font-size: 16px;
  font-weight: 760;
}

.top-actions,
.package-actions,
.panel-header,
.tabs,
.segmented {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  padding: 16px 18px 22px;
}

.workspace > * {
  min-width: 0;
}

.rail,
.main-grid {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

.main-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
}

.rail .panel {
  box-shadow: var(--shadow-soft);
}

.wide {
  grid-column: 1 / -1;
}

.visual {
  min-height: 540px;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  text-transform: none;
  letter-spacing: 0;
}

.unit-label {
  text-transform: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft-panel);
  color: var(--ink);
  padding: 10px 12px;
  min-height: 42px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

textarea {
  min-height: 168px;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  text-transform: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(47, 102, 177, 0.78);
  box-shadow: 0 0 0 3px rgba(47, 102, 177, 0.14);
}

.input-grid,
.compact-grid {
  display: grid;
  gap: 12px;
}

.input-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.spectrum-shape-grid {
  padding: 12px;
  border: 1px solid rgba(47, 102, 177, 0.16);
  border-radius: 8px;
  background: #f8fbff;
}

.spectrum-results-grid {
  background: #fbfcfd;
}

.inline-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.full-label {
  margin-top: 12px;
}

.primary,
.secondary,
.ghost,
.tabs button,
.segmented button {
  min-height: 40px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 760;
}

.primary {
  background: var(--blue);
  color: white;
  box-shadow: 0 6px 16px rgba(47, 102, 177, 0.2);
}

.primary:hover {
  background: var(--blue-dark);
}

.secondary {
  color: var(--blue-dark);
  background: rgba(47, 102, 177, 0.09);
}

.ghost {
  color: var(--ink);
  background: #edf1f5;
  border: 1px solid #dde5ec;
}

.tabs,
.segmented {
  padding: 3px;
  border-radius: 7px;
  background: #edf2f7;
  border: 1px solid #dce5ee;
}

.tabs button,
.segmented button {
  color: var(--muted);
  background: transparent;
}

.tabs button.active,
.segmented button.active {
  color: white;
  background: var(--blue);
  box-shadow: 0 4px 12px rgba(47, 102, 177, 0.18);
}

.hidden {
  display: none;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

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

th {
  background: #f1f5f9;
  color: #3b4858;
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: middle;
}

tbody tr:hover {
  background: #f8fbff;
}

td input {
  min-height: 34px;
  padding: 6px 8px;
}

tr:last-child td {
  border-bottom: 0;
}

.small-danger {
  min-width: 34px;
  min-height: 34px;
  border-radius: 6px;
  color: var(--red);
  background: #f8e8e8;
  font-weight: 900;
}

.file-drop {
  display: block;
  padding: 14px;
  border: 1px dashed #aab8c6;
  border-radius: 8px;
  color: var(--blue-dark);
  background: #f8fbff;
  text-align: center;
  margin-top: 12px;
}

.primary-drop {
  border-color: rgba(47, 102, 177, 0.35);
  background: rgba(47, 102, 177, 0.08);
  color: var(--blue-dark);
  font-weight: 900;
}

.file-drop input {
  display: none;
}

.file-status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.field-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

canvas {
  width: 100%;
  height: 420px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.graph-mode-note {
  margin-bottom: 10px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 780;
  text-transform: uppercase;
}

.spectrum-tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  min-width: 120px;
  border: 1px solid rgba(49, 95, 157, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  box-shadow: 0 10px 25px rgba(31, 43, 48, 0.16);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.35;
}

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

.runner-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft-panel);
  box-shadow: var(--shadow-soft);
}

.runner-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: var(--shadow-soft);
}

.metrics span,
.metrics em,
.runner-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 740;
  text-transform: uppercase;
}

.runner-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  line-height: 1.25;
  color: #1d2a39;
}

.metrics strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
  margin: 4px 0;
  font-weight: 780;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 780;
}

.badge.good {
  color: var(--green);
  background: #e7f4ea;
}

.badge.warn {
  color: var(--amber);
  background: #fff3de;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  background: #fbfcfd;
  box-shadow: var(--shadow-soft);
}

.step b {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e3eaf2;
  color: var(--ink);
  font-size: 12px;
}

.step.active {
  color: var(--ink);
  border-color: rgba(47, 102, 177, 0.28);
}

.step.active b {
  color: white;
  background: var(--blue);
}

.run-status {
  margin-bottom: 12px;
  border: 1px solid rgba(49, 95, 157, 0.22);
  border-radius: 8px;
  padding: 11px 12px;
  color: #244c80;
  background: #f0f6ff;
  font-size: 13px;
  font-weight: 740;
  line-height: 1.4;
  box-shadow: var(--shadow-soft);
}

.run-status.good {
  border-color: rgba(47, 125, 70, 0.22);
  color: var(--green);
  background: #eaf6ed;
}

.run-status.warn {
  border-color: rgba(189, 122, 32, 0.24);
  color: var(--amber);
  background: #fff6e8;
}

.run-status.bad {
  border-color: rgba(184, 58, 58, 0.24);
  color: var(--red);
  background: #fdecec;
}

.download-iteration {
  min-height: 32px;
  white-space: nowrap;
  padding: 0 12px;
}

.run-log {
  min-height: 92px;
  max-height: 180px;
  margin-top: 12px;
  background: #142030;
  color: #dce9f6;
  border-color: #24364c;
}

.check-list {
  display: grid;
  gap: 10px;
}

.check {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-panel);
  box-shadow: var(--shadow-soft);
}

.check b {
  color: white;
  background: var(--green);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  text-align: center;
  line-height: 22px;
  font-size: 12px;
}

.check.warn b {
  background: var(--amber);
}

.check span {
  display: block;
  font-weight: 760;
}

.check small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.35;
}

pre {
  min-height: 250px;
  max-height: 430px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #142030;
  color: #dce9f6;
  padding: 14px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.package-actions {
  flex-wrap: wrap;
  margin-bottom: 12px;
}

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

.finding {
  border-left: 4px solid var(--blue);
  background: #f8fbff;
  border-radius: 6px;
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.finding.warn {
  border-left-color: var(--amber);
  background: #fff8ea;
}

.finding strong {
  display: block;
  margin-bottom: 5px;
}

.finding p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .workspace,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
  }

  .top-actions,
  .rail,
  .input-grid,
  .compact-grid,
  .metrics,
  .runner-summary,
  .stepper,
  .findings {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .workspace {
    padding: 12px;
  }

  canvas {
    height: 330px;
  }

  .visual {
    min-height: 470px;
  }
}
