/* VolKey Flow Scanner — static SPA styles.
   Dark theme tuned for sufficient contrast (WCAG AA text on background). */

:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c2430;
  --border: #30363d;
  --text: #e6edf3;        /* ~13:1 on --bg */
  --text-dim: #b0bac6;    /* ~7.5:1 on --bg */
  --accent: #4da3ff;
  --accent-strong: #1f6feb;
  --highlight-bg: #3a2e0b;
  --highlight-border: #d9a406;
  --highlight-text: #ffd966;
  --danger: #ff7b72;
  --ok: #56d364;
  --focus: #ffd966;
  --line-vol: #4da3ff;
  --line-sweep: #d29922;
  --line-notional: #56d364;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent-strong);
  color: #fff;
  padding: 8px 14px;
  z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ----------------------------- Header / tabs ----------------------------- */

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--accent); font-size: 20px; }
.site-header h1 { font-size: 18px; margin: 0; font-weight: 600; }

.tabs {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}
.tab {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
}
.tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: var(--panel-2);
}
.tab:hover { color: var(--text); }

/* ----------------------------- Main / views ----------------------------- */

main { padding: 20px; max-width: 1100px; margin: 0 auto; }
.view { }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.controls label { font-weight: 600; }

input[type="text"] {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  text-transform: uppercase;
  min-width: 140px;
}
input[type="text"]::placeholder { color: var(--text-dim); text-transform: none; }

.btn-primary {
  background: var(--accent-strong);
  color: #fff;
  border: 1px solid var(--accent-strong);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }

.hint { color: var(--text-dim); font-size: 13px; }

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 12px;
}
.legend-swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1px solid var(--highlight-border);
  background: var(--highlight-bg);
}

.status {
  min-height: 20px;
  margin: 8px 0;
  color: var(--text-dim);
  font-size: 14px;
}
.status.error { color: var(--danger); }
.status.empty { color: var(--text-dim); font-style: italic; }

/* ----------------------------- Tables ----------------------------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table caption { text-align: left; }
.data-table th, .data-table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th {
  background: var(--panel);
  color: var(--text-dim);
  font-weight: 600;
  position: sticky;
  top: 0;
}
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover { background: var(--panel-2); }

.data-table tbody tr.highlight {
  background: var(--highlight-bg);
}
.data-table tbody tr.highlight td:first-child {
  border-left: 3px solid var(--highlight-border);
}
.data-table tbody tr.highlight td.num.vol-oi,
.data-table tbody tr.highlight td.num.notional {
  color: var(--highlight-text);
  font-weight: 600;
}

/* Activity rows are activatable */
tr.row-activatable { cursor: pointer; }
tr.row-activatable:focus-visible,
tr.row-activatable:focus {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.right-C { color: var(--ok); }
.right-P { color: var(--danger); }

/* ----------------------------- Modal / chart ----------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

/* The hidden attribute must override display:flex so the drill-down modal is
   collapsed until a row is activated (attribute alone is too low-specificity). */
.overlay[hidden] {
  display: none;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: min(780px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 16px 18px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-header h2 { margin: 0; font-size: 16px; }
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  width: 32px; height: 32px;
  border-radius: 6px;
  cursor: pointer;
}
.btn-icon:hover { background: var(--panel-2); }

.chart-wrap { margin-top: 10px; }
.chart { width: 100%; height: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }

.chart-legend {
  list-style: none;
  display: flex;
  gap: 16px;
  padding: 0;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.legend-line { display: inline-block; width: 18px; height: 3px; border-radius: 2px; }
.line-vol { background: var(--line-vol); }
.line-sweep { background: var(--line-sweep); }
.line-notional { background: var(--line-notional); }

/* SVG chart elements */
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .grid { stroke: #232b36; stroke-width: 1; }
.chart .tick-label { fill: var(--text-dim); font-size: 11px; }
.chart .series-vol { stroke: var(--line-vol); }
.chart .series-sweep { stroke: var(--line-sweep); }
.chart .series-notional { stroke: var(--line-notional); }
.chart .series { fill: none; stroke-width: 2; }
.chart .dot { stroke: var(--bg); stroke-width: 1; }

/* ----------------------------- Footer ----------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}

/* Focus visibility across interactive elements */
button:focus-visible,
input:focus-visible,
.tab:focus-visible,
.skip-link:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
