/* Ops Dashboard - mockup stylesheet
 * Dark, dense, operator-first. Tables are the primary UI element.
 */

:root {
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --bg-hover: #1f2630;
  --border: #30363d;
  --border-soft: #21262d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --ok: #3fb950;
  --err: #f85149;
  --warn: #d29922;
  --info: #58a6ff;
  --neutral: #6e7681;
  --buy: #3fb950;
  --sell: #f85149;
  --mono: ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Consolas", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

code, pre, .mono { font-family: var(--mono); font-size: 12px; }

/* -- Top nav --------------------------------------------------------------- */
.topnav {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topnav .brand {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-right: 32px;
  letter-spacing: 0.3px;
}
.topnav .brand .badge {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  margin-left: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
}
.topnav nav {
  display: flex;
  gap: 4px;
  flex: 1;
}
.topnav nav a {
  padding: 6px 12px;
  border-radius: 4px;
  color: var(--text-muted);
  font-weight: 500;
}
.topnav nav a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.topnav nav a.active { background: var(--bg-hover); color: var(--text); }
.topnav .user {
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topnav .user .avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

/* -- Page layout ----------------------------------------------------------- */
.page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}
.page-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 16px;
}
.page-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.page-title .subtle {
  color: var(--text-muted);
  font-size: 12px;
}
.crumbs { color: var(--text-muted); font-size: 12px; margin-bottom: 6px; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { color: var(--text-dim); margin: 0 4px; }

/* -- Hero / KPI cards ------------------------------------------------------ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
}
.card .label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.card .value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.card .sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* -- Sections / panes ------------------------------------------------------ */
.section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
  overflow: hidden;
}
.section .section-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
}
.section .section-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.section .section-head h2 .count { color: var(--text-muted); font-weight: 400; margin-left: 6px; }
.section .section-head .actions { display: flex; gap: 6px; align-items: center; }
.section .section-body { padding: 0; }
.section .section-body.padded { padding: 14px; }
/* Opt-in horizontal scroll for unusually wide tables. Avoid setting this on
   .section .section-body globally because any non-visible overflow on the
   parent breaks position:sticky on `thead th`, causing the first data row to
   end up underneath a stuck header. */
.section .section-body.scrollable-x { overflow-x: auto; }

/* Two-column section layout for strategy detail */
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 16px;
}
@media (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr; }
}

/* -- Tables ---------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  /* Soft drop-shadow gives the thead perceived elevation; particularly
     useful when sticky positioning has it floating over scrolled data rows
     (you can see the data passing underneath instead of guessing). */
  box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.55);
  position: sticky;
  top: 48px;
  z-index: 5;
  white-space: nowrap;
}
tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 12.5px;
  white-space: nowrap;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}
tbody tr:hover { background: var(--bg-hover); }
tbody td.mono { font-family: var(--mono); font-size: 12px; }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody td.muted { color: var(--text-muted); }
tbody td.dim { color: var(--text-dim); }
tbody td.wrap { white-space: normal; max-width: 460px; }
tbody td .small { color: var(--text-muted); font-size: 11px; }

/* -- Pills / badges -------------------------------------------------------- */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}
.pill.ok      { background: rgba(63, 185, 80, 0.15);  color: var(--ok);  border-color: rgba(63, 185, 80, 0.4); }
.pill.err     { background: rgba(248, 81, 73, 0.15);  color: var(--err); border-color: rgba(248, 81, 73, 0.4); }
.pill.warn    { background: rgba(210, 153, 34, 0.15); color: var(--warn);border-color: rgba(210, 153, 34, 0.4); }
.pill.info    { background: rgba(88, 166, 255, 0.15); color: var(--info);border-color: rgba(88, 166, 255, 0.4); }
.pill.neutral { background: rgba(110, 118, 129, 0.15); color: var(--text-muted); border-color: rgba(110, 118, 129, 0.4); }
.pill.live    { background: rgba(63, 185, 80, 0.15); color: var(--ok); border-color: rgba(63, 185, 80, 0.4); }
.pill.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-right: 5px; vertical-align: 1px; box-shadow: 0 0 6px var(--ok); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--err); }
.dot.warn { background: var(--warn); }
.dot.dim { background: var(--text-dim); }

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--mono);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.tag.accept  { color: var(--ok);  border-color: rgba(63, 185, 80, 0.4); background: rgba(63, 185, 80, 0.08); }
.tag.reject  { color: var(--err); border-color: rgba(248, 81, 73, 0.4); background: rgba(248, 81, 73, 0.08); }
.tag.defer   { color: var(--warn);border-color: rgba(210, 153, 34, 0.4); background: rgba(210, 153, 34, 0.08); }
.tag.long    { color: var(--ok); border-color: rgba(63, 185, 80, 0.3); }
.tag.short, .tag.sell { color: var(--err); border-color: rgba(248, 81, 73, 0.3); }
.tag.buy { color: var(--ok); border-color: rgba(63, 185, 80, 0.3); }

/* Symbol tags that link to a TradingView Lightweight Charts page.
   Adds a hover affordance (color + subtle outline) and a small leading
   chart-icon so a row scan immediately reveals the cell is clickable. */
a.tag.chart-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.35);
  background: rgba(88, 166, 255, 0.06);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 80ms ease, border-color 80ms ease, color 80ms ease;
}
a.tag.chart-link::before {
  content: "";
  display: inline-block;
  width: 11px; height: 9px;
  background-image: linear-gradient(
    to top,
    currentColor 0 2px,
    transparent 2px 100%
  );
  /* Render three little vertical bars to evoke a candle chart icon. */
  background:
    linear-gradient(currentColor, currentColor) 0    50% / 2px 5px no-repeat,
    linear-gradient(currentColor, currentColor) 4px  35% / 2px 9px no-repeat,
    linear-gradient(currentColor, currentColor) 8px  60% / 2px 4px no-repeat;
  opacity: 0.85;
}
a.tag.chart-link:hover {
  color: var(--accent-hover);
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.14);
  text-decoration: none;
}

