/* ─── CSS VARIABLES ─────────────────────────────── */
:root {
  --bg: #0a0e1a;
  --bg2: #111827;
  --bg3: #1a2235;
  --border: #1e2d47;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --text-dim: #4a5568;
  --green: #10b981;
  --green-dim: #064e3b;
  --red: #ef4444;
  --red-dim: #7f1d1d;
  --blue: #3b82f6;
  --blue-dim: #1e3a5f;
  --yellow: #f59e0b;
  --purple: #8b5cf6;
  --orange: #f97316;
  --sidebar-w: 220px;
  --sidebar-w-collapsed: 60px;
  --topbar-h: 56px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

/* ─── RESET ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, sans-serif;
       line-height: 1.5; min-height: 100vh; overflow-x: hidden; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea { background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); padding: 0.4rem 0.6rem; border-radius: var(--radius-sm);
  outline: none; width: 100%; font-size: 0.875rem; }
input:focus, select:focus { border-color: var(--blue); }
input.readonly-input { opacity: 0.6; cursor: not-allowed; }
button { cursor: pointer; border: none; font-family: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ─── LAYOUT ─────────────────────────────────────── */
.main-wrapper { margin-left: var(--sidebar-w); min-height: 100vh;
  transition: margin-left var(--transition); display: flex; flex-direction: column; }
.page-content { padding: 1.5rem; flex: 1; }

/* ─── SIDEBAR ────────────────────────────────────── */
.sidebar { position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh;
  background: var(--bg2); border-right: 1px solid var(--border); z-index: 200;
  display: flex; flex-direction: column; transition: width var(--transition); overflow: hidden; }
.sidebar-logo { display: flex; align-items: center; gap: 0.5rem; padding: 1rem;
  border-bottom: 1px solid var(--border); min-height: var(--topbar-h); }
.logo-icon { font-size: 1.5rem; }
.logo-text { font-weight: 700; font-size: 1.1rem; color: var(--blue); white-space: nowrap; }
.sidebar-toggle { margin-left: auto; background: none; color: var(--text-muted);
  font-size: 1.1rem; padding: 0.2rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.75rem 0; }
.nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 1rem;
  color: var(--text-muted); transition: all var(--transition); white-space: nowrap; }
.nav-item:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--blue-dim); color: var(--blue); border-right: 3px solid var(--blue); }
.nav-icon { font-size: 1.1rem; flex-shrink: 0; }
.nav-section { padding: 0.75rem 1rem 0.25rem; color: var(--text-dim);
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; }

.sidebar-footer { padding: 0.75rem; border-top: 1px solid var(--border); }
.auto-trade-status { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem;
  border-radius: var(--radius-sm); background: var(--bg3); margin-bottom: 0.5rem;
  font-size: 0.8rem; color: var(--text-muted); }
.auto-trade-status.active { background: var(--green-dim); color: var(--green); }

/* ─── TOPBAR ─────────────────────────────────────── */
.topbar { height: var(--topbar-h); background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem; position: sticky;
  top: 0; z-index: 100; }
.topbar-title { font-weight: 600; font-size: 1rem; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.live-indicator { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem;
  color: var(--green); font-weight: 600; }
.live-label { letter-spacing: 0.05em; }
.notif-btn { position: relative; background: none; color: var(--text); font-size: 1.2rem;
  padding: 0.3rem; }
.notif-badge { position: absolute; top: -2px; right: -4px; background: var(--red);
  color: white; font-size: 0.65rem; font-weight: 700; border-radius: 999px;
  padding: 0.1rem 0.3rem; min-width: 16px; text-align: center; }
.notif-badge.hidden { display: none; }
.user-pill { background: var(--blue); color: white; width: 30px; height: 30px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; }
.sidebar-toggle-mobile { display: none; background: none; color: var(--text);
  font-size: 1.3rem; padding: 0.3rem; }

/* ─── PULSE DOT ──────────────────────────────────── */
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim);
  display: inline-block; position: relative; }
.pulse-dot.green { background: var(--green); }
.pulse-dot.green::after { content: ''; position: absolute; inset: -3px; border-radius: 50%;
  background: var(--green); opacity: 0.3; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.5); opacity: 0; } }

