/* Theme tokens for this page. Dark values are the literals they replace, so
   the dark theme is untouched; the light values are darkened to clear 4.5:1
   on a light surface, where the originals sat around 1.3:1. */
:root {
  --field-rgb: 8,10,14;
  --ss-green: #34c98f;
  --ss-green-mid: #2fb98a;
  --ss-amber: #e0a23a;
}
:root[data-theme="ivory"] {
  --field-rgb: 255,255,255;
  --ss-green: #0a7050;
  --ss-green-mid: #0a6b50;
  --ss-amber: #8a6410;
}

/* Stock Screener & Watchlist — Dhan-X dark theme (var(--ink), --forest, --amber). */

.ss-body { padding: 24px 36px 56px; display: flex; flex-direction: column; gap: 0; max-width: 1600px; }

/* ── Zone shell — distinct top-to-bottom sections (AI / Search / Watchlist) ── */
.ss-zone {
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px 22px 24px;
  border-radius: 16px;
  background: rgba(var(--cream-rgb),0.55);
  border: 1px solid rgba(var(--wash-rgb),0.05);
  margin: 14px 0;
}
.ss-zone-head { display: flex; flex-direction: column; gap: 4px; }
.ss-zone-title {
  font-size: 19px; font-weight: 700; color: var(--ink, #f0f3f6);
  margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.ss-zone-icon { font-size: 18px; line-height: 1; }
.ss-zone-sub { margin: 0; font-size: 13px; color: var(--text-muted, #9aa6b2); line-height: 1.55; }

/* Premium hero treatment for the AI zone: subtle teal glow + gradient border. */
.ss-zone-ai {
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(var(--forest-rgb),0.10), transparent 70%),
    linear-gradient(180deg, rgba(var(--forest-rgb),0.04), rgba(var(--cream-rgb),0.85));
  border: 1px solid rgba(var(--forest-rgb),0.28);
  box-shadow: 0 0 0 1px rgba(var(--forest-rgb),0.06), 0 18px 60px -20px rgba(var(--forest-rgb),0.18);
  padding: 26px 24px 26px;
}
.ss-zone-ai .ss-zone-title { font-size: 22px; }

/* "BETA" pill next to the AI title. */
.ss-beta-badge {
  display: inline-block;
  font-size: 11px; font-weight: 800; letter-spacing: 0.10em;
  background: rgba(240,181,90,0.18); color: var(--warn);
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid rgba(240,181,90,0.36);
  text-transform: uppercase;
}

/* Slim divider between zones. */
.ss-zone-divider {
  height: 1px; width: 100%;
  background: linear-gradient(90deg, transparent, rgba(var(--wash-rgb),0.08) 20%, rgba(var(--wash-rgb),0.08) 80%, transparent);
  margin: 0;
}

/* Heroic AI input — larger, glowing focus, prominent CTA. */
.ss-query-hero .ss-query-input {
  font-size: 16px; padding: 18px 130px 18px 44px;
  background: rgba(var(--field-rgb),0.85); border: 1px solid rgba(var(--forest-rgb),0.30);
  box-shadow: 0 4px 22px -10px rgba(var(--forest-rgb),0.30);
}
.ss-query-hero .ss-query-input:focus {
  outline: none; border-color: rgba(var(--forest-rgb),0.65);
  box-shadow: 0 0 0 3px rgba(var(--forest-rgb),0.18), 0 6px 28px -10px rgba(var(--forest-rgb),0.45);
}
.ss-query-hero .ss-query-btn { padding: 12px 22px; font-size: 14px; }

/* Small disclaimer beneath the AI input — amber left border to draw the eye. */
.ss-ai-disclaimer {
  margin: 10px 0 0; padding: 8px 12px;
  font-size: 11.5px; color: var(--text-muted, #b4bfc9); line-height: 1.55;
  background: rgba(240,181,90,0.06);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
}

/* Per-result rationale shown under AI cards. */
.ss-card-rationale {
  font-style: italic; font-size: 11.5px; color: var(--text-muted, #b4bfc9);
  line-height: 1.5; margin: 6px 0 0; padding-top: 6px;
  border-top: 1px dashed rgba(var(--wash-rgb),0.08);
}
.ss-card-rationale strong { font-style: normal; color: var(--sage-pale, #cdd6df); font-weight: 700; }

/* "prev. close" label shown when /quote falls back to /eod or /time_series. */
.ss-fallback-tag {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--text-muted, #93a0ad); margin-left: 6px;
}
.ss-card .ss-card-row .v.is-fallback,
.ss-detail-price.is-fallback,
.ss-wl-price.is-fallback {
  color: var(--text-muted, #cdd6df);
}

/* "In Watchlist" disabled state on the detail-card add button. */
.ss-btn-add-watch.is-in-watchlist {
  background: rgba(var(--forest-rgb),0.15); color: var(--forest, #00d4aa);
  border: 1px solid rgba(var(--forest-rgb),0.30); cursor: default; opacity: 1;
}

/* Clickable watchlist rows. */
.ss-wl-row { cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease; }
.ss-wl-row:hover { background: rgba(var(--forest-rgb),0.05); border-color: rgba(var(--forest-rgb),0.25); }
.ss-wl-row .ss-wl-actions button { cursor: pointer; }

.ss-block-label {
  display: block; font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted, #9aa6b2); margin: 0 0 8px;
}
.ss-block-title { font-size: 16px; color: var(--ink, #f0f3f6); margin: 4px 0 0; }
.ss-wl-title { margin-top: 12px; }
.ss-count, .ss-wl-meta { color: var(--text-muted, #9aa6b2); font-weight: 500; font-size: 13px; margin-left: 6px; }
.ss-status { font-size: 12.5px; color: var(--text-muted, #9aa6b2); min-height: 18px; margin: 8px 0 0; }
.ss-status.is-error { color: var(--neg); }

/* ── 1) Search bar + autocomplete ─────────────────────────────────────── */
.ss-search-block { display: flex; flex-direction: column; }
.ss-search-wrap { position: relative; }
.ss-search-wrap > .ss-search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 16px; color: var(--text-muted, #9aa6b2); pointer-events: none;
}
.ss-search-input {
  width: 100%; box-sizing: border-box;
  background: rgba(var(--cream-rgb),0.92); border: 1px solid rgba(var(--wash-rgb),0.12);
  border-radius: 12px; padding: 14px 44px 14px 42px;
  color: var(--ink, #e8ecf0); font-size: 15px; font-weight: 500;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ss-search-input:focus { outline: none; border-color: rgba(var(--forest-rgb),0.55); box-shadow: 0 0 0 4px rgba(var(--forest-rgb),0.08); }
.ss-search-input::placeholder { color: rgba(var(--wash-rgb),0.35); }
.ss-search-clear {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: rgba(var(--wash-rgb),0.08); color: var(--ink, #e8ecf0);
  border: 0; width: 24px; height: 24px; border-radius: 50%;
  font-size: 16px; line-height: 1; cursor: pointer;
}
.ss-search-clear:hover { background: rgba(var(--wash-rgb),0.16); }

.ss-search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  margin: 0; padding: 6px; list-style: none;
  background: var(--cream-dark); border: 1px solid rgba(var(--wash-rgb),0.14); border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0,0,0,0.45);
  max-height: 380px; overflow-y: auto;
}
.ss-search-dropdown li {
  display: grid; grid-template-columns: 72px 1fr auto; align-items: baseline; gap: 12px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.ss-search-dropdown li[aria-selected="true"] { background: rgba(var(--forest-rgb),0.10); }
.ss-search-dropdown li:hover { background: rgba(var(--forest-rgb),0.10); }
.ss-sd-sym { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 700; color: var(--ink, #f0f3f6); font-size: 13.5px; }
.ss-sd-name { color: var(--ink, #e8ecf0); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-sd-meta { color: var(--text-muted, #9aa6b2); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── 2) Stock detail card ─────────────────────────────────────────────── */
.ss-detail-loading {
  padding: 24px 28px; border-radius: 14px;
  background: rgba(var(--cream-rgb),0.85); border: 1px solid rgba(var(--wash-rgb),0.10);
  color: var(--text-muted, #9aa6b2); font-size: 13px;
}
.ss-detail-loading.is-error { color: var(--neg); border-color: rgba(255,122,107,0.40); }

.ss-detail-card {
  background: linear-gradient(180deg, rgba(var(--forest-rgb),0.06) 0%, rgba(var(--cream-rgb),0.92) 60%);
  border: 1px solid rgba(var(--forest-rgb),0.30);
  border-radius: 14px; padding: 22px 24px;
  display: flex; flex-direction: column; gap: 18px;
}
.ss-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ss-detail-id { display: flex; flex-direction: column; gap: 4px; }
.ss-detail-sym { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 700; font-size: 26px; color: var(--ink, #f0f3f6); }
.ss-detail-name { font-size: 14.5px; color: var(--ink, #cfd6dd); }
.ss-detail-meta { font-size: 11.5px; color: var(--text-muted, #9aa6b2); text-transform: uppercase; letter-spacing: 0.06em; }
.ss-detail-price-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.ss-detail-price { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 700; font-size: 26px; color: var(--ink, #f0f3f6); }
.ss-detail-change { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13.5px; font-weight: 600; color: var(--text-muted, #9aa6b2); }
.ss-detail-change.is-pos { color: var(--forest, #00d4aa); }
.ss-detail-change.is-neg { color: var(--neg); }

.ss-detail-chart { width: 100%; }
.ss-detail-chart svg { width: 100%; height: 130px; display: block; }
.ss-spark-empty { padding: 22px 0; text-align: center; color: var(--text-muted, #9aa6b2); font-size: 12.5px; }
.ss-spark-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-faint, #6f7b88); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; }

.ss-detail-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.ss-stat {
  background: rgba(var(--wash-rgb),0.03); border: 1px solid rgba(var(--wash-rgb),0.08);
  border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px;
}
.ss-stat-label { font-size: 11px; color: var(--text-muted, #9aa6b2); text-transform: uppercase; letter-spacing: 0.06em; }
.ss-stat-value { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 15px; font-weight: 700; color: var(--ink, #f0f3f6); }

.ss-detail-actions { display: flex; gap: 10px; }
.ss-detail-actions .ss-btn-add-watch { max-width: 320px; }

/* ── 3) NL "Ask a question" + result cards ────────────────────────────── */
.ss-nl-block { display: flex; flex-direction: column; }
.ss-query {
  display: flex; align-items: center; gap: 10px;
  background: rgba(var(--cream-rgb),0.85); border: 1px solid rgba(var(--wash-rgb),0.10);
  border-radius: 12px; padding: 4px 6px 4px 16px;
}
.ss-query:focus-within { border-color: rgba(var(--forest-rgb),0.50); }
.ss-query-icon { font-size: 16px; color: var(--text-muted, #9aa6b2); }
.ss-query-input {
  flex: 1 1 auto; min-width: 0; background: transparent; border: 0; outline: 0;
  color: var(--ink, #e8ecf0); font-size: 14px; padding: 12px 8px;
}
.ss-query-input::placeholder { color: rgba(var(--wash-rgb),0.35); }
.ss-query-btn {
  background: var(--forest, #00d4aa); color: var(--on-accent); border: 0;
  padding: 10px 18px; border-radius: 9px; font-weight: 700; font-size: 13px; cursor: pointer;
}
.ss-query-btn:disabled { opacity: 0.6; cursor: progress; }

.ss-results-head { display: flex; align-items: baseline; gap: 12px; margin-top: 14px; }
.ss-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 6px; }
.ss-card {
  background: rgba(var(--cream-rgb),0.85); border: 1px solid rgba(var(--wash-rgb),0.09);
  border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
  cursor: pointer; transition: border-color .15s ease, transform .15s ease;
}
.ss-card:hover { border-color: rgba(var(--forest-rgb),0.40); transform: translateY(-1px); }
.ss-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ss-tk { font-weight: 700; font-size: 16px; color: var(--ink, #f0f3f6); font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-tk-meta { font-size: 11px; color: var(--text-muted, #9aa6b2); text-transform: uppercase; letter-spacing: 0.06em; }
.ss-name { font-size: 13px; color: var(--text-muted, #aeb9c4); line-height: 1.45; overflow: hidden; text-overflow: ellipsis; }
.ss-card-row { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-muted, #9aa6b2); }
.ss-card-row .v { color: var(--ink, #e8ecf0); font-weight: 600; font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-card-row .v.is-pos { color: var(--forest, #00d4aa); }
.ss-card-row .v.is-neg { color: var(--neg); }
.ss-card-actions { margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.ss-card.is-missing { border-style: dashed; opacity: 0.85; }
.ss-card.is-missing .ss-tk-meta { color: var(--neg); }
.ss-card-nodata { font-size: 12px; color: var(--text-muted, #9aa6b2); font-style: italic; }

/* ── 4) Watchlist ─────────────────────────────────────────────────────── */
.ss-watchlist { display: flex; flex-direction: column; gap: 8px; }
.ss-wl-row {
  display: grid; grid-template-columns: 90px 1fr 110px 110px auto; gap: 10px; align-items: center;
  background: rgba(var(--sidebar-rgb),0.92); border: 1px solid rgba(var(--wash-rgb),0.09);
  border-radius: 11px; padding: 10px 14px;
}
.ss-wl-row.is-live { border-color: rgba(var(--forest-rgb),0.30); }
.ss-wl-sym { font-weight: 700; color: var(--ink, #f0f3f6); font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-wl-name { color: var(--text-muted, #aeb9c4); font-size: 13px; }
.ss-wl-price { font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--ink, #f0f3f6); font-weight: 700; text-align: right; }
.ss-wl-change { font-family: 'JetBrains Mono', ui-monospace, monospace; text-align: right; font-size: 12.5px; color: var(--text-muted, #9aa6b2); }
.ss-wl-change.is-pos { color: var(--forest, #00d4aa); }
.ss-wl-change.is-neg { color: var(--neg); }
.ss-wl-actions { display: flex; gap: 6px; justify-self: end; }
.ss-wl-empty { font-size: 13px; color: var(--text-muted, #9aa6b2); padding: 14px 4px; }
.ss-wl-foot { font-size: 11.5px; color: var(--text-faint, #6f7b88); margin-top: -2px; }
.ss-wl-alerts { font-size: 11px; color: var(--text-muted, #9aa6b2); display: flex; gap: 8px; flex-wrap: wrap; }
.ss-wl-alerts .chip { background: rgba(var(--wash-rgb),0.05); border: 1px solid rgba(var(--wash-rgb),0.10); border-radius: 999px; padding: 2px 8px; }
.ss-wl-alerts .chip.fired { background: rgba(255,122,107,0.10); border-color: rgba(255,122,107,0.40); color: var(--neg); }
.ss-wl-alerts .chip.armed { color: var(--forest, #00d4aa); border-color: rgba(var(--forest-rgb),0.32); }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.ss-btn-primary, .ss-btn-secondary {
  border: 0; border-radius: 8px; padding: 7px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.ss-btn-primary { background: var(--forest, #00d4aa); color: var(--on-accent); }
.ss-btn-secondary { background: rgba(var(--wash-rgb),0.06); color: var(--ink, #e8ecf0); border: 1px solid rgba(var(--wash-rgb),0.12); }
.ss-btn-secondary:hover { border-color: rgba(var(--forest-rgb),0.50); }
.ss-btn-primary:disabled, .ss-btn-secondary:disabled { opacity: 0.55; cursor: not-allowed; }

/* Prominent "+ Add to Watchlist" — used in both the detail card and result cards. */
.ss-btn-add-watch {
  width: 100%;
  background: var(--forest, #00d4aa); color: var(--on-accent);
  border: 0; border-radius: 9px;
  padding: 11px 14px;
  font-size: 13.5px; font-weight: 800; letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
  box-shadow: 0 1px 0 rgba(var(--wash-rgb),0.10) inset, 0 6px 14px rgba(var(--forest-rgb),0.18);
}
.ss-btn-add-watch:hover  { transform: translateY(-1px); box-shadow: 0 1px 0 rgba(var(--wash-rgb),0.12) inset, 0 10px 18px rgba(var(--forest-rgb),0.24); }
.ss-btn-add-watch:active { transform: translateY(0); }
.ss-btn-add-watch:disabled { opacity: 0.85; cursor: progress; transform: none; }
.ss-btn-add-watch.is-added {
  background: var(--badge-bg); color: var(--badge-fg);
  box-shadow: 0 1px 0 rgba(110,240,196,0.10) inset, 0 6px 14px rgba(20,58,43,0.40);
}

/* ── Alert modal ──────────────────────────────────────────────────────── */
.ss-alert-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 70; }
.ss-alert-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--cream-dark); border: 1px solid rgba(var(--wash-rgb),0.14); border-radius: 14px;
  padding: 20px 22px; width: 92%; max-width: 420px; z-index: 80; color: var(--ink, #e8ecf0);
}
.ss-alert-modal h3 { margin: 0 0 4px; font-size: 17px; }
.ss-alert-sub { font-size: 12.5px; color: var(--text-muted, #9aa6b2); margin: 0 0 16px; }
.ss-alert-row { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.ss-alert-row label { font-size: 12.5px; color: var(--text-muted, #aeb9c4); }
.ss-alert-row label strong { color: var(--ink, #f0f3f6); }
.ss-alert-row input {
  background: var(--cream); color: var(--ink, #f0f3f6); border: 1px solid rgba(var(--wash-rgb),0.14);
  border-radius: 8px; padding: 9px 11px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 14px;
}
.ss-alert-row input:focus { outline: none; border-color: rgba(var(--forest-rgb),0.55); }
.ss-alert-note { font-size: 11.5px; color: var(--text-faint, #6f7b88); margin: 4px 0 14px; }
.ss-alert-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Toast ────────────────────────────────────────────────────────────── */
.ss-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 12px);
  background: var(--cream-dark); color: var(--ink, #f0f3f6); border: 1px solid rgba(var(--wash-rgb),0.14);
  border-radius: 10px; padding: 10px 16px; font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; z-index: 90;
}
.ss-toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.ss-toast.is-error { border-color: rgba(255,122,107,0.45); color: var(--neg); }

/* Mobile: iOS Safari auto-zooms inputs with font-size < 16px on focus. */
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
}

/* Mobile: collapse the 5-column watchlist row to a 2-column "name + price"
   layout below 480px. The change %, alerts chips and per-row actions still
   render — they just wrap onto a second row under the name and price so
   nothing overflows or gets squeezed to a few characters wide. */
@media (max-width: 480px) {
  .ss-wl-row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 6px;
  }
  .ss-wl-name { grid-column: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ss-wl-price { grid-column: 2; grid-row: 1; }
  /* Move the symbol above the name so it owns the first row alongside price. */
  .ss-wl-sym { grid-column: 1; grid-row: 1; }
  /* Secondary content wraps below, spanning the full width. */
  .ss-wl-change,
  .ss-wl-alerts,
  .ss-wl-actions {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .ss-wl-actions { justify-self: end; }
}

/* ── Suggested prompts (2×4 grid) ──────────────────────────────────────────── */
.ss-suggested {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0 4px;
}
.ss-suggested[hidden] { display: none; }
.ss-sugg-card {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  background: rgba(var(--sidebar-rgb),0.92);
  border: 1px solid rgba(var(--wash-rgb),0.10);
  border-radius: 11px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}
.ss-sugg-card:hover,
.ss-sugg-card:focus-visible {
  background: rgba(var(--forest-rgb),0.06);
  border-color: rgba(var(--forest-rgb),0.30);
  outline: none;
}
.ss-sugg-text { min-width: 0; }
.ss-sugg-title {
  font-size: 13.5px; font-weight: 700; color: var(--ink, #f0f3f6); margin-bottom: 3px;
}
.ss-sugg-prompt {
  font-size: 12px; color: var(--text-muted, #9aa6b2); line-height: 1.45;
}
.ss-sugg-copy {
  position: relative; flex: 0 0 auto;
  background: none; border: 0; cursor: pointer;
  color: var(--text-muted, #9aa6b2); font-size: 15px; line-height: 1;
  padding: 2px 4px; border-radius: 6px;
}
.ss-sugg-copy:hover { color: var(--forest, #00d4aa); background: rgba(var(--wash-rgb),0.05); }
.ss-sugg-tip {
  position: absolute; top: -26px; right: 0;
  background: var(--forest, #00d4aa); color: var(--on-accent);
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease; white-space: nowrap;
}
.ss-sugg-copy.is-copied .ss-sugg-tip { opacity: 1; transform: translateY(0); }

/* ── Fundamentals metric strip (query cards + watchlist rows) ───────────────── */
.ss-card-metrics {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  margin: 8px 0 2px; font-size: 11.5px; white-space: normal;
}
.ss-metric { display: inline-flex; gap: 5px; align-items: baseline; }
.ss-metric-k { color: var(--text-muted, #8794a0); }
.ss-metric-v { color: var(--ink, #e8ecf0); font-weight: 600; font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-wl-name .ss-card-metrics { margin: 5px 0 0; }

@media (max-width: 640px) {
  .ss-suggested { grid-template-columns: 1fr; }
}

/* ═══════════════ Watchlist quality table (View 2) ═══════════════ */
/* The full fundamentals table is wider than the viewport: scroll it
   horizontally and pin the Company/Fund column so it's always visible. */
.ss-wl-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ss-wl-table { width: auto; min-width: 100%; border-collapse: collapse; font-size: 13px; }
/* Per-column min-widths (sum ≈ 1340px → scrolls on a 1280px screen). */
.ss-wl-table .ss-th, .ss-wl-table .ss-td { min-width: 80px; }
.ss-wl-table .ss-td-price, .ss-wl-table [data-col="price"] { min-width: 100px; }
.ss-wl-table .ss-td-2line, .ss-wl-table [data-col="netMargin"] { min-width: 100px; }
.ss-wl-table [data-field="revenue"], .ss-wl-table [data-col="revenue"] { min-width: 120px; }
.ss-wl-table [data-field="fiftyTwoLow"], .ss-wl-table [data-field="fiftyTwoHigh"],
.ss-wl-table [data-col="fiftyTwoLow"], .ss-wl-table [data-col="fiftyTwoHigh"] { min-width: 90px; }
.ss-wl-table .ss-td-alert, .ss-wl-table th:last-child { min-width: 60px; }
.ss-wl-table .ss-th {
  position: sticky; top: 0; z-index: 1;
  text-align: right; padding: 11px 10px; white-space: nowrap;
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted, #9aa6b2); background: var(--table-head);
  border-bottom: 1px solid rgba(var(--wash-rgb),0.12);
}
.ss-wl-table .ss-th-left { text-align: left; }
/* Sticky first column (Company / Fund) — header stacks above body cells. */
.ss-wl-table .ss-td-company, .ss-wl-table .ss-th-left {
  position: sticky; left: 0; z-index: 2;
  min-width: 200px; width: 200px;
  background: var(--table-sticky); border-right: 1px solid rgba(var(--wash-rgb),0.12);
}
.ss-wl-table thead .ss-th-left { z-index: 3; }
.ss-wl-table .ss-th-sort { cursor: pointer; user-select: none; }
.ss-wl-table .ss-th-sort:hover { color: var(--ink, #e8ecf0); }
.ss-wl-trow { cursor: pointer; transition: background 0.12s ease; }
.ss-wl-trow:hover { background: rgba(var(--forest-rgb),0.06); }
.ss-wl-trow:hover .ss-td-company { background: var(--table-sticky-hover); }
.ss-wl-trow.is-expanded { background: rgba(var(--forest-rgb),0.10); }
.ss-wl-trow.is-expanded .ss-td-company { background: var(--table-sticky-expanded); }
/* Roomier rows (≥56px): 14px vertical padding + the two-line company cell. */
.ss-td {
  text-align: right; padding: 14px 10px; white-space: nowrap; font-size: 13px;
  border-bottom: 1px solid rgba(var(--wash-rgb),0.06);
  font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--ink, #e8ecf0);
}
.ss-td-company { text-align: left; font-family: inherit; }
/* Company/Fund cell may ellipsis its two lines rather than widen the column. */
.ss-co-name, .ss-co-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-co-name { font-size: 15px; font-weight: 600; color: var(--ink, #f0f3f6); }
.ss-co-sub { font-size: 12px; color: var(--text-muted, #8794a0); margin-top: 3px; }
/* Two-line metric cells (Net Margin, Revenue): main value + coloured sub-line. */
.ss-td-2line .ss-td-main { font-size: 13px; }
.ss-td-2line .ss-td-sub { font-size: 11px; margin-top: 3px; font-weight: 600; }
.ss-td-sub.cc-g { color: var(--ss-green); }
.ss-td-sub.cc-r { color: var(--neg); }
.ss-td-price { font-size: 15px; font-weight: 500; }
.ss-chg { font-size: 13px; font-weight: 600; }
.ss-chg.is-pos { color: var(--forest, #00d4aa); }
.ss-chg.is-neg { color: var(--neg); }
.ss-td-dash, .ss-cell-load { color: var(--text-muted, #6b7682); }
/* metric colour coding (dark-theme-readable text variants of the spec palette) */
.ss-td.cc-g { color: var(--ss-green); }
.ss-td.cc-a { color: var(--ss-amber); }
.ss-td.cc-r { color: var(--neg); }
/* score pill — exact spec chips */
.ss-score-pill {
  display: inline-block; min-width: 40px; padding: 4px 10px; border-radius: 12px;
  font-weight: 800; font-size: 13px; font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.ss-score-pill.cc-g { background: #EAF3DE; color: #27500A; }
.ss-score-pill.cc-a { background: #FAEEDA; color: #633806; }
.ss-score-pill.cc-r { background: #FCEBEB; color: #791F1F; }
.ss-score-pill.ss-score-load { background: transparent; color: var(--text-muted, #6b7682); }
.ss-td-alert { white-space: nowrap; }
.ss-bell, .ss-wl-x {
  background: none; border: 0; cursor: pointer; font-size: 14px; padding: 3px 5px; border-radius: 6px;
}
.ss-bell-off { filter: grayscale(1) opacity(0.5); }
.ss-bell-on { filter: none; }
.ss-bell:hover, .ss-wl-x:hover { background: rgba(var(--wash-rgb),0.06); }
.ss-wl-x { color: var(--text-muted, #8794a0); }
.ss-wl-empty { color: var(--text-muted, #9aa6b2); padding: 18px 4px; font-size: 13px; }

/* ═══════════════ Expanded stock card (View 3) ═══════════════ */
/* The expand's colspan cell is as wide as the (wider-than-viewport) table, which
   pushed the inline chart's right-hand y-axis and the period-% block off-screen.
   Pin the cell to the left of the scroll viewport so the expand content stays put
   while the table scrolls; toggleExpand() sizes .ss-expand-host to the visible
   wrapper width so the whole compact chart + signal block fit in view. */
.ss-wl-expand-row > td { padding: 0; background: rgba(var(--sidebar-rgb),0.55); border-bottom: 1px solid rgba(var(--wash-rgb),0.10); position: sticky; left: 0; }
.ss-wl-expand-row .ss-expand-host { max-width: 100%; }
.ss-card-expand { padding: 16px; }
/* Stock-identifier header at the top of the expanded card (FIX 1). */
.ss-ex-head { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; margin: 0 0 14px; }
.ss-ex-logo {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff; letter-spacing: 0.02em;
}
.ss-ex-id { min-width: 0; }
.ss-ex-name { font-size: 16px; font-weight: 700; color: var(--ink, #f0f3f6); overflow: hidden; text-overflow: ellipsis; }
.ss-ex-sub { font-size: 12px; color: var(--text-muted, #8794a0); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.ss-ex-px { font-size: 13px; color: var(--ink, #c7d0d9); margin-top: 4px; font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-ex-px .ss-chg.is-pos { color: var(--forest, #00d4aa); }
.ss-ex-px .ss-chg.is-neg { color: var(--neg); }
/* Non-operating-company caution banner (FIX 3). */
.ss-nonop-banner {
  display: flex; align-items: flex-start; gap: 8px;
  background: rgba(240,181,90,0.10); border: 1px solid rgba(240,181,90,0.35);
  border-left: 3px solid var(--warn); border-radius: 8px;
  padding: 9px 12px; margin: 0 0 14px; font-size: 11px; line-height: 1.5; color: #f0d39a;
}
.ss-nonop-ico { flex: 0 0 auto; }
.ss-nonop-banner-drill { font-size: 12.5px; padding: 12px 16px; margin: 6px 0 22px; max-width: none; }
.ss-expand-skel, .ss-expand-err { color: var(--text-muted, #9aa6b2); font-size: 13px; padding: 8px 2px; }
.ss-expand-err { color: #ff9a8c; }
/* Informational, not a warning: the stock is fine, the provider just has no
   statements for it, so no composite score is shown. Neutral blue-grey keeps it
   distinct from the amber non-operating caution above. */
.ss-expand-note {
  background: rgba(120,160,200,0.10); border: 1px solid rgba(120,160,200,0.30);
  border-left: 3px solid #78a0c8; border-radius: 8px;
  padding: 9px 12px; margin: 0 0 14px; font-size: 11.5px; line-height: 1.55; color: #c3d4e4;
}
.ss-ex-metrics { display: flex; flex-direction: column; gap: 10px; }
.ss-mrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ss-mtile {
  background: rgba(var(--wash-rgb),0.03); border: 1px solid rgba(var(--wash-rgb),0.08);
  border-radius: 10px; padding: 10px 12px; min-width: 0;
}
.ss-mtile-k { font-size: 11px; color: var(--text-muted, #8794a0); text-transform: uppercase; letter-spacing: 0.03em; }
.ss-mtile-v { font-size: 17px; font-weight: 700; color: var(--ink, #f0f3f6); font-family: 'JetBrains Mono', ui-monospace, monospace; margin: 3px 0; }
.ss-mtile-sub { font-size: 11px; color: var(--text-muted, #8794a0); }
.ss-ex-score { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; margin-top: 16px; }
.ss-pbars { display: flex; flex-direction: column; gap: 7px; }
.ss-pbar { display: grid; grid-template-columns: 110px 1fr 28px; gap: 8px; align-items: center; font-size: 12px; }
.ss-pbar-name { color: var(--text-muted, #aeb9c4); white-space: nowrap; }
.ss-pbar-track { background: rgba(var(--wash-rgb),0.08); border-radius: 999px; height: 8px; overflow: hidden; }
.ss-pbar-fill { display: block; height: 100%; border-radius: 999px; }
.ss-pbar-fill.pb-strong { background: var(--ss-green-mid); }
.ss-pbar-fill.pb-mid { background: #6cc08a; }
.ss-pbar-fill.pb-weak { background: #d99a3a; }
.ss-pbar-fill.pb-none { background: #c2554c; }
.ss-pbar-score { text-align: right; font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--ink, #e8ecf0); font-weight: 600; }
.ss-score-circle {
  width: 92px; height: 92px; border-radius: 50%; border: 3px solid var(--text-muted, #6b7682);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
}
.ss-score-circle.cc-g { border-color: var(--ss-green); }
.ss-score-circle.cc-a { border-color: var(--ss-amber); }
.ss-score-circle.cc-r { border-color: var(--neg); }
.ss-score-num { font-size: 26px; font-weight: 800; color: var(--ink, #f0f3f6); font-family: 'JetBrains Mono', ui-monospace, monospace; line-height: 1; }
.ss-score-den { font-size: 11px; color: var(--text-muted, #8794a0); }
.ss-score-verdict { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted, #aeb9c4); margin-top: 3px; }
.ss-ai-strip { border-left: 2px solid var(--forest, #00d4aa); padding: 14px 16px; margin: 16px 0 4px; max-width: 650px; font-size: 14px; line-height: 2.0; }
.ss-ai-skel { color: var(--text-muted, #8794a0); font-size: 14px; font-style: italic; }
.ss-ai-why { font-weight: 700; color: var(--ink, #f0f3f6); font-size: 14px; margin-bottom: 6px; }
.ss-ai-text { color: var(--text-muted, #b4bfc9); font-size: 14px; line-height: 2.0; }
.ss-ai-strip .ss-ai-p { margin: 6px 0; color: var(--text-muted, #b4bfc9); }
.ss-ai-strip .ss-ai-p strong { color: var(--ink, #e8ecf0); font-weight: 700; }
.ss-ai-strip .ss-ai-ul { margin: 4px 0 8px; padding-left: 18px; list-style: none; }
.ss-ai-strip .ss-ai-ul li { position: relative; margin-bottom: 6px; color: var(--text-muted, #b4bfc9); }
.ss-ai-strip .ss-ai-ul li::before { content: '•'; position: absolute; left: -14px; color: var(--forest, #00d4aa); }
.ss-ai-strip .ss-ai-ul li strong { color: var(--ink, #e8ecf0); font-weight: 700; }
.ss-ex-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

@media (max-width: 720px) {
  .ss-mrow { grid-template-columns: repeat(2, 1fr); }
  .ss-ex-score { grid-template-columns: 1fr; justify-items: start; }
  .ss-pbar { grid-template-columns: 92px 1fr 24px; }
}

/* ═══════════════ Phase 2 — 7-pillar drill-down ═══════════════ */
body.ss-drill-open { overflow: hidden; }
.ss-drill {
  position: fixed; inset: 0; z-index: 1100; overflow-y: auto;
  background: var(--cream, #0c0e12);
  -webkit-overflow-scrolling: touch;
}
.ss-drill-inner { max-width: 1080px; margin: 0 auto; padding: 22px 18px 60px; }
.ss-drill-loading { color: var(--text-muted, #9aa6b2); padding: 30px 2px; font-size: 14px; }
.ss-drill-back {
  background: none; border: 1px solid rgba(var(--wash-rgb),0.14); color: var(--ink, #e8ecf0);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 13px; margin-bottom: 18px;
}
.ss-drill-back:hover { border-color: var(--forest, #00d4aa); color: var(--forest, #00d4aa); }

/* header */
.ss-drill-head { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; margin-bottom: 18px; }
.ss-drill-logo {
  width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; color: #fff; letter-spacing: 0.02em;
}
.ss-drill-name { font-size: 20px; font-weight: 800; color: var(--ink, #f0f3f6); }
.ss-drill-sub { font-size: 12.5px; color: var(--text-muted, #8794a0); margin-top: 2px; }
.ss-drill-px { font-size: 13px; color: var(--ink, #c7d0d9); margin-top: 4px; font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-drill-scorebox { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ss-verdict-badge { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; padding: 3px 10px; border-radius: 999px; }
.ss-verdict-badge.cc-g { background: #EAF3DE; color: #27500A; }
.ss-verdict-badge.cc-a { background: #FAEEDA; color: #633806; }
.ss-verdict-badge.cc-r { background: #FCEBEB; color: #791F1F; }
.ss-drill-ai { margin: 6px 0 22px; }

/* pillar cards */
.ss-pcards { display: grid; grid-template-columns: 1fr; gap: 14px; }
.ss-pcard {
  background: rgba(var(--wash-rgb),0.03); border: 1px solid rgba(var(--wash-rgb),0.08);
  border-left-width: 3px; border-radius: 12px; padding: 14px 16px;
}
.ss-pcard.pc-strong { border-left-color: var(--ss-green-mid); }
.ss-pcard.pc-mid { border-left-color: #6cc08a; }
.ss-pcard.pc-weak { border-left-color: #d99a3a; }
.ss-pcard.pc-poor { border-left-color: #c2554c; }
.ss-pcard.pc-info { border-left-color: #6b7682; }
.ss-pcard-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.ss-pcard-title { font-size: 15px; font-weight: 700; color: var(--ink, #f0f3f6); }
.ss-pbadge { font-size: 13px; font-weight: 800; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.ss-pbadge.cc-g { background: #EAF3DE; color: #27500A; }
.ss-pbadge.cc-mg { background: #DDEFD0; color: #2c5a14; }
.ss-pbadge.cc-a { background: #FAEEDA; color: #633806; }
.ss-pbadge.cc-r { background: #FCEBEB; color: #791F1F; }
.ss-pbadge-info { background: rgba(var(--wash-rgb),0.08); color: var(--text-muted, #aeb9c4); }
.ss-dt-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ss-dt-grid-3 { grid-template-columns: repeat(3, 1fr); }
.ss-dt { background: rgba(var(--wash-rgb),0.025); border: 1px solid rgba(var(--wash-rgb),0.06); border-radius: 9px; padding: 9px 11px; min-width: 0; }
.ss-dt-k { font-size: 11px; color: var(--text-muted, #8794a0); text-transform: uppercase; letter-spacing: 0.02em; }
.ss-dt-v { font-size: 16px; font-weight: 700; color: var(--ink, #f0f3f6); font-family: 'JetBrains Mono', ui-monospace, monospace; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-dt-c { font-size: 11px; color: var(--text-muted, #8794a0); }
.ss-pcard-insight { border-left: 3px solid var(--text-muted, #6b7682); padding: 7px 0 7px 11px; margin-top: 12px; font-size: 13px; line-height: 1.8; color: var(--text-muted, #b4bfc9); }
.ss-pcard-insight.in-g { border-left-color: var(--ss-green-mid); }
.ss-pcard-insight.in-a { border-left-color: #d99a3a; }
.ss-pcard-insight.in-r { border-left-color: #c2554c; }
.ss-pcard-insight.in-info { border-left-color: #6b7682; }

/* revenue mini bar chart (Pillar 3) */
.ss-rev-chart { margin-top: 12px; }
.ss-rev-note { font-size: 12px; color: var(--text-muted, #8794a0); font-style: italic; }
.ss-rev-bars { display: flex; align-items: flex-end; gap: 16px; height: 120px; padding: 6px 4px 0; }
.ss-rev-bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 0 0 64px; height: 100%; }
.ss-rev-fill { width: 38px; background: linear-gradient(180deg, var(--ss-green-mid), #1c8e69); border-radius: 6px 6px 0 0; }
.ss-rev-val { font-size: 11px; color: var(--ink, #c7d0d9); font-family: 'JetBrains Mono', ui-monospace, monospace; margin-bottom: 4px; }
.ss-rev-yr { font-size: 11px; color: var(--text-muted, #8794a0); margin-top: 6px; }

/* multi-range price chart (drilldown, under the price header) — the hero */
.ss-drill-chart { margin: 18px 0 10px; }

/* signal block: price + day change, after-hours line, period change */
.ss-chart-signal { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; margin-bottom: 14px; }
.ss-sig-main { display: flex; align-items: baseline; gap: 9px; }
.ss-sig-price { font-size: 26px; font-weight: 800; color: var(--ink, #f0f3f6); font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-sig-day { font-size: 15px; font-weight: 700; }
.ss-sig-ah { display: flex; align-items: baseline; gap: 8px; }
.ss-sig-ah[hidden] { display: none; }
.ss-sig-ah-price { font-size: 16px; font-weight: 700; color: var(--text-muted, #8794a0); font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-sig-ah-chg { font-size: 13px; font-weight: 700; }
.ss-sig-tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint, #6f7b88); }
.ss-sig-period { margin-left: auto; display: flex; align-items: baseline; gap: 9px; }
.ss-sig-period-range { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-muted, #8794a0); }
.ss-sig-period-chg { font-size: 17px; font-weight: 800; }
.ss-sig-period-abs { font-size: 12px; color: var(--text-muted, #8794a0); font-family: 'JetBrains Mono', ui-monospace, monospace; }

.ss-chart-ranges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.ss-chart-range {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background: rgba(var(--wash-rgb),0.05); border: 1px solid rgba(var(--wash-rgb),0.1);
  color: var(--text-muted, #8794a0); font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 7px; transition: color .15s, background .15s, border-color .15s;
}
.ss-chart-range:hover { color: var(--ink, #e8ecf0); border-color: rgba(var(--forest-rgb),0.45); }
.ss-chart-range.is-active { color: var(--surface-sidebar); background: var(--forest); border-color: var(--forest); }
.ss-chart-body { position: relative; height: 360px; }   /* hero height (drilldown) */
.ss-chart-compact .ss-chart-body { height: 200px; }      /* inline expand — compact */
.ss-chart-compact .ss-sig-price { font-size: 20px; }
.ss-chart-compact { margin: 4px 0 14px; }
.ss-chart-canvas { width: 100% !important; height: 100% !important; display: block; }
.ss-chart-status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 0 16px; font-size: 13px; color: var(--text-faint, #6f7b88);
}
/* [hidden] alone can't hide an element with an explicit display; be explicit. */
.ss-chart-status[hidden] { display: none; }
@media (max-width: 640px) {
  .ss-chart-body { height: 260px; }
  .ss-sig-price { font-size: 22px; }
  .ss-sig-period { margin-left: 0; }
}

/* scoring rubric */
.ss-rubric { margin-top: 28px; border-top: 1px solid rgba(var(--wash-rgb),0.1); padding-top: 22px; }
.ss-rubric-title { font-size: 17px; font-weight: 800; color: var(--ink, #f0f3f6); margin: 0 0 4px; }
.ss-rubric-sub { font-size: 13px; color: var(--text-muted, #9aa6b2); margin: 0 0 16px; }
.ss-rubric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ss-rubric-card { background: rgba(var(--wash-rgb),0.03); border: 1px solid rgba(var(--wash-rgb),0.08); border-radius: 10px; padding: 12px 14px; }
.ss-rubric-name { font-weight: 700; color: var(--ink, #f0f3f6); font-size: 13.5px; margin-bottom: 4px; }
.ss-rubric-what { font-size: 12px; color: var(--text-muted, #b4bfc9); }
.ss-rubric-thr { font-size: 11.5px; color: var(--text-muted, #8794a0); margin: 5px 0; font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-rubric-why { font-size: 12px; color: var(--text-muted, #9aa6b2); font-style: italic; }
.ss-rubric-legend { margin-top: 14px; font-size: 12.5px; color: var(--text-muted, #b4bfc9); }
.ss-rubric-formula { margin-top: 6px; font-size: 12.5px; color: var(--ink, #c7d0d9); font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-drill-actions { margin-top: 22px; }

@media (max-width: 720px) {
  .ss-drill-head { grid-template-columns: auto 1fr; }
  .ss-drill-scorebox { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; gap: 12px; }
  .ss-dt-grid, .ss-dt-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .ss-rubric-grid { grid-template-columns: 1fr; }
}

/* ═══════════════ Screener AI result cards (Part 2) ═══════════════ */
.ss-rcard {
  background: rgba(var(--sidebar-rgb),0.92); border: 1px solid rgba(var(--wash-rgb),0.09);
  border-radius: 12px; padding: 14px 16px; cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}
.ss-rcard:hover, .ss-rcard:focus-visible { background: rgba(var(--forest-rgb),0.06); border-color: rgba(var(--forest-rgb),0.30); outline: none; }
.ss-rcard-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ss-rcard .ss-tk { font-weight: 800; font-size: 15px; color: var(--ink, #f0f3f6); font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-rcard-score { min-height: 22px; }
.ss-rcard-name { font-size: 13px; color: var(--ink, #d7dee6); margin-top: 4px; }
.ss-rcard-sub { font-size: 11px; color: var(--text-muted, #8794a0); }
.ss-rcard-price { font-size: 13px; font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--ink, #e8ecf0); margin: 8px 0; }
.ss-rcard-price .ss-chg.is-pos { color: var(--forest, #00d4aa); }
.ss-rcard-price .ss-chg.is-neg { color: var(--neg); }
.ss-card-nodata { color: var(--text-muted, #8794a0); font-style: italic; font-size: 12px; }
.ss-rcard-metrics { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--text-muted, #8794a0); margin-bottom: 8px; }
.ss-rcard-metrics .ss-rm b { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 700; color: var(--ink, #e8ecf0); }
.ss-rcard-metrics .ss-rm.cc-g b { color: var(--ss-green); }
.ss-rcard-metrics .ss-rm.cc-a b { color: var(--ss-amber); }
.ss-rcard-metrics .ss-rm.cc-r b { color: var(--neg); }
.ss-card-rationale { font-size: 12px; color: var(--text-muted, #aeb9c4); line-height: 1.5; margin-bottom: 10px; }
.ss-card-rationale strong { color: var(--ink, #d7dee6); }
.ss-rcard-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ss-rcard-actions .ss-btn-secondary, .ss-rcard-actions .ss-btn-primary { font-size: 12px; padding: 7px 12px; }
.ss-btn-secondary.is-in-watchlist { color: var(--forest, #00d4aa); border-color: rgba(var(--forest-rgb),0.4); cursor: default; }

/* search & add row (watchlist page) — make room for the Add button */
.ss-search-wrap #wlAddBtn { flex: 0 0 auto; }
.ss-footnote { margin-top: 18px; font-size: 12.5px; color: var(--text-muted, #9aa6b2); }
.ss-footnote a { color: var(--forest, #00d4aa); }
.ss-expand-host { display: block; }

/* ═══════════════ Watchlist country groups (US / India) ═══════════════ */
/* Country is the outer organiser; Stocks / ETFs split sits inside it. The
   heading has to outrank .ss-wl-sec-title below it, hence display face + rule. */
.ss-wl-country + .ss-wl-country { margin-top: 38px; }
.ss-wl-country-title {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-size: 20px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--ink, #f0f3f6);
  margin: 0 0 4px; padding-bottom: 12px;
  border-bottom: 2px solid rgba(var(--forest-rgb),0.35);
}
.ss-wl-country-title .ss-wl-flag { font-size: 22px; line-height: 1; }
.ss-wl-country-title .ss-wl-meta {
  font-size: 13px; font-weight: 500; text-transform: none; letter-spacing: 0;
  color: var(--text-muted, #93a0ad);
}
/* First section inside a country sits closer to its banner than the default. */
.ss-wl-country .ss-wl-section:first-of-type .ss-wl-sec-title { margin-top: 14px; }

/* ═══════════════ Watchlist sections (Stocks / ETFs split) ═══════════════ */
.ss-wl-section { margin-bottom: 20px; }
.ss-wl-section + .ss-wl-section { margin-top: 26px; }
.ss-wl-sec-title {
  font-size: 16px; font-weight: 600; color: var(--ink, #f0f3f6);
  margin: 20px 0 12px; padding-bottom: 10px;
  border-bottom: 1px solid rgba(var(--wash-rgb),0.10);
}
.ss-wl-sec-title .ss-wl-meta { font-size: 13px; text-transform: none; letter-spacing: 0; }

/* ═══════════════ ETF expanded card + drill ═══════════════ */
.ss-etf-tag, .ss-rcard-etf-tag {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: #6fd0ff; background: rgba(80,170,255,0.12); border: 1px solid rgba(80,170,255,0.30);
  padding: 2px 9px; border-radius: 999px;
}
.ss-etf .ss-etf-tag { margin-bottom: 12px; }
.ss-mrow-4 { grid-template-columns: repeat(4, 1fr); }
.ss-etf-holds { margin-top: 14px; }
.ss-etf-holds-h {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted, #9aa6b2); margin-bottom: 8px;
}
.ss-etf-hold {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid rgba(var(--wash-rgb),0.06); font-size: 13px;
}
.ss-etf-hold:last-child { border-bottom: 0; }
.ss-etf-hold-n { color: var(--ink, #e8ecf0); font-weight: 500; }
.ss-etf-hold-w { color: var(--text-muted, #aeb9c4); font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ss-drill-id { min-width: 0; }

@media (max-width: 720px) {
  .ss-mrow-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ═══ WATCHLIST ON A PHONE ════════════════════════════════════════════════
   Option B: symbol and name on the left, price and day change on the right,
   then three metrics as labelled chips underneath.

   The desktop table carries fifteen columns for a stock and eight for an ETF.
   At 390px that could only scroll sideways, so everything past Price was out
   of sight — the data was present and unreachable.

   The SAME cells are re-gridded rather than a second markup being rendered for
   phones: one DOM, and patchStockRow() keeps updating by [data-field] exactly
   as it does on desktop. Cells are placed BY NAME into named grid areas, not by
   nth-child, so adding or reordering a column cannot silently move the layout.
   ═════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* 36px of body padding plus 22px of zone padding is 116px of chrome on a
     390px screen — nearly a third of it — leaving 274px for content that has
     to hold a name, a sparkline, a price and two controls. These are desktop
     numbers that were never revisited for a phone. */
  .ss-body { padding: 16px 12px 40px; }
  .ss-zone { padding: 14px 12px 16px; }

  /* The row grid can only hand out space it has been given, and it was not
     being given any: .ss-watchlist is a flex item that sized to its content
     (272px inside a 318px zone), so the 1fr column resolved to 0 and the
     company name — which truncates — clipped to nothing while the ticker,
     which does not, painted outside its own box. Same family as the
     min-width:auto trap documented on .main-content in styles.css. */
  .ss-watchlist, .ss-wl-country, .ss-wl-section, .ss-wl-table-wrap {
    width: 100%; min-width: 0;
  }
  .ss-wl-table-wrap { overflow-x: visible; }
  .ss-wl-table thead { position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .ss-wl-table, .ss-wl-table tbody { display: block; width: 100%; max-width: 100%; min-width: 0; }

  /* The phone row follows the Apple Stocks anatomy: ticker leads, a sparkline
     sits in the middle, price and its change sit right. The score — the one
     thing Apple cannot show — takes the space under the ticker. Price and
     alert span both rows so the right-hand side reads as one block. */
  .ss-wl-table tbody tr.ss-wl-trow {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(88px,1fr) auto auto auto;
    grid-template-areas:
      "co sp px al"
      "sc sp ch al";
    column-gap: 10px;
    row-gap: 3px;
    align-items: center;
    padding: 9px 14px;
    border-bottom: 1px solid rgba(var(--wash-rgb),0.06);
  }
  .ss-wl-table tbody tr.ss-wl-trow:last-child { border-bottom: none; }

  /* Hidden by default, with the three chosen metrics opting back in — a column
     added later cannot leak onto the phone layout unannounced. */
  .ss-wl-table tbody tr.ss-wl-trow > td { display: none; padding: 0; border: none; }

  .ss-wl-table .ss-td-company {
    display: block !important; grid-area: co;
    /* On desktop this is a sticky pinned column: position:sticky, z-index:2 and
       a FIXED width:200px. Resetting min-width and max-width was not enough —
       width:200px still applied, so the cell overflowed its grid column and
       z-index painted it OVER the price. Long names ran straight through the
       number beside them. */
    position: static !important; z-index: auto !important;
    width: auto !important; min-width: 0 !important; max-width: none !important;
    background: transparent !important; text-align: left;
  }
  /* Ticker first, name second — the reverse of the desktop order, done in CSS so
     there is only one markup path. The sector is dropped: at this width it
     pushed the name into an ellipsis for information nobody reads here. */
  .ss-wl-table .ss-td-company { display: flex !important; flex-direction: column-reverse; }
  .ss-wl-table .ss-co-sector { display: none; }
  .ss-wl-table .ss-co-sub {
    font-size: 16px; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em;
    color: var(--ink); overflow: visible; text-overflow: clip;
  }
  .ss-wl-table .ss-co-name {
    font-size: 12px; font-weight: 400; color: var(--text-muted); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  /* The price cell is dissolved so its three children become grid items of the
     row itself. Kept as one cell they shared a single column, and a wide price
     like $1,964.30 pushed the sparkline onto its own line above the figure
     rather than beside it. */
  .ss-wl-table .ss-td-price { display: contents !important; }
  .ss-wl-table .ss-td-price .ss-spark { grid-area: sp; align-self: center; }
  .ss-wl-table .ss-td-price [data-field="price"] {
    grid-area: px; align-self: end; text-align: right; white-space: nowrap;
    font-size: 15px; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em;
    font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  }
  /* The change becomes a filled pill — the one saturated element on the row,
     which is the trick that makes the eye land on what actually moved. */
  .ss-wl-table .ss-td-price .ss-chg {
    grid-area: ch; align-self: start; justify-self: stretch;
    margin-top: 3px; padding: 2px 6px; border-radius: 6px;
    text-align: center; font-size: 11.5px; font-weight: 600; line-height: 1.35;
    font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  }
  .ss-wl-table .ss-td-price .ss-chg.is-pos { background: var(--forest); color: #04130f; }
  .ss-wl-table .ss-td-price .ss-chg.is-neg { background: var(--amber); color: #2a0f06; }
  .ss-wl-table .ss-td-price .ss-chg.is-ah  { opacity: 0.82; }
  /* No figure to show. Left unfilled this sat in the row looking like a value,
     so it carries the muted treatment instead: visibly "we don't have this"
     rather than a quiet claim that the stock did not move. */
  .ss-wl-table .ss-td-price .ss-chg:not(.is-pos):not(.is-neg) {
    background: rgba(var(--wash-rgb), 0.5); color: var(--text-muted);
  }

  /* Side by side. Stacking them set an 80px floor on the row height — half
     again as tall as it needed to be — for no gain. Both keep the 40px touch
     target; the width comes back out of the sparkline instead. */
  .ss-wl-table .ss-td-alert {
    display: flex !important; grid-area: al; flex-direction: row;
    align-items: center; justify-content: flex-end; gap: 0; min-width: 0;
  }

  /* The chips. ::before supplies the label the hidden header used to carry.
     Stocks show P/E, Score and YTD; ETFs have no score or YTD column, so they
     show P/E, yield and market cap instead. */
  .ss-wl-table [data-field="pe"],
  .ss-wl-table [data-field="score"],
  .ss-wl-table [data-field="returnYtd"],
  .ss-wl-table [data-field="divYield"],
  .ss-wl-table [data-field="mcap"] {
    align-items: baseline; gap: 4px;
    margin-top: 9px; padding: 3px 8px; border-radius: 5px;
    background: rgba(var(--wash-rgb),0.06);
    font-size: 11.5px; color: var(--ink); white-space: nowrap; text-align: left;
    justify-self: start;
  }
  .ss-wl-table [data-field="pe"]::before        { content: 'P/E '; color: var(--text-muted); }
  .ss-wl-table [data-field="score"]::before     { content: 'Score '; color: var(--text-muted); }
  .ss-wl-table [data-field="returnYtd"]::before { content: 'YTD '; color: var(--text-muted); }
  .ss-wl-table [data-field="divYield"]::before  { content: 'Yield '; color: var(--text-muted); }
  .ss-wl-table [data-field="mcap"]::before      { content: 'Mkt cap '; color: var(--text-muted); }

  /* One chip, not three. P/E and YTD are a tap away in the expanded row; the
     score is the reason this product exists, so it is the one that stays. */
  .ss-wl-table[data-table="stock"] [data-field="score"] { display: inline-flex !important; grid-area: sc; margin-top: 0; }
  .ss-wl-table[data-table="etf"]   [data-field="mcap"]  { display: inline-flex !important; grid-area: sc; margin-top: 0; }

  /* The score cell carries its own pill styling on desktop; inside a chip it
     only needs to be the number. */
  .ss-wl-table [data-field="score"] .ss-score-pill,
  .ss-wl-table [data-field="score"] > span { background: none !important; padding: 0 !important; }

  .ss-wl-table .ss-bell, .ss-wl-table .ss-wl-x {
    min-width: 40px; min-height: 40px; display: inline-flex;
    align-items: center; justify-content: center;
  }

  /* 100%, not a character count: the ellipsis has to answer to the grid column
     it is actually in, not to a guess about how wide that column might be.
     Sizing and weight now come from the Apple-anatomy block above — this is
     only the truncation behaviour, which still applies to both lines. */
  .ss-wl-table .ss-co-name,
  .ss-wl-table .ss-co-sub { max-width: 100%; }
}

/* After-hours: same colour semantics as a normal day move, but dimmed and with
   an "AH" suffix, so a post-bell number is never mistaken for the day's close
   figure. The two are measured from different anchors — the day move from the
   previous close, the AH move from today's close — and a reader has to be able
   to tell which one they are looking at. */
.ss-chg.is-ah { opacity: 0.78; font-style: italic; }

/* ── Sparkline (phone watchlist) ───────────────────────────────────────────
   Hidden by default: on desktop the row is a wide table with real return
   columns, so a 54px squiggle adds nothing, and the per-symbol fetch would be
   spent on something nobody can see. The client only requests the data when
   the phone layout actually matches. */
.ss-spark { display: none; }
@media (max-width: 640px) {
  .ss-spark { display: block; width: 38px; height: 24px; }
  .ss-spark svg { width: 100%; height: 100%; display: block; }
  .ss-spark path { stroke: var(--text-faint); }
  .ss-spark.is-up path { stroke: var(--forest); }
  .ss-spark.is-dn path { stroke: var(--amber); }
  /* No series, or too few points to draw one: collapse rather than leave a
     54px hole that makes the row look broken. */
  .ss-spark.is-empty { width: 0; }
}
