:root {
  --bg: #0f0f1a;
  --bg-card: #16213e;
  --bg-card-hover: #1a2747;
  --bg-input: #1a1a2e;
  --bg-sidebar: #0d1117;
  --bg-sidebar-hover: #161b22;
  --border: #2a2a4a;
  --text: #e0e0e0;
  --text-dim: #8888aa;
  --green: #00ff88;
  --red: #ff4444;
  --blue: #4488ff;
  --accent: #00ff88;
  --yellow: #ffaa00;
  --sidebar-width: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Login ── */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-box h1 { font-size: 24px; margin-bottom: 8px; color: var(--accent); }
.login-box p { color: var(--text-dim); margin-bottom: 24px; font-size: 14px; }

.login-box input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.login-box input:focus { border-color: var(--accent); }

.login-box button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.login-box button:hover { opacity: 0.9; }
.login-box button:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

/* ── App Shell ── */
.app-shell { display: none; }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo { font-size: 22px; }
.sidebar-title { font-size: 14px; font-weight: 700; color: var(--accent); line-height: 1.2; }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text);
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(0,255,136,0.05);
}

.nav-icon { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; }
.nav-label { white-space: nowrap; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-status { font-size: 12px; line-height: 1.8; }
.status-row { display: flex; gap: 6px; }
.status-label { color: var(--text-dim); }

.sidebar-meta {
  margin: 8px 0;
  font-size: 11px;
}

.btn-logout {
  width: 100%;
  padding: 8px;
  margin-top: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ── Hamburger ── */
.hamburger {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  width: 40px;
  height: 40px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.view { animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.view-header {
  padding: 20px 24px 0;
}

.view-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.content {
  max-width: 1400px;
  padding: 20px 24px 40px;
}

/* ── Cards ── */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: background 0.2s;
}

.card:hover { background: var(--bg-card-hover); }

.card-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.card-value { font-size: 28px; font-weight: 700; }
.card-value.positive { color: var(--green); }
.card-value.negative { color: var(--red); }
.card-value.neutral { color: var(--text-dim); }
.card-value small { font-size: 13px; font-weight: 400; }

/* ── Resolution bar ── */
.resolution-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  margin-bottom: 24px;
  font-size: 13px;
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ── Outcome tags ── */
.outcome-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.outcome-up { background: rgba(0,255,136,0.15); color: var(--green); }
.outcome-down { background: rgba(255,68,68,0.15); color: var(--red); }

/* ── Result badges ── */
.result-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.result-win { background: rgba(0,255,136,0.15); color: var(--green); }
.result-loss { background: rgba(255,68,68,0.15); color: var(--red); }

/* ── Sections ── */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 24px;
  overflow: hidden;
}

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

.section-header h2 { font-size: 16px; font-weight: 600; }

.section-body {
  padding: 16px 20px;
  overflow-x: auto;
}

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

th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }

td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(42,42,74,0.5);
  white-space: nowrap;
}
td.market-cell {
  white-space: normal;
  word-break: break-word;
  min-width: 200px;
  max-width: 350px;
}
a.market-link {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}
a.market-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

tr:hover td { background: rgba(255,255,255,0.02); }

.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-dim { color: var(--text-dim); }
.text-blue { color: var(--blue); }

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

.filter-group select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  min-width: 120px;
}

.filter-group select:focus { border-color: var(--accent); outline: none; }

/* ── Charts ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.chart-card h3 { font-size: 14px; margin-bottom: 16px; color: var(--text-dim); }

/* ── Timeline ── */
.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(42,42,74,0.5);
  font-size: 13px;
}

.timeline-time {
  color: var(--text-dim);
  font-size: 11px;
  min-width: 80px;
  flex-shrink: 0;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.timeline-content { flex: 1; }
.timeline-market { font-weight: 500; }
.timeline-detail { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

/* ── Wallet ── */
.wallet-display {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  padding: 10px 16px;
  border-radius: 8px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.copy-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.copy-btn:hover { color: var(--accent); background: rgba(0,255,136,0.1); }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
}

.pagination button {
  padding: 6px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination button:hover:not(:disabled) { border-color: var(--accent); }
.pagination span { color: var(--text-dim); font-size: 12px; }

/* ── Loading ── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Info Cards ── */
.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}

.info-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--accent);
}

.info-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(0,255,136,0.05);
  border-radius: 8px;
}

.flow-step {
  padding: 6px 14px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.flow-arrow { color: var(--accent); font-size: 18px; font-weight: 700; }

.info-steps {
  padding-left: 20px;
  line-height: 2;
  color: var(--text);
  font-size: 14px;
}

.info-list {
  list-style: none;
  padding: 0;
  line-height: 2.2;
  font-size: 14px;
}

.info-list li::before {
  content: '•';
  color: var(--accent);
  font-weight: 700;
  margin-right: 10px;
}

/* ── Glossary Table ── */
.glossary-table {
  font-size: 14px;
}

.glossary-table th {
  font-size: 12px;
  padding: 12px 16px;
  background: var(--bg-sidebar);
}

.glossary-table td {
  padding: 12px 16px;
  white-space: normal;
  line-height: 1.5;
}

.glossary-table tbody tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}

.glossary-table tbody tr:hover td {
  background: rgba(0,255,136,0.03);
}

.glossary-table td:first-child {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  min-width: 130px;
}

/* ── Badge (status) ── */
.badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-green { background: rgba(0,255,136,0.15); color: var(--green); }
.badge-red { background: rgba(255,68,68,0.15); color: var(--red); }
.badge-yellow { background: rgba(255,170,0,0.15); color: var(--yellow); }
.badge-blue { background: rgba(68,136,255,0.15); color: var(--blue); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar-overlay.open {
    display: block;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .view-header {
    padding: 60px 16px 0;
  }
  
  .content { padding: 16px; }
  .charts-grid { grid-template-columns: 1fr; }
  .cards-row { grid-template-columns: repeat(2, 1fr); }
  .card-value { font-size: 22px; }

  .wallet-display {
    font-size: 11px;
    word-break: break-all;
  }
  
  .wallet-full { word-break: break-all; white-space: normal; }
  
  .info-flow { gap: 6px; }
  .flow-step { font-size: 11px; padding: 4px 8px; }
}

/* ── Settings ── */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(42,42,74,0.5);
  gap: 16px;
}

.setting-row:last-child { border-bottom: none; }

.setting-label {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  min-width: 120px;
}

.setting-value {
  font-size: 14px;
  font-weight: 600;
}

.setting-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.settings-input {
  width: 80px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.settings-input:focus { border-color: var(--green); }

.btn-settings {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.btn-settings:hover { opacity: 0.85; }
.btn-settings:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-green { background: var(--green); color: #000; }
.btn-red { background: var(--red); color: #fff; }
.btn-yellow { background: var(--yellow); color: #000; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-dim { background: var(--border); color: var(--text); }

.bot-actions {
  display: flex;
  gap: 8px;
}

.settings-note {
  color: var(--yellow);
  font-size: 13px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(255,170,0,0.08);
  border-radius: 6px;
}

.logs-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.logs-container {
  background: #0d1117;
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  max-width: 420px;
  width: 90%;
}

.modal-card h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

.modal-card p {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Wallet Subtabs ── */
.wallet-subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.subtab {
  padding: 8px 20px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.subtab:hover { border-color: var(--accent); color: var(--text); }
.subtab.active { border-color: var(--accent); color: var(--accent); background: rgba(0,255,136,0.08); }

.wallet-balance-card { min-height: 120px; }

@media (max-width: 480px) {
  .cards-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
}
