:root {
  color-scheme: dark;
  --bg: #0a0f12;
  --band: #101820;
  --panel: #151f2a;
  --panel-2: #1a2632;
  --line: #293746;
  --text: #edf4f1;
  --muted: #98a8a7;
  --green: #34d399;
  --red: #fb7185;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --button: #e8eef0;
  --button-text: #071014;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.lab-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 24, 32, 0.96);
  backdrop-filter: blur(12px);
}

.back-link {
  display: inline-flex;
  margin-bottom: 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0.12em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
}

h2 {
  font-size: 15px;
}

#status {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

label.check {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  color: var(--text);
  font-size: 13px;
  text-transform: none;
}

input {
  width: 116px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d141b;
  color: var(--text);
  padding: 0 10px;
}

#access-token {
  width: 138px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
}

button {
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: var(--button);
  color: var(--button-text);
  padding: 0 13px;
  font-weight: 750;
  cursor: pointer;
}

button.ghost,
td button {
  border: 1px solid var(--line);
  background: #202c38;
  color: var(--text);
}

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

.lab-shell {
  padding: 20px 22px 44px;
}

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

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

.metric {
  min-height: 82px;
  padding: 14px;
}

.metric span,
.subtext,
#count {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

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

.table-panel,
.panel {
  overflow: hidden;
}

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

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.panel-actions .audit-toggle {
  height: 36px;
}

.compact-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  color: var(--muted);
  font-size: 12px;
  text-transform: none;
}

.compact-input {
  width: 58px;
  height: 32px;
  padding: 0 8px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #111922;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

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

.market-name {
  display: grid;
  gap: 4px;
  min-width: 250px;
}

.market-name strong {
  font-weight: 760;
}

.date-badge {
  display: inline-grid;
  gap: 2px;
  width: fit-content;
  margin-top: 2px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d141b;
  color: var(--text);
  line-height: 1.1;
}

.date-badge strong {
  font-size: 12px;
  font-weight: 850;
}

.date-badge small {
  color: var(--muted);
  font-size: 11px;
}

.date-badge.tomorrow {
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.1);
}

.date-badge.today {
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.08);
}

.date-badge.past {
  border-color: rgba(251, 113, 133, 0.5);
  background: rgba(251, 113, 133, 0.08);
}

.subtext {
  font-size: 12px;
  line-height: 1.35;
}

.pill {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 74px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.buy {
  color: #061410;
  background: var(--green);
  border-color: var(--green);
}

.pill.tiny {
  color: #190f04;
  background: var(--amber);
  border-color: var(--amber);
}

.pill.avoid {
  color: #23070d;
  background: var(--red);
  border-color: var(--red);
}

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

.side {
  font-weight: 850;
}

.yes,
.pos {
  color: var(--green);
}

.no,
.neg {
  color: var(--red);
}

.mid {
  color: var(--amber);
}

.confidence {
  color: var(--blue);
}

.risk-list {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.risk-list span {
  color: var(--amber);
  font-size: 12px;
}

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

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
  margin-top: 16px;
}

.context-item,
.ledger-item {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.audit-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  border-bottom: 1px solid var(--line);
}

.audit-metric {
  min-height: 72px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.audit-metric:last-child {
  border-right: 0;
}

.audit-metric span,
.audit-metric small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.audit-metric strong {
  display: block;
  margin: 6px 0 4px;
  font-size: 18px;
}

.context-item:last-child,
.ledger-item:last-child {
  border-bottom: 0;
}

.context-item h3,
.ledger-item h3 {
  margin: 0 0 7px;
  font-size: 14px;
}

.context-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.context-item p,
.ledger-item p {
  margin-top: 8px;
}

dialog {
  width: min(880px, calc(100vw - 36px));
  max-height: min(780px, calc(100vh - 36px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

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

#detail-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.detail-block {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.detail-block h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.detail-block p,
.detail-block li {
  color: var(--muted);
  line-height: 1.5;
}

.detail-block ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

@media (max-width: 980px) {
  .lab-topbar,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

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

  .audit-metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .audit-metric:last-child {
    border-bottom: 0;
  }

  input,
  #access-token,
  button,
  .compact-input {
    width: 100%;
  }

  .compact-label {
    width: 100%;
    justify-content: space-between;
  }
}
