/* WhatsApp Trading Agent — Review Dashboard design system.
   Dark theme by default; :root[data-theme="light"] overrides below. */

:root {
  --bg-0: #0a0c11;
  --bg-1: #12141c;
  --bg-2: #181b25;
  --bg-3: #21252f;
  --border: #262a36;
  --border-soft: #1c1f29;
  --text-0: #edeef2;
  --text-1: #a8adba;
  --text-2: #6b7180;
  --accent: #6c8fff;
  --accent-soft: rgba(108, 143, 255, 0.14);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --warning: #f5b942;
  --warning-soft: rgba(245, 185, 66, 0.14);

  --status-waiting: #f5b942;
  --status-needs_review: #ff9f43;
  --status-running: #4d8dff;
  --status-entry_pending: #f5b942;
  --status-active: #4d8dff;
  --status-partial_exit: #2dd4bf;
  --status-break_even: #a78bfa;
  --status-trailing: #22d3ee;
  --status-target_hit: #34d399;
  --status-stop_loss: #f87171;
  --status-exited: #9099ab;
  --status-cancelled: #6b7280;

  /* Real-money mode must be visually unmistakable from Paper's calmer
     palette everywhere it appears — the mode pill, the Real Trading
     page, the "REAL TRADING ENABLED" banner. */
  --real-mode-accent: #ff5c5c;
  --real-mode-accent-soft: rgba(255, 92, 92, 0.16);

  --sidebar-w: 250px;
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
}

:root[data-theme="light"] {
  --bg-0: #f4f5f8;
  --bg-1: #ffffff;
  --bg-2: #ffffff;
  --bg-3: #eef0f4;
  --border: #e2e4ea;
  --border-soft: #edeef2;
  --text-0: #1a1d26;
  --text-1: #565b6b;
  --text-2: #8a8fa0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- App shell ---------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand { font-weight: 700; letter-spacing: 0.01em; }

#sidebar-toggle {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-0);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- Global status bar (topbar contents) ---------- */

.status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-wrap: wrap;
  font-size: 0.78rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-2);
  flex-shrink: 0;
}

.status-pill--ok { color: var(--success); border-color: transparent; background: var(--success-soft); }
.status-pill--ok .dot { background: var(--success); }
.status-pill--bad { color: var(--danger); border-color: transparent; background: var(--danger-soft); }
.status-pill--bad .dot { background: var(--danger); }
.status-pill--warn { color: var(--warning); border-color: transparent; background: var(--warning-soft); }
.status-pill--warn .dot { background: var(--warning); }
.status-pill--real { color: var(--real-mode-accent); border-color: transparent; background: var(--real-mode-accent-soft); font-weight: 700; }
.status-pill--real .dot { background: var(--real-mode-accent); }

.topbar-admin {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-left: 0.6rem;
  margin-left: 0.2rem;
  border-left: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-2);
}

.topbar-admin form { display: inline; }
.topbar-admin button {
  background: none; border: none; color: var(--text-2); cursor: pointer;
  font-size: 0.8rem; padding: 0; text-decoration: underline;
}
.topbar-admin button:hover { color: var(--text-0); }

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.4rem 1.25rem;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #9b6cff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.nav-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  padding: 0.9rem 0.6rem 0.4rem;
}

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link svg { flex-shrink: 0; opacity: 0.85; }
.nav-link:hover { background: var(--bg-3); color: var(--text-0); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link.active svg { opacity: 1; }

.nav-link.disabled {
  color: var(--text-2);
  cursor: default;
  justify-content: space-between;
}

.soon-pill {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--bg-3);
  color: var(--text-2);
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
}

.theme-toggle-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
  color: var(--text-1);
}

.switch {
  position: relative;
  width: 38px;
  height: 21px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--text-1);
  transition: transform 0.15s ease, background 0.15s ease;
}

:root[data-theme="light"] .switch::after { transform: translateX(17px); background: var(--accent); }

/* ---------- Main content ---------- */

.main {
  min-width: 0;
  padding: 1.75rem 2rem 3rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 1.4rem; margin: 0 0 0.2rem; font-weight: 700; }