.lvl { font-family: var(--mono); font-size: 11px; padding: 0 4px; border-radius: 2px; }
.lvl.info { color: var(--info); }
.lvl.warn { color: var(--warn); }
.lvl.error { color: var(--err); }

.pnl-pos { color: var(--ok); }
.pnl-neg { color: var(--err); }

/* -- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  font-family: var(--sans);
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-muted); text-decoration: none; }
.btn.primary  { background: rgba(63, 185, 80, 0.12); border-color: rgba(63, 185, 80, 0.4); color: var(--ok); }
.btn.danger   { background: rgba(248, 81, 73, 0.12); border-color: rgba(248, 81, 73, 0.4); color: var(--err); }
.btn.warn     { background: rgba(210, 153, 34, 0.12); border-color: rgba(210, 153, 34, 0.4); color: var(--warn); }
.btn.subtle   { color: var(--text-muted); background: transparent; }
.btn.subtle:hover { color: var(--text); background: var(--bg-hover); }
.btn.sm { padding: 2px 8px; font-size: 11px; }

/* -- Filter chips ---------------------------------------------------------- */
.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elevated);
}
.filters .label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-right: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11.5px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.chip:hover { color: var(--text); border-color: var(--text-muted); }
.chip.active { color: var(--text); background: var(--bg-hover); border-color: var(--accent); }
.chip .count { color: var(--text-dim); margin-left: 4px; font-variant-numeric: tabular-nums; }
.chip.active .count { color: var(--text-muted); }

input.search {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--sans);
  min-width: 240px;
}
input.search:focus { outline: none; border-color: var(--accent); }

select.select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--sans);
}

/* -- Code blocks (logs / yaml) -------------------------------------------- */
pre.tail, pre.yaml {
  margin: 0;
  padding: 12px 16px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}
pre.tail .ts { color: var(--text-muted); }
pre.tail .lvl-info { color: var(--info); }
pre.tail .lvl-warn { color: var(--warn); }
pre.tail .lvl-error { color: var(--err); }
pre.tail .tag-tag { color: var(--accent); }
pre.tail .run { color: var(--text-dim); }

/* YAML highlighter (very simple) */
pre.yaml .key     { color: var(--accent); }
pre.yaml .string  { color: var(--ok); }
pre.yaml .num     { color: var(--warn); }
pre.yaml .bool    { color: var(--warn); }
pre.yaml .comment { color: var(--text-dim); font-style: italic; }
pre.yaml .anchor  { color: #d2a8ff; }
pre.yaml .yaml-line {
  display: block;
  padding-right: 8px;
}
pre.yaml .ln {
  display: inline-block;
  width: 36px;
  text-align: right;
  color: var(--text-dim);
  user-select: none;
  margin-right: 12px;
}

/* -- Tabs (CSS-only via :target) ------------------------------------------ */
.tabs {
  display: flex;
  gap: 0;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
}
.tabs a {
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* -- Pagination ----------------------------------------------------------- */
.pager {
  padding: 10px 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  font-size: 12px;
  color: var(--text-muted);
}
.pager .controls { display: flex; gap: 4px; align-items: center; }

/* -- Drawer (Inspect) ----------------------------------------------------- */
.drawer-link { cursor: pointer; }
.drawer {
  position: fixed;
  top: 48px;
  right: 0;
  bottom: 0;
  width: 540px;
  max-width: 100vw;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  z-index: 50;
  transform: translateX(100%);
  transition: transform 200ms ease;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0,0,0,0.4);
}
.drawer.open { transform: translateX(0); }

/* When the inspect drawer is open in the static mockup it would otherwise
   sit on top of the page and cover the right-most table columns
   (decision_id, Inspect, pager). Reserve drawer-width of right padding on
   the main page so the table can shrink instead of being overlapped.
   Uses CSS :has() — supported in all modern browsers; degrades gracefully
   to "drawer overlays" on older engines, which is how the production
   dashboard behaves anyway (drawer is opened on demand, not pre-pinned). */
body:has(aside.drawer.open) main.page {
  padding-right: 556px; /* 540px drawer + 16px gutter */
}

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

/* -- Util ----------------------------------------------------------------- */
.row-flex { display: flex; gap: 8px; align-items: center; }
.row-flex.between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
}
hr.divider { border: 0; border-top: 1px solid var(--border-soft); margin: 0; }

/* -- Toggle --------------------------------------------------------------- */
.toggle {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.toggle a {
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg);
}
.toggle a:hover { color: var(--text); text-decoration: none; }
.toggle a.active { background: var(--bg-hover); color: var(--text); }
.toggle a + a { border-left: 1px solid var(--border); }

/* -- Definition list ----------------------------------------------------- */
.dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 4px 16px;
  margin: 0;
  padding: 12px 14px;
}
.dl dt { color: var(--text-muted); font-size: 12px; }
.dl dd { margin: 0; font-size: 12.5px; font-family: var(--mono); }

/* checks list (Inspect drawer) */
.checks { padding: 0; }
.checks .check {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
}
.checks .check .name { font-family: var(--mono); }
.checks .check .stage { color: var(--text-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.3px; }
.checks .check .val   { color: var(--text-muted); font-family: var(--mono); font-size: 11px; }
.checks .check .pass  { color: var(--ok); }
.checks .check .fail  { color: var(--err); font-weight: 600; }
