/* ═══════════════════════════════════════════════════════════
   Koda Monkey Bot — Dark Theme Dashboard
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg:        #0d0f12;
  --bg2:       #141820;
  --bg3:       #1c2130;
  --border:    #252d3d;
  --text:      #d4daf0;
  --text-dim:  #6b7894;
  --accent:    #4f8ef7;
  --green:     #3ecf8e;
  --red:       #f75f6e;
  --yellow:    #f7c94f;
  --orange:    #f79c4f;
  --mono:      'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

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

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 13px;
  line-height: 1.5;
  padding-top: env(safe-area-inset-top);
}

/* ── SCROLLBAR ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── LOGIN ────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px;
  width: 340px;
  text-align: center;
}
.login-logo { margin-bottom: 12px; }
.login-logo-img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-sub { color: var(--text-dim); margin-bottom: 28px; font-size: 12px; }
.login-box input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.login-box input:focus { border-color: var(--accent); }
.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.login-box button:hover { opacity: 0.85; }
.error-msg { color: var(--red); margin-top: 10px; font-size: 12px; }
.hidden { display: none !important; }

/* ── HEADER ───────────────────────────────────────────────── */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.header-logo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

/* ── PAGE LINKS ───────────────────────────────────────────── */
#app-links {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
#app-links a {
  text-decoration: none;
  color: var(--text-dim);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
#app-links a:hover, #app-links a.active {
  color: var(--text);
  background: var(--bg3);
}

/* ── PORTFOLIO BAR ────────────────────────────────────────── */
.portfolio-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-wrap: nowrap;
  white-space: nowrap;
  position: sticky;
  top: 88px;
  z-index: 99;
  height: 34px;
  scrollbar-width: none;
}
.portfolio-bar::-webkit-scrollbar { display: none; }
.port-metric {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 12px 0 0;
  min-width: 85px;
  height: 34px;
}
.port-metric.port-breakeven {
  min-width: 0;
  flex: 1;
}
.port-label {
  font-size: 8px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1px;
  line-height: 1;
}
.port-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.port-cost { color: var(--text-dim); font-weight: 400; }
.port-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 10px 0 2px;
  flex-shrink: 0;
}

/* ── BADGES ───────────────────────────────────────────────── */
.badge-paper {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(247,201,79,0.15);
  color: var(--yellow);
  border: 1px solid rgba(247,201,79,0.3);
}
.badge-live {
  background: rgba(245,75,95,0.15);
  color: var(--red);
  border: 1px solid rgba(245,75,95,0.3);
}
.badge-active {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(62,207,142,0.15);
  color: var(--green);
  border: 1px solid rgba(62,207,142,0.3);
}
.badge-killed {
  background: rgba(247,95,110,0.2);
  color: var(--red);
  border: 1px solid var(--red);
}
.badge-paused {
  background: rgba(247,201,79,0.15);
  color: var(--yellow);
  border: 1px solid rgba(247,201,79,0.3);
}
.count-badge {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--text-dim);
}

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn-sm {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-control {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--mono);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-control:hover { border-color: var(--yellow); color: var(--yellow); }
.btn-danger {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--mono);
  background: rgba(247,95,110,0.1);
  border: 1px solid var(--red);
  color: var(--red);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-danger:hover { background: rgba(247,95,110,0.2); }
.btn-success {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--mono);
  background: rgba(62,207,142,0.1);
  border: 1px solid var(--green);
  color: var(--green);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-success:hover { background: rgba(62,207,142,0.2); }

/* ── PAGES ────────────────────────────────────────────────── */
.page { display: none; padding: 20px; max-width: 1400px; margin: 0 auto; }
.page.active { display: block; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 18px; }

/* ── STATS GRID ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.stat-label { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; }

/* ── ROW TWO ──────────────────────────────────────────────── */
.row-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 900px) { .row-two { grid-template-columns: 1fr; } }

/* ── PANELS ───────────────────────────────────────────────── */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.panel-header h2 { font-size: 13px; }

