:root {
  --bg: #f3f5f0;
  --surface: #ffffff;
  --surface-soft: #f8faf5;
  --ink: #1d2424;
  --muted: #66706c;
  --line: #d9dfd7;
  --accent: #2e6f6d;
  --accent-2: #b4553a;
  --accent-3: #4c6fae;
  --warn: #a75f00;
  --bad: #a73535;
  --good: #2f7a4e;
  --shadow: 0 18px 50px rgba(31, 42, 38, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1800px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

h1 {
  font-size: 32px;
  line-height: 1.05;
}

.subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 24px);
  font-weight: 700;
}

.credit {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

h2 {
  font-size: 15px;
}

.status-pill {
  border: 1px solid var(--line);
  background: #edf5f3;
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel,
.main-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 14px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.tab,
.toolbar-actions button {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 10px;
  cursor: pointer;
  font-weight: 700;
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.control-section {
  border-top: 1px solid var(--line);
  padding: 14px 0 8px;
}

.control-section:first-of-type {
  border-top: 0;
}

.control-section h2 {
  margin-bottom: 10px;
}

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

label span {
  color: var(--ink);
  font-weight: 800;
}

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

select,
.file-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 9px;
  background: #fff;
  color: var(--ink);
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.disclaimer {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  padding: 2px 4px;
}

.hidden {
  display: none !important;
}

.peak-card {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 10px;
  margin: 10px 0;
}

.peak-card h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.main-panel {
  min-width: 0;
  padding: 18px;
}

.plot-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 14px;
}

.plot-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-actions button:hover,
.tab:hover {
  border-color: var(--accent);
}

.chart-wrap {
  width: 100%;
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.metric {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 10px;
  min-width: 0;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric strong.good {
  color: var(--good);
}

.metric strong.warn {
  color: var(--warn);
}

.metric strong.bad {
  color: var(--bad);
}

.table-section {
  margin-top: 18px;
}

.table-section h2 {
  margin-bottom: 10px;
}

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

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

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

th {
  background: #eef3ed;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

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

  .controls {
    position: static;
    max-height: none;
  }

  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .plot-toolbar {
    display: grid;
  }

  h1 {
    font-size: 25px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
