/* ============================================================
   AlgoLumina Stocks — Design System v2
   Dark-first, mobile-first, no external dependencies
   ============================================================ */

/* --- CSS Custom Properties --------------------------------- */
:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface-2:   #1c2128;
  --surface-3:   #21262d;
  --border:      #30363d;
  --border-soft: #21262d;
  --accent:      #2E86AB;
  --accent-dim:  #1a4f66;
  --success:     #27AE60;
  --success-dim: #1a5e3a;
  --warning:     #E67E22;
  --warning-dim: #7a4210;
  --danger:      #E74C3C;
  --danger-dim:  #7a1a13;
  --text:        #e6edf3;
  --text-soft:   #c9d1d9;
  --muted:       #8b949e;
  --muted-dim:   #484f58;

  --radius:      6px;
  --radius-lg:   10px;
  --radius-pill: 100px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.4);
  --shadow-md:   0 4px 12px rgba(0,0,0,.5);
  --shadow-lg:   0 8px 24px rgba(0,0,0,.6);

  --nav-w:       220px;
  --topbar-h:    52px;
  --rail-w:      280px;
  --bottomnav-h: 56px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46,134,171,.25);
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
select option { background: var(--surface-3); }
hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
img { max-width: 100%; }
svg { vertical-align: middle; }