/* ── FEED LISTS ───────────────────────────────────────────── */
.feed-list {
  padding: 8px;
  max-height: 280px;
  overflow-y: auto;
}
.feed-item {
  padding: 8px 10px;
  border-radius: 5px;
  margin-bottom: 4px;
  border-left: 3px solid var(--border);
  font-size: 12px;
  line-height: 1.4;
  background: var(--bg);
}
.feed-item.spike { border-left-color: var(--yellow); }
.feed-item.arb   { border-left-color: var(--accent); }
.feed-item.win   { border-left-color: var(--green); }
.feed-item.loss  { border-left-color: var(--red); }
.feed-item.error { border-left-color: var(--red); background: rgba(247,95,110,0.05); }
.feed-item.warn  { border-left-color: var(--orange); }
.feed-item.info  { border-left-color: var(--accent); }
.feed-item-time { color: var(--text-dim); font-size: 10px; }
.empty-state { color: var(--text-dim); padding: 16px; text-align: center; font-size: 12px; }

/* ── PROGRESS BAR (spike confirmation) ───────────────────── */
.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--yellow);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ── CONTROLS PANEL ──────────────────────────────────────── */
.controls-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}
.controls-panel h2 { font-size: 13px; margin-bottom: 14px; }
.controls-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.control-group { display: flex; flex-direction: column; gap: 6px; }
.control-label { font-size: 11px; color: var(--text-dim); }

/* ── TABLE ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
thead tr { background: var(--bg3); border-bottom: 1px solid var(--border); }
th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid rgba(37,45,61,0.5);
  cursor: pointer;
  transition: background 0.1s;
}
tbody tr:hover { background: var(--bg3); }
td { padding: 8px 12px; }
.pnl-positive { color: var(--green); }
.pnl-negative { color: var(--red); }
.status-open   { color: var(--yellow); }
.status-closed { color: var(--text-dim); }
.mode-paper    { color: var(--text-dim); font-size: 10px; }
.mode-live     { color: var(--red); font-size: 10px; }

/* ── JOURNAL FILTERS ──────────────────────────────────────── */
.journal-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.journal-filters select, .journal-filters input {
  padding: 5px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
}
.journal-filters select:focus, .journal-filters input:focus {
  border-color: var(--accent);
}

/* ── REASONING PANEL ──────────────────────────────────────── */
.reasoning-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}
.reasoning-panel h3 { font-size: 13px; margin-bottom: 10px; color: var(--accent); }
#reasoning-text { font-size: 12px; line-height: 1.6; color: var(--text); }

/* ── PATTERNS ─────────────────────────────────────────────── */
.patterns-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.pattern-stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 120px;
}
.pattern-stat-label { font-size: 10px; color: var(--text-dim); }
.pattern-stat-val   { font-size: 18px; font-weight: 700; }

.pattern-list { padding: 8px; max-height: 400px; overflow-y: auto; }
.pattern-item {
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.pattern-desc { font-size: 12px; margin-bottom: 4px; }
.pattern-meta { font-size: 11px; color: var(--text-dim); display: flex; gap: 10px; flex-wrap: wrap; }
.pattern-ev-pos { color: var(--green); }
.pattern-ev-neg { color: var(--red); }

.category-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.category-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}
.category-name { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; }
.category-wr   { font-size: 16px; font-weight: 700; }

/* ── READINESS ────────────────────────────────────────────── */
.readiness-score {
  text-align: center;
  padding: 32px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 20px;
}
.readiness-pct  { font-size: 56px; font-weight: 700; }
.readiness-text { font-size: 14px; color: var(--text-dim); margin-top: 8px; }

.checklist { display: flex; flex-direction: column; gap: 8px; }
.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.check-icon { font-size: 16px; flex-shrink: 0; }
.check-name { flex: 1; font-size: 13px; }
.check-value { color: var(--text-dim); font-size: 12px; }
.check-item.passed { border-left: 3px solid var(--green); }
.check-item.failed { border-left: 3px solid var(--border); opacity: 0.7; }

