:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e5e9f0;
  --text: #1a2233;
  --muted: #6b7688;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff4ff;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fff7ed;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- App shell: fixed sidebar + topbar + content ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: #111827;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  padding: 14px 10px 6px;
}
.nav-group-label:first-child { padding-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: none;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
}
.nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }

.admin-only { display: none; }
.superadmin-only { display: none; }

.sidebar-footer {
  padding: 12px 18px;
  font-size: 11px;
  color: #6b7280;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 25;
}
.sidebar-backdrop.visible { display: block; }

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-toggle {
  display: none;
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
}

.back-btn {
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
}
.back-btn:hover { background: rgba(0, 0, 0, 0.04); }

header.topbar {
  padding: 12px 22px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}

header.topbar h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.topbar-spacer { flex: 1; }

.calendar-status {
  font-size: 12.5px;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 20px;
  background: #f1f5f9;
  white-space: nowrap;
}
.calendar-status.open { color: var(--green); background: var(--green-soft); }
.calendar-status.closed { color: var(--muted); background: #f1f5f9; }

/* ---------- Auth header area ---------- */
.auth-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.auth-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.auth-btn.primary:hover { background: var(--accent-dark); }
.auth-btn:hover { background: #f8fafc; }

.auth-user { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.auth-role {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 10px;
}

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--card);
  border-radius: 14px;
  width: 100%;
  max-width: 380px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; padding: 4px; }

.form-field { margin-bottom: 12px; }
.form-field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.form-field input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}
.form-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.form-error { color: var(--red); font-size: 12.5px; margin-bottom: 10px; min-height: 16px; }