/* --- App Shell --------------------------------------------- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Bar */
#topBar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.topbar-brand img { height: 28px; width: auto; }
.topbar-title { font-size: .9rem; font-weight: 700; color: var(--text); }
.topbar-subtitle { font-size: .72rem; color: var(--muted); }
.topbar-spacer { flex: 1; min-width: 0; }
.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* Main workspace */
#workspaceShell, #workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Nav Rail */
#navRail {
  width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 8px 0;
}
.nav-section-title {
  font-size: .68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 14px 16px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--text-soft);
  font-size: .875rem;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-radius: 0;
  transition: background .1s, color .1s;
  position: relative;
  cursor: pointer;
  min-height: 40px;
}
.nav-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 6px 16px;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: .6; }
.nav-item.active .nav-item-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  min-width: 18px;
  text-align: center;
}
.nav-badge.warning { background: var(--warning); color: #fff; }
.nav-badge.accent  { background: var(--accent); color: #fff; }
.nav-badge.success { background: var(--success); color: #fff; }

/* Content area */
#contentArea {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}
.module-content {
  padding: 20px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* Summary Rail */
#summaryRail {
  width: var(--rail-w);
  min-width: 220px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  flex-shrink: 0;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.rail-section {}
.rail-section-title {
  font-size: .68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 8px;
}
.rail-kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: .8rem;
  gap: 6px;
}
.rail-kv:last-child { border-bottom: none; }
.rail-kv .key  { color: var(--muted); flex: 0 0 auto; }
.rail-kv .val  { flex: 1; font-weight: 600; text-align: right; word-break: break-all; font-size: .78rem; }

/* Bottom Nav (mobile) */
#bottomNav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
}
.bnav-inner { display: flex; height: 100%; }
.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: .62rem;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  transition: color .1s;
  position: relative;
  padding: 4px 2px;
  min-width: 44px;
  min-height: 44px;
}
.bnav-item.active { color: var(--accent); }
.bnav-icon { font-size: 1.15rem; line-height: 1; }
.bnav-badge {
  position: absolute;
  top: 5px; right: calc(50% - 20px);
  background: var(--danger);
  color: #fff;
  font-size: .58rem;
  font-weight: 700;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  min-width: 14px;
  text-align: center;
}

/* Login screen */
#loginScreen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-height: calc(100vh - var(--topbar-h));
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-logo img { height: 38px; }
.login-logo h2 { font-size: 1.15rem; }
.login-logo .caption { text-align: center; }

/* ============================================================
   Typography
   ============================================================ */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
h4 { font-size: .875rem; font-weight: 600; }
.caption { font-size: .8rem; color: var(--muted); }
.muted { color: var(--muted); font-size: .85rem; }
.mono  { font-family: var(--mono); font-size: .85em; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
  cursor: pointer;
  min-height: 36px;
  min-width: 44px;
  text-decoration: none;
}
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn-sm  { padding: 5px 11px; font-size: .8rem; min-height: 30px; }
.btn-lg  { padding: 12px 24px; font-size: 1rem; min-height: 44px; }
.btn-full { width: 100%; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: #2475a0; border-color: #2475a0; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover:not(:disabled) { background: #219152; }

.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled)  { background: #c0392b; }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover:not(:disabled) { background: #ca6f1e; }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-icon {
  padding: 7px 8px;
  min-width: 34px;
  min-height: 34px;
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
  border: 1px solid transparent;
}
/* Run statuses */
.badge-running   { background: rgba(39,174,96,.15);   color: var(--success); border-color: rgba(39,174,96,.3); }
.badge-starting  { background: rgba(230,126,34,.15);  color: var(--warning); border-color: rgba(230,126,34,.3); }
.badge-stopped   { background: rgba(139,148,158,.12); color: var(--muted);   border-color: var(--border); }
.badge-failed    { background: rgba(231,76,60,.15);   color: var(--danger);  border-color: rgba(231,76,60,.3); }
.badge-archived  { background: rgba(139,148,158,.08); color: var(--muted-dim); border-color: var(--border-soft); }
/* Order statuses — 7-state machine */
.badge-submitted { background: rgba(212,160,23,.15);  color: #d4a017;        border-color: rgba(212,160,23,.3); }
.badge-pending   { background: rgba(212,160,23,.15);  color: #d4a017;        border-color: rgba(212,160,23,.3); }
.badge-working   { background: rgba(46,134,171,.15);  color: var(--accent);  border-color: rgba(46,134,171,.3); }
.badge-accepted  { background: rgba(46,134,171,.15);  color: var(--accent);  border-color: rgba(46,134,171,.3); }
.badge-partial   { background: rgba(230,126,34,.15);  color: var(--warning); border-color: rgba(230,126,34,.3); }
.badge-cancelling{ background: rgba(230,126,34,.12);  color: var(--warning); border-color: rgba(230,126,34,.25); }
.badge-cancelled { background: rgba(139,148,158,.12); color: var(--muted);   border-color: var(--border); }
.badge-filled    { background: rgba(39,174,96,.15);   color: var(--success); border-color: rgba(39,174,96,.3); }
.badge-done      { background: rgba(39,174,96,.15);   color: var(--success); border-color: rgba(39,174,96,.3); }
.badge-rejected  { background: rgba(231,76,60,.15);   color: var(--danger);  border-color: rgba(231,76,60,.3); }
/* Env badges */
.badge-paper { background: rgba(230,126,34,.12); color: var(--warning); border-color: rgba(230,126,34,.3); font-size: .75rem; padding: 3px 10px; }
.badge-live  { background: rgba(231,76,60,.12);  color: var(--danger);  border-color: rgba(231,76,60,.3);  font-size: .75rem; padding: 3px 10px; }
/* Health */
.badge-ok      { background: rgba(39,174,96,.15);   color: var(--success); border-color: rgba(39,174,96,.3); }
.badge-error   { background: rgba(231,76,60,.15);   color: var(--danger);  border-color: rgba(231,76,60,.3); }
.badge-unknown { background: rgba(139,148,158,.12); color: var(--muted);   border-color: var(--border); }
/* Side badges */
.badge-buy  { background: rgba(39,174,96,.15);  color: var(--success); border-color: rgba(39,174,96,.3); }
.badge-sell { background: rgba(231,76,60,.15);  color: var(--danger);  border-color: rgba(231,76,60,.3); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: .9rem; flex: 1; }
.card-header-meta { display: flex; align-items: center; gap: 8px; }
.card-body  { padding: 16px; }
.card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  min-width: 130px;
}
.stat-label { font-size: .72rem; color: var(--muted); margin-bottom: 5px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.1rem; font-weight: 700; line-height: 1.2; word-break: break-all; }
.stat-value.success { color: var(--success); }
.stat-value.danger  { color: var(--danger); }
.stat-value.warning { color: var(--warning); }
.stat-value.accent  { color: var(--accent); }
.stat-sub { font-size: .72rem; color: var(--muted); margin-top: 4px; }

/* Run card */
.run-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.run-card:hover  { border-color: var(--accent); background: var(--surface-2); }
.run-card.active { border-color: var(--accent); background: var(--accent-dim); }
.run-card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.run-card-name { font-size: .9rem; font-weight: 600; flex: 1; word-break: break-all; }
.run-card-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .75rem; color: var(--muted); }

/* Item card (orders/positions on mobile) */
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.item-card + .item-card { margin-top: 10px; }
.item-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.item-card-symbol { font-size: 1rem; font-weight: 700; }
.item-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
  font-size: .8rem;
  margin-bottom: 12px;
}
.item-card-label { color: var(--muted); }
.item-card-value { font-weight: 500; text-align: right; }
.item-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  background: var(--surface);
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-3); }
.data-table .col-num { text-align: right; font-family: var(--mono); font-size: .82rem; }
.data-table .col-action { text-align: right; white-space: nowrap; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-size: .8rem; font-weight: 500; color: var(--text-soft); }
.form-row { display: flex; gap: 12px; align-items: flex-end; }
.form-row .form-group { flex: 1; margin-bottom: 0; }
.input-hint { font-size: .72rem; color: var(--muted); margin-top: 3px; }