/* ─── BUTTONS ────────────────────────────────────── */
.btn { padding: 0.45rem 1rem; border-radius: var(--radius-sm); font-size: 0.875rem;
  font-weight: 500; transition: all var(--transition); background: var(--bg3);
  color: var(--text); border: 1px solid var(--border); }
.btn:hover { background: var(--border); }
.btn-primary { background: var(--blue); color: white; border-color: var(--blue); }
.btn-primary:hover { background: #2563eb; }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-dim); }
.btn-full { width: 100%; justify-content: center; }
.btn-xs { padding: 0.2rem 0.6rem; font-size: 0.75rem; border-radius: var(--radius-sm);
  background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); }
.btn-xs:hover { color: var(--text); border-color: var(--text-muted); }
.btn-xs.btn-primary { background: var(--blue); color: white; border-color: var(--blue); }
.btn-xs.btn-danger { color: var(--red); border-color: var(--red-dim); }
.btn-xs.btn-trade { color: var(--green); border-color: var(--green-dim); }
.btn-icon { background: none; color: var(--text-muted); font-size: 1rem; }

/* ─── PANELS ─────────────────────────────────────── */
.panel { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 1.5rem; }
.panel-header { display: flex; align-items: center; gap: 1rem; padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border); }
.panel-header h2 { font-size: 0.95rem; font-weight: 600; flex: 1; }
.panel-body { padding: 1.2rem; }

