/* ============================================================
   TRADING AGENT — Terminal Fintech Dark Theme
   Fonts: Exo 2 (display) · Figtree (body) · JetBrains Mono (data)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Exo+2:wght@500;600;700;800&family=Figtree:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ── */
:root {
  --bg:        #07090f;
  --surface:   #0d1117;
  --surface2:  #131920;
  --surface3:  #1a2232;
  --border:    #1e2d3d;
  --border2:   #2a3f55;
  --text:      #cdd9e5;
  --text-muted:#5a7a9a;
  --text-dim:  #3d5570;
  --accent:    #00c9ff;
  --accent2:   #0088bb;
  --green:     #00e676;
  --green-dim: rgba(0,230,118,0.12);
  --red:       #ff4444;
  --red-dim:   rgba(255,68,68,0.12);
  --yellow:    #ffb300;
  --yellow-dim:rgba(255,179,0,0.12);
  --purple:    #bd93f9;

  --sidebar-w: 230px;
  --topbar-h:  56px;
  --radius:    10px;
  --radius-sm: 6px;
  --font-body: 'Figtree', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-display: 'Exo 2', sans-serif;

  --glow-accent: 0 0 20px rgba(0,201,255,0.15);
  --glow-green:  0 0 20px rgba(0,230,118,0.15);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  display: flex;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,201,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,201,255,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: var(--glow-accent);
}

.sidebar-logo .sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  font-weight: 500;
}

/* Status bar */
.sidebar-status {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.status-dot.running {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s ease-in-out infinite;
}
.status-dot.error { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green); }
  50%       { opacity: 0.5; box-shadow: 0 0 3px var(--green); }
}

.status-text { font-weight: 500; color: var(--text); }
.next-run { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); }

/* Nav */
nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }

nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  cursor: pointer;
  position: relative;
}

nav a .nav-icon {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 15px;
  transition: all 0.15s;
  flex-shrink: 0;
}

nav a:hover {
  color: var(--text);
  background: var(--surface2);
}
nav a:hover .nav-icon { background: var(--surface3); }

nav a.active {
  color: var(--accent);
  background: rgba(0,201,255,0.06);
}
nav a.active .nav-icon {
  background: rgba(0,201,255,0.1);
}
nav a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  box-shadow: var(--glow-accent);
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
}

/* ══════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════ */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: rgba(13,17,23,0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h2 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  font-size: 18px;
}

.content { padding: 24px; flex: 1; max-width: 1400px; }

/* ── Panels ── */
.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ══════════════════════════════════════
   STAT CARDS
══════════════════════════════════════ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,201,255,0.3), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.card:hover { border-color: var(--border2); transform: translateY(-1px); }
.card:hover::before { opacity: 1; }

.card-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.card-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.5px;
}

.card-change {
  font-size: 11px;
  margin-top: 6px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ══════════════════════════════════════
   SECTION HEADERS
══════════════════════════════════════ */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.section-header h3 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.section-tag {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-left: 8px;
}

/* ══════════════════════════════════════
   MARKET MOVERS
══════════════════════════════════════ */
#movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

.movers-col-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.movers-col-label.gainers { color: var(--green); }
.movers-col-label.losers  { color: var(--red); }

.price-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.price-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: border-color 0.15s, background 0.15s;
}
.price-card:hover { border-color: var(--border2); background: var(--surface2); }

.price-card .symbol {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}
.price-card .price {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  margin-top: 2px;
  color: var(--text);
}
.price-card .change { font-size: 11px; margin-top: 1px; }