.page-header p.subtitle { margin: 0; color: var(--text-1); font-size: 0.88rem; }
.page-header-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---------- Buttons / links ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-0);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.btn-sm { padding: 0.32rem 0.6rem; font-size: 0.78rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- Cards / stat grid ---------- */

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-card .stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  margin-bottom: 0.35rem;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-card .stat-value.accent { color: var(--accent); }
.stat-card .stat-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
}

.coming-soon-card {
  position: relative;
  opacity: 0.55;
  filter: grayscale(0.3);
}
.coming-soon-card::after {
  content: "Coming soon";
  position: absolute;
  top: 0.8rem;
  right: 0.9rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-2);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
}

/* ---------- Status badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-waiting { background: rgba(245,185,66,0.14); color: var(--status-waiting); }
.badge-needs_review { background: rgba(255,159,67,0.14); color: var(--status-needs_review); }
.badge-running { background: rgba(77,141,255,0.14); color: var(--status-running); }
.badge-entry_pending { background: rgba(245,185,66,0.14); color: var(--status-entry_pending); }
.badge-active { background: rgba(77,141,255,0.14); color: var(--status-active); }
.badge-partial_exit { background: rgba(45,212,191,0.14); color: var(--status-partial_exit); }
.badge-break_even { background: rgba(167,139,250,0.14); color: var(--status-break_even); }
.badge-trailing { background: rgba(34,211,238,0.14); color: var(--status-trailing); }
.badge-target_hit { background: rgba(52,211,153,0.14); color: var(--status-target_hit); }
.badge-stop_loss { background: rgba(248,113,113,0.14); color: var(--status-stop_loss); }
.badge-exited { background: rgba(144,153,171,0.14); color: var(--status-exited); }
.badge-cancelled { background: rgba(107,114,128,0.14); color: var(--status-cancelled); }
.badge-high-risk { background: rgba(248,113,113,0.18); color: var(--danger); font-weight: 700; letter-spacing: 0.03em; margin-left: 0.4rem; }

.badge-buy { background: var(--success-soft); color: var(--success); }
.badge-sell { background: var(--danger-soft); color: var(--danger); }

.badge-source-whatsapp { background: rgba(37,211,102,0.16); color: #25d366; }
.badge-source-telegram { background: rgba(42,171,238,0.16); color: #2aabee; }

.badge-review-correct { background: var(--success-soft); color: var(--success); }
.badge-review-incorrect { background: var(--danger-soft); color: var(--danger); }
.badge-review-needs_review { background: var(--warning-soft); color: var(--warning); }
.badge-review-unreviewed { background: var(--bg-3); color: var(--text-2); }

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-1);
}

table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid var(--border-soft); }
thead th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg-1);
}
thead th a { display: inline-flex; align-items: center; gap: 0.3rem; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--bg-2); }
tbody tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* ---------- Filters ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.7rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1.1rem;
}

.filter-field { display: flex; flex-direction: column; gap: 0.3rem; }
.filter-field label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); }

input[type=text], input[type=search], input[type=number], input[type=date], select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.6rem;
  min-width: 140px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.quick-filters { display: flex; gap: 0.4rem; margin-right: auto; }
.quick-filters a {
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-1);
  border: 1px solid transparent;
}
.quick-filters a:hover { background: var(--bg-3); }
.quick-filters a.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Trade detail ---------- */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.chart-preview {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-2);
}
.chart-preview img { width: 100%; }

.raw-message {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  font-size: 0.86rem;
  color: var(--text-1);
  white-space: pre-wrap;
}

.reply-raw-list { display: flex; flex-direction: column; gap: 0.5rem; }
.reply-raw-list .raw-message { position: relative; padding-left: 1.6rem; }
.reply-raw-list .raw-message::before {
  content: "\275E";
  position: absolute;
  left: 0.6rem;
  top: 0.65rem;
  color: var(--text-2);
  font-size: 0.8rem;
}

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem 1.2rem; }
.field { display: flex; flex-direction: column; gap: 0.2rem; }
.field .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); }
.field .value { font-size: 1rem; font-weight: 600; }

.confidence-value { font-size: 1.6rem; font-weight: 700; }
.confidence-value.high { color: var(--success); }
.confidence-value.low { color: var(--danger); }

