/* ══════════════════════════════════════════════
   Dashboard Page Styles
   ══════════════════════════════════════════════ */

/* ── Hero ────────────────────────────────────── */
.hero {
  display: grid;
  gap: 16px;
  margin-bottom: 28px;
}
.eyebrow {
  font: 700 12px/1.2 "Consolas", monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
  max-width: 10ch;
}
.lede {
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

/* ── Mobile Navigation ───────────────────────── */
.mobile-menu-toggle {
  display: none;
  font-size: 1.5rem;
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
  padding: 8px;
}
.nav-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.nav-links.mobile-open {
  flex-direction: column;
  align-items: stretch;
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  background: var(--card);
  padding: 16px;
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.nav-links.mobile-open a,
.nav-links.mobile-open .theme-toggle {
  width: 100%;
  text-align: center;
  margin: 4px 0;
}

/* ── Grid Layout ─────────────────────────────── */
.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(12, 1fr);
}

/* ── Metric Cards ────────────────────────────── */
.metric {
  grid-column: span 3;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.metric .value {
  font-size: 2.2rem;
  font-weight: 700;
}
.metric .label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
}

/* ── Panels ──────────────────────────────────── */
.panel { grid-column: span 6; }
.summary-panel { grid-column: span 6; }
.table-panel { grid-column: span 12; overflow: auto; }
.log-panel { grid-column: span 12; }

/* ── Summary ─────────────────────────────────── */
.summary-grid { display: grid; gap: 12px; }
.summary-row {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.62);
  border: 1px solid var(--line);
}
.summary-key {
  color: var(--muted);
  font: 700 0.74rem/1 "Consolas", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.summary-value { font-size: 1.05rem; font-weight: 700; }
.summary-value.ok { color: var(--accent-2); }
.summary-value.bad { color: var(--danger); }
.summary-value.warn { color: #b86f1b; }

/* ── Tabs ────────────────────────────────────── */
.tabbar {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px;
  background: rgba(30, 31, 28, 0.08);
  gap: 4px;
}
.tabbar button {
  background: transparent;
  color: var(--ink);
  border: none;
  padding: 10px 14px;
}
.tabbar button.active {
  background: var(--ink);
  color: #fff7ef;
}

/* ── Toggle ──────────────────────────────────── */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.76);
  border: 1px solid var(--line);
  color: var(--ink);
  font: 700 0.76rem/1 "Consolas", monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.toggle input {
  margin: 0;
  accent-color: var(--accent-2);
}

/* ── Log Box ─────────────────────────────────── */
.log-box {
  min-height: 280px;
  max-height: 420px;
  overflow: auto;
  border-radius: 18px;
  padding: 16px;
  background: rgba(30, 31, 28, 0.92);
  color: #f3eee5;
  border: 1px solid rgba(255,255,255,0.06);
  font: 0.84rem/1.55 "Consolas", monospace;
  white-space: pre-wrap;
}
.log-line { display: block; white-space: pre-wrap; }
.log-line.signal { color: #9ee493; }
.log-line.blocked { color: #ff8f8f; }
.log-line.candidate { color: #ffc36b; }

/* ── Active Signals Cards ────────────────────── */
.active-signals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.active-signal-card {
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.active-signal-card.long { border-left: 4px solid var(--accent-2); }
.active-signal-card.short { border-left: 4px solid var(--danger); }
.signal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.signal-pair { font-size: 1.2rem; font-weight: 700; }
.signal-direction.long { color: var(--accent-2); }
.signal-direction.short { color: var(--danger); }
.signal-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.signal-metric {
  background: rgba(255,255,255,0.5);
  padding: 8px;
  border-radius: 8px;
}
.signal-metric-key {
  font: 700 0.65rem/1 "Consolas", monospace;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.signal-metric-value { font-size: 1rem; font-weight: 700; }
.pnl-positive { color: var(--accent-2); }
.pnl-negative { color: var(--danger); }
.progress-bar {
  height: 8px;
  background: rgba(0,0,0,0.1);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s;
}
.signal-footer {
  display: flex;
  justify-content: space-between;
  font: 700 0.7rem/1 "Consolas", monospace;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Chart Container ─────────────────────────── */
#chart-container {
  height: 250px;
  width: 100%;
  position: relative;
}

/* ── Mobile Responsive ───────────────────────── */
@media (max-width: 900px) {
  .shell { width: 100% !important; max-width: 100% !important; padding: 10px !important; margin: 0 !important; }
  .mobile-menu-toggle {
    display: block !important;
    position: fixed !important;
    top: 10px !important; left: 10px !important;
    z-index: 1000 !important;
    background: var(--card) !important;
    border: 1px solid var(--line) !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
  }
  nav { position: relative !important; height: 50px !important; }
  .nav-links {
    display: none !important;
    position: fixed !important;
    top: 60px !important; left: 0 !important; right: 0 !important;
    background: var(--card) !important;
    padding: 16px !important;
    border-bottom: 1px solid var(--line) !important;
    box-shadow: var(--shadow) !important;
    z-index: 999 !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  .nav-links.mobile-open { display: flex !important; }
  .nav-links a, .nav-links .theme-toggle {
    width: 100% !important; text-align: center !important;
    padding: 12px !important; margin: 0 !important;
  }
  .hero { margin-top: 60px !important; }
  .hero h1 { font-size: 1.4rem !important; line-height: 1.2 !important; }
  .hero .lede { font-size: 0.85rem !important; line-height: 1.4 !important; }
  .grid { display: flex !important; flex-direction: column !important; gap: 10px !important; width: 100% !important; }
  .card { width: 100% !important; max-width: 100% !important; padding: 12px !important; margin: 0 !important; }
  .metric { width: 100% !important; min-height: 90px !important; padding: 10px !important; }
  .metric .value { font-size: 1.5rem !important; }
  .metric .label { font-size: 0.65rem !important; }
  .toolbar { display: flex !important; flex-direction: column !important; gap: 6px !important; width: 100% !important; }
  .toolbar > * { width: 100% !important; max-width: 100% !important; }
  .toolbar select, .toolbar button, .toolbar input { height: 40px !important; font-size: 0.9rem !important; }
  .toolbar .toggle { display: flex !important; justify-content: center !important; align-items: center !important; }
  table { font-size: 0.7rem !important; width: 100% !important; max-width: 100% !important; overflow-x: auto !important; display: block !important; }
  th, td { padding: 4px 2px !important; white-space: nowrap !important; }
  .active-signals-grid { display: flex !important; flex-direction: column !important; gap: 10px !important; }
  .active-signal-card { width: 100% !important; }
  #chart-container { width: 100% !important; max-width: 100% !important; height: 250px !important; min-height: 250px !important; position: relative !important; overflow: hidden !important; }
  #chart-container canvas { width: 100% !important; height: 100% !important; }
  .summary-grid { display: flex !important; flex-direction: column !important; gap: 8px !important; }
  .summary-row { width: 100% !important; padding: 8px !important; }
  .log-box { font-size: 0.7rem !important; max-height: 300px !important; }
  .signal-metrics { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }
  .signal-metric-value { font-size: 0.85rem !important; }
}

@media (max-width: 480px) {
  .shell { padding: 6px !important; }
  .mobile-menu-toggle { top: 6px !important; left: 6px !important; padding: 6px 10px !important; font-size: 1.2rem !important; }
  .hero { margin-top: 50px !important; }
  .hero h1 { font-size: 1.2rem !important; }
  .hero .lede { font-size: 0.8rem !important; }
  .metric { min-height: 80px !important; padding: 8px !important; }
  .metric .value { font-size: 1.2rem !important; }
  .metric .label { font-size: 0.6rem !important; }
  .card { padding: 8px !important; }
  #chart-container { height: 200px !important; min-height: 200px !important; }
  .signal-metrics { grid-template-columns: 1fr !important; }
  .toolbar select, .toolbar button, .toolbar input { height: 36px !important; font-size: 0.85rem !important; }
}

/* ── Cycle Table Styles ──────────────────────── */
.table-wrapper {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}

#cycles-table {
  font-size: 0.82rem;
  white-space: nowrap;
  border-collapse: collapse;
}

#cycles-table th {
  position: sticky;
  top: 0;
  background: var(--card, #fff);
  z-index: 10;
  padding: 8px 6px;
  text-align: left;
  border-bottom: 2px solid var(--line);
  font: 700 0.72rem/1 "Consolas", monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

#cycles-table td {
  padding: 6px 6px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.cycle-row:hover {
  background: rgba(0,0,0,0.03);
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-signal { background: #d4edda; color: #155724; }
.status-no_signal { background: #f8f9fa; color: #6c757d; }
.status-skip { background: #fff3cd; color: #856404; }
.status-confidence_fail { background: #f8d7da; color: #721c24; }
.status-cooldown { background: #d1ecf1; color: #0c5460; }
.status-error { background: #f8d7da; color: #721c24; }
.status-unknown { background: #e2e3e5; color: #383d41; }

.blocker-cell {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.75rem;
}