/* Side toggle (Buy / Sell) */
.side-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.side-toggle-btn {
  flex: 1;
  padding: 9px 8px;
  border: none;
  background: var(--surface-3);
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .1s, color .1s;
  min-height: 40px;
}
.side-toggle-btn.buy.active  { background: var(--success); color: #fff; }
.side-toggle-btn.sell.active { background: var(--danger);  color: #fff; }

/* ============================================================
   Notification Panel
   ============================================================ */
#notifPanel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  width: 340px;
  max-height: calc(100vh - var(--topbar-h));
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .22s ease;
  box-shadow: var(--shadow-lg);
}
#notifPanel.open { transform: translateX(0); }
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notif-list { overflow-y: auto; flex: 1; }
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: .82rem;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--surface-2); }
.notif-item-title { font-weight: 600; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.notif-item-body  { color: var(--text-soft); font-size: .8rem; }
.notif-item-time  { font-size: .7rem; color: var(--muted); margin-top: 5px; }
.notif-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.notif-dot.fill    { background: var(--success); }
.notif-dot.warning { background: var(--warning); }
.notif-dot.error   { background: var(--danger); }
.notif-dot.info    { background: var(--accent); }
.notif-empty { padding: 32px 20px; text-align: center; color: var(--muted); font-size: .85rem; }
.notif-mark-read { color: var(--accent); font-size: .78rem; cursor: pointer; background: none; border: none; }
.notif-mark-read:hover { text-decoration: underline; }

.bell-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  color: var(--muted);
  cursor: pointer;
  transition: background .1s, color .1s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: 34px;
}
.bell-btn:hover { background: var(--surface-3); color: var(--text); }
.bell-count {
  position: absolute;
  top: -5px; right: -5px;
  background: var(--danger);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: var(--radius-pill);
  min-width: 14px;
  text-align: center;
  pointer-events: none;
}

/* ============================================================
   Toasts
   ============================================================ */
#toastContainer {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + 12px);
  right: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
  max-width: 320px;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  font-size: .85rem;
  box-shadow: var(--shadow-md);
  pointer-events: all;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toastIn .2s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--accent); }