.grading-actions { display: flex; gap: 0.5rem; margin: 1rem 0 0.4rem; flex-wrap: wrap; }
.currently-labeled { font-size: 0.8rem; color: var(--text-2); }

details.edit-panel { margin-top: 1.1rem; border-top: 1px solid var(--border-soft); padding-top: 0.9rem; }
details.edit-panel summary { cursor: pointer; font-weight: 600; font-size: 0.86rem; color: var(--text-1); }
details.edit-panel summary:hover { color: var(--text-0); }
.edit-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-top: 0.8rem; }
.edit-form-grid .full { grid-column: 1 / -1; }
.edit-form-grid input { width: 100%; }
.edit-form-grid label { font-size: 0.72rem; color: var(--text-2); display: block; margin-bottom: 0.25rem; }

/* ---------- Timeline ---------- */

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li {
  position: relative;
  padding: 0 0 1.3rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot-color, var(--accent));
  box-shadow: 0 0 0 3px var(--bg-1), 0 0 0 4px var(--border);
}
.timeline li::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 14px;
  bottom: -4px;
  width: 2px;
  background: var(--border);
}
.timeline li:last-child::after { display: none; }
.timeline .tl-time { font-size: 0.72rem; color: var(--text-2); font-family: var(--mono); }
.timeline .tl-label { font-weight: 600; font-size: 0.9rem; }
.timeline .tl-label.rejected { color: var(--text-2); font-weight: 500; }

/* ---------- Reply cards (existing detailed AI interpretation) ---------- */

.event-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 0.9rem;
  background: var(--bg-1);
}
.event-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }

/* ---------- Live monitor ---------- */

.live-feed { display: flex; flex-direction: column; gap: 0.55rem; }
.live-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  animation: fade-in 0.25s ease;
}
.live-item .live-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.live-item .live-dot.processed { background: var(--success); }
.live-item .live-dot.ignored { background: var(--text-2); }
.live-item .live-meta { flex: 1; min-width: 0; }
.live-item .live-time { font-size: 0.72rem; color: var(--text-2); font-family: var(--mono); }
.live-item .live-text { font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-item .live-engine { margin-top: 0.3rem; font-size: 0.74rem; color: var(--text-2); display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.live-status-pill { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; color: var(--text-2); }
.live-pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(52,211,153,0); }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Settings ---------- */

.settings-section { margin-bottom: 1.75rem; }
.settings-section h2 { font-size: 1rem; margin: 0 0 0.9rem; }
.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  background: var(--bg-1);
}
.channel-row .channel-name { font-weight: 600; }
.channel-row .channel-meta { font-size: 0.78rem; color: var(--text-2); }
.channel-actions { display: flex; gap: 0.4rem; }

.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.8rem; }
.config-item {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
}
.config-item .label { font-size: 0.7rem; text-transform: uppercase; color: var(--text-2); margin-bottom: 0.25rem; }
.config-item .value { font-family: var(--mono); font-size: 0.92rem; }
.config-note { font-size: 0.78rem; color: var(--text-2); margin-top: 0.6rem; }

/* ---------- Statistics charts ---------- */

.chart-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.chart-card h3 { margin: 0 0 0.9rem; font-size: 0.95rem; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.bar-row { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.5rem; font-size: 0.82rem; }
.bar-row .bar-label { width: 110px; flex-shrink: 0; color: var(--text-1); }
.bar-row .bar-track { flex: 1; height: 10px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.bar-row .bar-value { width: 34px; text-align: right; font-family: var(--mono); color: var(--text-2); }

/* ---------- Export page ---------- */

.export-options { display: flex; gap: 1rem; flex-wrap: wrap; }
.export-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; width: 220px; text-align: center; }
.export-card .export-icon { margin-bottom: 0.7rem; color: var(--accent); }
.export-card h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.export-card p { margin: 0 0 1rem; font-size: 0.8rem; color: var(--text-2); }

/* ---------- Empty state ---------- */

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-2); }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .detail-grid, .event-columns, .chart-grid, .edit-form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  #sidebar-toggle { display: flex; }
  .status-bar { display: none; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 82%;
    max-width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 30;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0);
  }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 0 0 9999px rgba(0,0,0,0.5); }
  .main { padding: 1.25rem 1rem 2.5rem; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
