:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --head: #243447;
  --text: #111827;
  --muted: #5b6472;
  --line: #d7dde6;
  --accent: #0369a1;
  --warn: #a16207;
  --bad: #b91c1c;
  --good: #047857;
  --strong: #d9f99d;
  --candidate: #dcfce7;
  --fish: #e0f2fe;
  --safe: #eef2ff;
  --low: #f8fafc;
  --short: #fee2e2;
  --event: #fef3c7;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  min-height: 74px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--head);
  color: #fff;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 750;
}

h2 {
  font-size: 15px;
}

p,
span,
td,
th,
li {
  font-size: 13px;
}

#subtitle,
.panel-heading p,
.metric span {
  color: var(--muted);
}

main {
  width: 100%;
  margin: 0 auto;
  padding: 12px 12px 32px;
}

.status-pill {
  min-width: 112px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #d7dde6;
}

.status-pill.actionable {
  color: var(--good);
  border-color: rgba(52, 211, 153, 0.45);
}

.status-pill.review {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.45);
}

.status-pill.blocked {
  color: var(--bad);
  border-color: rgba(251, 113, 133, 0.45);
}

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

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

.metric {
  min-height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
}

.metric strong {
  font-size: 19px;
}

.panel {
  margin-top: 12px;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.table-wrap {
  overflow: auto;
  max-height: 68vh;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 3;
  color: var(--text);
  font-weight: 650;
  background: #e2e8f0;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

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

.run-log,
.checks {
  list-style: none;
  margin: 0;
  padding: 6px 14px 12px;
}

.run-log li,
.checks li {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.run-log li:last-child,
.checks li:last-child {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  justify-content: center;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.sticky-underlying {
  position: sticky;
  left: 0;
  box-shadow: 1px 0 0 var(--line), 8px 0 12px rgba(15, 23, 42, 0.08);
}

th.sticky-underlying {
  z-index: 8;
}

td.sticky-underlying {
  z-index: 4;
  font-weight: 750;
}

.help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  margin-left: 5px;
  border: 1px solid #94a3b8;
  border-radius: 50%;
  color: #475569;
  font-size: 10px;
  line-height: 1;
}

.legend,
.scroll-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.legend {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.swatch {
  width: 12px;
  height: 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  display: inline-block;
}

.swatch.strong,
tr.tier-strong_candidate td {
  background: var(--strong);
}

.swatch.candidate,
tr.tier-candidate td,
tr.tier-watch td {
  background: var(--candidate);
}

.swatch.fish,
tr.tier-fish_20 td,
tr.tier-fish_10 td {
  background: var(--fish);
}

.swatch.safe,
tr.tier-safer_low_return td {
  background: var(--safe);
}

tr.tier-low_return td {
  background: var(--low);
}

.swatch.short,
tr.tier-short_dte_fish td,
tr.tier-short_dte_watch td {
  background: var(--short);
}

.swatch.event,
tr.tier-needs_event_check td,
tr.tier-blocked_event td {
  background: var(--event);
}

.scroll-controls button {
  width: 34px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.chart-link {
  color: var(--accent);
  font-weight: 700;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.top-actions button,
.login-panel button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 12px;
  font-weight: 700;
}

.login-panel {
  width: min(420px, 100%);
  margin: 56px auto;
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.login-panel h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

.login-panel form {
  display: flex;
  gap: 8px;
}

.login-panel input {
  flex: 1;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 10px;
}

#login-error {
  min-height: 18px;
  margin-top: 10px;
  color: var(--bad);
}

@media (max-width: 760px) {
  .topbar,
  .panel-heading,
  .top-actions {
    align-items: flex-start;
    flex-direction: column;
  }

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

  main {
    padding: 12px;
  }

  .login-panel form {
    flex-direction: column;
  }
}
