:root {
  --bg: #0f1216;
  --panel: #171b21;
  --border: #262c35;
  --text: #e7eaee;
  --muted: #8a93a3;
  --buy: #35c26b;
  --sell: #e05c5c;
  --warn: #e0b23c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  padding: 24px;
}

h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

.rate-filters {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}
.rate-filters select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  margin-left: 6px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.card .rate { font-size: 32px; font-weight: 700; margin: 6px 0; }
.card.buy .rate { color: var(--buy); }
.card.sell .rate { color: var(--sell); }
.card .meta { font-size: 12px; color: var(--muted); }
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 6px;
}
.badge.turbulent { background: rgba(224, 178, 60, 0.15); color: var(--warn); }
.badge.borrowed { background: rgba(138, 147, 163, 0.15); color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 24px;
}
.panel h2 { font-size: 14px; margin: 0 0 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.025); }

/* Daily-rates table: tint each rate "family" (proposed/offered/accepted/
   completed) a distinct low-opacity color so the four 3-column groups read
   as bands at a glance. Layers under the zebra striping above since both
   are translucent. */
.fam-proposed  { background: rgba(110, 168, 254, 0.09); }
.fam-offered   { background: rgba(224, 178, 60, 0.09); }
.fam-accepted  { background: rgba(53, 194, 107, 0.09); }
.fam-completed { background: rgba(45, 212, 191, 0.09); }
.status-completed { color: var(--buy); }
.status-cancelled { color: var(--sell); }
.status-open { color: var(--warn); }
.mono { font-variant-numeric: tabular-nums; }

.status-line { font-size: 12px; color: var(--muted); margin-bottom: 24px; }
.status-line button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
}
.status-line button:hover { border-color: var(--muted); }

canvas { width: 100%; height: 160px; display: block; cursor: crosshair; }

.chart-wrap { position: relative; }
.chart-tooltip {
  position: absolute;
  display: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}
.chart-tooltip .tt-date { color: var(--muted); margin-bottom: 4px; }
.chart-tooltip .tt-row.buy { color: var(--buy); }
.chart-tooltip .tt-row.sell { color: var(--sell); }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.tab-btn.active { color: var(--text); border-color: var(--muted); background: rgba(255,255,255,0.03); }

.expand-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  width: 20px;
}
.expand-btn:hover { color: var(--text); }

tr.timeline-row td { white-space: normal; padding: 12px 16px; background: rgba(255,255,255,0.02); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.timeline li { font-size: 12px; color: var(--muted); display: flex; gap: 8px; }
.timeline li .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 3px; flex-shrink: 0; background: var(--muted); }
.timeline li.posted .dot { background: #6ea8fe; }
.timeline li.offer_accepted .dot, .timeline li.completed .dot { background: var(--buy); }
.timeline li.offer_rejected .dot, .timeline li.cancelled .dot { background: var(--sell); }
.timeline li.offer_pending .dot { background: var(--warn); }
.timeline li .approx { font-style: italic; opacity: 0.7; }

.pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.pager button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
.pager button:disabled { opacity: 0.4; cursor: default; }

.daily-controls { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.daily-controls select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 3px 6px;
  margin-left: 6px;
}
.daily-controls a {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
}
.daily-controls a:hover { border-color: var(--muted); }

.table-scroll { overflow-x: auto; }
#tab-daily table th, #tab-daily table td { text-align: right; }
#tab-daily table th:first-child, #tab-daily table td:first-child { text-align: left; }
#tab-daily table th:nth-child(2), #tab-daily table td:nth-child(2) { text-align: left; }