/* ─── KPI GRID ───────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; display: flex; align-items: center; gap: 0.75rem; }
.kpi-icon { font-size: 1.8rem; }
.kpi-value { font-size: 1.3rem; font-weight: 700; line-height: 1.2; }
.kpi-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.05em; }

/* ─── DASHBOARD GRID ─────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.panel-wide { grid-column: span 2; }
.panel-chart { grid-column: span 2; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; }
  .panel-wide, .panel-chart { grid-column: span 1; } }

/* ─── SIGNALS LIST ───────────────────────────────── */
.signals-list { padding: 0.5rem; }
.signal-row { padding: 0.75rem; border-bottom: 1px solid var(--border); }
.signal-row:last-child { border-bottom: none; }
.signal-row.confidence-high { border-left: 3px solid var(--green); }
.signal-row.confidence-med { border-left: 3px solid var(--yellow); }
.signal-row.confidence-low { border-left: 3px solid var(--text-dim); }
.signal-ticker { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.3rem; }
.signal-title { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.signal-meta { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

/* ─── BADGES ─────────────────────────────────────── */
.ticker-badge { background: var(--blue-dim); color: var(--blue); padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm); font-weight: 700; font-size: 0.8rem; font-family: monospace; }
.ticker-badge.sm { font-size: 0.7rem; padding: 0.1rem 0.3rem; }
.signal-badge { padding: 0.15rem 0.5rem; border-radius: var(--radius-sm);
  font-size: 0.7rem; font-weight: 700; }
.signal-strong_buy,.signal-buy { background: var(--green-dim); color: var(--green); }
.signal-watch { background: #1a2c1a; color: var(--yellow); }
.signal-sell,.signal-strong_sell { background: var(--red-dim); color: var(--red); }
.side-badge { padding: 0.1rem 0.5rem; border-radius: var(--radius-sm); font-size: 0.7rem; font-weight: 700; }
.side-badge.buy { background: var(--green-dim); color: var(--green); }
.side-badge.sell { background: var(--red-dim); color: var(--red); }
.cat-badge { padding: 0.1rem 0.4rem; border-radius: var(--radius-sm); font-size: 0.65rem;
  background: var(--bg3); color: var(--text-muted); }
.cat-badge.cat-ai_pivot,.cat-badge.cat-ai_infrastructure { color: var(--purple); }
.cat-badge.cat-oil_major,.cat-badge.cat-oil_services { color: var(--orange); }
.status-badge { padding: 0.1rem 0.4rem; border-radius: var(--radius-sm); font-size: 0.65rem; }
.status-current { background: var(--blue-dim); color: var(--blue); }
.status-past { background: var(--bg3); color: var(--text-muted); }
.status-possible { background: #1a1a2e; color: var(--purple); }
.active-badge { background: var(--green-dim); color: var(--green); font-size: 0.65rem;
  padding: 0.1rem 0.4rem; border-radius: var(--radius-sm); font-weight: 700; }
.paper-badge { background: var(--yellow); color: #000; font-size: 0.65rem;
  padding: 0.1rem 0.4rem; border-radius: var(--radius-sm); font-weight: 700; }
.auto-badge { background: var(--purple); color: white; font-size: 0.65rem;
  padding: 0.1rem 0.4rem; border-radius: var(--radius-sm); font-weight: 700; }
.broker-badge { background: var(--bg3); color: var(--text); font-size: 0.75rem;
  padding: 0.15rem 0.5rem; border-radius: var(--radius-sm); font-weight: 600; border: 1px solid var(--border); }

/* ─── CONFIDENCE BAR ─────────────────────────────── */
.confidence-bar-wrap { flex: 1; height: 6px; background: var(--bg3); border-radius: 3px; min-width: 60px; }
.confidence-bar-wrap.sm { height: 4px; min-width: 40px; }
.confidence-bar { height: 100%; border-radius: 3px; background: var(--blue); transition: width 0.3s; }
.confidence-bar.conf-high { background: var(--green); }
.confidence-bar.conf-med { background: var(--yellow); }
.confidence-bar.conf-low { background: var(--text-dim); }
.confidence-pct { font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.confidence-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.confidence-dot.conf-h { background: var(--green); }
.confidence-dot.conf-m { background: var(--yellow); }
.confidence-dot.conf-l { background: var(--text-dim); }

/* ─── NEWS MINI LIST ─────────────────────────────── */
.news-mini-list { padding: 0.25rem 0; max-height: 400px; overflow-y: auto; }
.news-mini-row { padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.news-mini-row:hover { background: var(--bg3); }
.news-mini-meta { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.25rem; }
.news-mini-title { font-size: 0.8rem; color: var(--text-muted); line-height: 1.3; }

/* ─── NEWS GRID ──────────────────────────────────── */
.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.news-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; cursor: pointer; transition: border-color var(--transition); }
.news-card:hover { border-color: var(--blue); }
.news-card-header { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.news-card-title { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.4rem; line-height: 1.4; }
.news-card-summary { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4;
  margin-bottom: 0.5rem; max-height: 50px; overflow: hidden; }
.news-card-footer { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.target-pct { font-size: 0.8rem; font-weight: 700; }
.news-source { font-size: 0.7rem; color: var(--text-dim); margin-left: auto; }

/* ─── CATEGORY TABS ──────────────────────────────── */
.category-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem;
  padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.cat-tab { padding: 0.3rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.75rem;
  background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); cursor: pointer; }
.cat-tab:hover { color: var(--text); }
.cat-tab.active { background: var(--blue-dim); color: var(--blue); border-color: var(--blue); }

/* ─── FILTERS BAR ────────────────────────────────── */
.filters-bar { display: flex; gap: 1rem; align-items: flex-end; margin-bottom: 1rem; flex-wrap: wrap;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; }
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-group label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.filter-group select, .filter-group input[type=text] { width: auto; min-width: 100px; }
input[type=range] { -webkit-appearance: none; height: 4px; background: var(--border);
  border-radius: 2px; cursor: pointer; width: 100px; border: none; padding: 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--blue); cursor: pointer; }

/* ─── TRADES TABLE ───────────────────────────────── */
.trades-table-wrap { overflow-x: auto; }
.trades-table { width: 100%; }
.trades-table th { padding: 0.6rem 0.75rem; font-size: 0.7rem; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap; }
.trades-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border);
  font-size: 0.85rem; }
.trades-table tr:hover td { background: var(--bg3); }
.pnl-cell { font-weight: 600; }
.pnl-cell .pct { font-size: 0.75rem; opacity: 0.8; }
.mini-confidence { display: flex; align-items: center; gap: 0.4rem; }
.confidence-bar.sm { height: 4px; }
.action-cell { white-space: nowrap; display: flex; gap: 0.4rem; align-items: center; }

/* ─── TRADE CONTROLS BAR ─────────────────────────── */
.trade-controls-bar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem; padding: 0.75rem 1rem; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius); }
.auto-toggle-wrap { display: flex; align-items: center; gap: 0.5rem; }
.auto-info { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.75rem;
  color: var(--text-muted); margin-left: 1rem; }