.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-msg  { flex: 1; font-weight: 500; line-height: 1.4; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Drawer / Confirm dialog
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.overlay.open { opacity: 1; pointer-events: all; }

.confirm-dialog {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.confirm-box h3 { margin-bottom: 8px; }
.confirm-box > p { color: var(--text-soft); font-size: .9rem; margin-bottom: 16px; }
.confirm-details { margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.confirm-kv {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: .85rem;
}
.confirm-kv:last-child { border-bottom: none; }
.confirm-kv .key { color: var(--muted); }
.confirm-kv .val { font-weight: 600; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ============================================================
   Module layout helpers
   ============================================================ */
.module-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.module-header h2 { font-size: 1.1rem; }
.module-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.section-gap { margin-top: 24px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.split-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 960px) {
  .split-panel      { grid-template-columns: 2fr 1fr; }
  .split-panel.even { grid-template-columns: 1fr 1fr; }
}

/* Log viewer */
.log-viewer {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--mono);
  font-size: .77rem;
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-all;
}

/* Chart */
.chart-area {
  background: var(--surface-2);
  border-radius: var(--radius);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .85rem;
  position: relative;
  overflow: hidden;
}

/* Status dot pulse */
.status-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.running  { background: var(--success); box-shadow: 0 0 0 3px rgba(39,174,96,.2); animation: dot-pulse 2s infinite; }
.status-dot.starting { background: var(--warning); animation: dot-pulse 1.5s infinite; }
.status-dot.stopped  { background: var(--muted); }
.status-dot.failed   { background: var(--danger); }
@keyframes dot-pulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }

/* Concentration bar */
.conc-bar { height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.conc-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.conc-fill.safe    { background: var(--success); }
.conc-fill.caution { background: var(--warning); }
.conc-fill.danger  { background: var(--danger); }

/* Progress bar */
.progress-bar  { background: var(--surface-3); border-radius: 4px; height: 7px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.progress-fill.safe    { background: var(--success); }
.progress-fill.caution { background: var(--warning); }
.progress-fill.danger  { background: var(--danger); }

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

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: .9rem;
}
.empty-state .empty-icon { font-size: 2rem; margin-bottom: 8px; }

/* Alert inline */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .85rem;
  border: 1px solid;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert.warning { background: rgba(230,126,34,.1); border-color: rgba(230,126,34,.3); color: var(--warning); }
.alert.error   { background: rgba(231,76,60,.1);  border-color: rgba(231,76,60,.3);  color: var(--danger); }
.alert.info    { background: rgba(46,134,171,.1);  border-color: rgba(46,134,171,.3); color: var(--accent); }
.alert.success { background: rgba(39,174,96,.1);   border-color: rgba(39,174,96,.3);  color: var(--success); }

/* Action log */
.action-log-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: .82rem;
}
.action-log-item:last-child { border-bottom: none; }
.action-log-time { font-size: .7rem; color: var(--muted); }

/* ============================================================
   Utilities
   ============================================================ */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 12px; }
.mt-4  { margin-top: 16px; }
.mb-2  { margin-bottom: 8px; }
.mb-3  { margin-bottom: 12px; }
.mb-4  { margin-bottom: 16px; }
.w-full  { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden   { display: none !important; }
.nowrap   { white-space: nowrap; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.up   { color: var(--success); }
.down { color: var(--danger); }
.bold { font-weight: 700; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1280px) { #summaryRail { display: none; } }
@media (max-width: 1024px) { :root { --nav-w: 190px; } }

@media (max-width: 767px) {
  :root { --topbar-h: 48px; }
  #navRail      { display: none !important; }
  #summaryRail  { display: none !important; }
  #bottomNav    { display: block !important; }
  #contentArea  { padding-bottom: var(--bottomnav-h); width: 100%; }
  .module-content { padding: 16px; max-width: 100%; }
  .stat-grid    { grid-template-columns: 1fr 1fr; gap: 10px; }
  [style*="repeat(4,1fr)"] { grid-template-columns: 1fr 1fr !important; }
  .desktop-only { display: none !important; }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .card-grid    { grid-template-columns: 1fr; }
  .split-panel  { grid-template-columns: 1fr !important; }
  .form-row     { grid-template-columns: 1fr !important; }
  .side-toggle  { width: 100%; }
  .side-toggle-btn { flex: 1; }
  .module-header { gap: 8px; flex-wrap: wrap; }
  .module-actions { margin-left: 0; width: 100%; justify-content: stretch; }
  .module-actions .btn { flex: 1; }
  #notifPanel { width: 100%; left: 0; border-left: none; }
  #toastContainer { right: 12px; bottom: calc(var(--bottomnav-h) + 10px); max-width: calc(100vw - 24px); }
  .chart-area svg, svg[viewBox] { max-height: 200px; }
  /* Mobile topbar: keep only tenant + health + bell */
  #topBar { padding: 0 10px; gap: 8px; }
  .topbar-brand img { height: 22px; }
  .topbar-title { font-size: .8rem; }
  .topbar-subtitle { display: none; }
  #tbAuthLabel { display: none !important; }
  #tbRefreshBtn { display: none !important; }
  #tbLogoutBtn { display: none !important; }
  #topHealthBadge { display: none; }
  .topbar-meta { gap: 6px; }
  .topbar-meta .badge { font-size: .65rem; padding: 2px 6px; }
}

/* More drawer (mobile) */
.more-drawer {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200; display: flex; flex-direction: column;
}
.more-drawer.hidden { display: none !important; }
.more-drawer-backdrop {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
}
.more-drawer-panel {
  position: relative; margin-top: auto;
  background: var(--surface); border-radius: 18px 18px 0 0;
  max-height: 80vh; overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.more-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.more-drawer-header h3 { margin: 0; font-size: 1rem; }
.more-drawer-list { padding: 8px 0; }
.more-drawer-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 14px 20px;
  background: none; border: none; color: var(--text);
  font-size: .95rem; font-weight: 500; cursor: pointer;
  transition: background .1s;
}
.more-drawer-item:hover { background: var(--surface-3); }
.more-drawer-icon { font-size: 1.2rem; width: 28px; text-align: center; }
.more-drawer-user {
  padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,0.08);
  color: rgba(226,232,240,0.7);
}
.more-drawer-footer {
  border-top: 1px solid rgba(255,255,255,0.08); padding: 8px 0;
}
.more-drawer-signout { color: #ef4444 !important; }
.more-drawer-signout:hover { background: rgba(239,68,68,0.1) !important; }

@media (min-width: 768px) {
  .mobile-only { display: none !important; }
  #toastContainer { bottom: 16px; }
}

/* ============================================================
   Bare button classes (used by comprehensive modules)
   ============================================================ */
button.primary,
a.primary,
.button-row .primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font-size: .875rem; font-weight: 500;
  cursor: pointer; min-height: 38px; transition: background .15s;
}
button.primary:hover { background: #2475a0; }

button.secondary,
a.secondary,
.button-row .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-3);
  color: var(--text-soft); font-size: .875rem; font-weight: 500;
  cursor: pointer; min-height: 38px; transition: background .15s;
}
button.secondary:hover { background: var(--surface-2); color: var(--text); }

button.ghost,
a.ghost,
.button-row .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-soft); font-size: .875rem; font-weight: 500;
  cursor: pointer; min-height: 38px; transition: background .15s;
}
button.ghost:hover { background: var(--surface-3); color: var(--text); }

