:root {
  --bg: #0b1015; --panel: #101820; --panel-2: #0b131b; --border: #293544; --border-2: #40505e;
  --text: #dbe4ec; --bright: #edf2f7; --muted: #8e9cab; --amber: #efb44b; --cyan: #70d4df; --red: #ed987e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.muted { color: var(--muted); }
.warning { color: var(--amber); }
.error { color: var(--red); min-height: 1.4em; margin: 0; }
.negative { color: var(--red); }
.text-button { background: none; border: 0; padding: 4px 0; color: var(--cyan); }
.text-button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
.outline-button, .primary-button { padding: 6px 12px; border: 1px solid var(--border-2); background: #17232d; border-radius: 3px; color: var(--bright); }
.outline-button:hover:not(:disabled), .primary-button:hover:not(:disabled) { border-color: var(--cyan); }
.primary-button { background: #1d3640; border-color: #2f6672; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; letter-spacing: .02em; color: var(--bright); }
.session { display: flex; align-items: center; gap: 14px; }
.role-pill { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--amber); border: 1px solid #5a4824; padding: 2px 8px; border-radius: 10px; }
.role-pill:empty { display: none; }
main#app { padding: 18px 20px 40px; }
.heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.heading h1 { font-size: 17px; font-weight: 600; margin: 0; color: var(--bright); }
.state { font-size: 11px; letter-spacing: .08em; padding: 2px 8px; border: 1px solid var(--border-2); border-radius: 3px; color: var(--cyan); }
.state-stale, .state-unavailable, .state-source_error, .state-sweep_error { color: var(--amber); border-color: #5a4824; }

.admin-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 10px 0; margin: 8px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { appearance: none; width: 32px; height: 18px; border-radius: 9px; background: #26323e; border: 1px solid var(--border-2); position: relative; margin: 0; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: left .12s; }
.switch input:checked { background: #1d3640; border-color: var(--cyan); }
.switch input:checked::after { left: 16px; background: var(--cyan); }
.storage { display: inline-flex; gap: 8px; align-items: baseline; }
.storage strong { font-weight: 500; font-variant-numeric: tabular-nums; }

.venue-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; border: 0; padding: 0; margin: 14px 0 4px; }
.venue-filter legend { float: left; margin-right: 6px; color: var(--muted); padding: 0; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { accent-color: var(--cyan); margin: 0; }
.table-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; margin: 6px 0 8px; }

.table-scroll { overflow-x: auto; max-width: 100%; border-top: 1px solid var(--border); }
.scanner-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; min-width: 1350px; }
.scanner-table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--bg); }
.scanner-table th.numeric .th-controls { justify-content: flex-end; }
.th-controls { display: flex; align-items: center; gap: 4px; }
.sort-button { background: none; border: 0; padding: 2px 0; color: inherit; font-weight: 500; }
th[aria-sort="ascending"] .sort-button, th[aria-sort="descending"] .sort-button { color: var(--cyan); }
.sort-indicator { margin-left: 4px; font-size: 11px; }
.filter-button { display: inline-flex; background: none; border: 0; padding: 3px; color: #5d6b79; border-radius: 3px; }
.filter-button:hover, .filter-button.active { color: var(--cyan); }
.filter-button.active { background: #17232d; }
.scanner-table td { padding: 9px 10px; border-bottom: 1px solid #1a242f; vertical-align: middle; }
.scanner-table .numeric { text-align: right; white-space: nowrap; }
.data-row:hover { background: #0f171f; }
.market-cell { min-width: 260px; max-width: 420px; }
.row-toggle { color: var(--amber); text-align: left; font-weight: 500; padding: 0; line-height: 1.4; }
.cell-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.venue-cell { min-width: 130px; white-space: nowrap; }
.venue-cell strong { color: var(--bright); font-weight: 600; }
.venue-cell div { line-height: 1.75; }
.quote-link { color: var(--cyan); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.quote-selected { color: var(--cyan); font-weight: 600; }
.status { font-size: 12px; white-space: nowrap; }
.status-current { color: var(--cyan); }
.status-archived { color: var(--muted); }
.status-candidate { color: var(--amber); }
.action-col { width: 40px; text-align: center; }
.icon-button { display: inline-flex; padding: 6px; background: none; border: 1px solid transparent; border-radius: 3px; color: var(--cyan); }
.icon-button:hover { border-color: var(--border-2); background: #17232d; }
.icon-button.done { color: var(--amber); }
.empty { text-align: center; color: var(--muted); padding: 28px !important; }

.detail-row > td { background: #0a1117; padding: 6px 10px 10px; }
.leg { display: grid; grid-template-columns: 95px minmax(200px, 1fr) auto; gap: 3px 14px; align-items: baseline; padding: 8px 12px; margin: 6px 0; background: var(--panel-2); border: 1px solid var(--border); }
.leg h4 { margin: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #aab8c7; }
.leg p, .leg small { margin: 0; }
.leg-question { color: var(--bright); }
.leg > .quote-selected { grid-column: 3; grid-row: 1; white-space: nowrap; }
.leg > small { grid-column: 2; grid-row: 2; font-size: 11px; }
.leg > .leg-cost { grid-column: 3; grid-row: 2; font-size: 11px; text-align: right; }
.evidence { font-size: 11px; margin: 6px 2px 0; }

.pager { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 12px 0; }
.history { margin: 18px 0; font-size: 12px; }
.history summary { cursor: pointer; color: #aab8c7; }
.history-row { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; margin: 10px 0; }
.history input { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 3px; padding: 4px 8px; }

.filter-menu { position: absolute; z-index: 20; width: 240px; max-height: 340px; overflow: auto; display: grid; gap: 8px; padding: 12px; background: var(--panel); border: 1px solid var(--border-2); box-shadow: 0 8px 24px #0009; border-radius: 3px; }
.filter-menu input[type=search], .filter-menu input[type=number] { width: 100%; padding: 6px 8px; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 3px; }
.filter-menu .range { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.filter-actions { display: flex; justify-content: space-between; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; padding: 26px; background: var(--panel); border: 1px solid var(--border); border-radius: 4px; }
.login-card .brand { font-size: 16px; }
.login-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.role-button { padding: 10px; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 3px; color: var(--bright); }
.role-button[aria-pressed="true"] { border-color: var(--cyan); color: var(--cyan); background: #12232b; }
#login-form { display: grid; gap: 8px; }
#login-form[hidden] { display: none; }
#login-form label { color: var(--muted); font-size: 12px; }
#login-form input { padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 3px; color: var(--bright); }

@media (max-width: 700px) {
  .topbar, main#app { padding-left: 16px; padding-right: 16px; }
  .leg { grid-template-columns: 1fr; }
  .leg > *, .leg > .quote-selected, .leg > small, .leg > .leg-cost { grid-column: 1; grid-row: auto; text-align: left; white-space: normal; }
}

/* Navigation, footer, legal pages */
a { color: var(--cyan); }
a.brand { text-decoration: none; }
.topbar { flex-wrap: wrap; }
.topnav { display: flex; gap: 18px; margin-right: auto; margin-left: 28px; }
.topnav[hidden] { display: none; }
.topnav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.topnav a[aria-current="page"] { color: var(--bright); border-bottom-color: var(--amber); }
.topnav a:hover { color: var(--bright); }
.site-footer { justify-content: center; display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 14px 20px 22px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.legal-page { max-width: 820px; margin: 0 auto; padding: 20px 20px 40px; line-height: 1.6; }
.legal-page h1 { font-size: 20px; color: var(--bright); margin: 18px 0 4px; }
.legal-page h2 { font-size: 14px; color: var(--bright); margin: 22px 0 6px; }
.legal-page li { margin: 4px 0; }
.legal-list { padding-left: 20px; }
.legal-list li { margin: 8px 0; }
.legal-list strong { color: var(--bright); }
.login-legal { font-size: 11px; margin: 16px 0 0; }
#username-field { display: grid; gap: 8px; }
#username-field[hidden] { display: none; }
#login-form input { width: 100%; }

/* Daily disclaimer modal */
body.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: #05080bd9; }
.modal { width: 100%; max-width: 720px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border-2); border-top: 3px solid var(--amber); border-radius: 4px; box-shadow: 0 16px 48px #000c; }
.modal h2 { margin: 0; padding: 16px 20px 10px; font-size: 16px; color: var(--bright); }
.modal-body { overflow-y: auto; padding: 0 20px; line-height: 1.55; }
.modal-body .legal-list li { margin: 7px 0; }
.modal-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 14px 20px; border-top: 1px solid var(--border); }
.modal-actions a { margin-right: auto; }

/* Admin page */
.admin-page { padding: 18px 20px 40px; }
.admin-page h1 { font-size: 17px; color: var(--bright); margin: 0 0 12px; }
.admin-page h2 { font-size: 15px; color: var(--bright); margin: 28px 0 10px; }
.issue-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); }
.issue-form label:not(.check) { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.issue-form input:not([type=checkbox]), .visit-filters select { padding: 7px 9px; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 3px; color: var(--bright); min-width: 170px; }
.issue-form label.wide input { min-width: 280px; }
.issued { margin: 12px 0; padding: 12px 16px; border: 1px solid #2f6672; background: #0f1d23; display: grid; gap: 8px; max-width: 980px; }
.issued[hidden] { display: none; }
.issued-row { display: grid; grid-template-columns: 100px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.issued code { color: var(--amber); overflow-wrap: anywhere; font-size: 13px; }
.issued > .text-button { justify-self: start; }
.admin-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 12px; }
.admin-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 7px 9px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: 7px 9px; border-bottom: 1px solid #1a242f; vertical-align: top; }
.admin-table .numeric { text-align: right; }
.admin-table .nowrap { white-space: nowrap; }
.admin-table td.strong { color: var(--bright); font-weight: 600; }
.admin-table .actions { display: flex; flex-wrap: wrap; gap: 4px 12px; min-width: 260px; }
.visits-table { min-width: 1500px; }
.visits-table td { max-width: 260px; overflow-wrap: anywhere; }
.warn-row td { color: var(--amber); }
.status-active { color: var(--cyan); }
.status-revoked, .status-expired { color: var(--red); }
.visit-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin-bottom: 10px; }
.visit-filters label:not(.check) { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); }
@media (max-width: 700px) {
  .topnav { margin-left: 0; order: 3; width: 100%; }
  .admin-page, .legal-page, .site-footer { padding-left: 16px; padding-right: 16px; }
  .issue-form input:not([type=checkbox]), .issue-form label.wide input { min-width: 0; width: 100%; }
  .issue-form label:not(.check) { flex: 1 1 100%; }
  .issued-row { grid-template-columns: 1fr; gap: 4px; }
}
.filter-menu label[hidden] { display: none; }
.filter-choices { display: grid; gap: 4px; max-height: 220px; overflow: auto; }
.probe-row td { color: #5d6b79; }
.admin-page .table-tools { margin-top: 0; }
.guest-note { margin: 0 0 8px; }
.guest-note[hidden] { display: none; }
.issue-hint { flex-basis: 100%; font-size: 11px; }
