/* PrintMoney Web Dashboard — Light, gentle theme */

:root {
  --bg-primary: #f5f6f8;
  --bg-card: #ffffff;
  --bg-hover: #f0f1f4;
  --text-primary: #1a1d28;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --green: #16a34a;
  --green-dim: #15803d;
  --red: #dc2626;
  --red-dim: #b91c1c;
  --amber: #d97706;
  --blue: #2563eb;
  --border: #e5e7eb;
  --radius: 10px;

  /* Per-account accent colors */
  --accent-alpaca: #2563eb;     /* Blue — paper/sandbox feel */
  --accent-schwab: #7e22ce;     /* Purple — real money, distinct */
}

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

/* ─── Broker Account Tabs ──────────────────────────────────────────────── */
.broker-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border-radius: 14px;
  padding: 5px;
  margin: 16px 24px;
  max-width: 480px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.broker-tab {
  flex: 1;
  padding: 11px 24px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.broker-tab:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.broker-tab.active[data-broker="primary"] {
  color: white;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.broker-tab.active[data-broker="secondary"] {
  color: white;
  background: linear-gradient(135deg, #7e22ce, #9333ea);
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
}

.tab-count {
  font-size: 10px;
  font-weight: 700;
  background: rgba(255,255,255,0.25);
  padding: 1px 6px;
  border-radius: 8px;
}

.broker-content {
  display: none;
  animation: brokerFadeIn 0.2s ease-out;
}

.broker-content.active {
  display: block;
}

/* Account-specific accents applied to the whole content area */
.broker-content[data-broker="secondary"] .card-header {
  border-bottom-color: rgba(147, 51, 234, 0.15);
}

/* Read-only badge for secondary account */
.readonly-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(147, 51, 234, 0.1);
  color: var(--accent-schwab);
  border: 1px solid rgba(147, 51, 234, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 8px;
}

@keyframes brokerFadeIn {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ─── Global Cards (Scanner + Signals — outside tabs) ──────────────── */
.global-card {
  margin: 8px 16px;
}

/* ── Broker Selector Toggle (inside signal cards) ──────────────────── */
.broker-selector {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: var(--bg-hover);
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-left: auto;
}

.broker-selector-btn {
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.broker-selector-btn.selected {
  background: var(--accent-alpaca);
  color: white;
}

.broker-selector-btn.selected.live {
  background: var(--accent-schwab);
}

.broker-selector-btn:not(.selected):hover {
  color: var(--text-secondary);
  background: rgba(0,0,0,0.04);
}

/* Mobile: global cards full-width */
@media (max-width: 600px) {
  .global-card {
    margin: 4px 8px;
  }
}

/* ─── Account Identity Banners ───────────────────────────────────────── */
/* Prominent, always-visible banner that makes it impossible to confuse accounts */

.account-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  margin: 0 16px 4px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
}

.account-banner-icon {
  font-size: 18px;
}

.account-banner-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.account-banner-broker {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.8;
}

.account-banner-readonly {
  margin-left: auto;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 4px;
  letter-spacing: 1px;
}

/* Paper trading banner — blue, relaxed feel */
.account-banner--paper {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0.04));
  border: 1px solid rgba(37, 99, 235, 0.2);
  color: #1d4ed8;
}

/* Live account banner — purple, with stronger visual weight */
.account-banner--live {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.1), rgba(147, 51, 234, 0.04));
  border: 1px solid rgba(147, 51, 234, 0.25);
  color: #7e22ce;
}

.account-banner--live .account-banner-readonly {
  background: rgba(147, 51, 234, 0.12);
  border: 1px solid rgba(147, 51, 234, 0.3);
  color: #7e22ce;
}

