/* ─── RESET & BASE ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0a0c13;
  --card-bg:      #111827;
  --border:       #1e293b;
  --row-hover:    #161d2e;
  --accent:       #6366f1;
  --accent-dim:   rgba(99,102,241,0.15);
  --text-primary: #e2e8f0;
  --text-sec:     #94a3b8;
  --text-muted:   #4b5563;
  --green:        #22c55e;
  --red:          #ef4444;
  --yes-bg:       rgba(99,102,241,0.18);
  --yes-color:    #818cf8;
  --no-bg:        rgba(244,63,94,0.18);
  --no-color:     #fb7185;
  --buy-bg:       rgba(34,197,94,0.15);
  --buy-color:    #4ade80;
  --sell-bg:      rgba(239,68,68,0.15);
  --sell-color:   #f87171;
  --mono:         'Courier New', Courier, monospace;
  --r:            8px;
}

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ─── HEADER ───────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 24px;
  color: var(--accent);
  line-height: 1;
}

.logo-text {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ─── MAIN LAYOUT ───────────────────────────────────────────────────────────── */
.app-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

/* ─── SEARCH ───────────────────────────────────────────────────────────────── */
.search-section {
  margin-bottom: 36px;
}

.search-bar {
  display: flex;
  gap: 10px;
  max-width: 680px;
}

.address-input {
  flex: 1;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 13px;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}

.address-input::placeholder { color: var(--text-muted); font-family: inherit; }
.address-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.wallet-name {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-sec);
}
.wallet-name strong { color: var(--accent); }

/* ─── ERROR ─────────────────────────────────────────────────────────────────── */
.error-box {
  margin-top: 12px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--r);
  color: #fca5a5;
  font-size: 13px;
  padding: 12px 16px;
  max-width: 680px;
}

/* ─── BUTTONS ───────────────────────────────────────────────────────────────── */
.btn {
  cursor: pointer;
  border: none;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 22px;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4f52d6; }

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-sec);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--row-hover); color: var(--text-primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-sec);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--row-hover); }

.btn-sm { font-size: 12px; padding: 6px 14px; }

/* ─── STATS ─────────────────────────────────────────────────────────────────── */
.stats-section {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

@media (max-width: 960px)  { .stats-section { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px)  { .stats-section { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── TABS SECTION ──────────────────────────────────────────────────────────── */
.tabs-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.tabs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.tabs-nav { display: flex; }

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-sec);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 16px 20px;
  position: relative;
  transition: color 0.15s;
  white-space: nowrap;
}
.tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.15s;
}
.tab-btn.active { color: var(--accent); }
.tab-btn.active::after { opacity: 1; }
.tab-btn:hover:not(.active) { color: var(--text-primary); }

.tabs-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.last-updated { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ─── DATE FILTER ───────────────────────────────────────────────────────────── */
.date-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.filter-label { font-size: 12px; color: var(--text-sec); white-space: nowrap; }

.filter-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.date-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s;
  color-scheme: dark;
}
.date-input:focus { border-color: var(--accent); }

/* ─── LOADING ───────────────────────────────────────────────────────────────── */
.loading-indicator {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 40px 24px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

.loading-text { font-size: 13px; color: var(--text-sec); }

/* ─── TABLE WRAPPER ─────────────────────────────────────────────────────────── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ─── TABLE ─────────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead tr { border-bottom: 1px solid var(--border); }

.data-table th {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
}

.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--text-primary); }
.data-table th.sortable.sort-asc::after  { content: ' ↑'; color: var(--accent); }
.data-table th.sortable.sort-desc::after { content: ' ↓'; color: var(--accent); }

.data-table th.num-col,
.data-table td.num-col { text-align: right; }

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover:not(.empty-row) { background: var(--row-hover); }

.data-table td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.empty-row td {
  color: var(--text-muted);
  font-size: 13px;
  padding: 48px 16px;
  text-align: center;
}

/* ─── CELL CONTENT ──────────────────────────────────────────────────────────── */
.market-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
}

.market-title {
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.market-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.market-link:hover { opacity: 1; }

/* Badges */
.badge {
  display: inline-block;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.badge-yes   { background: var(--yes-bg);  color: var(--yes-color);  }
.badge-no    { background: var(--no-bg);   color: var(--no-color);   }
.badge-buy   { background: var(--buy-bg);  color: var(--buy-color);  }
.badge-sell  { background: var(--sell-bg); color: var(--sell-color); }
.badge-other { background: rgba(148,163,184,0.1); color: var(--text-sec); }

/* Numeric cells */
.num-val {
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}
.num-val.positive { color: var(--green); }
.num-val.negative { color: var(--red); }
.num-val.dim      { color: var(--text-muted); }

/* ─── PAGINATION ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.page-info {
  font-size: 12px;
  color: var(--text-sec);
  min-width: 140px;
  text-align: center;
}

/* ─── TRADES LAG BAR ─────────────────────────────────────────────────────────── */
.trades-lag-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: rgba(234,179,8,0.08);
  border-bottom: 1px solid rgba(234,179,8,0.2);
  flex-wrap: wrap;
}

.lag-icon { color: #facc15; font-size: 14px; flex-shrink: 0; }

.lag-text {
  font-size: 12px;
  color: #fde68a;
  flex: 1;
}

/* ─── CHECKBOX COL ───────────────────────────────────────────────────────────── */
.cb-col {
  width: 36px;
  padding-left: 16px !important;
  padding-right: 6px !important;
}

.data-table input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.row-selected {
  background: rgba(99,102,241,0.08) !important;
}

/* ─── SELECTION BAR ──────────────────────────────────────────────────────────── */
.selection-bar {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e253a;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 100;
  white-space: nowrap;
}

.selection-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ─── BET SLIP MODAL ─────────────────────────────────────────────────────────── */
.slip-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.slip-modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.slip-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.slip-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.slip-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.slip-close-btn:hover { color: var(--text-primary); background: var(--row-hover); }

.slip-body {
  overflow-y: auto;
  flex: 1;
}

.slip-trades-wrap {
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

.slip-table td.slip-idx {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  width: 30px;
}

.slip-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0;
}

.slip-stat {
  flex: 1;
  min-width: 110px;
  padding: 18px 20px;
  border-right: 1px solid var(--border);
}
.slip-stat:last-child { border-right: none; }

.slip-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.slip-stat-value {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text-primary);
}
.slip-stat-value.accent { color: var(--accent); }

/* ─── SCROLLBAR ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-header  { padding: 0 16px; }
  .app-main    { padding: 24px 16px 60px; }
  .tabs-header { padding: 0 12px; }
  .tab-btn     { padding: 14px 14px; font-size: 13px; }
  .date-filter { padding: 12px 16px; }
  .data-table th,
  .data-table td { padding: 10px 12px; }
  .market-title  { max-width: 180px; }
}