button.danger,
a.danger,
.button-row .danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius);
  border: 1px solid var(--danger); background: var(--danger);
  color: #fff; font-size: .875rem; font-weight: 500;
  cursor: pointer; min-height: 38px; transition: background .15s;
}
button.danger:hover { background: #c0392b; }

/* ============================================================
   Module shared layout (maintenance, strategies, etc.)
   ============================================================ */
.module-title { font-size: 1.1rem; font-weight: 700; }

.button-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
}
.metric-label {
  display: block; font-size: .72rem; font-weight: 500;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 5px;
}
.metric-card strong { font-size: 1.5rem; font-weight: 700; line-height: 1; }

.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}
.section-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
}
.card-title-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-title-row h3 { font-size: .95rem; font-weight: 600; margin: 0 0 4px; }
.card-title-row p  { margin: 0; }

.list-stack { display: grid; gap: 10px; }

.row-item {
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 12px 14px;
}
.row-item-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.row-item-head strong { font-size: .9rem; word-break: break-all; }

.status-badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: var(--radius-pill); font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
  border: 1px solid transparent;
}
.status-badge.is-running  { background: rgba(39,174,96,.15);  color: var(--success); border-color: rgba(39,174,96,.3); }
.status-badge.is-starting { background: rgba(230,126,34,.15); color: var(--warning); border-color: rgba(230,126,34,.3); }
.status-badge.is-stopped  { background: rgba(139,148,158,.12); color: var(--muted);  border-color: var(--border); }
.status-badge.is-failed   { background: rgba(231,76,60,.15);  color: var(--danger);  border-color: rgba(231,76,60,.3); }
.status-badge.is-archived { background: rgba(139,148,158,.08); color: var(--muted-dim); border-color: var(--border-soft); }