.auto-info span { background: var(--bg3); padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm); }

/* ─── TAB BAR ────────────────────────────────────── */
.tab-bar { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab { padding: 0.6rem 1.2rem; background: none; color: var(--text-muted);
  font-size: 0.875rem; border-bottom: 2px solid transparent; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── PERFORMANCE ROW ────────────────────────────── */
.perf-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem; margin-bottom: 1rem; }
.perf-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem; }

/* ─── TOGGLE SWITCH ──────────────────────────────── */
.toggle-switch { position: relative; display: inline-flex; width: 40px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; border-radius: 22px; background: var(--bg3);
  border: 1px solid var(--border); cursor: pointer; transition: var(--transition); }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px;
  top: 2px; left: 2px; border-radius: 50%; background: var(--text-muted); transition: var(--transition); }
.toggle-switch input:checked + .toggle-slider { background: var(--green-dim); border-color: var(--green); }
.toggle-switch input:checked + .toggle-slider::before { background: var(--green); transform: translateX(18px); }
.toggle-switch.sm { width: 32px; height: 18px; }
.toggle-switch.sm .toggle-slider::before { width: 12px; height: 12px; }
.toggle-switch.sm input:checked + .toggle-slider::before { transform: translateX(14px); }

/* ─── MODAL ──────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 300; backdrop-filter: blur(2px); }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.95);
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  width: min(500px, 95vw); max-height: 90vh; overflow-y: auto; z-index: 400;
  opacity: 0; pointer-events: none; transition: all 0.2s; }
.modal.modal-lg { width: min(700px, 95vw); }
.modal.open { opacity: 1; pointer-events: all; transform: translate(-50%, -50%) scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.2rem; }
.modal-footer { display: flex; gap: 0.75rem; padding: 1rem 1.2rem; border-top: 1px solid var(--border); }

/* ─── FORMS ──────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.form-group .hint { font-size: 0.65rem; color: var(--text-dim); font-weight: 400; margin-left: 0.5rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.form-row .form-group { flex: 1; min-width: 140px; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer;
  font-size: 0.85rem; color: var(--text); }
.checkbox-label input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; }

/* ─── SLIDER INPUT ───────────────────────────────── */
.slider-input { display: flex; align-items: center; gap: 0.75rem; }
.slider-input input[type=range] { flex: 1; }
.slider-input span { min-width: 40px; font-size: 0.85rem; font-weight: 600; }

/* ─── SETTINGS LAYOUT ────────────────────────────── */
.settings-section { margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: none; }
.settings-section h3 { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 1rem; }

/* ─── SPLITS BAR ─────────────────────────────────── */
.splits-visual { margin-bottom: 1rem; }
.split-bar { display: flex; height: 24px; border-radius: var(--radius-sm); overflow: hidden; }
.split-seg { display: flex; align-items: center; justify-content: center; font-size: 0.65rem;
  font-weight: 600; overflow: hidden; transition: width 0.3s; }
.seg-reinvest { background: var(--green-dim); color: var(--green); }
.seg-withdraw { background: var(--blue-dim); color: var(--blue); }
.seg-reserve { background: var(--bg3); color: var(--text-muted); }

/* ─── NOTIFICATION PANEL ─────────────────────────── */
.notif-overlay { display: none; position: fixed; inset: 0; z-index: 250; }
.notif-panel { position: fixed; right: -380px; top: 0; bottom: 0; width: 380px; max-width: 100vw;
  background: var(--bg2); border-left: 1px solid var(--border); z-index: 300;
  display: flex; flex-direction: column; transition: right 0.3s; }
.notif-panel.open { right: 0; }
.notif-header { display: flex; align-items: center; gap: 0.5rem; padding: 1rem;
  border-bottom: 1px solid var(--border); }
.notif-header span { flex: 1; font-weight: 600; }
.notif-list { flex: 1; overflow-y: auto; }
.notif-item { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  cursor: pointer; }
.notif-item.unread { background: var(--bg3); }
.notif-item:hover { background: var(--bg3); }
.notif-item-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.2rem; }
.notif-item-msg { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }
.notif-item-time { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.25rem; }
.notif-loading { padding: 2rem; text-align: center; color: var(--text-muted); }
.notif-prefs-grid { padding: 0.5rem 1rem; }
.notif-prefs-header { display: grid; grid-template-columns: 1fr 60px 60px; gap: 0.5rem;
  padding: 0.5rem 0; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase;
  border-bottom: 1px solid var(--border); }
