:root {
  color-scheme: dark;
  --bg: #070708;
  --surface: #121214;
  --surface-2: #1a1a1e;
  --line: #2a2a30;
  --text: #f4f4f5;
  --muted: #9b9ba3;
  --accent: #ffffff;
  --accent-dim: #d4d4d8;
  --teal: #3d8f8f;
  --teal-dim: rgba(61, 143, 143, 0.15);
  --orange: #e8a04c;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent-dim); }

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 16px; }

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
}

.tab.active {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  font-weight: 600;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

input, select, button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 12px;
}

input, select { min-width: 0; flex: 1; }

button {
  cursor: pointer;
  font-weight: 600;
}

button.primary {
  background: var(--accent);
  color: #111;
  border: none;
}

button.ghost {
  background: transparent;
}

button.small {
  padding: 6px 10px;
  font-size: 12px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.muted { color: var(--muted); font-size: 13px; }

.error { color: var(--danger); font-size: 13px; margin-top: 8px; }

.table-wrap { overflow-x: auto; margin-top: 12px; }

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

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

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

tr:hover td { background: rgba(255, 255, 255, 0.02); }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--teal-dim);
  color: #9ee0e0;
}

.badge.mine { background: rgba(255,255,255,0.08); color: var(--muted); }

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

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.metric {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.metric .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.metric .value {
  font-size: 22px;
  font-weight: 650;
  margin-top: 4px;
}

.metric .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.verdict {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--teal-dim);
  border: 1px solid rgba(61, 143, 143, 0.25);
  font-size: 14px;
}

.chart-block { margin-top: 18px; }

.chart-block h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

canvas.chart {
  width: 100%;
  height: 140px;
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.auth-panel {
  max-width: 420px;
  margin: 40px auto;
}

.auth-panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.auth-panel form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.hidden { display: none !important; }

.picker-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .picker-row { grid-template-columns: 1fr; }
  header { flex-direction: column; align-items: flex-start; }
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

.legend .a::before { background: #fff; }
.legend .b::before { background: rgba(255,255,255,0.35); }

footer {
  margin-top: 48px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.lab-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.lab-slot {
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  min-height: 72px;
}

.lab-slot.filled {
  border-style: solid;
  border-color: rgba(61, 143, 143, 0.45);
}

.lab-slot .slot-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.dim-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}

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

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

.dim-table .delta {
  color: var(--orange);
  font-weight: 600;
}

.rec-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--teal-dim);
  border: 1px solid rgba(61, 143, 143, 0.3);
  font-size: 14px;
  line-height: 1.55;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.winner-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font-size: 12px;
  font-weight: 700;
}
