/* Boostfolio — Trade-Republic-inspired design system, dark (default) + light */

:root {
  --bg: #000000;
  --surface: #121214;
  --surface-hover: #1c1c1f;
  --border: #26262a;
  --text: #f5f5f7;
  --text-muted: #8e8e93;
  --text-subtle: #636366;

  --positive: #23c16b;
  --positive-soft: rgba(35, 193, 107, 0.12);
  --negative: #ff453a;
  --negative-soft: rgba(255, 69, 58, 0.12);
  --accent: #3a8dfd;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, monospace;

  --topbar-bg: rgba(0, 0, 0, 0.85);

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --surface-hover: #ebebef;
  --border: #e2e2e6;
  --text: #0b0b0d;
  --text-muted: #6e6e73;
  --text-subtle: #8e8e93;

  --positive: #178a4c;
  --positive-soft: rgba(23, 138, 76, 0.1);
  --negative: #d92c20;
  --negative-soft: rgba(217, 44, 32, 0.1);

  --topbar-bg: rgba(255, 255, 255, 0.85);

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color 150ms ease, color 150ms ease;
}

a { color: inherit; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }

/* ============ TOPBAR ============ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}
.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 14px;
}
.brand-title { font-weight: 700; font-size: 1rem; }

.topbar-balance {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
}
.topbar-balance-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.topbar-balance-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1rem;
}

.theme-toggle-btn, .settings-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.theme-toggle-btn:hover, .settings-btn:hover { background: var(--surface-hover); }

.main { max-width: 960px; margin: 0 auto; padding: 1.5rem 1.25rem 6.5rem; }

/* ============ BOTTOM FLOATING NAV ============ */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1rem;
  z-index: 20;
  pointer-events: none;
}
.bottom-nav-pill {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  text-decoration: none;
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  transition: background 150ms ease, color 150ms ease;
}
.bottom-nav-item:hover { color: var(--text); }
.bottom-nav-item.active { background: var(--surface); color: var(--text); }
.bottom-nav-icon { display: inline-flex; line-height: 1; }
.bottom-nav-label { font-size: 0.62rem; font-weight: 600; }
.bottom-nav-fab {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  flex-shrink: 0;
}
.bottom-nav-fab.active { outline: 2px solid var(--text); outline-offset: 2px; }

/* ============ SETTINGS PANEL ============ */

.settings-row {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:first-child { padding-top: 0; }
.settings-row:last-child { border-bottom: none; padding-bottom: 0; }
.settings-row-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.sync-list { display: flex; flex-direction: column; gap: 0.4rem; }
.sync-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
}

/* ============ DASHBOARD HEADER ============ */

.back-link {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--text); }

.dash-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.dash-header { margin-bottom: 1.25rem; }

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-primary:hover { opacity: 0.85; }

/* ============ MODAL ============ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 1rem; }
.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem;
}
.modal-close-btn:hover { color: var(--text); }
.modal-body { padding: 1rem 1.2rem; overflow-y: auto; }
.modal-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  margin: 0;
}
.modal-footer {
  padding: 0.9rem 1.2rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}
.dash-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dash-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 2.6rem;
  font-weight: 700;
  margin: 0.15rem 0 0.3rem;
  letter-spacing: -0.02em;
}
.dash-delta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-mono);
}
.dash-delta.positive { color: var(--positive); }
.dash-delta.negative { color: var(--negative); }
.dash-delta.neutral { color: var(--text-muted); }

/* ============ PERIOD TABS ============ */

.period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1.1rem 0 0.75rem;
}
.period-tab {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  white-space: nowrap;
}
.period-tab:hover { background: var(--surface-hover); color: var(--text); }
.period-tab.active { background: var(--surface); color: var(--text); border-color: var(--border); }

.tag-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1.1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tag-tabs::-webkit-scrollbar { display: none; }
.tag-tab {
  flex-shrink: 0;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease;
}
.tag-tab:hover { color: var(--text); }
.tag-tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.view-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}
.view-toggle-btn {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  white-space: nowrap;
}
.view-toggle-btn:hover { background: var(--surface-hover); color: var(--text); }
.view-toggle-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============ PENDING BETS BANNER ============ */

.pending-banner { margin: 0 0 1.4rem; }
.pending-banner-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.55rem;
}
.pending-banner-scroll {
  display: flex;
  gap: 0.7rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0.2rem;
}
.pending-banner-scroll::-webkit-scrollbar { display: none; }
.pending-chip {
  flex-shrink: 0;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  text-decoration: none;
  color: var(--text);
}
.pending-chip-label {
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.3;
  margin-bottom: 0.65rem;
}
.pending-chip-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.pending-chip-odds {
  flex-shrink: 0;
  background: #ffc800;
  color: #1a1a1a;
  font-weight: 800;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}
.pending-chip-stake { font-size: 0.72rem; color: var(--text-muted); }
.pending-chip-stake .value { font-family: var(--font-mono); color: var(--text); font-weight: 600; }

/* ============ CHART ============ */

#chart-container {
  position: relative;
  height: 280px;
  margin: 0.5rem 0 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
}

.chart-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  z-index: 5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  font-size: 0.78rem;
  white-space: nowrap;
  box-shadow: var(--shadow, 0 4px 12px rgba(0, 0, 0, 0.35));
}
.chart-tooltip .chart-tooltip-date {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-bottom: 0.15rem;
}
.chart-tooltip .chart-tooltip-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.chart-tooltip .chart-tooltip-value.positive { color: var(--positive); }
.chart-tooltip .chart-tooltip-value.negative { color: var(--negative); }

