:root {
  color-scheme: dark;
  --bg: #07110f;
  --panel: #0d1a17;
  --panel-2: #12231e;
  --line: rgba(205, 255, 229, .1);
  --text: #f1f8f4;
  --muted: #91a79f;
  --lime: #b9f36b;
  --mint: #50dfa7;
  --coral: #ff806f;
  --shadow: 0 20px 55px rgba(0, 0, 0, .28);
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 82% 12%, rgba(80, 223, 167, .11), transparent 28rem),
    radial-gradient(circle at 5% 55%, rgba(185, 243, 107, .06), transparent 24rem),
    linear-gradient(rgba(205, 255, 229, .035) 1px, transparent 1px) 0 0 / 100% 26px,
    var(--bg);
  font-family: var(--font-sans);
}

button, input { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 15, .78);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; font-size: 18px; letter-spacing: -.02em; }
.brand strong { color: var(--lime); font-weight: 650; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--lime); color: #102013; font-weight: 850; box-shadow: 0 0 24px rgba(185,243,107,.18); }
.connection { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #e7b65f; box-shadow: 0 0 0 4px rgba(231,182,95,.1); }
.status-dot.online { background: var(--mint); box-shadow: 0 0 0 4px rgba(80,223,167,.1); }
.status-dot.error { background: var(--coral); box-shadow: 0 0 0 4px rgba(255,128,111,.1); }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.dashboard { margin-top: 26px; border: 1px solid var(--line); border-radius: 24px; background: rgba(13,26,23,.82); box-shadow: var(--shadow), 0 0 0 1px rgba(80,223,167,.04), 0 0 60px -20px rgba(80,223,167,.18); overflow: hidden; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px; border-bottom: 1px solid var(--line); }
.filters { display: flex; min-width: 0; gap: 6px; padding: 4px; overflow-x: auto; border-radius: 13px; background: rgba(0,0,0,.18); }
.filter, .refresh { border: 0; cursor: pointer; transition: transform .15s, box-shadow .15s, background .18s ease, color .18s ease; }
.filter { padding: 9px 14px; border-radius: 9px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 650; white-space: nowrap; }
.filter:hover { color: var(--text); }
.filter.active { color: #112014; background: var(--lime); }
.actions { display: flex; align-items: center; gap: 9px; }
.refresh { height: 39px; padding: 0 16px; border-radius: 11px; color: #102013; background: var(--lime); font-size: 13px; font-weight: 700; }
.refresh:hover { transform: translateY(-1px); box-shadow: 0 0 0 5px rgba(185,243,107,.12); }
.refresh:active { transform: translateY(0) scale(.97); }
.refresh.spinning { pointer-events: none; opacity: .7; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(130px, 1fr)) auto; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.summary > div { display: flex; flex-direction: column; gap: 3px; }
.summary-value { font-family: var(--font-mono); font-size: 20px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.summary-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.auto-refresh { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; cursor: pointer; }
.auto-refresh input { position: absolute; opacity: 0; }
.auto-refresh span { width: 30px; height: 17px; border-radius: 20px; background: #31423d; position: relative; transition: .2s; }
.auto-refresh span::after { content: ""; width: 11px; height: 11px; background: white; border-radius: 50%; position: absolute; left: 3px; top: 3px; transition: .2s; }
.auto-refresh input:checked + span { background: var(--mint); }
.auto-refresh input:checked + span::after { transform: translateX(13px); }

.paper-panel { padding: 16px 22px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, rgba(185,243,107,.045), rgba(80,223,167,.025)); }
.paper-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.paper-heading > div { display: flex; align-items: center; gap: 8px; }
.paper-heading b { font-size: 12px; }
.paper-heading small, #paper-scan { color: var(--muted); font-size: 9px; }
.mode-dry-run { color: var(--mint); }
.mode-live { color: var(--coral); }
.paper-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 4px rgba(185,243,107,.09); }
.strategy-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 16px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(2,13,11,.55); }
.strategy-tab { min-width: 0; padding: 10px 12px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; font: inherit; font-size: 9px; font-weight: 700; text-align: center; transition: background .18s ease, color .18s ease, box-shadow .18s ease; }
.strategy-tab:hover { color: var(--text); background: rgba(185,243,107,.055); }
.strategy-tab.active { color: #102014; background: var(--lime); box-shadow: 0 5px 18px rgba(185,243,107,.13); }
.paper-strategy-description { min-height: 13px; margin: 10px 2px 0; color: #80978e; font-size: 9px; }
.paper-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.paper-metrics div { display: flex; flex-direction: column; gap: 3px; }
.paper-metrics span { font-family: var(--font-mono); font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.paper-metrics small { color: var(--muted); font-size: 8px; letter-spacing: .06em; text-transform: uppercase; }
.paper-metrics .positive { color: var(--lime); }
.paper-metrics .negative { color: var(--coral); }
.paper-rules { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; color: #647a72; font-size: 8px; }
.history-view { padding: 20px 22px 24px; }
.history-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.history-heading > div { display: flex; flex-direction: column; gap: 4px; }
.history-heading b { font-size: 17px; }
.history-heading span { color: var(--muted); font-size: 9px; }
.history-heading .history-pnl { align-items: flex-end; }
.history-heading .history-pnl b { font-family: var(--font-mono); font-size: 19px; font-variant-numeric: tabular-nums; }
.history-heading .history-pnl b.positive { color: var(--lime); }
.history-heading .history-pnl b.negative { color: var(--coral); }
.history-heading .history-pnl small { color: var(--muted); font-size: 8px; }
.paper-history { margin-top: 12px; }
.paper-history-empty { margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); text-align: center; font-size: 10px; }
.paper-history-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.paper-history-row { display: grid; grid-template-columns: 1.3fr .9fr 1fr 1.2fr .8fr; gap: 14px; align-items: center; padding: 10px 12px; border-bottom: 1px solid rgba(205,255,229,.06); }
.paper-history-row:last-child { border-bottom: 0; }
.paper-history-row > div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.paper-history-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.paper-history-row > div:nth-child(n+2) b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.paper-history-row span { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 8px; }
.paper-history-row .positive { color: var(--lime); }
.paper-history-row .negative { color: var(--coral); }
.paper-history-sales { gap: 6px !important; }
.paper-history-sales b { margin-top: 2px; }
.paper-history-sales b:first-child { margin-top: 0; }

.event-grid { display: grid; grid-template-columns: 1fr; gap: 14px; padding: 18px; }
.event-card { border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(145deg, rgba(18,35,30,.92), rgba(10,23,19,.92)); overflow: hidden; animation: rise .28s both; }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } }
.event-head { padding: 18px 18px 15px; }
.event-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.series { color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.series b { color: var(--mint); }
.event-badges { display: flex; align-items: center; gap: 7px; }
.volume-pill { padding: 4px 8px; border-radius: 20px; color: var(--lime); background: rgba(185,243,107,.075); font-size: 9px; font-weight: 700; white-space: nowrap; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 20px; color: #ffa497; background: rgba(255,128,111,.1); font-size: 10px; font-weight: 750; }
.live-pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--coral); }
.event-title { margin: 0; font-size: 17px; line-height: 1.35; letter-spacing: -.02em; }
.score-line { display: flex; gap: 14px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.score { color: var(--text); font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.paper-event { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 16px; padding: 9px 18px; border-top: 1px solid var(--line); color: var(--muted); background: rgba(185,243,107,.025); font-size: 9px; }
.paper-event b { color: var(--lime); text-transform: uppercase; letter-spacing: .06em; }
.paper-event em { color: #647a72; font-style: normal; }
.paper-trade { padding: 4px 7px; border-radius: 6px; font-weight: 650; }
.paper-trade.profit { color: var(--lime); background: rgba(185,243,107,.08); }
.paper-trade.loss { color: #ff9c8f; background: rgba(255,128,111,.08); }
.winner-label { padding: 11px 18px 0; border-top: 1px solid var(--line); color: #647a72; font-size: 9px; font-weight: 750; letter-spacing: .1em; }
.winner-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; padding: 10px 18px 18px; }
.draw-avatar { color: var(--muted); font-size: 13px; }
.winner.draw .winner-name { color: var(--muted); }
.player-result-shell { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: rgba(0,0,0,.14); }
.winner { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(0,0,0,.14); }
.player-result-shell .winner { border: 0; border-radius: 0; background: transparent; }
.player-identity { min-width: 0; display: flex; align-items: center; gap: 9px; }
.player-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.player-avatar { flex: 0 0 44px; width: 44px; height: 44px; display: grid; place-items: center; overflow: hidden; border: 1px solid rgba(185,243,107,.16); border-radius: 50%; color: var(--lime); background: linear-gradient(145deg, #183329, #0b1c16); font-size: 11px; font-weight: 800; }
.player-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center 18%; }
.winner-name { min-width: 0; font-size: 11px; font-weight: 650; line-height: 1.25; }
.winner-quote { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.winner-quote small { display: block; margin-bottom: 2px; color: var(--muted); font-size: 7px; font-weight: 750; letter-spacing: .08em; }
.winner-quote b { color: var(--lime); font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; }
.winner-quote .odds { margin-top: 2px; color: var(--text); font-family: var(--font-mono); font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.winner.unavailable { grid-column: 1 / -1; color: var(--muted); }
.chart-shell { border-top: 1px solid var(--line); }
.chart-button { width: 100%; padding: 11px 18px; border: 0; color: var(--lime); background: rgba(185,243,107,.025); cursor: pointer; font-size: 10px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.chart-button:hover { background: rgba(185,243,107,.07); }
.chart-button:disabled { opacity: .55; cursor: wait; }
.chart-content { padding: 4px 18px 15px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px 24px; padding: 10px 0 2px; font-size: 10px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 50%; }
.chart-legend em { font-style: normal; font-weight: 750; }
.chart-legend .up { color: var(--lime); }
.chart-legend .down { color: #ff9c8f; }
.chart-loading, .chart-empty { margin: 12px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.chart-source { margin: 8px 0 0; color: #526860; font-size: 7px; text-align: right; }
.price-chart-scroll { overflow-x: auto; }
.price-chart-wrap { position: relative; min-width: 620px; }
.h2h-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.h2h-table th { text-align: left; padding: 6px 8px; color: var(--muted); font-weight: 700; font-size: 9px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); }
.h2h-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.h2h-table tr:last-child td { border-bottom: 0; }
.h2h-table b { color: var(--lime); font-variant-numeric: tabular-nums; }
.price-chart { display: block; width: 100%; min-width: 620px; height: auto; }
.chart-grid { stroke: rgba(205,255,229,.08); stroke-width: 1; }
.chart-axis { fill: #647a72; font-size: 9px; }
.chart-hover-line { stroke: rgba(255,255,255,.42); stroke-width: 1; stroke-dasharray: 4 4; pointer-events: none; }
.chart-hover-dot { stroke: #07130f; stroke-width: 3; pointer-events: none; }
.chart-tooltip { position: absolute; z-index: 3; min-width: 165px; padding: 9px 10px; border: 1px solid rgba(205,255,229,.16); border-radius: 9px; color: var(--text); background: rgba(5,16,12,.96); box-shadow: 0 10px 30px rgba(0,0,0,.28); transform: translate(10px, 0); pointer-events: none; font-size: 9px; }
.chart-tooltip.align-left { transform: translate(calc(-100% - 10px), 0); }
.chart-tooltip strong { display: block; margin-bottom: 6px; color: var(--muted); font-size: 9px; font-weight: 650; text-transform: capitalize; }
.chart-tooltip span { display: flex; align-items: center; gap: 5px; margin-top: 4px; }
.chart-tooltip span i { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); }
.chart-tooltip span:first-of-type i { background: var(--lime); }
.chart-tooltip span b { margin-left: auto; padding-left: 10px; color: var(--lime); }

.notice { margin: 18px 18px 0; padding: 24px; border: 1px solid rgba(185,243,107,.18); border-radius: 15px; color: var(--muted); text-align: center; background: rgba(185,243,107,.035); }
.notice strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.notice button { margin-top: 14px; padding: 9px 14px; border: 0; border-radius: 9px; color: #102013; background: var(--lime); cursor: pointer; font-weight: 700; }
.loading { min-height: 220px; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--muted); }
.loading span { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); animation: pulse 1s infinite alternate; }
.loading span:nth-child(2) { animation-delay: .2s; }
.loading span:nth-child(3) { animation-delay: .4s; }
.loading p { margin-left: 8px; font-size: 13px; }
@keyframes pulse { to { opacity: .25; transform: translateY(-5px); } }

footer { width: min(1180px, calc(100% - 40px)); margin: 22px auto 34px; display: flex; justify-content: space-between; color: #5f756d; font-size: 11px; }

@media (max-width: 800px) {
  .toolbar { align-items: stretch; flex-direction: column; }
  .actions { width: 100%; }
  .event-grid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(3, 1fr); }
  .auto-refresh { grid-column: 1 / -1; }
  .paper-metrics { grid-template-columns: repeat(3, 1fr); }
  .paper-history-row { grid-template-columns: repeat(2, 1fr); }
  .strategy-tabs { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  main { width: min(100% - 22px, 1180px); }
  .topbar { padding: 0 14px; }
  .connection span:last-child { display: none; }
  .filters { overflow-x: auto; }
  .filter { padding-inline: 11px; white-space: nowrap; }
  .refresh span { display: none; }
  .summary { padding: 15px; }
  .summary-value { font-size: 16px; }
  .paper-heading, .paper-heading > div { align-items: flex-start; flex-direction: column; }
  .strategy-tabs { grid-template-columns: 1fr; }
  .paper-metrics { grid-template-columns: repeat(2, 1fr); }
  .paper-history-row { grid-template-columns: 1fr; }
  .event-grid { padding: 10px; }
  .winner-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; gap: 6px; }
}