/* ══════════════════════════════════════
   TABLES
══════════════════════════════════════ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  white-space: nowrap;
}

td {
  padding: 11px 16px;
  border-bottom: 1px solid rgba(30,45,61,0.6);
  font-size: 13px;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,201,255,0.02); }

/* ══════════════════════════════════════
   BADGES
══════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.badge-buy    { background: var(--green-dim); color: var(--green); }
.badge-sell   { background: var(--red-dim); color: var(--red); }
.badge-closed { background: rgba(0,201,255,0.1); color: var(--accent); }
.badge-failed { background: var(--red-dim); color: var(--red); }

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border2); background: var(--surface3); color: var(--text); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #07090f;
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: var(--glow-accent);
}
.btn-primary:hover { background: #33d4ff; border-color: #33d4ff; color: #07090f; }

.btn-danger { background: var(--red-dim); color: var(--red); border-color: rgba(255,68,68,0.25); }
.btn-danger:hover { background: rgba(255,68,68,0.2); border-color: rgba(255,68,68,0.4); }

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

.btn-run {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #07090f;
  border: none;
  font-weight: 700;
  font-size: 12px;
  padding: 8px 16px;
  box-shadow: var(--glow-accent);
  letter-spacing: 0.3px;
}
.btn-run:hover { box-shadow: 0 0 30px rgba(0,201,255,0.3); transform: translateY(-1px); color: #07090f; }

/* ══════════════════════════════════════
   CHART
══════════════════════════════════════ */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  height: 220px;
  position: relative;
}

/* ══════════════════════════════════════
   LOG STREAM
══════════════════════════════════════ */
.log-stream {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  display: flex;
  flex-direction: column-reverse;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

.log-stream::-webkit-scrollbar { width: 4px; }
.log-stream::-webkit-scrollbar-track { background: transparent; }
.log-stream::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.log-entry {
  padding: 7px 14px;
  border-bottom: 1px solid rgba(30,45,61,0.4);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: background 0.1s;
}
.log-entry:hover { background: rgba(0,201,255,0.02); }
.log-entry:last-child { border-bottom: none; }

.log-ts {
  color: var(--text-dim);
  flex-shrink: 0;
  font-size: 10px;
  padding-top: 1px;
  min-width: 56px;
}

.log-type {
  flex-shrink: 0;
  width: 88px;
  font-size: 10px;
  font-weight: 500;
  padding-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-type.thought     { color: var(--purple); }
.log-type.tool_call   { color: var(--accent); }
.log-type.tool_result { color: var(--green); }
.log-type.decision    { color: var(--yellow); font-weight: 700; }
.log-type.error       { color: var(--red); }
.log-type.trade       { color: var(--green); font-weight: 700; }

.log-content {
  color: var(--text);
  word-break: break-all;
  flex: 1;
  line-height: 1.5;
}

/* Decision log rendered as markdown */
.log-entry.decision-entry {
  flex-direction: column;
  gap: 0;
  border-left: 2px solid var(--yellow);
  background: rgba(255,179,0,0.03);
  padding: 12px 14px;
}

.decision-entry .log-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.decision-markdown {
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.7;
  padding: 14px 16px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow-x: auto;
}

/* Markdown content styling */
.decision-markdown h1,
.decision-markdown h2,
.decision-markdown h3 {
  font-family: var(--font-display);
  color: var(--accent);
  margin: 14px 0 8px;
  font-weight: 700;
  line-height: 1.3;
}
.decision-markdown h1 { font-size: 16px; }
.decision-markdown h2 { font-size: 14px; }
.decision-markdown h3 { font-size: 13px; color: var(--text); }

.decision-markdown p { margin-bottom: 8px; }
.decision-markdown p:last-child { margin-bottom: 0; }

.decision-markdown strong { color: var(--text); font-weight: 600; }
.decision-markdown em { color: var(--text-muted); }

.decision-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-family: var(--font-mono);
  font-size: 11px;
}
.decision-markdown th {
  background: var(--surface3);
  color: var(--accent);
  padding: 6px 10px;
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid var(--border);
}
.decision-markdown td {
  padding: 5px 10px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  background: transparent;
}
.decision-markdown tr:hover td { background: rgba(0,201,255,0.02); }

.decision-markdown ul,
.decision-markdown ol {
  padding-left: 18px;
  margin-bottom: 8px;
}
.decision-markdown li { margin-bottom: 3px; }

.decision-markdown code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface3);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 3px;
}

