:root,
[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-2: #ffffff;
  --bg-3: #eef1f6;
  --panel: #ffffff;
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #6d4ef0;
  --accent-hover: #5b3de0;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #d97706;
  --font: "Inter", system-ui, sans-serif;
  --sidebar-bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.95);
  --table-head-bg: #f8fafc;
  --row-hover: rgba(15, 23, 42, 0.03);
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
  --bg: #06080f;
  --bg-2: #0c1018;
  --bg-3: #121820;
  --panel: #0f1319;
  --border: rgba(255, 255, 255, 0.07);
  --text: #f3f4f6;
  --muted: #8b95a8;
  --accent: #7c5cfc;
  --accent-hover: #6d4ef0;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --sidebar-bg: #080a10;
  --topbar-bg: rgba(6, 8, 15, 0.95);
  --table-head-bg: rgba(0, 0, 0, 0.2);
  --row-hover: rgba(255, 255, 255, 0.02);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ── App shell ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 72px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-brand { margin-bottom: 0.5rem; }

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c5cfc, #4f46e5);
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
  overflow-y: auto;
  padding: 0 0.35rem;
}

.sidebar-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.55rem 0.25rem;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 500;
  text-align: center;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: rgba(124, 92, 252, 0.12);
  color: var(--text);
}

.sidebar-icon { font-size: 1.1rem; line-height: 1; }

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

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
}

.topbar-logo {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}