/* ============ TILES ============ */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.75rem;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.tile-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.tile-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
  font-weight: 700;
}
.tile-value.positive { color: var(--positive); }
.tile-value.negative { color: var(--negative); }

.tile-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.tile-pair .tile { grid-column: span 1; }

/* ============ POSITION-STYLE LIST ============ */

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 1.75rem 0 0.6rem;
}

.position-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.position-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}
.position-row:last-child { border-bottom: none; }
.position-row:hover { background: var(--surface-hover); }
.position-name { font-weight: 600; font-size: 0.92rem; text-transform: capitalize; }
.position-sub { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.1rem; }
.position-metric { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.position-pct { font-weight: 700; font-size: 0.92rem; }
.position-pct.positive { color: var(--positive); }
.position-pct.negative { color: var(--negative); }

/* ============ TABLES ============ */

/* Tables scroll horizontally within their own bounded box on narrow
   screens — the page itself must never gain a horizontal scrollbar. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 540px;
  border-collapse: separate;
  border-spacing: 0;
}
thead th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
}
tbody td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }
td.num, th.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
td.positive { color: var(--positive); }
td.negative { color: var(--negative); }

/* ============ BADGES ============ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-won { background: var(--positive-soft); color: var(--positive); }
.badge-lost { background: var(--negative-soft); color: var(--negative); }
.badge-pending { background: rgba(142, 142, 147, 0.15); color: var(--text-muted); }
.badge-refunded { background: rgba(58, 141, 253, 0.15); color: var(--accent); }
.badge-cashed_out { background: rgba(58, 141, 253, 0.15); color: var(--accent); }
.badge-boost { background: rgba(255, 200, 0, 0.15); color: #ffc800; }

/* ============ BET CARDS ============ */

.bet-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.9rem;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
}
.bet-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 700;
}
.bet-card-header-left { display: flex; align-items: center; gap: 0.5rem; }
.bet-card-platform { color: var(--text-muted); text-transform: capitalize; font-weight: 600; }
.bet-card-body {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem 0;
}
.bet-card-selection { flex: 1; min-width: 0; }
.bet-card-selection-label { font-weight: 700; font-size: 0.95rem; line-height: 1.35; }
.bet-card-promo { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.2rem; }
.odds-badge {
  flex-shrink: 0;
  background: #ffc800;
  color: #1a1a1a;
  font-weight: 800;
  font-size: 1rem;
  font-family: var(--font-mono);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
}
.bet-card-fixture {
  margin: 0.85rem 1rem 0;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.bet-card-numbers {
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.bet-card-number-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}
.bet-card-number-row .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.bet-card-number-row .value.positive { color: var(--positive); }
.bet-card-number-row .value.negative { color: var(--negative); }
.bet-card-meta {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-subtle);
}

/* ============ PIE CHARTS ============ */

.pie-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1.25rem;
}
.pie-card-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.9rem; }
.pie-card-body {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.pie-chart {
  width: 140px;
  height: 140px;
  min-width: 140px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pie-legend { display: flex; flex-direction: column; gap: 0.45rem; flex: 1; min-width: 140px; }
.pie-legend-row { display: flex; align-items: center; gap: 0.55rem; font-size: 0.85rem; }
.pie-legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.pie-legend-label { flex: 1; text-transform: capitalize; }
.pie-legend-value { font-family: var(--font-mono); color: var(--text-muted); font-size: 0.8rem; }

/* ============ FORMS / FILTERS ============ */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.filter-bar select, .filter-bar label {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  font-family: var(--font-sans);
}
.filter-bar label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }

/* ============ DETAIL PAGE ============ */

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
}
.detail-row { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-muted); }
.detail-row .positive { color: var(--positive); }
.detail-row .negative { color: var(--negative); }

.leg {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.leg:last-child { border-bottom: none; }

.muted { color: var(--text-muted); }

/* ============ BAR CHART (categorical breakdowns) ============ */

.barchart {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.barchart-row { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); display: block; }
.barchart-row:last-child { border-bottom: none; }
.barchart-row:hover { background: var(--surface-hover); }
.barchart-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}
.barchart-label { font-weight: 600; font-size: 0.88rem; text-transform: capitalize; }
.barchart-sub { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.1rem; }
.barchart-metric { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.barchart-value { font-weight: 700; font-size: 0.88rem; }
.barchart-value.positive { color: var(--positive); }
.barchart-value.negative { color: var(--negative); }
.barchart-track {
  position: relative;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.barchart-fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 3px; }
.barchart-fill.positive { background: var(--positive); }
.barchart-fill.negative { background: var(--negative); }

.stats-section-title { font-size: 0.95rem; font-weight: 700; margin: 1.75rem 0 0.6rem; }
.stats-section-title:first-child { margin-top: 0; }

@media (max-width: 640px) {
  .main { padding: 1rem 0.9rem 6rem; }
  .dash-value { font-size: 2rem; }
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  thead th, tbody td { padding: 0.5rem 0.7rem; font-size: 0.8rem; }
  .detail-row { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
}

@media (max-width: 420px) {
  .topbar { padding: 0.8rem 1rem; }
  .bottom-nav-item { padding: 0.4rem 0.55rem; }
  .bottom-nav-label { font-size: 0.58rem; }
}