.meta-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px 12px; font-size: .82rem; margin-bottom: 10px;
}
.meta-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.meta-value { font-weight: 500; }

.json-box {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  font-family: var(--mono); font-size: .78rem;
  line-height: 1.6; max-height: 240px; overflow-y: auto;
  color: var(--text-soft); white-space: pre-wrap; word-break: break-all;
}

@media (max-width: 767px) {
  .section-grid { grid-template-columns: 1fr; }
  .metric-grid  { grid-template-columns: 1fr 1fr; }
  .meta-grid    { grid-template-columns: 1fr; }
  .button-row   { flex-direction: column; }
  .button-row > * { width: 100%; }
}

/* ============================================================
   Trade FAB (floating action button)
   ============================================================ */
.trade-fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 90;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 12px 24px;
  font-size: .9rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.trade-fab:hover { background: #2475a0; transform: scale(1.05); }

@media (min-width: 768px) {
  .trade-fab { bottom: 24px; right: 24px; }
}

/* ============================================================
   Symbol search dropdown
   ============================================================ */
.symbol-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 280px;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.symbol-dropdown.hidden { display: none; }
.symbol-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  transition: background .1s;
}
.symbol-dropdown-item:last-child { border-bottom: none; }
.symbol-dropdown-item:hover,
.symbol-dropdown-item.active {
  background: var(--accent-dim);
}
.symbol-dropdown-sym {
  font-weight: 700;
  font-size: .9rem;
  min-width: 55px;
}
.symbol-dropdown-name {
  color: var(--muted);
  font-size: .82rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.symbol-locked {
  background: var(--surface-2) !important;
  border-color: rgba(96,165,250,0.4) !important;
  color: #60a5fa !important;
}
.symbol-clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  font-size: .85rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}
.symbol-clear-btn:hover {
  color: #ef4444;
  background: rgba(239,68,68,0.12);
}