.decision-markdown blockquote {
  border-left: 3px solid var(--yellow);
  padding: 6px 12px;
  margin: 8px 0;
  background: var(--yellow-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}

.decision-markdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* Collapse toggle for decisions */
.decision-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--yellow);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  user-select: none;
  background: none;
  border: none;
  padding: 0;
}
.decision-toggle:hover { color: #ffd040; }
.decision-toggle .chevron { transition: transform 0.2s; }
.decision-toggle.collapsed .chevron { transform: rotate(-90deg); }

/* ══════════════════════════════════════
   RUNS LIST
══════════════════════════════════════ */
.run-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  transition: background 0.1s;
}
.run-item:hover { background: var(--surface2); }
.run-item:last-child { border-bottom: none; }
.run-item.active-run { background: rgba(0,201,255,0.05); border-left: 2px solid var(--accent); }

.run-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  font-family: var(--font-mono);
}

/* ══════════════════════════════════════
   FORMS
══════════════════════════════════════ */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
}

.form-section h3 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-row:last-child { margin-bottom: 0; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font-body);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,201,255,0.08);
}
input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

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

/* ══════════════════════════════════════
   ALERTS
══════════════════════════════════════ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 14px;
  line-height: 1.5;
}
.alert-success { background: var(--green-dim); border: 1px solid rgba(0,230,118,0.25); color: var(--green); }
.alert-error   { background: var(--red-dim);   border: 1px solid rgba(255,68,68,0.25); color: var(--red); }
.alert-warning { background: var(--yellow-dim); border: 1px solid rgba(255,179,0,0.25); color: var(--yellow); }
.alert-info    { background: rgba(0,201,255,0.06); border: 1px solid rgba(0,201,255,0.2); color: var(--accent); }

/* ══════════════════════════════════════
   PAGINATION
══════════════════════════════════════ */
.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  justify-content: flex-end;
}
.page-info { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

/* ══════════════════════════════════════
   UTILITIES
══════════════════════════════════════ */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-mono   { font-family: var(--font-mono); }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 13px;
}
.empty .icon { font-size: 28px; margin-bottom: 10px; opacity: 0.6; }

/* ── Toggle ── */
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer;
  inset: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 24px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: 0.2s;
}
.toggle input:checked + .toggle-slider {
  background: rgba(0,230,118,0.15);
  border-color: var(--green);
  box-shadow: 0 0 8px rgba(0,230,118,0.2);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: var(--green);
}

/* ══════════════════════════════════════
   MOBILE BOTTOM NAV
══════════════════════════════════════ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  backdrop-filter: blur(12px);
}

.mobile-nav-inner {
  display: flex;
  height: 100%;
}

.mobile-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.15s;
  cursor: pointer;
}
.mobile-nav a .mnav-icon { font-size: 18px; }
.mobile-nav a.active { color: var(--accent); }

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.6); }

  .main { margin-left: 0; }

  .mobile-menu-btn { display: flex; }
  .mobile-nav { display: flex; }

  .content { padding: 16px; padding-bottom: 76px; }

  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px 16px; }
  .card-value { font-size: 20px; }

  #movers-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Logs panel: stack vertically on mobile */
  #panel-logs .logs-layout {
    grid-template-columns: 1fr !important;
    height: auto !important;
  }
  #panel-logs .runs-col {
    max-height: 220px;
    overflow-y: auto;
  }
  #panel-logs .log-stream {
    height: 50vh !important;
  }

  .form-row { grid-template-columns: 1fr; }

  /* Tables: horizontal scroll on mobile */
  .table-wrap { overflow-x: auto; }

  th, td { padding: 8px 12px; font-size: 12px; }
}

@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .topbar h2 { font-size: 15px; }
}

/* Sidebar overlay backdrop on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }
