:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --line: #dfe3e6;
  --text: #202428;
  --muted: #687078;
  --green: #18794e;
  --green-bg: #edf7f1;
  --amber: #8a5a00;
  --amber-bg: #fff7e5;
  --red: #b42318;
  --red-bg: #fff1f0;
  --blue: #315f8a;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: 400; }
h1, h2, h3, p { margin: 0; font-weight: 400; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; }
strong, b { font-weight: 500; }
.topbar { min-height: 56px; padding: 8px 28px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #fff; }
.topbar-brand, .topbar-actions, .session-controls, .controls, .section-heading { display: flex; align-items: center; gap: 12px; }
.topbar-actions { margin-left: auto; }
.session-controls { margin-left: 0; }
.viewer-state, .owner-state { color: var(--muted); font-size: 11px; }
.market-clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.mode-control { display: flex; align-items: center; gap: 8px; }
.mode-control > span { color: var(--muted); font-size: 11px; }
main { width: min(1280px, calc(100% - 40px)); margin: 12px auto 40px; display: grid; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
label { color: var(--muted); font-size: 12px; }
select, button { font: inherit; min-height: 34px; border-radius: 4px; }
select { color: var(--text); background: #fff; border: 1px solid #cfd4d8; padding: 0 34px 0 10px; }
button { color: #fff; background: #33383d; border: 1px solid #33383d; padding: 0 14px; font-weight: 400; cursor: pointer; }
button:hover { background: #202428; }
button:disabled { opacity: .55; cursor: wait; }
button.secondary { color: var(--text); background: #fff; border: 1px solid #cfd4d8; min-height: 30px; }
input { width: 100%; min-height: 36px; color: var(--text); background: #fff; border: 1px solid #cfd4d8; border-radius: 4px; padding: 0 10px; font: inherit; }
.login-dialog { width: min(380px, calc(100% - 32px)); padding: 0; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 5px; }
.login-dialog::backdrop { background: rgb(32 36 40 / 35%); }
.login-form { display: grid; gap: 14px; padding: 18px; }
.login-form label { display: grid; gap: 5px; }
.login-form .section-heading { margin-bottom: 0; }
.dialog-close { min-width: 30px; min-height: 30px; padding: 0; color: var(--muted); background: #fff; border-color: var(--line); font-size: 20px; }
.login-error { color: var(--red); font-size: 12px; }
.section-heading { justify-content: space-between; margin-bottom: 10px; }
.run-id { color: var(--muted); font-family: Consolas, monospace; font-size: 11px; }
.empty-state { color: var(--muted); padding: 16px 8px; text-align: center; }
.hidden { display: none !important; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 780px; }
th, td { padding: 8px 9px; text-align: left; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 400; }
th { color: var(--muted); }
td { font-variant-numeric: tabular-nums; }
.tag { display: inline-flex; padding: 2px 5px; border-radius: 3px; font-size: 10px; font-weight: 400; }
.tag.ready { color: var(--green); background: var(--green-bg); }
.tag.stale { color: var(--amber); background: var(--amber-bg); }
.tag.error, .tag.failed { color: var(--red); background: var(--red-bg); }
.history-card { padding: 14px 16px; }
.history-list { display: grid; gap: 0; }
.history-row { display: grid; grid-template-columns: 170px 1fr 190px; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.history-row .price { font-size: 13px; font-weight: 400; text-align: right; }
.history-alert { color: var(--red); margin-left: 8px; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 440px; background: var(--red-bg); border: 1px solid #efb7b2; color: var(--red); padding: 12px 14px; border-radius: 4px; }
@media (max-width: 800px) {
  .topbar { padding: 8px 16px; align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; margin-left: 0; }
  .session-controls { position: absolute; top: 10px; right: 16px; }
  .mode-control { flex: 1; }
  .mode-control select { width: 100%; }
  main { width: min(100% - 24px, 1280px); }
  .history-row { grid-template-columns: 1fr; gap: 4px; }
  .history-row .price { text-align: left; }
}