:root {
  --page-bg: #f6f7fb;
  --card-bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #3457d5;
  --accent-hover: #2c46b8;
  --accent-soft: #eaefff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --overbought: #dc2626;
  --oversold: #059669;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

/* Every page/panel/modal in this app toggles visibility via the plain
   `hidden` attribute (dashboard-nav.js, dashboard-auth.js, ...). The
   browser's default `[hidden] { display: none }` UA rule loses to any
   author rule on the same element that sets `display` (e.g. `.modal-
   overlay { display: flex }`), origin trumping specificity — so anything
   with its own `display` declaration needs this to actually hide. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- sidebar ---------- */

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}

.brand-logo {
  height: 28px;
  width: auto;
  display: block;
}

.brand-logo-lg {
  height: 46px;
}

.topbar-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  object-fit: contain;
}

.primary-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.nav-icon {
  display: inline-flex;
  flex: 0 0 18px;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.nav-item:hover {
  background: var(--page-bg);
  color: var(--fg);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-note {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  padding: 12px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ---------- mobile nav (topbar / drawer / scrim) ----------
   Desktop default: topbar and scrim stay invisible, sidebar-close hidden —
   the sidebar is the plain always-visible column above. Everything here
   only activates under the <=900px media query further down. */

.mobile-topbar {
  display: none;
  align-items: center;
  gap: 4px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  padding: 0 12px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  z-index: 70;
}

.mobile-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: none;
  background: transparent;
  color: var(--fg);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.mobile-menu-toggle:hover {
  background: var(--page-bg);
}

.mobile-menu-toggle svg {
  width: 22px;
  height: 22px;
}

.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}

.sidebar-close {
  display: none;
  margin-left: auto;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.sidebar-close svg {
  width: 18px;
  height: 18px;
}

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  z-index: 80;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar-scrim.visible {
  display: block;
  opacity: 1;
}

/* ---------- content ---------- */

.content {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 80px;
  max-width: 1180px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.panel h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-connecting {
  color: var(--muted);
  background: var(--page-bg);
}

.badge-connected {
  color: var(--success);
  background: var(--success-soft);
}

.badge-disconnected {
  color: var(--danger);
  background: var(--danger-soft);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

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

th {
  font-family: var(--font-sans);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover {
  background: var(--page-bg);
}

tr.row-flash {
  animation: flash 900ms ease-out;
}

@keyframes flash {
  from {
    background: var(--accent-soft);
  }
  to {
    background: transparent;
  }
}

.muted {
  color: var(--muted);
}

/* ---------- controls ---------- */

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

.control-row input[type="text"],
.control-row input[type="email"],
select {
  font: inherit;
  font-size: 13.5px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--fg);
  min-width: 180px;
}

.control-row input[type="text"]:focus,
.control-row input[type="email"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.control-row input[type="file"] {
  font: inherit;
  font-size: 13px;
  color: var(--fg);
}

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-danger {
  background: var(--card-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-secondary:hover {
  background: var(--accent-soft);
}

.danger-zone {
  border-top: 3px solid var(--danger-soft);
}

.control-status {
  font-size: 12.5px;
  color: var(--muted);
}

.control-status.ok {
  color: var(--success);
}

.control-status.error {
  color: var(--danger);
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
  margin: 6px 0 0;
}

/* ---------- Stock Analysis page ---------- */

.analysis-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.analysis-picker label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.analysis-symbol-search {
  width: 260px;
}

.analysis-symbol-search .prompt {
  border-radius: var(--radius-sm) !important;
}

.analysis-empty p {
  color: var(--muted);
}

.decision-card {
  border-color: var(--accent-soft);
}

.decision-row {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.decision-metric {
  display: flex;
  flex-direction: column;
}

.decision-metric span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.decision-metric strong {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.decision-metric small {
  color: var(--muted);
}

.decision-metric.label-overbought strong {
  color: var(--overbought);
}

.decision-metric.label-oversold strong {
  color: var(--oversold);
}

.decision-narrative {
  margin: 8px 0;
}

.decision-caveat {
  color: var(--muted);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin: 10px 0 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.stat-tile {
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}

.stat-tile span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.stat-tile strong {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-tile small {
  color: var(--muted);
  font-size: 11px;
}

.chart-container {
  padding: 4px 0 0;
}

.chart-container svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.75;
}

.chart-hline {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 4 3;
  opacity: 0.6;
}

.chart-hline.zero {
  stroke-dasharray: none;
  stroke: var(--border);
  opacity: 1;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 10px;
  font-family: var(--font-sans);
}

.chart-empty {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

/* ---------- Learning page ---------- */

.course-progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.course-progress-head h3 {
  margin: 0;
}

.course-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 14px;
}

.course-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.course-outline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.outline-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--page-bg);
  color: var(--fg);
  cursor: pointer;
}

.outline-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.outline-check {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex: 0 0 8px;
}

.outline-check.done {
  background: var(--success);
}

.course-module summary {
  list-style: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.course-module summary::-webkit-details-marker {
  display: none;
}

.course-module summary::after {
  content: "+";
  margin-left: auto;
  color: var(--muted);
  font-weight: 400;
  font-size: 18px;
}

.course-module[open] summary::after {
  content: "–";
}

.module-badge {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 999px;
}

.module-body {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.module-body p,
.module-body li {
  line-height: 1.6;
}

.module-body ul,
.module-body ol {
  padding-left: 20px;
  margin: 0 0 14px;
}

.module-body li {
  margin-bottom: 8px;
}

.module-body ol li button {
  margin-left: 8px;
}

.callout {
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--fg);
  margin: 0 0 14px;
}

.callout a {
  color: var(--accent);
}

.callout-app {
  border-color: var(--accent-soft);
  background: var(--accent-soft);
}

.btn-goto {
  margin-left: 8px;
  padding: 5px 12px;
  font-size: 12.5px;
}

.module-complete {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.citation-list {
  margin: 0;
  padding-left: 20px;
}

.citation-list li {
  margin-bottom: 8px;
}

.citation-list a {
  color: var(--accent);
}

.glossary-table td,
.glossary-table th {
  white-space: normal;
}

.glossary-table td:first-child {
  white-space: nowrap;
  font-weight: 600;
  color: var(--fg);
}

.glossary-table td:last-child {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 13px;
}

/* ---------- Screener page ---------- */

.screener-empty p {
  color: var(--muted);
}

.link-btn {
  font: inherit;
  font-family: var(--font-mono);
  font-weight: 700;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

/* ---------- screener mobile cards ----------
   Desktop default: never shown, the wide table above is used instead.
   Under the <=900px breakpoint further down, the two swap — a wide table
   is the classic mobile anti-pattern (forced horizontal scroll per row);
   one card per symbol reads far better on a narrow screen. */

.screener-cards {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.screener-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.screener-card-header {
  font-family: var(--font-mono);
  font-size: 15px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.screener-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 16px;
}

.screener-card-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.screener-card-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.screener-card-value {
  font-size: 13.5px;
}

.chip {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.chip-front {
  background: var(--success-soft);
  color: var(--success);
}

.chip-back {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-contracting {
  background: var(--accent-soft);
  color: var(--accent);
}

.chip-elevated {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-normal-vol,
.chip-mixed {
  background: var(--page-bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.chip-unable {
  background: var(--page-bg);
  color: var(--muted);
  border: 1px dashed var(--border);
}

.chip-factor {
  background: var(--accent-soft);
  color: var(--accent);
}

.tag-filter-chip {
  font: inherit;
  border: none;
  cursor: pointer;
}

.tag-filter-chip.chip-normal-vol {
  border: 1px solid var(--border);
}

/* ---------- Macro & factor outlook (Stock Analysis page) ---------- */

.factor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.horizon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.horizon-card {
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.horizon-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.horizon-card-head strong {
  font-size: 13px;
}

.horizon-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.risk-list {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  color: var(--muted);
}

.risk-list li {
  margin-bottom: 3px;
}

.chip-optimism {
  background: var(--success-soft);
  color: var(--success);
}

.chip-pessimism {
  background: var(--danger-soft);
  color: var(--danger);
}

.col-picker {
  position: relative;
  display: inline-block;
}

.col-picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  width: 230px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

.col-picker-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.col-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.col-picker-item input:disabled {
  cursor: not-allowed;
}

.col-picker-item input:disabled + * {
  color: var(--muted);
}

/* ---------- post-it note (Learning page, Module 5) ---------- */

.postit {
  background: #fff9c4;
  border: 1px solid #e6d84f;
  border-radius: 3px;
  box-shadow: 2px 3px 8px rgba(16, 24, 40, 0.15);
  padding: 16px 18px;
  margin: 0 0 16px;
  transform: rotate(-0.6deg);
  color: #4a4420;
  font-size: 13px;
}

.postit strong {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  margin-bottom: 8px;
  color: #6b5f10;
}

.postit ul {
  margin: 0;
  padding-left: 18px;
}

.postit li {
  margin-bottom: 6px;
  line-height: 1.5;
}

/* ---------- account block (sidebar) ---------- */

.account-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 4px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.account-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.account-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tier-badge {
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-link {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  white-space: nowrap;
}

.btn-link:hover {
  text-decoration: underline;
}

/* ---------- private-preview badge (shared: login, /legal, sidebar) ---------- */

.preview-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ---------- disclaimer strip (global) ---------- */

.disclaimer-strip {
  position: fixed;
  left: 240px;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: #fffbeb;
  color: #92650a;
  border-top: 1px solid #fde68a;
  font-size: 11.5px;
  text-align: center;
  padding: 6px 16px;
}

.disclaimer-strip a {
  color: inherit;
  text-decoration: underline;
  white-space: nowrap;
}

.disclaimer-strip-links {
  font-size: 10.5px;
  opacity: 0.85;
}

.content {
  /* two-line strip on desktop, three on narrow screens */
  padding-bottom: 64px;
}

@media (max-width: 900px) {
  .disclaimer-strip {
    left: 0;
  }

  .mobile-topbar {
    display: flex;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .shell {
    padding-top: 56px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 270px;
    flex: none;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 28px rgba(17, 24, 39, 0.18);
  }

  .content {
    padding: 20px 16px 90px;
    max-width: 100%;
  }

  .page-header h2 {
    font-size: 20px;
  }

  .screener-table-view {
    display: none;
  }

  .screener-cards {
    display: flex;
  }

  .screener-card-grid {
    grid-template-columns: 1fr;
  }

  /* Sparkline column dropped — 80+90+90+24px of fixed columns plus gaps
     already exceeds a phone's usable width, and price+change matter more
     than the trend line at a glance. */
  .watchlist-row {
    grid-template-columns: 64px 1fr 70px 22px;
  }

  .watchlist-sparkline-cell {
    display: none;
  }
}

/* ---------- first-login disclaimer modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(17, 24, 39, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-card h2 {
  margin: 0;
  font-size: 18px;
}

.modal-card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
}

.modal-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--fg);
  cursor: pointer;
}

.modal-check input {
  margin-top: 2px;
}

/* ---------- admin: pilot list ---------- */

.invite-result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  border: 1px solid #a7f3d0;
  font-size: 13px;
  line-height: 1.6;
}

.invite-result.invite-result-warn {
  background: #fffbeb;
  border-color: #fde68a;
}

.invite-result code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.6);
  padding: 1px 6px;
  border-radius: 4px;
}

.status-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
}

.status-pill-active {
  color: var(--success);
  background: var(--success-soft);
}

.status-pill-inactive {
  color: var(--muted);
  background: var(--page-bg);
}

.status-pill-warn {
  color: #92650a;
  background: #fffbeb;
}

.row-actions {
  display: flex;
  gap: 10px;
}

/* ---------- custom factors (Screener page) ---------- */

.custom-factors-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.custom-factor-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.custom-factor-row:last-child {
  border-bottom: none;
}

.custom-factor-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 260px;
  min-width: 0;
}

.custom-factor-info strong {
  font-size: 13.5px;
}

.custom-factor-info .muted {
  font-size: 12.5px;
}

.chip-bullish {
  background: var(--success-soft);
  color: var(--success);
}

.chip-bearish {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-neutral {
  background: var(--page-bg);
  color: var(--muted);
}

.filter-chip-remove {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-weight: 700;
  margin-left: 4px;
  padding: 0;
}

/* ---------- KPI tiles (Overview page) ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.kpi-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

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

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.kpi-value.kpi-good {
  color: var(--success);
}

.kpi-value.kpi-bad {
  color: var(--danger);
}

.kpi-value.kpi-warn {
  color: #b45309;
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.sharpe-cell.positive {
  color: var(--success);
  font-weight: 600;
}

.sharpe-cell.negative {
  color: var(--danger);
}

.freshness-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.freshness-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.freshness-fresh {
  color: var(--success);
}

.freshness-aging {
  color: #b45309;
}

.freshness-stale {
  color: var(--danger);
}

/* ---------- What-if factor lab (Predictions page) ---------- */

.predlab-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
}

.predlab-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.predlab-symbol {
  font-size: 18px;
  font-weight: 700;
}

.predlab-price-val {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.predlab-composite {
  margin-top: 14px;
  padding: 16px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.predlab-composite-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.predlab-composite-score {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.predlab-composite-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.predlab-composite-disclaimer {
  margin: 10px 0 0;
  font-size: 12px;
  font-style: italic;
}

.predlab-gauge {
  position: relative;
  height: 10px;
  border-radius: 6px;
  background: var(--border);
  overflow: hidden;
}

.predlab-gauge-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 6px;
  transition: width 0.1s linear, left 0.1s linear;
}

.predlab-gauge-fill.gauge-bullish {
  background: var(--success);
}

.predlab-gauge-fill.gauge-bearish {
  background: var(--danger);
}

.predlab-gauge-fill.gauge-neutral {
  background: var(--muted);
}

.predlab-gauge-zero {
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--card-bg);
}

.predlab-factors {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.predlab-factor-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.predlab-factor-unavailable {
  opacity: 0.55;
}

.predlab-factor-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 320px;
  min-width: 0;
}

.predlab-factor-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.predlab-factor-value {
  font-size: 12.5px;
  font-weight: 600;
}

.predlab-factor-explanation {
  font-size: 12px;
}

.predlab-factor-weight {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 200px;
}

.predlab-factor-weight input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.predlab-weight-val {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  width: 28px;
  text-align: right;
}

/* ---------- watchlists ---------- */

.watchlist-card summary {
  gap: 10px;
}

.watchlist-count {
  font-size: 12px;
  font-weight: 400;
  margin-left: auto;
}

.watchlist-delete-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
}

.watchlist-delete-btn:hover {
  background: var(--danger-soft);
}

.watchlist-rows {
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}

.watchlist-row {
  display: grid;
  grid-template-columns: 80px 1fr 90px 90px 24px;
  align-items: center;
  gap: 14px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
}

.watchlist-row:last-child {
  border-bottom: none;
}

.watchlist-row-symbol {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13.5px;
  text-align: left;
}

.watchlist-sparkline-cell {
  height: 30px;
  min-width: 0;
}

.sparkline {
  width: 100%;
  height: 30px;
  display: block;
  color: var(--muted);
}

.watchlist-price {
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.watchlist-change {
  text-align: right;
  font-weight: 600;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.watchlist-change.watchlist-up {
  color: var(--success);
}

.watchlist-change.watchlist-down {
  color: var(--danger);
}

.watchlist-change.watchlist-flat {
  color: var(--muted);
}

.watchlist-remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  line-height: 1;
}

.watchlist-remove-btn:hover {
  color: var(--danger);
}

.watchlist-add-row {
  margin-top: 10px;
}

.watchlist-add-input {
  min-width: 220px;
}

.watchlist-empty p {
  color: var(--muted);
}

/* ---------- degraded / "system under heavy use" banner ----------
   Shown by dashboard-degraded.js when the backend returns 429. Fixed to the
   viewport so it is visible regardless of scroll position, and sat above the
   disclaimer strip rather than covering it. */
.busy-banner {
  position: fixed;
  right: 1rem;
  bottom: 3.5rem;
  z-index: 900;
  width: min(22rem, calc(100vw - 2rem));
  background: var(--card-bg);
  border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 6px 28px rgba(0, 0, 0, .16);
  padding: .9rem 1rem 1rem;
}

.busy-banner__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}

.busy-banner__badge {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: .18rem .45rem;
  border-radius: 3px;
}

.busy-banner__close {
  background: none;
  border: 0;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 .2rem;
}
.busy-banner__close:hover { color: var(--fg); }

.busy-banner__msg { margin: 0 0 .5rem; font-size: .88rem; line-height: 1.5; }

.busy-banner__retry,
.busy-banner__quota,
.busy-banner__fallback {
  margin: 0 0 .35rem;
  font-size: .8rem;
  color: var(--muted);
}

.busy-banner__learn {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.busy-banner__learn strong { display: block; font-size: .84rem; margin-bottom: .25rem; }
.busy-banner__learn p { margin: 0 0 .6rem; font-size: .8rem; line-height: 1.5; color: var(--muted); }

@media (max-width: 900px) {
  .busy-banner { right: .5rem; left: .5rem; width: auto; bottom: 3.25rem; }
}

/* ---------- Pricing Research page ----------
   The swing model's own surface (dashboard-pricing-research.js). */

/* Numeric emphasis in tables. Named .pos/.neg rather than reusing the KPI
   colour classes because those are sized/weighted for tiles, not table cells. */
.pos { color: var(--success); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }
.mut { color: var(--muted); }

/* The standing honesty notice at the top of Pricing Research. Amber rather
   than red: the model is unproven, not broken, and red would read as an
   error state. */
.callout-warn {
  border-left: 4px solid #d97706;
  background: #fffbeb;
}
.callout-warn h3 {
  margin-top: 0;
  color: #92400e;
}
.callout-warn .hint { color: #78350f; }

/* The positive counterpart to .callout-warn — used where a panel is stating
   the product's own argument rather than a caveat. */
.callout-ok {
  border-left: 4px solid #059669;
  background: #ecfdf5;
}
.callout-ok h3 {
  margin-top: 0;
  color: #065f46;
}
.callout-ok .hint { color: #064e3b; }

/* Marks a factor whose weight the desk has explicitly set, as opposed to one
   still sitting on its default. The distinction matters on the Analyst Desk:
   a default-weighted target is a starting point nobody has reviewed. */
.desk-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 10px;
  background: #ecfdf5;
  color: #065f46;
  vertical-align: middle;
}

/* A checkbox that sits inline in a control row rather than above its input. */
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.inline-check input { margin: 0; }

#pr-symbol { min-width: 9rem; }

@media (max-width: 900px) {
  /* The control row wraps to its own lines rather than squeezing the select
     and the button side by side into an unusable width. */
  #page-pricing-research .control-row {
    flex-wrap: wrap;
    align-items: stretch;
  }
  #page-pricing-research .control-row .btn { width: 100%; }
}

/* ---------- Learning Module 7: the pipeline diagram + integration tables ---------- */

.module-figure { margin: 1.25rem 0; }
.module-figure figcaption {
  font-size: .82rem;
  color: var(--muted);
  margin-top: .5rem;
  line-height: 1.55;
}

/* The SVG scales by viewBox, so unlike dashboard-charts.js's JS-sized charts
   it renders correctly even though this module is a collapsed <details>. */
.pipeline-svg {
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
}
.pipeline-svg .d-src rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; }
.pipeline-svg .d-box rect { fill: var(--page-bg); stroke: var(--border); stroke-width: 1; }
.pipeline-svg .d-txt { fill: var(--fg); }
.pipeline-svg .d-sub { fill: var(--muted); }
.pipeline-svg .d-lane { fill: var(--accent); letter-spacing: .04em; }
.pipeline-svg .d-arrow path { stroke: var(--muted); stroke-width: 1.3; fill: none; }
.pipeline-svg .d-feed path { stroke: var(--accent); stroke-width: 1; fill: none; stroke-dasharray: 3 3; opacity: .55; }
.pipeline-svg .d-fill { fill: var(--muted); }

/* live / not-wired status pills in the integration table */
.tag-live, .tag-off {
  display: inline-block;
  font-size: .66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .1rem .35rem;
  border-radius: 3px;
  margin-right: .35rem;
  vertical-align: middle;
}
.tag-live { color: var(--success); background: var(--success-soft); }
.tag-off { color: var(--danger); background: var(--danger-soft); }

/* An integration we do NOT call is dimmed, so the table reads at a glance as
   "what is actually connected" rather than an undifferentiated list. */
.glossary-table tr.row-off td { opacity: .72; }

/* Inline warning callout inside a module — amber, matching the Pricing
   Research notice, because these are honest caveats rather than errors. */
.callout-warn-inline {
  border-left: 3px solid #d97706;
  background: #fffbeb;
  color: #78350f;
  padding: .7rem .9rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .9rem;
  line-height: 1.6;
}

/* ---------- admin: broadcast composer ---------- */

#broadcast-body-input {
  width: 100%;
  margin: 10px 0;
  padding: 10px 12px;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--fg);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
}

#broadcast-body-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* The real send, visually separated from the harmless "test to myself" so
   the irreversible button never looks like the safe one. `.btn` sets a solid
   accent background, so this has to reset it explicitly — inheriting it gave
   red text on blue, which was unreadable. */
.btn-danger-outline,
.btn.btn-danger-outline {
  background: var(--card-bg);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- responsive tables ----------
   Measured: at 390px, 19 tables needed 1.1x-2.5x the available width, so a
   row could only be read by dragging it sideways. dashboard-responsive-tables.js
   stamps each cell with its column header; below 700px the table stops being a
   grid and each row becomes a small card of label/value pairs.

   Tablet keeps the real table — at 820px only two tables overflowed, and both
   by under 10%, which the tighter cell padding below absorbs. */

@media (max-width: 1024px) and (min-width: 901px) {
  th,
  td {
    padding: 6px 7px;
  }

  /* The run ledger's dataset_key is the one genuinely long value here, and
     it was pushing the table ~20px past a tablet's width. It is already
     truncated with a title tooltip, so letting it wrap costs nothing. */
  #runs-table td {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 900px) {
  .table-scroll table.stackable {
    display: block;
    font-size: 13px;
  }

  .table-scroll table.stackable thead {
    /* Hidden, not removed: the header text is the source for every
       data-label, and screen readers still get it from the attribute. */
    display: none;
  }

  .table-scroll table.stackable tbody,
  .table-scroll table.stackable tr {
    display: block;
  }

  .table-scroll table.stackable tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    margin-bottom: 10px;
    background: var(--card-bg);
  }

  .table-scroll table.stackable tr:hover {
    background: var(--card-bg);
  }

  .table-scroll table.stackable td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    /* Long values (dataset keys, reasons, user agents) must wrap rather than
       reintroduce the sideways scroll this whole rule exists to remove.
       `anywhere` and not `break-word`: measured, `break-word` refuses to
       split a long unbroken token like a dataset key, which put the
       sideways scroll straight back (glossary 2.4x, run ledger 1.2x). The
       cost is that a short value can break mid-token — an IP rendering as
       "127.0." / "0.1" — which is cosmetic, where the overflow was not. */
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: right;
  }

  .table-scroll table.stackable td:last-child {
    border-bottom: none;
  }

  .table-scroll table.stackable td::before {
    content: attr(data-label);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-align: left;
    flex: 0 0 auto;
    margin-right: auto;
  }

  .table-scroll table.stackable td[data-nolabel] {
    justify-content: flex-end;
  }

  .table-scroll table.stackable td[data-nolabel]::before {
    content: none;
  }

  /* "loading…" / "nothing yet" rows: one cell spanning the table, which must
     not be dressed up as a label/value pair. */
  .table-scroll table.stackable tr.stack-message td {
    display: block;
    text-align: center;
    border-bottom: none;
  }

  .table-scroll table.stackable tr.stack-message td::before {
    content: none;
  }
}

/* ---------- "best on a larger screen" notice ----------
   For the few pages whose value IS the dense side-by-side comparison, where
   stacking each row would destroy the thing the page is for. Shown only on
   the screens where it's true. */

.desktop-note {
  display: none;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #92650a;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
}

@media (max-width: 900px) {
  .desktop-note {
    display: flex;
  }
}