[data-theme="dark"] .topbar-logo {
  background: linear-gradient(90deg, #fff, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar-nav {
  display: flex;
  gap: 1rem;
}

.topbar-nav a {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.topbar-nav a:hover { color: var(--text); }

.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.topbar-search input,
.search-wrap input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.88rem;
}

.topbar-search input:focus { outline: none; border-color: rgba(124, 92, 252, 0.5); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 0.4rem;
}

.btn-ghost {
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.btn-ghost:hover { color: var(--text); }

.btn-primary {
  padding: 0.45rem 1rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
}

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

.search-results {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 420px;
  overflow-y: auto;
  display: none;
  z-index: 100;
}

.search-results.open { display: block; }

.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.search-result:last-child { border-bottom: none; }
.search-result:hover,
.search-result.active { background: rgba(255, 255, 255, 0.05); }
.search-result.muted {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.search-result-main {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  flex: 1;
}

.search-result-text {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.search-result-top {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
}

.search-result-symbol {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.search-result-exchange {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
}

.search-result-name {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-score-empty {
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 2rem;
  text-align: center;
}

.search-result .score-badge {
  flex-shrink: 0;
}

/* ── Ticker ── */
.ticker-bar {
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  padding: 0.45rem 0;
}

.ticker-track {
  display: flex;
  gap: 2.5rem;
  white-space: nowrap;
  animation: ticker-scroll 40s linear infinite;
  padding: 0 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.ticker-item strong { color: var(--text); margin-right: 0.35rem; }
.ticker-item em { font-style: normal; font-weight: 600; }
.ticker-item em.up { color: var(--green); }
.ticker-item em.down { color: var(--red); }

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ── Page content ── */
.page-content {
  padding: 1rem 1.25rem 3rem;
  flex: 1;
}

.free-notice {
  background: rgba(124, 92, 252, 0.1);
  border: 1px solid rgba(124, 92, 252, 0.25);
  color: #c4b5fd;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.error-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

/* ── Feature cards ── */
.feature-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.feature-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1rem 0.9rem;
  transition: border-color 0.15s, transform 0.15s;
}

.feature-card:hover {
  border-color: rgba(124, 92, 252, 0.35);
  transform: translateY(-1px);
}

.feature-badge {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.feature-badge.live { background: rgba(34, 197, 94, 0.2); color: var(--green); }
.feature-badge.pro { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.feature-badge.active { background: rgba(245, 158, 11, 0.2); color: var(--orange); }
.feature-badge.new { background: rgba(124, 92, 252, 0.25); color: #a78bfa; }
.feature-badge.track { background: rgba(239, 68, 68, 0.2); color: #f87171; }

.feature-icon {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.feature-icon.green { background: rgba(34, 197, 94, 0.15); }
.feature-icon.blue { background: rgba(59, 130, 246, 0.15); }
.feature-icon.orange { background: rgba(245, 158, 11, 0.15); }
.feature-icon.purple { background: rgba(124, 92, 252, 0.15); }
.feature-icon.red { background: rgba(239, 68, 68, 0.15); }

.feature-card h3 {
  margin: 0 0 0.2rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ── Screener ── */
.screener-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.screener-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.screener-toolbar h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.screener-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-dropdown-wrap {
  position: relative;
}

.editor-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 240px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 60;
  padding: 0.75rem;
}

.filter-panel {
  min-width: 280px;
}

.editor-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
}

.editor-panel-foot {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  padding: 0;
}

.column-editor-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 280px;
  overflow-y: auto;
}

.column-editor-panel {
  min-width: 360px;
  max-width: min(92vw, 420px);
  max-height: min(80vh, 640px);
  overflow-y: auto;
}

.column-preset-row,
.column-preset-save {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.column-preset-select {
  flex: 1;
  min-width: 0;
}

.column-preset-save .sl-input {
  flex: 1;
  min-width: 0;
}

.column-editor-add-section {
  margin-top: 0.35rem;
}

.column-editor-add-section .column-editor-section-label {
  margin-top: 0;
}

.column-editor-search {
  margin-bottom: 0.45rem;
}

.column-editor-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0.35rem 0 0.3rem;
}

.column-editor-visible-list,
.column-editor-available-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 180px;
  overflow-y: auto;
}

.column-editor-available-list {
  max-height: 160px;
}

.column-editor-visible-item,
.column-editor-available-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1px solid transparent;
  font-size: 0.84rem;
}

.column-editor-visible-item.dragging {
  opacity: 0.55;
}

.column-editor-visible-item.drag-over {
  border-color: var(--accent);
}

.column-editor-visible-item.locked {
  opacity: 0.85;
}

.col-drag {
  cursor: grab;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1;
  user-select: none;
}

.col-drag-locked {
  cursor: default;
  opacity: 0.45;
}

.col-visible-label,
.col-available-label {
  flex: 1;
  min-width: 0;
}

.col-locked-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.col-group-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.col-add-btn,
.col-remove-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 1.55rem;
  height: 1.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
}

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

.col-remove-btn:hover {
  border-color: #e25555;
  color: #e25555;
}

.col-btn-danger:hover {
  border-color: #e25555;
  color: #e25555;
}

.column-editor-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0.35rem 0.2rem;
}

.sl-btn-sm {
  padding: 0.32rem 0.55rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.column-editor-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.filter-add-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sl-input {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  width: 100%;
}

.active-filters {
  display: none;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem 0;
}

.active-filters.has-filters {
  display: flex;
}

.filter-chip-active {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(124, 92, 252, 0.1);
  border: 1px solid rgba(124, 92, 252, 0.25);
  color: var(--text);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
}

.filter-chip-active button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.filter-chip-active button:hover { color: var(--red); }

.sl-select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
}

.sl-btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
}

.sl-btn-outline:hover:not(:disabled) {
  border-color: rgba(124, 92, 252, 0.4);
  color: var(--text);
}

.sl-btn-outline:disabled { opacity: 0.4; cursor: not-allowed; }

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.chip {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
}

.chip:hover,
.chip.active {
  border-color: rgba(124, 92, 252, 0.45);
  color: var(--text);
  background: rgba(124, 92, 252, 0.1);
}

.screener-table-wrap {
  overflow-x: auto;
}

.screener-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.screener-table th,
.screener-table td {
  padding: 0.55rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.screener-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
  background: var(--table-head-bg);
}

.screener-table th.num,
.screener-table td.num { text-align: right; }

.screener-table th.has-col-tooltip {
  cursor: help;
  position: relative;
}

.screener-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.screener-table th.sortable:hover .col-head-label {
  color: var(--text);
}

.screener-table th.sort-active .col-head-label {
  color: var(--accent);
}

.sort-indicator {
  margin-left: 0.2rem;
  font-size: 0.68rem;
  opacity: 0.45;
}

.screener-table th.sort-active .sort-indicator {
  opacity: 1;
  color: var(--accent);
}

.col-head-label {
  position: relative;
  display: inline-block;
  border-bottom: 1px dashed transparent;
}

.screener-table th.has-col-tooltip:hover .col-head-label,
.screener-table th.has-col-tooltip:focus-visible .col-head-label {
  border-bottom-color: var(--muted);
}

.screener-table th.has-col-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 1rem;
  z-index: 80;
  display: none;
  width: max-content;
  max-width: 260px;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg-2);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.screener-table th.has-col-tooltip.num::after {
  left: auto;
  right: 1rem;
}

.screener-table th.has-col-tooltip:hover::after,
.screener-table th.has-col-tooltip:focus-visible::after {
  display: block;
}

.screener-table tr:hover td { background: var(--row-hover); }

.loading-cell {
  color: var(--muted);
  text-align: center;
  padding: 2rem !important;
}

.company-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 190px;
  white-space: normal;
}

.stock-logo-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.stock-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
}

.stock-logo-fallback {
  display: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7c5cfc, #4f46e5);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--border);
}

.symbol-with-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.symbol-with-logo:hover .symbol-text strong {
  color: var(--accent);
}

.symbol-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.symbol-text strong {
  font-weight: 700;
  font-size: 0.88rem;
}

.symbol-name {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result.symbol-with-logo {
  align-items: center;
}

.data-table .symbol-with-logo .stock-logo-wrap {
  flex-shrink: 0;
}

.company-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.company-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.company-meta .ticker {
  font-weight: 700;
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.company-meta .ticker:hover { color: #a78bfa; }

.company-name {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screener-table td.num {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.screener-table td.num .positive,
.screener-table td.num .negative {
  font-weight: 700;
}

.row-actions {
  display: flex;
  gap: 0.1rem;
  align-items: center;
  flex-shrink: 0;
}

.row-action {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0.15rem 0.25rem;
  line-height: 1;
  opacity: 0.55;
  transition: opacity 0.15s, color 0.15s;
}

.row-action:hover,
.row-action.active,
.btn-watch.active {
  opacity: 1;
  color: var(--accent);
}

.btn-watch.active { color: var(--orange); }

.row-actions button.row-action { cursor: pointer; }

.positive { color: var(--green); }
.negative { color: var(--red); }

.forecast-pct {
  display: block;
  font-size: 0.78rem;
  margin-top: 0.05rem;
  font-weight: 600;
}

.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.82rem;
}

.rating-high { background: rgba(34, 197, 94, 0.18); color: var(--green); }
.rating-mid { background: rgba(245, 158, 11, 0.18); color: var(--orange); }
.rating-low { background: rgba(239, 68, 68, 0.18); color: var(--red); }

.score-pending {
  color: var(--muted);
  font-size: 0.85rem;
}

.sentiment-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.sentiment-bullish { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.sentiment-neutral { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.sentiment-bearish { background: rgba(239, 68, 68, 0.15); color: var(--red); }

.spark { width: 100px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-top: 1px solid var(--border);
}

.page-info { color: var(--muted); font-size: 0.85rem; }

.page-btns {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.page-numbers {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.page-num {
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.page-num:hover:not(:disabled):not(.active) {
  border-color: var(--accent);
  color: var(--accent);
}

.page-num.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: default;
}

.page-num:disabled {
  opacity: 0.55;
  cursor: default;
}

.page-ellipsis {
  color: var(--muted);
  padding: 0 0.15rem;
  font-size: 0.85rem;
  user-select: none;
}

/* ── Ask AI FAB ── */
.ask-ai-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: 0 8px 32px rgba(37, 99, 235, 0.45);
  z-index: 50;
}

.ask-ai-fab:hover { filter: brightness(1.08); }

/* ── Legacy pages (screeners, stock detail) ── */
.container { width: min(1200px, calc(100% - 2rem)); margin-inline: auto; }
.site-header, .hero, .section, .panel, .site-footer { /* kept for subpages */ }
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(16px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 1rem; padding: 0.9rem 0; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); }
.nav-link { color: var(--muted); padding: 0.45rem 0.75rem; border-radius: 8px; }
.nav-link.active, .nav-link:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 1.5rem; }
.panel-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); }
.ticker-link { color: var(--text); font-weight: 600; }
.metric-item { background: var(--bg-3); border-radius: 10px; padding: 0.85rem; border: 1px solid var(--border); }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; padding: 1.25rem; }
.chart-wrap { padding: 1rem; height: 320px; }

@media (max-width: 1100px) {
  .feature-cards { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sidebar span:not(.sidebar-icon) { display: none; }
  .sidebar { width: 52px; }
  .topbar-nav { display: none; }
  .feature-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .feature-cards { grid-template-columns: 1fr; }
}

/* ── Page headers ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.breadcrumbs {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--text); }
.crumb-sep { margin: 0 0.35rem; opacity: 0.5; }

.page-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  max-width: 60ch;
}

/* ── Screener grid page ── */
.screener-grid-page {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.screener-grid-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  position: relative;
  transition: border-color 0.15s, transform 0.15s;
  min-height: 110px;
}

.screener-grid-card:hover:not(.soon) {
  border-color: rgba(124, 92, 252, 0.4);
  transform: translateY(-1px);
}

.screener-grid-card.soon { opacity: 0.55; pointer-events: none; }

.screener-grid-card.create-card {
  border-style: dashed;
  border-color: rgba(124, 92, 252, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.screener-grid-icon {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: rgba(124, 92, 252, 0.15);
  border-radius: 8px;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.screener-grid-icon.create {
  font-size: 1.5rem;
  color: var(--accent);
  background: rgba(124, 92, 252, 0.2);
}

.screener-grid-card h3 {
  margin: 0 0 0.2rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.screener-grid-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.soon-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.65rem;
  background: var(--bg-3);
  color: var(--muted);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* ── Strategies ── */
.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.strategy-card { padding: 1.25rem; }

.strategy-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.strategy-icon { font-size: 1.75rem; }

.strategy-card h3 { margin: 0 0 0.5rem; }

.strategy-card p { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.75rem; }

.strategy-focus { font-size: 0.82rem; color: var(--muted); margin-bottom: 1rem !important; }

/* ── Shared UI ── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}

.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }

.info-card {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  color: #93c5fd;
}

.live-pulse { display: flex; align-items: center; gap: 0.5rem; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.inline-form input,
.inline-form select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
}

.portfolio-card { margin-bottom: 1rem; }
.portfolio-card .inline-form { padding: 1rem; border-top: 1px solid var(--border); }

.news-list { display: flex; flex-direction: column; gap: 0.75rem; }
.news-card { padding: 1rem 1.25rem; }
.news-card h3 { margin: 0.35rem 0; font-size: 1rem; }
.news-card a { color: var(--text); }
.news-card a:hover { color: #a78bfa; }

.notes-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.note-card p { margin: 0.5rem 0; }

.metric-item .label {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-item .value {
  font-family: ui-monospace, monospace;
  font-weight: 600;
  margin-top: 0.2rem;
}

.btn-watch.active { color: var(--orange); }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 { margin: 0; font-size: 1.05rem; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th.num,
.data-table td.num { text-align: right; }

.data-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.tab {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.tab.active {
  background: rgba(124, 92, 252, 0.15);
  border-color: rgba(124, 92, 252, 0.4);
  color: var(--text);
}

