:root {
  color-scheme: light dark;
  --bg: #f5f5f3;
  --panel: #ffffff;
  --text: #161616;
  --muted: #6f6f6c;
  --line: #deded9;
  --accent: #1664d9;
  --accent-soft: #dbe8ff;
  --danger: #bd2c2c;
  --shadow: 0 18px 48px rgba(22, 22, 22, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111210;
    --panel: #1b1c1a;
    --text: #f3f3ee;
    --muted: #aaa9a2;
    --line: #343530;
    --accent: #62a0ff;
    --accent-soft: #203452;
    --danger: #ff6b6b;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
}

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

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(320px, 1.6fr);
  gap: 24px;
  padding: 20px;
  margin-bottom: 18px;
}

.settings-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.9fr) 130px auto;
  gap: 12px;
  align-items: end;
}

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

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, var(--bg));
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.status {
  min-height: 22px;
  color: var(--muted);
  margin: 0 0 14px;
}

.status.error {
  color: var(--danger);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric {
  min-height: 118px;
  padding: 18px;
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 0;
}

.chart {
  min-height: 260px;
  padding: 18px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 250px;
}

.axis-label {
  fill: var(--muted);
  font-size: 12px;
}

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

.table-wrap {
  overflow: auto;
  padding: 12px 18px 18px;
}

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

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

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 700;
}

td code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text);
}

.empty {
  color: var(--muted);
  padding: 12px 0;
}

@media (max-width: 1060px) {
  .controls,
  .settings-form,
  .split {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1280px);
    padding-top: 20px;
  }

  .page-header {
    display: grid;
  }

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