/* ── HEALTH ───────────────────────────────────────────────── */
.health-metric {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.health-metric:last-child { border-bottom: none; }
.health-ok   { color: var(--green); }
.health-warn { color: var(--yellow); }
.health-err  { color: var(--red); }

/* ── TOAST ────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: 7px;
  font-size: 12px;
  max-width: 320px;
  animation: slideIn 0.3s ease;
  border-left: 3px solid;
}
.toast-success { background: var(--bg2); border-color: var(--green); color: var(--green); }
.toast-error   { background: var(--bg2); border-color: var(--red);   color: var(--red); }
.toast-info    { background: var(--bg2); border-color: var(--accent); color: var(--accent); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── MARKETS TABLE ────────────────────────────────────────── */
.market-title {
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}
.market-price { font-weight: 600; font-size: 12px; white-space: nowrap; }
.market-vol   { color: var(--text-dim); font-size: 11px; }
.market-age   { color: var(--text-dim); font-size: 11px; white-space: nowrap; }

/* Category badges */
.cat-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.cat-economics {
  background: rgba(79, 142, 247, 0.15);
  color: var(--accent);
  border: 1px solid rgba(79, 142, 247, 0.3);
}
.cat-political {
  background: rgba(168, 100, 240, 0.15);
  color: #a864f0;
  border: 1px solid rgba(168, 100, 240, 0.3);
}
.cat-weather-trade {
  background: rgba(62, 207, 142, 0.15);
  color: var(--green);
  border: 1px solid rgba(62, 207, 142, 0.3);
}
.cat-other {
  background: rgba(107, 120, 148, 0.15);
  color: var(--text-dim);
  border: 1px solid rgba(107, 120, 148, 0.3);
}

/* ── MISC ─────────────────────────────────────────────────── */
.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral  { color: var(--text-dim); }

/* ── THREE-TIER P&L ───────────────────────────────────────── */
.three-tier-summary { display: flex; gap: 12px; padding: 12px; background: var(--bg2); border-radius: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tier-item { padding: 8px 16px; border-radius: 6px; font-size: 13px; }
.tier-item.locked { background: rgba(62,207,142,0.15); color: var(--green); }
.tier-item.unrealized { background: rgba(79,142,247,0.15); color: var(--accent); }
.tier-item.realized { background: rgba(107,120,148,0.15); color: var(--text-dim); }
.tier-total { padding: 8px 16px; font-size: 14px; font-weight: bold; color: var(--text); }

/* ── STRATEGY GROUPS ─────────────────────────────────────── */
.positions-grouped { display: flex; flex-direction: column; gap: 16px; }
.strategy-group { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.strategy-group-header { background: var(--bg2); padding: 12px 16px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.strategy-group-header.arb { border-left: 3px solid var(--green); }
.strategy-group-header.info-flow { border-left: 3px solid var(--accent); }
.strategy-group-header.momentum { border-left: 3px solid var(--yellow); }
.strategy-group-body { padding: 12px; }
.arb-pair { background: rgba(62,207,142,0.05); border: 1px solid rgba(62,207,142,0.2); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.arb-pair-header { font-weight: 600; margin-bottom: 8px; display: flex; justify-content: space-between; }
.arb-leg { padding: 6px 0; padding-left: 20px; font-size: 12px; color: var(--text-dim); }
.arb-leg::before { content: '├─ '; font-family: monospace; }
.arb-leg:last-of-type::before { content: '└─ '; font-family: monospace; }
.locked-badge { background: rgba(62,207,142,0.2); color: var(--green); padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.position-item { background: var(--bg2); border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.position-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.position-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; font-size: 11px; }
.metric-cell { background: var(--bg); padding: 4px 8px; border-radius: 4px; }
.metric-label { color: var(--text-dim); font-size: 10px; }
.metric-value { font-weight: 600; }

/* ── REPUTATION ──────────────────────────────────────────── */
.reputation-list { display: flex; flex-direction: column; gap: 6px; }
.reputation-item { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 6px; background: var(--bg2); }
.rep-active { border-left: 3px solid var(--green); }
.rep-watchlist { border-left: 3px solid var(--yellow); }
.rep-blacklisted { border-left: 3px solid var(--red); opacity: 0.7; }

/* ── STRATEGY PERF TABLE ─────────────────────────────────── */
.strategy-perf-table { width: 100%; border-collapse: collapse; }
.strategy-perf-table th { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-dim); font-size: 11px; text-transform: uppercase; }
.strategy-perf-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }

/* ── RESET PANEL ─────────────────────────────────────────── */
.danger-zone { border: 1px solid var(--red) !important; }
.reset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 12px; }
.btn-warning { background: var(--yellow); color: #000; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-family: var(--mono); font-size: 12px; }
.port-locked { background: rgba(62,207,142,0.08); border-radius: 6px; padding: 4px 8px; }

/* ═══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — bottom nav, mobile card, breakpoints
   ═══════════════════════════════════════════════════════════ */

/* Hide mobile-only elements on desktop */
.port-mobile-card { display: none; }
.bottom-nav       { display: none; }
.drawer-overlay   { display: none; }
.more-drawer      { display: none; }

/* ── MOBILE BOTTOM NAV ────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
.bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 10px;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.bnav-item.active, .bnav-item:active { color: var(--accent); }
.bnav-icon { font-size: 20px; line-height: 1; }
.bnav-label { font-size: 10px; }

/* ── MORE DRAWER ──────────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  -webkit-tap-highlight-color: transparent;
}
.more-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  z-index: 301;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.more-drawer.open { transform: translateY(0); }
.more-drawer-header {
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 16px;
  color: var(--text-dim);
}
.more-drawer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  font-size: 11px;
  text-align: center;
  min-height: 64px;
  -webkit-tap-highlight-color: transparent;
}
.more-item:active { background: var(--border); }
.more-item-danger { color: var(--red); }
.more-icon { font-size: 22px; }

/* ── MOBILE PORTFOLIO CARD ────────────────────────────────── */
.port-mobile-card {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.port-mobile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.port-mobile-cell {
  padding: 14px 16px;
  border-right: 1px solid var(--border);
}
.port-mobile-cell-right { border-right: none; }
.port-mobile-cell-top   { border-top: 1px solid var(--border); }
.port-mobile-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.port-mobile-big {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}
.port-mobile-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.port-mobile-footer {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
}
.port-mobile-regime-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(62,207,142,0.15);
  color: var(--green);
  border: 1px solid rgba(62,207,142,0.3);
}

/* ── RESPONSIVE BREAKPOINTS ───────────────────────────────── */
@media (max-width: 768px) {
  /* Show mobile UI, hide desktop UI */
  .port-mobile-card { display: block; }
  .bottom-nav       { display: flex; }
  .more-drawer      { display: block; } /* always rendered, off-screen via transform */

  /* Links hidden on mobile — bottom nav handles navigation */
  #app-links { display: none; }
  #app-header { padding: max(10px, env(safe-area-inset-top)) 12px 10px; }
  .header-brand { font-size: 13px; }
  .header-logo { width: 28px; height: 28px; }

  /* Hide desktop portfolio bar */
  #portfolio-bar { display: none; }

  /* Page padding adjusted for bottom nav + safe area */
  .page { padding: 12px 12px max(80px, calc(56px + env(safe-area-inset-bottom))); }

  /* Stats grid → 2 col */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* Panels go full-width */
  .row-two { grid-template-columns: 1fr; gap: 10px; }

  /* Tighter panel headers */
  .panel-header { padding: 10px 12px; }
  .panel-header h2 { font-size: 12px; }

  /* Feed list smaller max-height */
  .feed-list { max-height: 200px; }

  /* Journal table — hide less important cols on small screens */
  #trades-table th:nth-child(1),
  #trades-table td:nth-child(1),
  #trades-table th:nth-child(8),
  #trades-table td:nth-child(8),
  #trades-table th:nth-child(9),
  #trades-table td:nth-child(9),
  #trades-table th:nth-child(10),
  #trades-table td:nth-child(10),
  #trades-table th:nth-child(12),
  #trades-table td:nth-child(12),
  #trades-table th:nth-child(14),
  #trades-table td:nth-child(14) { display: none; }

  /* Markets table — keep only title + price + volume */
  #markets-table th:nth-child(2),
  #markets-table td:nth-child(2),
  #markets-table th:nth-child(5),
  #markets-table td:nth-child(5) { display: none; }

  /* Strategy table on mobile */
  .strategy-perf-table th:nth-child(n+5),
  .strategy-perf-table td:nth-child(n+5) { display: none; }

  /* Page header stacks */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-header h1 { font-size: 16px; }

  /* Readiness score smaller */
  .readiness-pct { font-size: 42px; }

  /* Reset grid stacks */
  .reset-grid { grid-template-columns: 1fr; }

  /* Controls grid scrollable */
  .controls-grid { flex-direction: column; gap: 10px; }

  /* Position metrics more compact */
  .position-metrics { grid-template-columns: repeat(2, 1fr); }

  /* Toast moves up for bottom nav */
  #toast-container { bottom: 72px; }

  /* Touch input: prevent iOS zoom */
  input, select, textarea { font-size: 16px !important; }

  /* Safari tap highlight */
  a, button { -webkit-tap-highlight-color: transparent; }

  /* Smooth momentum scroll */
  .feed-list, .table-wrap, .pattern-list { -webkit-overflow-scrolling: touch; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  /* Tablet: compact links */
  #app-links a { padding: 2px 6px; font-size: 11px; }
  .page { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