.notif-pref-row { display: grid; grid-template-columns: 1fr 60px 60px; gap: 0.5rem;
  align-items: center; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.event-name { font-size: 0.8rem; }

/* ─── TOAST ──────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 500;
  display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.75rem 1.2rem; border-radius: var(--radius); background: var(--bg2);
  border: 1px solid var(--border); color: var(--text); font-size: 0.85rem; max-width: 320px;
  box-shadow: var(--shadow); animation: slideIn 0.3s ease; }
.toast.success { border-color: var(--green); background: var(--green-dim); color: var(--green); }
.toast.error { border-color: var(--red); background: var(--red-dim); color: var(--red); }
.toast.warning { border-color: var(--yellow); color: var(--yellow); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; } }

/* ─── FLASH MESSAGES ─────────────────────────────── */
.flash-container { padding: 0.75rem 1.5rem 0; }
.flash { padding: 0.75rem 1rem; border-radius: var(--radius-sm); display: flex;
  align-items: center; justify-content: space-between; margin-bottom: 0.5rem; font-size: 0.85rem; }
.flash-error { background: var(--red-dim); border: 1px solid var(--red); color: var(--red); }
.flash-success { background: var(--green-dim); border: 1px solid var(--green); color: var(--green); }
.flash-info { background: var(--blue-dim); border: 1px solid var(--blue); color: var(--blue); }

/* ─── AUTH PAGE ──────────────────────────────────── */
.auth-page { display: flex; min-height: 100vh; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #0d1526 0%, var(--bg) 70%); }
.auth-container { width: 100%; display: flex; align-items: center; justify-content: center; }
.auth-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2.5rem; width: min(400px, 95vw); box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.auth-logo { text-align: center; margin-bottom: 2rem; }
.logo-icon-lg { font-size: 3rem; }
.auth-logo h1 { font-size: 1.8rem; font-weight: 800; color: var(--blue); margin: 0.5rem 0 0.25rem; }
.auth-logo p { color: var(--text-muted); font-size: 0.85rem; }
.auth-form .form-group { margin-bottom: 1rem; }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.75rem; color: var(--text-dim); }
.auth-bg-text { display: none; }

/* ─── ACCOUNTS PAGE ──────────────────────────────── */
.payment-accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem; padding: 1rem; }
.payment-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem; }
.payment-card.provider-mpesa { border-color: #00a651; }
.payment-card.provider-stripe { border-color: var(--purple); }
.payment-card.provider-paypal { border-color: #003087; }
.payment-card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.provider-icon { font-size: 1.5rem; }
.provider-name { font-weight: 700; font-size: 0.85rem; }
.payment-label { font-size: 0.75rem; color: var(--text-muted); }
.payment-identifier { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; font-family: monospace; }
.payment-balance { font-size: 1.3rem; font-weight: 700; color: var(--green); margin-bottom: 0.75rem; }
.payment-actions { display: flex; gap: 0.5rem; }
.broker-accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem; padding: 1rem; }
.broker-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; }
.broker-card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.broker-label { font-weight: 600; }
.broker-balances { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.75rem; }
.bal-row { display: flex; justify-content: space-between; font-size: 0.85rem; }
.bal-row span { color: var(--text-muted); }
.sync-time { font-size: 0.7rem; color: var(--text-dim); margin-bottom: 0.5rem; }
.summary-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem; padding: 1rem; }
.summary-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem; text-align: center; }
.sc-value { font-size: 1.1rem; font-weight: 700; }
.sc-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ─── API KEYS ───────────────────────────────────── */
.keys-list { padding: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.key-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; }
.key-card.key-active { border-color: var(--green); }
.key-header { display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 0.5rem; flex-wrap: wrap; gap: 0.5rem; }
.service-badge { font-size: 0.7rem; font-weight: 700; padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); }
.key-label { font-size: 0.85rem; font-weight: 600; }
.test-badge { font-size: 0.75rem; padding: 0.2rem 0.5rem; border-radius: var(--radius-sm); }
.test-ok { background: var(--green-dim); color: var(--green); }
.test-failed { background: var(--red-dim); color: var(--red); }
.test-untested { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.key-meta { display: flex; gap: 1rem; font-size: 0.75rem; color: var(--text-muted);
  margin-bottom: 0.5rem; flex-wrap: wrap; }
.key-actions { display: flex; gap: 0.5rem; }
.service-hint { font-size: 0.78rem; color: var(--text-muted); margin: 0.5rem 0;
  background: var(--bg3); padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
  border-left: 3px solid var(--blue); }
.eye-btn { margin-top: 0.25rem; }

/* ─── ACCOUNTING ─────────────────────────────────── */
.accounting-summary { padding: 0.75rem 1rem; }
.acct-row { display: flex; justify-content: space-between; padding: 0.4rem 0;
  border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.acct-row:last-child { border-bottom: none; }
.acct-total { font-weight: 700; font-size: 1rem; margin-top: 0.25rem; }
.entry-type-badge { padding: 0.1rem 0.4rem; border-radius: var(--radius-sm); font-size: 0.7rem; background: var(--bg3); }
.et-trade_profit, .et-deposit { background: var(--green-dim); color: var(--green); }
.et-trade_loss, .et-withdrawal { background: var(--red-dim); color: var(--red); }
.et-reinvestment { background: var(--blue-dim); color: var(--blue); }

/* ─── CHARTS ─────────────────────────────────────── */
.chart-controls { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }

/* ─── MISC ───────────────────────────────────────── */
.empty-state { padding: 2rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.spinner-center { display: flex; justify-content: center; padding: 2rem; }
.spinner { width: 24px; height: 24px; border: 2px solid var(--border);
  border-top-color: var(--blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-muted); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 0.5rem; }
.pagination { display: flex; gap: 0.25rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pagination button { padding: 0.3rem 0.6rem; border-radius: var(--radius-sm);
  background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border);
  font-size: 0.8rem; cursor: pointer; }
.pagination button.active { background: var(--blue); color: white; border-color: var(--blue); }
.news-loading { display: flex; align-items: center; justify-content: center; gap: 1rem;
  padding: 3rem; color: var(--text-muted); grid-column: 1/-1; }
.confidence-display { display: flex; align-items: center; gap: 1.5rem; margin: 1rem 0;
  background: var(--bg3); padding: 1rem; border-radius: var(--radius); }
.conf-gauge-wrap { position: relative; }
.conf-number { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  font-size: 1.1rem; font-weight: 700; }
.conf-details { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.85rem; }
.price-info { display: flex; gap: 1rem; flex-wrap: wrap; margin: 0.75rem 0; }
.price-pill { background: var(--bg3); padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; }
.price-pill span { color: var(--text-muted); }
.price-pill strong { font-size: 1rem; font-weight: 700; }
.mdl-section { margin-top: 1rem; }
.mdl-section h4 { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 0.4rem; font-weight: 600; }
.mdl-section p { font-size: 0.875rem; line-height: 1.6; }
.mdl-meta { font-size: 0.75rem; color: var(--text-muted); margin: 0.4rem 0; }
.role-badge { padding: 0.1rem 0.4rem; border-radius: var(--radius-sm); font-size: 0.7rem; font-weight: 700; }
.role-admin { background: var(--purple); color: white; }
.role-trader { background: var(--bg3); color: var(--text-muted); }
.group-filter { display: flex; gap: 0.25rem; }
.admin-intro { background: var(--blue-dim); border: 1px solid var(--blue); border-radius: var(--radius);
  padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.85rem; }
.accounts-list .account-row { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.account-row:last-child { border-bottom: none; }
.account-info { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.account-label { font-size: 0.85rem; color: var(--text-muted); }
.account-balances { display: flex; gap: 1.5rem; }
.balance-item { display: flex; flex-direction: column; }
.bal-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }
.bal-value { font-size: 0.9rem; font-weight: 600; }

/* ─── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle-mobile { display: block; }
  .sidebar-toggle { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .panel-wide, .panel-chart { grid-column: span 1; }
  .news-grid { grid-template-columns: 1fr; }
  .trade-controls-bar { flex-wrap: wrap; }
  .auto-info { display: none; }
  .filters-bar { flex-direction: column; }
  .modal { width: 96vw; }
  .page-content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .category-tabs { gap: 0.25rem; }
  .cat-tab { padding: 0.25rem 0.5rem; font-size: 0.7rem; }
}

/* ─── MISSING / SUPPLEMENTAL CLASSES ─────────────────────────────────────── */
.accounts-page { display: flex; flex-direction: column; gap: 1.5rem; }
.admin-layout  { display: flex; flex-direction: column; gap: 1.5rem; }
.kpi-body      { display: flex; flex-direction: column; gap: 0.15rem; }
.bg-ticker     { position: absolute; font-size: 1.2rem; font-weight: 700; color: rgba(59,130,246,0.12);
                 animation: float 8s ease-in-out infinite; pointer-events: none; }
.bg-ticker:nth-child(1) { top: 15%; left: 5%; animation-delay: 0s; }
.bg-ticker:nth-child(2) { top: 30%; right: 8%; animation-delay: 1.5s; }
.bg-ticker:nth-child(3) { top: 55%; left: 12%; animation-delay: 3s; }
.bg-ticker:nth-child(4) { top: 20%; right: 20%; animation-delay: 0.8s; color: rgba(16,185,129,0.2); font-size: 2rem; }
.bg-ticker:nth-child(5) { bottom: 20%; left: 30%; animation-delay: 2s; }
.bg-ticker:nth-child(6) { bottom: 35%; right: 10%; animation-delay: 4s; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-15px)} }

.key-status    { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.current-price { font-family: monospace; font-size: 0.85rem; }
.drag-handle   { cursor: grab; user-select: none; font-size: 1.1rem; padding: 0 0.5rem;
                 color: var(--text-dim); }
.drag-handle:active { cursor: grabbing; }
.nav-item.logout { margin-top: auto; color: var(--red); }
.nav-item.logout:hover { background: var(--red-dim); color: var(--red); }

/* ─── ADDITIONAL RESPONSIVE FIXES ─────────────────────────────────────────── */
/* Login page auth-bg positioning */
.auth-container { position: relative; }
.auth-bg-text   { display: block; position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.auth-card      { position: relative; z-index: 1; }

/* Table action cells */
.action-cell    { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; min-width: 140px; }

/* Settings form sections */
.settings-layout { display: flex; flex-direction: column; gap: 1.5rem; }
.settings-form   { display: flex; flex-direction: column; gap: 0; }

/* Dashboard quick trade modal z-index ensure */
#quickTradeOverlay, #quickTradeModal,
#newTradeOverlay, #newTradeModal { z-index: 350; }

/* News page confidence display centering */
.conf-gauge-wrap { position: relative; display: flex; align-items: flex-end; justify-content: center; }
.conf-number     { font-size: 1rem; font-weight: 700; text-align: center; }

/* Accounts page btn spacing */
.payment-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* LLM Management drag row */
#providerTableBody tr[data-pid]:hover { background: var(--bg3); }
#providerTableBody tr[data-pid][draggable] { transition: opacity 0.2s; }

/* Audit log table truncation */
.audit-detail-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Auto info mobile hide already handled; add tablet hide */
@media (max-width: 1024px) {
  .auto-info { display: none; }
  .kpi-grid  { grid-template-columns: repeat(3, 1fr); }
}

/* Very small mobile */
@media (max-width: 360px) {
  .kpi-grid  { grid-template-columns: 1fr 1fr; }
  .tab-bar   { overflow-x: auto; flex-wrap: nowrap; }
  .category-tabs { display: flex; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.5rem; }
  .cat-tab   { flex-shrink: 0; }
  .modal     { width: 100vw; border-radius: 0; top: auto; bottom: 0; transform: translateX(-50%); }
  .modal.open { transform: translateX(-50%) translateY(0); }
}

/* Touch-friendly tap targets */
@media (hover: none) {
  .btn, .btn-xs, .nav-item, .cat-tab, .tab { min-height: 40px; display: inline-flex; align-items: center; }
  .toggle-switch { width: 48px; height: 26px; }
  .toggle-slider::before { width: 20px; height: 20px; }
  .toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }
}

/* Print/export */
@media print {
  .sidebar, .topbar, .notif-panel, .toast-container, .btn, .btn-xs { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .panel { break-inside: avoid; }
}