.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.form-actions button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.form-actions .btn-primary { background: var(--accent); color: #fff; }
.form-actions .btn-primary:hover { background: var(--accent-dark); }
.form-actions .btn-secondary { background: #f1f5f9; color: var(--text); }
.form-actions .btn-secondary:hover { background: #e2e8f0; }

main { padding: 20px 24px 60px; max-width: 1150px; width: 100%; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.15s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel-header {
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.panel-header h2 { margin: 0 0 4px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.panel-header .sub { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* ---------- Tables: horizontal scroll wrapper keeps mobile from breaking layout ---------- */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--card);
}

table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  background: var(--card);
  font-size: 13px;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }

.pos { color: var(--green); font-weight: 700; }
.neg { color: var(--red); font-weight: 700; }

.sectors-chart {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.sector-bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 64px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}
.sector-bar-label {
  text-align: right;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.sector-bar-label:hover { color: var(--accent); }
.sector-bar-track {
  position: relative;
  height: 16px;
  background: var(--bg);
  border-radius: 3px;
}
.sector-bar-center {
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: var(--border);
}
.sector-bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  min-width: 2px;
}
.sector-bar-fill.pos-fill { background: var(--green); left: 50%; }
.sector-bar-fill.neg-fill { background: var(--red); right: 50%; }
.sector-bar-value { font-weight: 700; font-variant-numeric: tabular-nums; }

.symbol-link { cursor: pointer; color: var(--accent); font-weight: 700; }
.symbol-link:hover { text-decoration: underline; }

.broker-code[title] { border-bottom: 1px dotted var(--muted); cursor: help; }

.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.status-Pending { background: #f1f5f9; color: var(--muted); }
.status-Active { background: var(--accent-soft); color: var(--accent); }
.status-TP1_Hit, .status-TP2_Hit, .status-TP3_Hit { background: var(--green-soft); color: var(--green); }
.status-SL_Hit { background: var(--red-soft); color: var(--red); }
.status-Invalidated { background: var(--amber-soft); color: var(--amber); }
.status-Expired { background: #f1f5f9; color: var(--muted); }

.empty-state {
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty-state .empty-action { margin-top: 12px; }

.filters { margin-bottom: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.filters select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}

.search-box {
  width: 100%;
  max-width: 260px;
  padding: 8px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  display: block;
  background: #fff;
}
.search-box:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat-card .value { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.stat-card .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }

h3 { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 22px 0 8px; font-weight: 700; }

.chart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.chart-controls input.search-box { margin-bottom: 0; }
.chart-controls button {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.chart-controls button:hover { background: var(--accent-dark); }
.chart-controls button:disabled { background: var(--border); cursor: not-allowed; }

.overlay-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.overlay-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.overlay-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chart-info {
  margin-bottom: 10px;
  font-size: 13px;
}
.chart-info .signal-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 8px;
  font-weight: 800;
  margin-right: 8px;
}
.chart-info .signal-BUY { background: var(--green-soft); color: var(--green); }
.chart-info .signal-SELL { background: var(--red-soft); color: var(--red); }
.chart-info .signal-NEUTRAL { background: #f1f5f9; color: var(--muted); }

.chart-info .validation-row { margin-top: 6px; font-size: 12.5px; }
.validation-badge { display: inline-block; padding: 3px 8px; border-radius: 6px; font-weight: 600; }
.validation-badge.pass { background: var(--green-soft); color: var(--green); }
.validation-badge.fail { background: var(--red-soft); color: var(--red); }

.chart-container {
  width: 100%;
  height: 480px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Small action buttons used inline in tables ---------- */
.mini-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.mini-btn:hover { background: #f8fafc; border-color: var(--accent); color: var(--accent); }
.mini-btn.danger:hover { border-color: var(--red); color: var(--red); }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Portfolio page ---------- */
.section-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.section-card h3 { margin: 0 0 4px; }
.section-card > h3:first-child { margin-top: 0; }

.dp-portfolio-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.dp-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.dp-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.08s ease;
}
.dp-card:hover { transform: translateY(-1px); }
.dp-card.active { border-color: var(--accent); background: var(--accent-soft); }
.dp-card .value { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.dp-card .label { font-size: 11px; color: var(--muted); margin-top: 2px; font-weight: 600; }

.portfolio-hero {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-radius: 14px;
  padding: 22px 24px;
  color: #fff;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.25);
}
.portfolio-hero .hero-label { font-size: 12px; opacity: 0.85; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.portfolio-hero .hero-value { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 14px; }
.portfolio-hero .hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
}
.portfolio-hero .hero-stat-value { font-size: 15px; font-weight: 700; }
.portfolio-hero .hero-stat-label { font-size: 10.5px; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 2px; }

.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.subtab-btn {
  padding: 9px 14px;
  border: none;
  background: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subtab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.subtab-btn:hover { color: var(--text); }
.subtab-panel { display: none; }
.subtab-panel.active { display: block; }

/* ---------- Watchlist card grid ---------- */
.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.watch-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.watch-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.watch-card-title { display: flex; flex-direction: column; gap: 2px; }
.watch-card-title .company-name { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.watch-card-price { display: flex; align-items: baseline; gap: 8px; margin: 8px 0 6px; }
.watch-card-price .price { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.watch-card-ohlc { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.watch-card-signal {
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  margin-bottom: 8px;
  line-height: 1.5;
}
.watch-card-notes { font-size: 12.5px; color: var(--text); background: #f8fafc; border-radius: 6px; padding: 6px 9px; margin-bottom: 8px; }
.watch-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}

/* ---------- Admin: role/permission chips + role cards ---------- */
.role-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #f1f5f9;
  color: var(--muted);
}
.role-superadmin { background: #fdf2f8; color: #be185d; }
.role-admin { background: var(--accent-soft); color: var(--accent); }
.role-user { background: var(--green-soft); color: var(--green); }

.role-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.role-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.permission-list { display: flex; flex-wrap: wrap; gap: 6px; }
.role-chip-remove { background: none; border: none; padding: 0 0 0 4px; margin: 0; cursor: pointer; color: inherit; opacity: 0.6; font-size: 13px; line-height: 1; }
.role-chip-remove:hover { opacity: 1; }
.role-card-header .role-card-actions { margin-left: auto; display: flex; gap: 6px; }
.role-perm-groups h4 { margin: 14px 0 6px; font-size: 13px; }
.role-perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 14px; }
.role-perm-grid label { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.role-perm-grid label input { margin-top: 2px; }
.role-perm-grid label code { font-size: 11.5px; }
.role-perm-grid label .sub { display: block; }
.permission-chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

/* ---------- Inline add-holding / add-watchlist forms ---------- */
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.inline-form .form-field { margin-bottom: 0; min-width: 110px; flex: 1; }
.inline-form button {
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  height: 38px;
}
.inline-form button:hover { background: var(--accent-dark); }

.login-prompt {
  text-align: center;
  padding: 40px 20px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 13.5px;
}
.login-prompt button { margin-top: 12px; }

/* ---------- Toasts (interactive feedback on actions) ---------- */
.toast-stack {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  animation: toastIn 0.18s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.fade-out { animation: toastOut 0.18s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(4px); } }

@media (max-width: 480px) {
  .toast-stack { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}

/* ---------- Sortable table headers ---------- */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
th.sortable .sort-arrow { margin-left: 4px; opacity: 0.5; font-size: 10px; }
th.sortable.sort-active .sort-arrow { opacity: 1; color: var(--accent); }

/* ---------- Buttons in a loading state ---------- */
button.is-loading { opacity: 0.65; cursor: wait; pointer-events: none; }

/* ---------- Row click affordance beyond just the symbol ---------- */
tbody tr { transition: background-color 0.1s ease; }

/* =============== Mobile responsiveness =============== */
@media (max-width: 900px) {
  .sidebar-toggle { display: block; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.2);
  }

  header.topbar { padding: 10px 14px; gap: 10px; }
  header.topbar h1 { font-size: 14px; }
  .calendar-status { font-size: 11px; padding: 4px 8px; }

  main { padding: 14px 14px 50px; }

  .panel-header h2 { font-size: 15px; }

  table { min-width: 480px; font-size: 12px; }
  th, td { padding: 8px 9px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card .value { font-size: 19px; }

  .portfolio-hero { padding: 16px 18px; }
  .portfolio-hero .hero-value { font-size: 26px; }
  .dp-cards-row { grid-template-columns: repeat(2, 1fr); }
  .section-card { padding: 14px 16px; }

  .chart-container { height: 340px; }

  .modal { max-width: 100%; border-radius: 12px; }

  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form .form-field { min-width: 0; }
  .inline-form button { width: 100%; }
}

@media (max-width: 420px) {
  header.topbar h1 { display: none; }
}

/* ---- Horizon Read / TP Ladder / Multi-Timeframe Structure / Desk Read (Chart tab) ---- */
.analysis-section { margin-top: 20px; }
.analysis-block { margin-bottom: 22px; }
.analysis-block h3 { font-size: 15px; margin: 0 0 2px; }
.analysis-block .block-sub { font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }

.h-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 1100px) { .h-cards { grid-template-columns: repeat(2, 1fr); } }
.h-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; }
.h-card .rail { width: 4px; flex-shrink: 0; }
.h-card.bullish .rail { background: var(--green); }
.h-card.bearish .rail { background: var(--red); }
.h-card.neutral .rail { background: var(--muted); }
.h-card .h-body { padding: 12px 13px; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.h-card h4 { margin: 0; font-size: 13.5px; color: var(--text); }
.h-card .h-window { font-size: 11px; color: var(--muted); margin-top: -5px; }
.h-stance { align-self: flex-start; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; padding: 2px 7px; border-radius: 5px; }
.h-card.bullish .h-stance { background: var(--green-soft); color: var(--green); }
.h-card.bearish .h-stance { background: var(--red-soft); color: var(--red); }
.h-card.neutral .h-stance { background: var(--accent-soft); color: var(--muted); }
.h-reasons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.h-reasons li { font-size: 11.5px; color: var(--text); padding-left: 12px; position: relative; line-height: 1.35; }
.h-reasons li::before { content: "—"; position: absolute; left: 0; color: var(--muted); }
.h-card.neutral .h-reasons li { font-style: italic; color: var(--muted); }
.h-levels { margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 3px; }
.h-levels .row { display: flex; justify-content: space-between; font-size: 11.5px; }
.h-levels .row .k { color: var(--muted); }
.h-levels .row .v { font-weight: 600; }
.h-levels .row .v.stop { color: var(--red); }
.h-levels .row .v.target { color: var(--green); }

.tp-ladder { display: flex; gap: 8px; flex-wrap: wrap; }
.tp-step { flex: 1; min-width: 100px; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; background: var(--bg); display: flex; flex-direction: column; gap: 3px; }
.tp-step .label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.tp-step .val { font-size: 15px; font-weight: 700; color: var(--text); }
.tp-step .pct { font-size: 10.5px; font-weight: 600; color: var(--green); }
.tp-step.stop .val { color: var(--red); }
.tp-step.tp .val, .tp-step.tp .pct { color: var(--green); }
.tp-step.tp1 { background: var(--green-soft); }
.tp-step.tp2 { background: #d1fae5; }
.tp-step.tp3 { background: #a7f3d0; }
.tp-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }

.mtf-chain { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 900px) { .mtf-chain { grid-template-columns: repeat(2, 1fr); } }
.mtf-tf { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 5px; }
.mtf-tf .tf-top { display: flex; justify-content: space-between; align-items: center; }
.mtf-tf .tf-name { font-size: 12px; font-weight: 700; color: var(--text); }
.mtf-tf .tf-role { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mtf-trend { font-size: 10.5px; font-weight: 700; text-transform: uppercase; align-self: flex-start; padding: 2px 6px; border-radius: 5px; }
.mtf-trend.bullish { background: var(--green-soft); color: var(--green); }
.mtf-trend.bearish { background: var(--red-soft); color: var(--red); }
.mtf-trend.ranging { background: var(--amber-soft); color: var(--amber); }
.mtf-tf .tf-detail { font-size: 11px; color: var(--muted); line-height: 1.35; }
.mtf-tf .tf-vol { font-size: 10.5px; color: var(--amber); font-style: italic; }
.mtf-verdict-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.verdict-pill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; padding: 3px 9px; border-radius: 100px; }
.verdict-pill.bullish { background: var(--green-soft); color: var(--green); }
.verdict-pill.bearish { background: var(--red-soft); color: var(--red); }
.verdict-pill.mixed, .verdict-pill.ranging { background: var(--amber-soft); color: var(--amber); }
.verdict-pill.insufficient_data { background: var(--accent-soft); color: var(--muted); }
.mtf-note { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.mtf-coverage { font-size: 10.5px; color: var(--muted); margin-top: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; }
.mtf-loading, .analysis-error { font-size: 12px; color: var(--muted); font-style: italic; }

.desk-narrative { font-size: 13px; line-height: 1.6; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.desk-narrative .bull-t { color: var(--green); font-weight: 600; }
.desk-narrative .bear-t { color: var(--red); font-weight: 600; }

/* ---- Desk Read: verdict gauge + breadth bar + grouped signals ---- */
.desk-verdict {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px;
}
.desk-gauge { flex-shrink: 0; }
.desk-verdict-text { display: flex; flex-direction: column; gap: 7px; min-width: 200px; }
.desk-verdict-tag { font-size: 21px; font-weight: 800; letter-spacing: .01em; }
.desk-verdict-tag.BUY { color: var(--green); }
.desk-verdict-tag.SELL { color: var(--red); }
.desk-verdict-tag.NEUTRAL { color: var(--amber); }
.desk-verdict-desc { font-size: 12px; color: var(--muted); line-height: 1.5; max-width: 54ch; }
.desk-horizon-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.desk-horizon-chip {
  font-size: 10.5px; font-weight: 600; padding: 3px 9px; border-radius: 100px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.desk-horizon-chip.bullish { color: var(--green); border-color: #bbf0cf; background: var(--green-soft); }
.desk-horizon-chip.bearish { color: var(--red); border-color: #f9c9c9; background: var(--red-soft); }

.desk-breadth {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 14px;
}
.desk-breadth-title { font-size: 11.5px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.desk-breadth-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.desk-breadth-bar .seg { display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700; color: #fff; }
.desk-breadth-bar .seg.bullish { background: var(--green); }
.desk-breadth-bar .seg.neutral { background: var(--amber); color: #3d2c05; }
.desk-breadth-bar .seg.bearish { background: var(--red); }
.desk-breadth-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.desk-breadth-legend span { display: inline-flex; align-items: center; gap: 5px; }
.desk-breadth-legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.desk-signals { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.desk-signal-group {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 15px;
}
.desk-signal-group-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.desk-signal-row { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-top: 1px solid var(--border); }
.desk-signal-row:first-of-type { border-top: none; padding-top: 1px; }
.desk-signal-stripe { width: 3px; align-self: stretch; border-radius: 2px; flex-shrink: 0; min-height: 16px; margin-top: 2px; }
.desk-signal-stripe.bull { background: var(--green); }
.desk-signal-stripe.bear { background: var(--red); }
.desk-signal-stripe.neutral { background: var(--amber); }
.desk-signal-text { font-size: 12px; line-height: 1.5; flex: 1; color: var(--text); }
.desk-signal-pill { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; padding: 2px 7px; border-radius: 100px; flex-shrink: 0; white-space: nowrap; margin-top: 1px; }
.desk-signal-pill.bull { background: var(--green-soft); color: var(--green); }
.desk-signal-pill.bear { background: var(--red-soft); color: var(--red); }
.desk-signal-pill.neutral { background: var(--amber-soft); color: var(--amber); }

.tp-scale { margin-bottom: 12px; }
.tp-scale text { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

@media (max-width: 700px) {
  .h-cards { grid-template-columns: 1fr; }
  .mtf-chain { grid-template-columns: 1fr; }
  .desk-verdict { flex-direction: column; align-items: flex-start; }
}

/* ---------- Backtest tab ---------- */
.inline-form select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--card);
  color: var(--text);
}
.inline-form .search-box { margin-bottom: 0; }
.inline-form button:disabled { opacity: 0.6; cursor: wait; }
.backtest-note { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 4px 0 14px; }
.backtest-muted { color: var(--muted); font-size: 12px; }
.inline-form button.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.inline-form button.secondary:hover { background: #f8fafc; }
.backtest-progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.backtest-progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s linear; }
.backtest-chart-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; margin-bottom: 18px; }
.backtest-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.backtest-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.backtest-legend .bar { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 5px; vertical-align: 2px; }
.backtest-tip { font-size: 12px; color: var(--muted); margin-bottom: 6px; font-variant-numeric: tabular-nums; min-height: 1.4em; }
.backtest-tip strong { color: var(--text); }
.backtest-tip .backtest-adj { color: #7c3aed; }
.backtest-tip .backtest-smc { color: #b45309; font-weight: 600; }
.backtest-tip .backtest-zone { color: #15803d; }
.backtest-tip .backtest-setup { color: #1d4ed8; }
.backtest-adj-note { font-size: 12px; color: var(--muted); background: #f5f3ff; border-left: 3px solid #7c3aed; border-radius: 4px; padding: 6px 10px; margin-bottom: 8px; }
.backtest-adj-note:empty { display: none; }
.backtest-adj-note strong { color: #6d28d9; }
#backtestChart { height: 440px; }
@media (max-width: 768px) { #backtestChart { height: 320px; } }
.weights-panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }
.weights-panel summary { cursor: pointer; font-weight: 600; }
.weights-panel summary span { font-weight: 400; color: var(--muted); }
.weights-panel[open] summary { margin-bottom: 6px; }

/* ---------- Seasonality tab ---------- */
.season-reliability { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; font-size: 13px; line-height: 1.5; margin-bottom: 16px; border-left: 3px solid var(--amber, #d97706); }
.season-bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 10px; margin-bottom: 18px; }
.season-col { display: flex; flex-direction: column; align-items: stretch; text-align: center; border-radius: 6px; padding: 4px 2px; }
.season-col.current { background: var(--accent-soft, #eff6ff); }
.season-half { height: 70px; display: flex; align-items: flex-end; justify-content: center; }
.season-half.down { align-items: flex-start; border-top: 1px solid var(--border); }
.season-bar { width: 60%; border-radius: 3px; }
.season-bar.up { background: var(--green); }
.season-bar.dn { background: var(--red); }
.season-val { font-size: 12px; font-weight: 700; margin-top: 4px; }
.season-name { font-size: 11.5px; font-weight: 600; }
.season-sub { font-size: 10.5px; color: var(--muted); }
.season-grid td, .season-grid th { text-align: center; font-size: 11.5px; padding: 5px 4px; white-space: nowrap; }
.season-grid th.current { color: var(--accent); }
@media (max-width: 768px) {
  .season-bars { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .season-half { height: 44px; }
}

/* ---------------- 4-Day Analysis tab ---------------- */
.an-asof { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.an-market { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-bottom: 12px; }
.an-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.an-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.an-card h3 { margin: 0 0 8px; font-size: 14.5px; }
.an-card h4 { margin: 8px 0 6px; font-size: 13px; }
.an-card p { margin: 6px 0; font-size: 13px; line-height: 1.5; }
.an-wide { grid-column: 1 / -1; }
.an-list { margin: 4px 0; padding-left: 18px; font-size: 13px; line-height: 1.55; }
.an-head-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.an-sym { font-size: 20px; font-weight: 700; }
.an-state { font-weight: 700; padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.an-state-bull { background: var(--green-soft); color: var(--green); }
.an-state-bear { background: var(--red-soft); color: var(--red); }
.an-state-wait { background: var(--amber-soft); color: var(--amber); }
.an-state-none { background: #f1f5f9; color: var(--muted); }
.an-head-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 10px; }
.an-stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.an-stat { font-size: 22px; font-weight: 700; }
.an-meter-track { position: relative; height: 8px; background: #eef1f5; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.an-meter-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); }
.an-meter-fill { position: absolute; top: 0; bottom: 0; }
.an-meter-fill.pos-fill { background: var(--green); }
.an-meter-fill.neg-fill { background: var(--red); }
.an-meter-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.an-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.an-three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.an-scenario { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.an-scenario.active { border-color: var(--accent); background: var(--accent-soft); }
.an-scenario dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
.an-scenario dt { color: var(--muted); }
.an-scenario dd { margin: 0; }
.an-notrade { background: #f8fafc; border-left: 3px solid var(--muted); padding: 6px 10px; }
.an-pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); vertical-align: middle; }
.an-score { font-size: 14px; }
.an-comp-pts { display: inline-block; min-width: 42px; font-variant-numeric: tabular-nums; }
.an-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.an-table.an-compact { min-width: 0; }
.an-card .table-scroll { max-width: 100%; }
.an-table th, .an-table td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--border); }
.an-quad { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.an-quad-leading { background: var(--green-soft); color: var(--green); }
.an-quad-improving { background: var(--accent-soft); color: var(--accent-dark); }
.an-quad-weakening { background: var(--amber-soft); color: var(--amber); }
.an-quad-lagging { background: var(--red-soft); color: var(--red); }
.an-quad-unknown { background: #f1f5f9; color: var(--muted); }
.an-amber { color: var(--amber); font-weight: 700; }
@media (max-width: 760px) {
  .an-grid, .an-two, .an-three, .an-head-stats { grid-template-columns: 1fr; }
  .an-market { grid-template-columns: 1fr; }
}

/* ---------------- Expert Views tab ---------------- */
.ex-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; }
.ex-basis { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; }
.ex-basis label { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-size: 13px; font-weight: 400; color: var(--text); }
.ex-attest input, .ex-basis input { width: auto; margin: 0; }
.an-card .sub, .an-card div.sub { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.ex-attest { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; margin: 8px 0; line-height: 1.45; }
#tab-experts textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; }
.ex-status { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.ex-status.hit { background: var(--green-soft); color: var(--green); }
.ex-status.miss { background: var(--red-soft); color: var(--red); }
.ex-status.open, .ex-status.pending { background: #f1f5f9; color: var(--muted); }
.ex-status.withdrawn { background: var(--amber-soft); color: var(--amber); }
@media (max-width: 760px) { .ex-form { grid-template-columns: 1fr 1fr; } }

/* manual signal weights */
#weightsTable tr.weight-manual td { background: var(--accent-soft); }
.weight-manual-input { padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }

/* ---------------- Trade Signals: accuracy and by-sector chart ---------------- */
.acc-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.acc-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.acc-head h3 { margin: 0; font-size: 14.5px; }
.acc-sub { margin: 12px 0 6px; font-size: 13px; }
.acc-tile-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.acc-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.acc-legend span { display: inline-flex; align-items: center; gap: 6px; }
.acc-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.acc-key-gen, .acc-bar-gen { background: #6f97ee; }
.acc-key-ok, .acc-bar-ok { background: #1d4ed8; }
.acc-chart { display: flex; flex-direction: column; gap: 6px; }
.acc-row { display: grid; grid-template-columns: minmax(110px, 190px) 1fr minmax(150px, auto); gap: 10px; align-items: center; font-size: 12.5px; }
.acc-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-bars { position: relative; height: 18px; }
.acc-bar { position: absolute; left: 0; height: 8px; border-radius: 0 4px 4px 0; }
.acc-bar-gen { top: 0; }
.acc-bar-ok { top: 10px; }
.acc-val { color: var(--text); white-space: nowrap; }
.acc-rate { color: var(--muted); }
.acc-row:hover { background: #f8fafc; }
@media (max-width: 640px) {
  .acc-row { grid-template-columns: 1fr; gap: 2px; }
}

/* recent floorsheet sessions */
.fs-catchup { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -2px 0 10px; font-size: 12.5px; }
.fs-chip { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; margin: 1px 0; }
.fs-stored { background: var(--green-soft); color: var(--green); }
.fs-no_trades { background: #f1f5f9; color: var(--muted); }
.fs-missing { background: var(--amber-soft); color: var(--amber); font-weight: 600; }

/* Volume Profile on the Chart tab */
.chart-container { position: relative; }
.vp-layer { position: absolute; top: 0; bottom: 0; width: 0; pointer-events: none; z-index: 2; }
.vp-bar { position: absolute; right: 0; background: rgba(100, 116, 139, 0.28); border-radius: 2px 0 0 2px; pointer-events: auto; }
.vp-bar.vp-in { background: rgba(37, 99, 235, 0.30); }
.vp-note { position: absolute; left: 8px; top: 6px; z-index: 3; font-size: 11px; color: var(--muted); background: rgba(255, 255, 255, 0.85); padding: 2px 6px; border-radius: 4px; pointer-events: none; }

/* Broker Analysis tab (brokers.js) */
.ba-views { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--card); }
.ba-view { background: transparent; color: var(--muted); border: 0; border-radius: 0; padding: 7px 14px; font-weight: 600; cursor: pointer; }
.ba-view + .ba-view { border-left: 1px solid var(--border); }
.ba-view.active { background: var(--accent-soft); color: var(--accent-dark); }
.ba-date { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.ba-head { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; font-size: 13.5px; line-height: 1.6; }
.ba-table td, .ba-table th { white-space: nowrap; }
.ba-table .sub { font-size: 11.5px; }
.ba-row { cursor: pointer; }
.ba-row:hover td { background: var(--accent-soft); }
.ba-row.selected td { background: var(--accent-soft); box-shadow: inset 0 -1px 0 var(--accent); }
.ba-side { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.ba-side.buy { background: var(--accent-soft); color: var(--accent-dark); }
.ba-side.sell { background: var(--red-soft); color: var(--red); }
.ba-side.neutral { background: var(--bg); color: var(--muted); }
.ba-acc-row { cursor: pointer; }
.ba-acc-row:hover td { background: var(--accent-soft); }
.ba-chart { width: 100%; height: 170px; }
.ba-chart-label { font-size: 11.5px; color: var(--muted); margin: 8px 0 2px; font-weight: 600; }
.ba-tip { min-height: 18px; margin-top: 6px; }
@media (max-width: 700px) {
  .ba-views { display: flex; }
  .ba-view { flex: 1; padding: 7px 6px; }
}

/* Bulk deals (bulk.js) */
.bd-tier { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; border: 1px solid transparent; }
.bd-tier.block { background: var(--accent-dark); color: #fff; }
.bd-tier.bulk { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent); }
.bd-tier.large { background: var(--bg); color: var(--text); border-color: var(--border); }
.bd-tier.nepse { background: var(--amber-soft); color: var(--amber); }
.stat-card .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
#bulkDeals .stat-grid { margin-bottom: 4px; }

/* Floorsheet viewer + Floorsheet Data (floorsheet.js) */
.fs-filters { flex-wrap: wrap; gap: 6px; align-items: center; }
.fs-sortable th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.fs-sortable th[data-sort]:hover { color: var(--accent-dark); }
.fs-sortable th.sorted[data-dir="desc"]::after { content: " ▼"; font-size: 10px; }
.fs-sortable th.sorted[data-dir="asc"]::after { content: " ▲"; font-size: 10px; }
.fs-day-head { margin: 8px 0 0; }
.fs-pick { cursor: pointer; }
.fs-pick:hover td { background: var(--accent-soft); }
.fd-nav { align-items: center; gap: 10px; margin: 6px 0; }
.fd-nav .fd-month-select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
  font-weight: 600; background: var(--card); color: var(--text); width: auto; }
.fd-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.fd-key { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.fd-calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; max-width: 640px; }
.fd-dow { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; }
.fd-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 52px; padding: 4px 6px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); cursor: pointer; font: inherit; text-align: left; }
.fd-cell.fd-pad { border: 0; background: transparent; cursor: default; }
.fd-n { font-weight: 700; font-size: 12.5px; }
.fd-g { font-size: 11px; font-weight: 700; }
.fd-c { font-size: 11px; color: var(--muted); }
.fd-cell.complete, .fd-key.complete { background: var(--green-soft); border-color: #86efac; }
.fd-cell.source_gap, .fd-key.source_gap { background: #f4f9ec; border-color: #bbd99a; }
.fd-cell.short, .fd-key.short { background: var(--amber-soft); border-color: #fcd34d; }
.fd-cell.missing, .fd-key.missing { background: var(--red-soft); border-color: #fca5a5; }
.fd-cell.holiday, .fd-key.holiday { background: #eef1f5; }
.fd-cell.weekend, .fd-key.weekend { background: var(--bg); color: var(--muted); }
.fd-cell.future, .fd-key.future { background: transparent; border-style: dashed; color: var(--muted); }
.fd-detail { margin: 8px 0 14px; line-height: 1.6; font-size: 13px; }
.fd-help { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; line-height: 1.5; }
@media (max-width: 700px) { .fd-cell { min-height: 44px; padding: 3px 4px; } .fd-c { display: none; } }

/* Data-health banner (health.js) */
.data-health {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 12px;
  margin: 16px auto 0; width: calc(100% - 48px); max-width: 1102px; padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--amber); background: var(--amber-soft); color: var(--text); font-size: 13px;
}
.data-health.error { border-color: var(--red); background: var(--red-soft); }
.data-health[hidden] { display: none; }
.data-health-toggle {
  flex: 1 1 260px; min-width: 0; text-align: left; background: none; border: none; padding: 0;
  color: inherit; font: inherit; cursor: pointer; overflow-wrap: anywhere;
}
.data-health-link { background: none; border: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.data-health ul { flex-basis: 100%; order: 3; margin: 4px 0 0; padding-left: 18px; }
.data-health li { margin: 2px 0; overflow-wrap: anywhere; }
.data-health li.error { color: var(--red); }
@media (max-width: 900px) { .data-health { width: calc(100% - 28px); margin-top: 12px; } }

/* ---------- NEPSE Market tab ---------- */
.mk-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.mk-stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.mk-rets { font-size: 12.5px; font-weight: 600; letter-spacing: 0; }
.mk-section { margin: 22px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.mk-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.mk-chart { width: 100%; height: 300px; margin-top: 6px; overflow: hidden; }
.mk-chart table { min-width: 0; } /* the global table min-width would stretch the chart's own layout table */
.mk-strip-label { margin-top: 8px; }
.mk-strip { display: flex; height: 14px; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.mk-strip span { flex: 1 1 0; min-width: 0; }
.mk-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.mk-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.mk-r-bull { background: #16a34a; }
.mk-r-bull-t { background: #86efac; }
.mk-r-neutral { background: #cbd5e1; }
.mk-r-bear-t { background: #fca5a5; }
.mk-r-bear { background: #dc2626; }
.mk-r-none { background: #f1f5f9; }
.mk-regime { display: inline-block; font-weight: 700; font-size: 13px; padding: 4px 12px; border-radius: 999px; color: #fff; letter-spacing: 0; }
.mk-regime.mk-r-bull-t { color: #14532d; }
.mk-regime.mk-r-neutral { color: #334155; }
.mk-regime.mk-r-bear-t { color: #7f1d1d; }
.stat-card .mk-regime { font-size: 14px; }
.mk-regime-big { margin-top: 6px; }
.mk-regime-big .mk-regime { font-size: 18px; padding: 6px 16px; }
.mk-conf { text-align: right; }
.mk-state { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: capitalize; }
.mk-s-low { background: #f1f5f9; color: var(--muted); }
.mk-s-normal { background: var(--accent-soft); color: var(--accent-dark); }
.mk-s-high { background: var(--amber-soft); color: var(--amber); }
.mk-s-extreme { background: var(--red-soft); color: var(--red); }
.mk-s-good { background: var(--green-soft); color: var(--green); }
.mk-kv td:first-child { color: var(--muted); }
.mk-kv td { padding: 5px 6px; vertical-align: middle; }
.mk-bar { position: relative; height: 6px; background: #eef1f5; border-radius: 3px; min-width: 80px; }
.mk-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; }
.mk-bar-fill.pos-fill { background: var(--green); }
.mk-bar-fill.neg-fill { background: var(--red); }
.mk-bar-mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--muted); }
.mk-ad { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin-top: 8px; }
.mk-ad-up { background: var(--green); }
.mk-ad-flat { background: #cbd5e1; }
.mk-ad-down { background: var(--red); }
.mk-ad-legend { display: flex; justify-content: space-between; font-size: 12px; margin: 4px 0 8px; }
.mk-comps td { vertical-align: top; }
.mk-comp-meter { width: 120px; }
.mk-comp-meter .an-meter-track { margin-top: 5px; }
#tab-market .an-table { min-width: 0; }
#tab-market .an-table td { white-space: normal; }
#tab-market .an-table.mk-wide { min-width: 560px; }
#tab-market .an-table.mk-wide td { white-space: nowrap; }
.mk-scroll { overflow-x: auto; max-width: 100%; }
#mkMovers h4 { margin: 6px 0; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
@media (max-width: 760px) {
  .an-three { grid-template-columns: 1fr; }
  .mk-conf { text-align: left; }
  .mk-comp-meter { display: none; }
}

/* ---------- Discount / Premium tab ---------- */
.zn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
@media (max-width: 520px) { .zn-grid { grid-template-columns: 1fr; } }
.zn-grid table { width: 100%; }
.zn-pos { position: relative; height: 6px; min-width: 70px; background: var(--border); border-radius: 3px; }
.zn-pos span { position: absolute; top: -3px; width: 4px; height: 12px; border-radius: 2px; margin-left: -2px; }
.zn-pos.discount span { background: var(--green); }
.zn-pos.premium span { background: var(--red); }
.zn-range { margin: 4px 0 8px; }
.zn-range input { width: 64px; }

/* ---------- Backtest signal picker ---------- */
.bt-pick-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0 10px; }
.bt-section { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.bt-section:first-of-type { border-top: 0; margin-top: 4px; }
.bt-section h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
/* one labelled field per cell: the grid keeps them from running into each other */
.bt-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 10px 14px; margin-bottom: 10px; }
.bt-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bt-field[hidden] { display: none; }
.bt-field > span:first-child { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.bt-field select {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: var(--card); color: var(--text); text-overflow: ellipsis;
}
.bt-field-wide { grid-column: span 2; }
.bt-check > span:last-child, .bt-fixed { display: flex; align-items: center; gap: 6px; min-height: 33px; font-size: 13px; }
.bt-check { cursor: pointer; }
.bt-presets > span:last-child { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 33px; }
.bt-presets { grid-column: span 2; }
@media (max-width: 640px) { .bt-fields { grid-template-columns: 1fr; } .bt-field-wide, .bt-presets { grid-column: auto; } }
.bt-pick-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.bt-pick-group { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px 8px; margin: 0; }
.bt-pick-group legend { font-weight: 600; padding: 0 4px; }
.bt-pick-group label { display: block; padding: 2px 0; cursor: pointer; }
#backtestVoteTable tr.bt-picked td { background: rgba(37, 99, 235, 0.08); font-weight: 600; }
.bt-pick-group label.bt-pick-off { cursor: not-allowed; opacity: 0.6; }

/* Floorsheet Data: trade-time badges (ShareHub / NEPSE / nepalytix times) */
.fd-t { font-size: 10px; line-height: 1; margin-left: auto; }
.fd-cell .fd-top { display: flex; width: 100%; align-items: center; gap: 4px; }
.fd-time-key { background: #eef4ff; border-color: #bfd3fe; }
.fs-page-input { width: 72px; padding: 2px 6px; text-align: center; }
.fs-time { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Chart tab: timeframe switch (1D from NEPSE; 1H / 15m / 5m from floorsheet trade times) */
.tf-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.chart-controls .tf-switch button { background: transparent; color: var(--text, #1e293b); border: 0; border-radius: 0; padding: 6px 12px; }
.chart-controls .tf-switch button + button { border-left: 1px solid var(--border); }
.chart-controls .tf-switch button.active { background: var(--accent); color: #fff; }
.chart-controls .tf-switch button:hover:not(.active) { background: var(--border); }

/* Backtest: T+2 / intraday rule toggles */
.bt-toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.bt-toggle.disabled { opacity: 0.45; cursor: not-allowed; }