/* ─── Account Banner Tag ───────────────────────────────────────────── */
.account-banner-tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 6px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.account-banner--paper .account-banner-tag {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.account-banner--live .account-banner-tag {
  background: rgba(126, 34, 206, 0.1);
  color: #7e22ce;
  border: 1px solid rgba(126, 34, 206, 0.2);
}

/* ─── Tab icon ───────────────────────────────────────────────────────── */
.tab-icon {
  font-size: 15px;
  margin-right: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   EQUITY CHART HERO — Robinhood-style full-width chart section
   ═══════════════════════════════════════════════════════════════════════ */
.equity-hero {
  background: var(--bg-card);
  margin: 0 16px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  transition: box-shadow 0.2s;
}

.equity-hero:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.equity-hero-inner {
  padding: 24px 24px 0;
}

.equity-hero-value {
  font-size: 36px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--text-primary);
}

.equity-hero-change {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
}

.equity-hero-change.positive { color: var(--green); }
.equity-hero-change.negative { color: var(--red); }

.equity-hero-period {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

.equity-chart-wrapper {
  position: relative;
  height: 200px;
  padding: 16px 12px 0;
}

.equity-timeline {
  display: flex;
  gap: 4px;
  padding: 12px 24px 16px;
  border-top: 1px solid var(--border);
}

.timeline-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.timeline-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.timeline-btn.active {
  color: white;
  background: var(--accent-alpaca);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.timeline-btn-live.active {
  background: var(--accent-schwab);
  box-shadow: 0 2px 6px rgba(126, 34, 206, 0.25);
}

/* ═══════════════════════════════════════════════════════════════════════
   COLLAPSIBLE SECTIONS — Trade history collapsed by default
   ═══════════════════════════════════════════════════════════════════════ */
.card-header-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

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

.card-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.collapse-icon {
  font-size: 10px;
  transition: transform 0.3s ease;
  color: var(--text-muted);
}

.collapse-icon.expanded {
  transform: rotate(90deg);
}

.collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.collapsible-body.expanded {
  max-height: 2000px;
}

/* ─── Secondary No-Trading Notice ──────────────────────────────────── */
.sec-no-trading-notice {
  padding: 24px 20px;
  text-align: center;
}

.no-trading-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.no-trading-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.no-trading-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 8px;
}

.no-trading-hint {
  font-size: 11px;
  color: var(--accent-alpaca);
}

/* ─── Secondary Position Summary ───────────────────────────────────── */
.sec-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.sec-summary-stat {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  background: var(--bg-card);
}

.sec-summary-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 3px;
}

.sec-summary-value {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ─── Footer Tab Badge ────────────────────────────────────────────── */
.footer-tab-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.3px;
}

.footer-tab-badge.paper {
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent-alpaca);
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.footer-tab-badge.live {
  background: rgba(126, 34, 206, 0.08);
  color: var(--accent-schwab);
  border: 1px solid rgba(126, 34, 206, 0.15);
}

/* ─── Account Info Grid (secondary) ───────────────────────────────── */
.sec-account-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 60px;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ──────────────────────────────────────────────────────────────── */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-left h1 {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-link { text-decoration: none; }
.logo-link:hover { text-decoration: none; }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-user {
  font-size: 12px;
  color: var(--text-secondary);
  margin-right: 4px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 6px rgba(22, 163, 74, 0.4);
}
.status-dot.disconnected {
  background: var(--red);
  box-shadow: 0 0 6px rgba(220, 38, 38, 0.4);
}

.mode-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent-alpaca);
  border: 1px solid rgba(37, 99, 235, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mode-badge.live {
  background: rgba(22, 163, 74, 0.1);
  color: var(--green);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

/* ── Dashboard Grid (responsive 2-column) ────────────────────────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
}

.dashboard-col {
  padding: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤900px)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  header {
    padding: 12px 16px;
  }
  .equity-hero {
    margin: 0 8px 8px;
  }
  .account-banner {
    margin: 0 8px 4px;
  }
  .broker-tabs {
    margin: 12px 8px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤600px)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  body {
    font-size: 14px;
    padding-bottom: 52px;
    -webkit-text-size-adjust: 100%;
  }

  /* ── Header: compact mobile layout ── */
  header {
    padding: 8px 12px;
    gap: 8px;
  }

  .header-left h1 {
    font-size: 17px;
  }

  .header-right {
    gap: 4px;
  }

  .header-right .btn-small {
    padding: 4px 8px;
    font-size: 10px;
  }

  .mode-badge {
    font-size: 9px;
    padding: 2px 6px;
  }

  /* ── Broker Tabs: full-width, bigger touch targets ── */
  .broker-tabs {
    margin: 8px;
    max-width: 100%;
    padding: 4px;
    border-radius: 12px;
  }

  .broker-tab {
    padding: 10px 12px;
    font-size: 12px;
    gap: 6px;
    border-radius: 9px;
  }

  .tab-icon {
    font-size: 14px;
  }

  /* ── Account Banner: stack on small screens ── */
  .account-banner {
    margin: 0 8px 4px;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .account-banner-label {
    font-size: 11px;
  }

  .account-banner-broker {
    font-size: 11px;
    width: 100%;
    order: 3;
  }

  .account-banner-tag {
    font-size: 9px;
    padding: 3px 8px;
  }

  /* ── Equity Hero: shorter chart, tighter padding ── */
  .equity-hero {
    margin: 0 8px 6px;
    border-radius: 8px;
  }

  .equity-hero-inner {
    padding: 16px 16px 0;
  }

  .equity-hero-value {
    font-size: 28px;
  }

  .equity-hero-change {
    font-size: 13px;
    gap: 6px;
  }

  .equity-chart-wrapper {
    height: 140px;
    padding: 12px 8px 0;
  }

  .equity-timeline {
    padding: 10px 12px 12px;
    gap: 2px;
    justify-content: center;
  }

  .timeline-btn {
    padding: 8px 12px;
    font-size: 12px;
    min-width: 40px;
    text-align: center;
    /* Touch-friendly 44px tap target */
    min-height: 36px;
  }

  /* ── Dashboard Grid: single column, no gap ── */
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-col {
    padding: 0;
  }

  /* ── Cards: edge-to-edge feel ── */
  .card {
    margin: 4px 8px;
    border-radius: 8px;
  }

  .card-header {
    padding: 10px 12px;
    font-size: 11px;
  }

  /* ── Account stats: keep 2-col but tighter ── */
  .stat {
    padding: 10px 12px;
  }

  .stat-value {
    font-size: 16px;
  }

  /* ── Risk grid: 2 columns on mobile instead of 3 ── */
  .risk-details-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px 12px 12px;
  }

  .risk-bar-container {
    padding: 10px 12px;
  }

  /* ── Scanner: stack vertically ── */
  .scanner-row {
    flex-direction: column;
    gap: 0;
    padding: 0;
  }

  .scanner-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }

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

  .scanner-divider {
    display: none;
  }

  /* ── Signal cards: tighter on mobile ── */
  .signal-card {
    padding: 12px;
  }

  .signal-details {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .signal-actions {
    flex-wrap: wrap;
  }

  .signal-actions .btn {
    flex: 1;
    min-width: 0;
    text-align: center;
  }

  /* ── Options: stack legs vertically ── */
  .options-legs {
    grid-template-columns: 1fr;
  }

  .options-summary {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* ── Position rows: touch-friendly padding ── */
  .position-row {
    padding: 12px;
  }

  .position-symbol {
    font-size: 15px;
  }

  /* ── Performance stats: 2 columns ── */
  .perf-stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* ── History toggle: bigger tap target ── */
  .card-header-toggle {
    padding: 14px 12px;
    min-height: 44px;
  }

  /* ── Footer: compact ── */
  footer {
    padding: 6px 12px;
    font-size: 10px;
    gap: 6px;
  }

  .footer-tab-badge {
    font-size: 9px;
    padding: 2px 6px;
  }

  /* ── Toast: full-width mobile ── */
  .pm-toast {
    bottom: 52px;
    left: 8px;
    right: 8px;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 8px;
  }

  /* ── Empty states: less padding ── */
  .empty-state {
    padding: 16px 12px;
    font-size: 12px;
  }

  /* ── Secondary account: tighter ── */
  .sec-no-trading-notice {
    padding: 20px 16px;
  }

  .no-trading-icon {
    font-size: 28px;
  }

  .sec-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .sec-account-info-grid {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE — Small phone (≤380px)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  .header-left h1 {
    font-size: 15px;
  }

  /* Hide settings text, keep only icon-like buttons */
  .header-right .btn-outline {
    padding: 4px 6px;
    font-size: 9px;
  }

  .equity-hero-value {
    font-size: 24px;
  }

  .equity-hero-change {
    font-size: 12px;
  }

  .equity-chart-wrapper {
    height: 120px;
  }

  .timeline-btn {
    padding: 6px 8px;
    font-size: 11px;
    min-width: 32px;
  }

  .stat-value {
    font-size: 14px;
  }

  .broker-tab {
    padding: 8px 8px;
    font-size: 11px;
  }

  .account-banner-label {
    font-size: 10px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   PWA / MOBILE APP — safe areas, standalone mode
   ═══════════════════════════════════════════════════════════════════════ */
/* Safe area insets for notched phones (iPhone X+) */
@supports (padding-top: env(safe-area-inset-top)) {
  header {
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  footer {
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* When launched as PWA standalone — no browser chrome */
@media (display-mode: standalone) {
  header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  footer {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
}

/* Prevent pull-to-refresh interference in standalone mode */
@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: contain;
  }
}

/* Touch optimization: no tap highlight, smooth scrolling */
* {
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */

.card {
  margin: 8px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.header-right-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.last-scan-label {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.last-scan-label.scan-stale {
  color: var(--amber);
}

/* ── Signal Scanner (unified) ────────────────────────────────────────────── */

.scanner-row {
  display: flex;
  gap: 0;
  padding: 10px 14px;
}

.scanner-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
}

.scanner-divider {
  width: 1px;
  background: var(--border);
  margin: -4px 0;
}

.scanner-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scanner-type {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.scanner-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auto-scan-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  user-select: none;
}

.auto-scan-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--green);
  cursor: pointer;
}

.toggle-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Account Grid ─────────────────────────────────────────────────────────── */

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  background: var(--bg-card);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }

/* ── Risk Bar ─────────────────────────────────────────────────────────────── */

.risk-bar-container {
  padding: 12px 14px;
}

.risk-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.risk-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--green);
  transition: width 0.5s ease, background 0.3s ease;
}

.risk-bar-fill.warning { background: var(--amber); }
.risk-bar-fill.danger { background: var(--red); }

.risk-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Risk Details Grid ─────────────────────────────────────────────────── */

.risk-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding: 10px 14px 14px;
}

.risk-detail {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.risk-detail-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.risk-detail-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.risk-mini-bar {
  height: 3px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}

.risk-mini-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--green);
  transition: width 0.5s ease, background 0.3s ease;
}

.risk-mini-fill.warning { background: var(--amber); }
.risk-mini-fill.danger { background: var(--red); }

/* ── Alerts ───────────────────────────────────────────────────────────────── */

.alert {
  margin: 8px 14px 12px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
}

/* ── Signal Cards ─────────────────────────────────────────────────────────── */

.signal-card {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

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

.signal-card:last-child {
  border-bottom: none;
}

.signal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.signal-symbol {
  font-size: 15px;
  font-weight: 700;
}

.signal-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.signal-badge.buy {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.signal-badge.sell {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}

.signal-details {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 11px;
}

.signal-detail-item {
  display: flex;
  flex-direction: column;
}

.signal-detail-label {
  color: var(--text-muted);
  font-size: 10px;
}

.signal-scores {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.score-bar-wrapper {
  flex: 1;
}

.score-bar-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
}

.score-bar {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.score-bar-fill.tech { background: var(--blue); }
.score-bar-fill.sent { background: var(--amber); }
.score-bar-fill.vol { background: var(--green); }

.signal-reasoning {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.6;
  padding: 8px;
  background: rgba(59, 130, 246, 0.05);
  border-left: 2px solid rgba(59, 130, 246, 0.3);
  border-radius: 4px;
}

.signal-reasoning-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #2563eb;
  margin-bottom: 5px;
}

.signal-warnings {
  margin-bottom: 10px;
}

.warning-tag {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  margin-right: 4px;
  margin-bottom: 4px;
}

.warning-tag.risk-warn {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

.warning-tag.tier2-warn {
  background: rgba(249, 115, 22, 0.12);
  color: #fb923c;
}

.auto-exec-notice {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin-top: 6px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius);
  color: var(--amber);
  font-size: 11px;
  font-weight: 500;
}

.auto-exec-icon { font-size: 14px; }

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

/* ── Signal context row ──────────────────────────────────────────────────── */

.signal-context-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.regime-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.4px;
}

.regime-bull     { background: rgba(34,197,94,0.1);   color: #15803d; border: 1px solid rgba(34,197,94,0.3); }
.regime-bear     { background: rgba(239,68,68,0.1);   color: #b91c1c; border: 1px solid rgba(239,68,68,0.3); }
.regime-sideways { background: rgba(234,179,8,0.1);   color: #a16207; border: 1px solid rgba(234,179,8,0.3); }
.regime-volatile { background: rgba(249,115,22,0.1);  color: #c2410c; border: 1px solid rgba(249,115,22,0.3); }
.regime-crisis   { background: rgba(220,38,38,0.15);  color: #991b1b; border: 1px solid rgba(220,38,38,0.3); }
.regime-unknown  { background: rgba(148,163,184,0.1); color: #64748b; border: 1px solid rgba(148,163,184,0.3); }

.strategy-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(139,92,246,0.08);
  color: #7c3aed;
  border: 1px solid rgba(139,92,246,0.2);
}

.size-mult-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(245,158,11,0.12);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,0.2);
}

.signal-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.time-horizon-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(20, 184, 166, 0.15);
  color: #2dd4bf;
  border: 1px solid rgba(20, 184, 166, 0.25);
}

.claude-powered {
  font-size: 10px;
  color: var(--text-muted);
}

/* ── Position rows ────────────────────────────────────────────────────────── */

.position-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

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

.position-info {
  display: flex;
  flex-direction: column;
}

.position-symbol {
  font-weight: 700;
  font-size: 14px;
}

.position-details {
  font-size: 11px;
  color: var(--text-muted);
}

.position-pnl {
  text-align: right;
}

.position-pnl-value {
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.position-pnl-pct {
  font-size: 11px;
}

/* ── Stop rows ────────────────────────────────────────────────────────────── */

.stop-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

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

/* ── Close position button ────────────────────────────────────────────────── */

.btn-close-position {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid rgba(239,68,68,0.35);
  background: rgba(239,68,68,0.08);
  color: #f87171;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-close-position:hover:not(:disabled) {
  background: rgba(239,68,68,0.18);
  color: #fca5a5;
}
.btn-close-position:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── Genome status badge ──────────────────────────────────────────────────── */

.genome-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(148,163,184,0.1);
  color: #64748b;
  border: 1px solid rgba(148,163,184,0.3);
  text-transform: none;
  letter-spacing: 0;
}

.genome-status.loaded {
  background: rgba(34,197,94,0.1);
  color: #15803d;
  border: 1px solid rgba(34,197,94,0.3);
}

/* ── Options signal card ─────────────────────────────────────────────────── */

.options-signal-card {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.options-signal-card:hover { background: var(--bg-hover); }
.options-signal-card:last-child { border-bottom: none; }

.options-signal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.options-signal-title {
  font-size: 15px;
  font-weight: 700;
}

.instrument-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.4px;
  background: rgba(139,92,246,0.08);
  color: #7c3aed;
  border: 1px solid rgba(139,92,246,0.2);
}

.options-legs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.options-leg {
  padding: 8px 10px;
  background: var(--bg-hover);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.options-leg-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.options-leg-strikes {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.options-leg-credit {
  font-size: 12px;
  color: var(--green);
}

.options-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 11px;
}

.options-summary-item {
  display: flex;
  flex-direction: column;
}

.options-summary-label {
  font-size: 10px;
  color: var(--text-muted);
}

.options-summary-value {
  font-weight: 600;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  padding: 8px 16px;
  transition: all 0.15s ease;
}

.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--blue);
  color: white;
}

.btn-success {
  background: var(--green);
  color: white;
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-small {
  padding: 4px 10px;
  font-size: 11px;
}

.btn-full {
  width: 100%;
  padding: 12px;
  font-size: 14px;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 24px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  z-index: 50;
}

/* ── Toast notification ───────────────────────────────────────────────────── */

.pm-toast {
  position: fixed;
  bottom: 56px;
  left: 12px;
  right: 12px;
  max-width: 600px;
  margin: 0 auto;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  color: #fff;
  background: #3b82f6;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.pm-toast--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.pm-toast--success  { background: #16a34a; }
.pm-toast--error    { background: #dc2626; }
.pm-toast--warning  { background: #b45309; }
.pm-toast--info     { background: #2563eb; }

/* ── Scan result banner ───────────────────────────────────────────────────── */

.scan-result {
  margin: 6px 14px 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-hover);
  border: 1px solid var(--border);
}

.scan-result--success { color: var(--green); }
.scan-result--neutral { color: var(--text-secondary); }
.scan-result--error   { color: var(--red); }

/* ── Animations ───────────────────────────────────────────────────────────── */

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading { animation: pulse 1.5s ease-in-out infinite; }

/* ── Auth pages (login, setup) ────────────────────────────────────────────── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-container {
  width: 100%;
  max-width: 400px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 32px;
}

.auth-logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 8px;
}

.auth-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--blue);
}

.form-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  padding: 10px 12px;
  margin-bottom: 16px;
  border-radius: 6px;
  font-size: 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.form-success {
  padding: 10px 12px;
  margin-bottom: 16px;
  border-radius: 6px;
  font-size: 12px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--green);
}

/* ── Settings page ────────────────────────────────────────────────────────── */

/* ── Performance Stats ────────────────────────────────────────────────────── */

.perf-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.perf-stat {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  background: var(--bg-card);
}

.perf-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 3px;
}

.perf-value {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.perf-value.positive { color: var(--green); }
.perf-value.negative { color: var(--red); }

/* ── Exit Reason Badges ──────────────────────────────────────────────────── */

.exit-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
}

.exit-reason-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid;
  background: var(--bg-hover);
}

/* ── Trade History ────────────────────────────────────────────────────────── */

.history-count {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

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

.history-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.history-instrument {
  font-weight: 600;
  font-size: 11px;
}

.history-info small {
  color: var(--text-muted);
  font-size: 10px;
}

.history-exit { margin: 0 12px; }

.exit-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.exit-take_profit, .exit-early_exit { background: rgba(34,197,94,0.1); color: #15803d; }
.exit-stop_loss { background: rgba(239,68,68,0.1); color: #b91c1c; }
.exit-time_exit { background: rgba(245,158,11,0.1); color: #a16207; }
.exit-expiry, .exit-manual_close, .exit-unknown { background: rgba(148,163,184,0.1); color: #64748b; }

.history-pnl {
  text-align: right;
  white-space: nowrap;
}

.history-pnl span {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.history-pnl small {
  display: block;
  font-size: 10px;
}

.history-pnl.positive { color: var(--green); }
.history-pnl.negative { color: var(--red); }

/* ── Equity Curve Canvas ─────────────────────────────────────────────────── */

#equity-curve {
  padding: 0 12px 8px;
}

/* ── Settings page ────────────────────────────────────────────────────────── */

.settings-main {
  max-width: 500px;
  margin: 24px auto;
  padding: 0 16px;
}

.settings-form {
  padding: 20px 14px;
}
