:root {
  --bg: #09090b; /* Dark background */
  --surface: #0f1115; /* Slightly lighter surface */
  --surface-hover: #181a20;
  --border: #27272a;
  --text-main: #e4e4e7;
  --text-muted: #a1a1aa;
  --primary: #facc15; /* Gold/Yellow for Prob */
  --accent: #3b82f6;
  
  /* Status Colors */
  --yes-bg: rgba(16, 185, 129, 0.2);
  --yes-text: #34d399;
  --no-bg: rgba(239, 68, 68, 0.2);
  --no-text: #f87171;
  --abstain-bg: rgba(113, 113, 122, 0.2);
  --abstain-text: #d4d4d8;

  --header-height: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-main);
  font-size: 14px;
}

/* Layout */
.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Navigation */
.topbar {
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-right: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand::before {
  content: " ";
  display: block;
  width: 12px;
  height: 12px;
  background: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 8px #ef4444;
}

.nav-links {
  display: flex;
  gap: 24px;
  margin-right: auto;
}

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

.back-button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.back-button:hover {
  background: var(--surface-hover);
  border-color: #3f3f46;
}

.nav-item {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-item:hover, .nav-item.active {
  color: #fff;
}

.search-container {
  display: flex;
  gap: 12px;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  width: 240px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--text-muted);
}

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

/* Main Content */
main {
  padding: 24px 40px;
  flex: 1;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
  color: #fff;
}

/* List / Table Style */
.list-header {
  display: grid;
  grid-template-columns: 60px 3fr 1fr 2fr 100px; /* #, Title, Prob, Preds, Status */
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.list-body {
  display: flex;
  flex-direction: column;
}

.list-row {
  display: grid;
  grid-template-columns: 60px 3fr 1fr 2fr 100px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  transition: background 0.2s;
  cursor: pointer;
  background: var(--surface);
}

.list-row:nth-child(even) {
  background: var(--bg);
}

.list-row:hover {
  background: var(--surface-hover);
}

.col-rank {
  color: var(--primary);
  font-weight: 700;
  font-family: monospace;
}

.col-title {
  font-weight: 500;
  padding-right: 20px;
  line-height: 1.4;
}

.col-prob {
  font-family: monospace;
  font-size: 16px;
  font-weight: 700;
}

.col-prob.high { color: var(--yes-text); }
.col-prob.low { color: var(--no-text); }
.col-prob.mid { color: var(--primary); }

.col-preds {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.pill.yes { background: var(--yes-bg); color: var(--yes-text); border-color: rgba(16, 185, 129, 0.2); }
.pill.no { background: var(--no-bg); color: var(--no-text); border-color: rgba(239, 68, 68, 0.2); }
.pill.abstain { background: var(--abstain-bg); color: var(--abstain-text); border-color: rgba(113, 113, 122, 0.2); }
.pill.result-success { border-color: rgba(16, 185, 129, 0.35); box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.15); }
.pill.result-failed { border-color: rgba(239, 68, 68, 0.35); box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.12); }

.status-badge {
  font-size: 11px;
  text-align: right;
  font-weight: 600;
}
.status-open { color: var(--yes-text); }
.status-closed { color: var(--text-muted); }

/* Modal (Dark) */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #18181b;
  width: 800px;
  max-width: 90vw;
  max-height: 85vh;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  margin-left: 16px;
}

.close-btn:hover { color: #fff; }

.modal-body {
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

/* History Items in Modal */
.history-list {
  display: flex;
  flex-direction: column;
}

.history-item {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child { border-bottom: none; }

.history-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.model-name {
  color: #fff;
  font-weight: 600;
  margin-right: 8px;
}

.rationale-text {
  font-size: 14px;
  line-height: 1.6;
  color: #d4d4d8;
}

.truncated-note {
  margin-top: 12px;
  font-size: 12px;
  color: #facc15;
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(9, 9, 11, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(250, 204, 21, 0.35);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Detail Page Layout */
.detail-main {
  padding: 32px 40px 60px;
  max-width: 1200px;
  margin: 0 auto;
}

.detail-header {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 36px;
}

.detail-title {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

.detail-meta-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.meta-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-label {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.meta-value {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.meta-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 16px;
}

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

.model-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.model-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  font-weight: 600;
}

.model-call {
  font-size: 14px;
  font-weight: 600;
}

.model-selection {
  font-size: 12px;
  color: var(--text-muted);
}

.prob-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.2);
  border-radius: 999px;
  color: var(--primary);
  font-size: 12px;
  font-family: monospace;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  background: rgba(39, 39, 42, 0.7);
  color: var(--text-muted);
}

.result-badge.result-success {
  background: var(--yes-bg);
  color: var(--yes-text);
  border-color: rgba(16, 185, 129, 0.35);
}

.result-badge.result-failed {
  background: var(--no-bg);
  color: var(--no-text);
  border-color: rgba(239, 68, 68, 0.35);
}

.history-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.forecast-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.forecast-header {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.forecast-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.forecast-time {
  font-size: 12px;
  color: var(--text-muted);
}

.market-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(113, 113, 122, 0.4);
  font-size: 12px;
  color: #e4e4e7;
  background: rgba(39, 39, 42, 0.6);
}

.forecast-text {
  font-size: 14px;
  line-height: 1.8;
  color: #d4d4d8;
  white-space: pre-line;
}

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

.market-info-panel {
  background: #27272a;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.big-prob {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg); 
}
::-webkit-scrollbar-thumb {
  background: #3f3f46; 
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #52525b; 
}