/* ── Ticket Live Price Banner ─────────────────────────────── */
.ticket-price-banner {
  min-height: 0;
  transition: min-height .2s;
}
.ticket-price-banner:empty {
  display: none;
}
.ticket-price-banner:not(:empty) {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: .85rem;
  min-height: 32px;
}
.ticket-price-value {
  font-weight: 700;
  font-size: .95rem;
  color: #e2e8f0;
}
.ticket-price-change {
  font-weight: 600;
  font-size: .82rem;
}
.ticket-price-change.up   { color: #34d399; }
.ticket-price-change.down { color: #f87171; }
.ticket-price-bidask {
  color: rgba(226,232,240,0.5);
  font-size: .78rem;
}
.ticket-price-loading {
  color: rgba(226,232,240,0.4);
  font-size: .8rem;
  font-style: italic;
}
.ticket-price-unavailable {
  color: rgba(248,113,113,0.7);
  font-size: .8rem;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — CRITICAL LAYOUT FIX
   Targets ALL layout systems: outer shell (IDs) + inner
   module workspace (classes from workspace.css, dashboard.css)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 639px) {

  /* ── Outer shell: hide desktop rails ── */
  #navRail        { display: none !important; }
  #summaryRail    { display: none !important; }
  #bottomNav      { display: block !important; }

  /* ── Dashboard cards grid single column ── */
  .dash-cards-grid { grid-template-columns: 1fr !important; }

  /* ── Outer shell: workspace full width ── */
  #workspaceShell {
    display: flex !important;
    flex-direction: column !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  #contentArea {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 1 1 auto !important;
    padding-bottom: 72px !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  .module-content {
    padding: 12px !important;
    max-width: 100vw !important;
    width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* ── Inner module workspace (workspace.css) ── */
  .page-shell {
    max-width: 100% !important;
    padding: 0 !important;
    padding-bottom: 80px !important;
    overflow-x: hidden !important;
  }

  .workspace {
    display: block !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  .nav-rail {
    display: none !important;
  }

  .summary-rail {
    display: none !important;
  }

  .content-panel {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .workspace-content {
    min-height: auto !important;
    width: 100% !important;
  }

  /* ── Dashboard/reports grids (dashboard.css) ── */
  .dashboard-workspace,
  .reports-workspace {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  .dashboard-hero,
  .reports-hero {
    grid-template-columns: 1fr !important;
  }

  .dashboard-hero-side,
  .reports-hero-side {
    grid-template-columns: 1fr 1fr !important;
  }

  .dashboard-kpi-grid,
  .reports-kpi-grid {
    grid-template-columns: 1fr !important;
  }

  .dashboard-grid,
  .reports-grid,
  .dashboard-chart-grid,
  .reports-chart-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Runs module grids ── */
  .runs-layout-grid {
    grid-template-columns: 1fr !important;
  }

  .runs-meta-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Command bar / context banner ── */
  .command-bar,
  .context-banner-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── App.css component overrides ── */
  .stat-grid      { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .stat-value     { font-size: 1.2rem !important; }
  .card-grid      { grid-template-columns: 1fr !important; }
  .split-panel    { grid-template-columns: 1fr !important; }
  .form-row       { flex-direction: column !important; }
  .two-col,
  .three-col      { grid-template-columns: 1fr !important; }
  .section-grid   { grid-template-columns: 1fr !important; }
  .metric-grid    { grid-template-columns: 1fr 1fr !important; }
  .meta-grid      { grid-template-columns: 1fr !important; }

  /* ── Cards full width ── */
  .card,
  .stat-card,
  .run-card,
  .item-card,
  .dashboard-card,
  .reports-card,
  .section-card,
  .metric-card {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* ── Tables scrollable ── */
  .table-wrap,
  .data-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* ── Body overflow guard ── */
  body {
    overflow-x: hidden !important;
    padding-bottom: 72px !important;
    width: 100vw !important;
    max-width: 100vw !important;
  }

  /* ── App root overflow guard ── */
  #app {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  /* ── Trade FAB above bottom nav ── */
  .trade-fab {
    bottom: calc(var(--bottomnav-h) + 12px) !important;
    right: 16px !important;
    padding: 14px 28px !important;
    font-size: 1rem !important;
  }

  /* ── Mobile tab bar from workspace.css ── */
  .mobile-tabbar {
    bottom: calc(var(--bottomnav-h) + 8px) !important;
  }
}
/* ═══ END MOBILE RESPONSIVE ═══ */

/* --- Site Footer ------------------------------------------- */
.site-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 18px;
  font-size: .78rem;
  color: var(--muted);
}
.site-footer a {
  color: var(--muted);
  transition: color .15s;
}
.site-footer a:hover { color: var(--text); text-decoration: none; }
.site-footer .footer-sep { opacity: .3; }

/* ── v2.8.0 UI Polish ─────────────────────────────────── */

/* Strategy card hover lift */
.sl-card { transition: border-color .15s, transform .2s, box-shadow .2s; }
.sl-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.35); }

/* Consistent empty states */
.empty-state, .sl-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 40px 20px; text-align: center; color: var(--muted);
}

/* Async button loading spinner */
.btn.loading { pointer-events: none; opacity: .7; }
.btn.loading::after {
  content: ''; display: inline-block; width: 12px; height: 12px; margin-left: 6px;
  border: 2px solid transparent; border-top-color: currentColor; border-radius: 50%;
  animation: btn-spin .6s linear infinite; vertical-align: middle;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Toast mobile safety — avoid topbar overlap */
@media (max-width: 639px) {
  #toastContainer { top: calc(var(--topbar-h) + 8px) !important; }
}

/* Nav active item emphasis */
#navRail a.active, #navRail button.active {
  font-weight: 700; border-left: 3px solid var(--accent);
  padding-left: calc(var(--nav-padding, 16px) - 3px);
}

/* Bot badge consistent sizing */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  font-size: .65rem; font-weight: 700; line-height: 1;
  background: var(--danger); color: #fff;
}
