/* ChartVanta visual layer — additive skin. No market data or execution behavior changes.
   Keep after all legacy styles so existing routes and HQ functionality remain intact. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #060d19; --bg-2: #081423;
  --panel: #0c1b2d; --panel-2: #102339; --panel-3: #173149;
  --border: #18354b; --border-strong: #24506a; --border-hi: #35728a;
  --text: #effaff; --text-2: #c3d6e2; --muted: #92aec0;
  --accent: #00cba9; --accent-hi: #00ebc0; --accent-text: #4fffe0;
  --accent-soft: rgba(0, 215, 177, .14); --link-hover: #a3ffed;
  --green: #00dfa9; --green-soft: rgba(0, 223, 169, .13);
  --red: #ff657d; --red-soft: rgba(255, 101, 125, .13);
  --radius: 12px; --radius-sm: 8px; --radius-lg: 16px;
  --shadow: 0 18px 45px rgba(0, 5, 16, .65);
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(800px 420px at 90% -140px, rgba(0, 242, 211, .10), transparent 70%),
    radial-gradient(600px 330px at -12% 15%, rgba(19, 112, 201, .12), transparent 72%),
    var(--bg);
}
:root[data-theme="dark"] .header {
  background: rgba(6, 16, 29, .95);
  border-bottom-color: rgba(51, 187, 191, .24);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 6px 22px rgba(1, 8, 18, .28);
}
:root[data-theme="dark"] .tape {
  background: #071726;
  border-bottom-color: rgba(51, 187, 191, .18);
}
:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .wl-rail { background: #081523; }
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .rh-card,
:root[data-theme="dark"] .ol-card,
:root[data-theme="dark"] .glance,
:root[data-theme="dark"] .scout-card,
:root[data-theme="dark"] .data-card,
:root[data-theme="dark"] .term-bar {
  background: linear-gradient(160deg, rgba(17, 38, 59, .98), rgba(10, 24, 42, .98));
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: 0 8px 26px rgba(0, 6, 18, .20);
}
:root[data-theme="dark"] .panel:hover,
:root[data-theme="dark"] .scout-card:hover,
:root[data-theme="dark"] .ol-card:hover {
  border-color: #275a68;
}
:root[data-theme="dark"] .hero {
  position: relative; overflow: hidden;
  background: radial-gradient(550px 250px at 98% 4%, rgba(0, 226, 184, .17), transparent 75%),
    linear-gradient(122deg, #102c43 0%, #091728 64%, #0a1d30 100%);
  border: 1px solid #26647a;
  border-radius: 19px;
  box-shadow: inset 0 1px 0 rgba(142, 255, 233, .13), 0 14px 35px rgba(0, 8, 23, .25);
}
:root[data-theme="dark"] .hero::after {
  content: ""; position: absolute; right: -45px; bottom: -118px; width: 310px; height: 240px;
  pointer-events: none; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 255, 201, .12), transparent 65%);
}
:root[data-theme="dark"] .hero-title,
:root[data-theme="dark"] .view-head h1 { color: #f5feff; }
:root[data-theme="dark"] .view-head h1 { font-size: calc(25px * var(--ts, 1.1)); letter-spacing: -.025em; }
:root[data-theme="dark"] .panel-head h2 { font-weight: 800; color: #eafcff; }
:root[data-theme="dark"] .brand { gap: 9px; }
:root[data-theme="dark"] .brand svg { width: 34px; height: 34px; filter: drop-shadow(0 0 7px rgba(0, 237, 194, .18)); }
:root[data-theme="dark"] .brand-name { font-size: calc(18px * var(--ts, 1.1)); letter-spacing: -.045em; font-weight: 850; }
:root[data-theme="dark"] .brand-os { color: #00ecc5; font-weight: 850; }
:root[data-theme="dark"] .brand-sub { color: #a1c6d6; font-size: calc(8px * var(--ts, 1.1)); letter-spacing: .23em; }
:root[data-theme="dark"] .nav-item { border-radius: 9px; }
:root[data-theme="dark"] .nav-item.active,
:root[data-theme="dark"] .nav-sub.active {
  background: linear-gradient(90deg, rgba(0, 210, 172, .20), rgba(0, 183, 184, .05));
  box-shadow: inset 3px 0 0 #00e5bc;
  color: #eafff9;
}
:root[data-theme="dark"] .nav-item.active svg { color: var(--accent-text); }
:root[data-theme="dark"] .btn { border-radius: 10px; }
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .cmd .send,
:root[data-theme="dark"] .login .btn-primary {
  background: linear-gradient(120deg, #00aa91, #00ddad);
  border-color: #09dbb5; color: #021d21; font-weight: 800;
  box-shadow: 0 3px 14px rgba(0, 211, 169, .12);
}
:root[data-theme="dark"] .btn-primary:hover,
:root[data-theme="dark"] .cmd .send:hover { background: #53f2d0; color: #022324; }
:root[data-theme="dark"] .tabs .tab.on,
:root[data-theme="dark"] .page-tabs .tab.on,
:root[data-theme="dark"] .tf.on,
:root[data-theme="dark"] .ol-chip.on {
  background: rgba(0, 211, 174, .20);
  color: #a7ffeb; border-color: #00cda9;
}
:root[data-theme="dark"] .term {
  --tc-bg: #081625; --tc-axis-bg: #081625;
  --tc-border: #20475d; --tc-grid: rgba(87, 145, 166, .13);
  --tc-grid-day: rgba(87, 145, 166, .23);
  --tc-text: #e4f6ff; --tc-axis: #a2bccc;
  --tc-up: #00dba3; --tc-down: #f9657e;
  --tc-line: #15d1d6; --tc-tag: #164e57;
  --tc-sma1: #42e8d0; --tc-sma2: #36b9f4; --tc-sma3: #b288ff;
}
:root[data-theme="dark"] .term-bar,
:root[data-theme="dark"] .term-symform {
  border-color: #1e4961; border-radius: 13px;
}
:root[data-theme="dark"] .term-btn.on { background: rgba(0, 209, 176, .19); color: #83ffe8; }
:root[data-theme="dark"] .ol-chip.on { color: #befff0; }
:root[data-theme="dark"] .ol-card { border-radius: 15px; }
:root[data-theme="dark"] .ol-card .ol-price,
:root[data-theme="dark"] .ol-sym { color: #f2ffff; }
:root[data-theme="dark"] .scout-card { border-left: 3px solid var(--card-color, var(--accent)); }
:root[data-theme="dark"] .scout-card .metric { font-weight: 800; }
:root[data-theme="dark"] .wr-row:hover { background: #123147; }
:root[data-theme="dark"] .wr-top { border-bottom-color: #24506a; }
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] select:focus,
:root[data-theme="dark"] textarea:focus { border-color: var(--accent); }
:root[data-theme="dark"] .login { background: rgba(2, 7, 17, .83); backdrop-filter: blur(12px); }
:root[data-theme="dark"] .login .box {
  border: 1px solid #215c66; background: #0b2033;
  box-shadow: 0 24px 80px rgba(0,0,0,.56);
}
:root[data-theme="dark"] .chat {
  background: #0a1b2d; border-color: #215166;
}
:root[data-theme="dark"] .bottom-nav {
  background: rgba(5, 17, 30, .97); border-top-color: #1e5267;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
:root[data-theme="dark"] .bottom-nav button.active { color: #44ffdb; }
:root[data-theme="dark"] .bottom-nav button.active::before {
  background: #00efc7; height: 3px; border-radius: 0 0 6px 6px;
  box-shadow: 0 0 12px rgba(0, 239, 199, .55);
}
@media (min-width: 861px) {
  :root[data-theme="dark"] .main { padding: 20px 24px 96px; }
  :root[data-theme="dark"] .grid { gap: 15px; }
}
@media (max-width: 860px) {
  :root[data-theme="dark"] .header { min-height: 55px; }
  :root[data-theme="dark"] .brand svg { width: 29px; height: 29px; }
  :root[data-theme="dark"] .brand-name { font-size: calc(15px * var(--ts, 1.1)); }
  :root[data-theme="dark"] .main { padding-left: 12px; padding-right: 12px; }
  :root[data-theme="dark"] .panel,
  :root[data-theme="dark"] .ol-card { border-radius: 13px; }
  :root[data-theme="dark"] .bottom-nav button { min-height: 61px; }
  :root[data-theme="dark"] .term { --term-h: clamp(390px, calc(100dvh - 250px), 750px); }
}
@media (max-width: 400px) {
  :root[data-theme="dark"] .brand-name { font-size: calc(13px * var(--ts, 1.1)); }
  :root[data-theme="dark"] .brand-sub { font-size: 8px; letter-spacing: .10em; }
}
@media (prefers-reduced-motion: reduce) {
  :root[data-theme="dark"] .hero,
  :root[data-theme="dark"] .btn-primary { transition: none; }
}

/* Keep full ChartVanta brand legible on the smallest screens, without covering action icons. */
@media (max-width: 520px) {
  :root[data-theme="dark"] .header .brand-sub { display: none; }
  :root[data-theme="dark"] .header .brand-name { white-space: nowrap; letter-spacing: -.06em; }
  :root[data-theme="dark"] .header .brand { gap: 5px; }
}

/* Data-source troubleshooting: readable provider names and one clear retry action per source. */
.data-issues { list-style: none; padding: 0; margin: 12px 0 2px; display: grid; gap: 10px; }
.data-issue {
  display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap;
  gap: 9px 12px; padding: 12px; border: 1px solid var(--border-strong);
  border-radius: 11px; background: var(--panel);
}
.data-issue-detail { flex: 1 1 220px; min-width: 0; }
.data-issue p { margin: 5px 0 0; line-height: 1.45; overflow-wrap: anywhere; }
.data-issue .btn { flex: none; white-space: nowrap; }
@media (max-width: 480px) {
  .data-issue .btn { width: 100%; min-height: 42px; }
}

/* Research workspace */
:root[data-theme="dark"] {
  --bg: #050e1a; --bg-2: #091624; --panel: #0c1c2d; --panel-2: #10253a;
  --border: #21374b; --accent: #00dfc4; --accent-text: #49efda;
}
.header #symbolButton { display: none; }
.cv-pulse { overflow: hidden; }
.cv-pulse-body { display: grid; gap: 14px; }
.cv-indices { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; }
.cv-indices button { appearance: none; cursor: pointer; text-align: left; min-width: 0; display: grid; gap: 4px;
  color: var(--text); background: var(--bg-2); border: 1px solid var(--border); padding: clamp(8px,1.25vw,18px); border-radius: 10px; }
.cv-indices button[aria-pressed="true"] { border-color: var(--accent); background: linear-gradient(120deg,var(--accent-soft),var(--bg-2)); }
.cv-indices span { color: var(--text-2); font-weight: 650; }
.cv-indices strong { font-size: clamp(16px,2vw,32px); font-variant-numeric: tabular-nums; letter-spacing: -.045em; }
.cv-indices b { font-size: .86em; }
.cv-plot { display: grid; align-content: center; min-height: 96px; background: repeating-linear-gradient(to top,transparent 0 31px,var(--border) 32px); }
.cv-plot a { display:block; }
.cv-trace { width:100%; height:clamp(90px,12vw,164px); display:block; color:var(--accent-text); }
.cv-trace polyline { fill:none; stroke:currentColor; stroke-width:2.3px; vector-effect:non-scaling-stroke; stroke-linejoin:round; }
.cv-trace polygon { fill:var(--accent-soft); }
.cv-stamp { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; color:var(--text-2); }
.cv-stamp small { display:block; color:var(--muted); margin-top:3px; }
.cv-stamp a,.rh-more { font-weight:700; color:var(--accent-text); }
#scoutHost .chat { display:flex; position:static; width:100%; height:auto; box-shadow:none; border:1px solid var(--border); border-radius:14px; overflow:hidden; }
#scoutHost #chatClose { display:none; }
#scoutHost .chat-log { min-height:110px; max-height:55dvh; overflow:auto; }
#scoutHost .chat-form { order:-2; }
#scoutHost .chat-suggest { order:-1; padding-top:10px; }
#scoutHost .steady-pane { max-height:none; }
#scoutHost .chat-form input { min-width:0; }
.data-summary { border-left:3px solid var(--accent); padding:8px 16px; background:var(--bg-2); }
.table-wrap { max-width:100%; overflow-x:auto; }
.chain th { white-space:nowrap; }
.screener-form { background:var(--bg-2); padding:12px; border-radius:10px; }
:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
@media(max-width:860px) {
  .header #symbolButton { display:inline-grid; }
  .header .sym-search { display:none; }
  body.sym-open .header .sym-search { display:flex; position:fixed; top:var(--sym-top,60px); inset-inline:12px; max-width:none; z-index:5; }
  .mobile-cmd,body.ask-here .mobile-cmd { display:none; }
  .bottom-nav { padding-bottom:env(safe-area-inset-bottom); }
  .sidebar { overflow-y:auto; overscroll-behavior:contain; }
  .home-grid,.home-col,.rh-card,.ol-card { min-width:0; }
  .cv-indices button { padding:9px 7px; }
}
.cv-watch-row { display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:12px; align-items:center; padding:12px 2px; color:var(--text); border-bottom:1px solid var(--border); }
.cv-watch-row small { display:block; font-size:.78em; font-weight:400; color:var(--muted); overflow-wrap:anywhere; }
.cv-manage summary { padding:12px 0; cursor:pointer; color:var(--accent-text); }
.cv-chain { display:grid; gap:12px; margin-top:16px; }
.cv-sides { display:flex; gap:4px; }
.cv-sides [aria-pressed="true"] { background:var(--accent-soft); border-color:var(--accent); color:var(--accent-text); }
.cv-chain .chain { width:100%; font-variant-numeric:tabular-nums; }
.cv-chain th:not(:first-child) { text-align:right; }
@media(max-width:520px) {
  .header .mkt-count { display:none; }
  .header .brand-wrap { flex:1 1 auto; }
  .header .brand-name { font-size:calc(17px * var(--ts,1.1)); }
  .header .header-right { gap:1px; }
  .header .icon-btn { min-width:32px; }
}
@media(max-width:360px) { .header .mkt { display:none; } }
.cv-indicators { display:flex; gap:6px; padding:8px; flex-wrap:wrap; background:var(--bg-2); }
.cv-indicators .term-btn { min-height:34px; border-radius:8px; }
.cv-indicators [aria-pressed="true"] { border-color:var(--accent); color:var(--accent-text); background:var(--accent-soft); }
.home-col .glance-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }

/* Keep the installed app's sticky header, tape and navigation inside the safe area. */
@media (display-mode: standalone) {
  :root { --bar-h:calc(55px + env(safe-area-inset-top)); }
  .header { padding-top:env(safe-area-inset-top); }
}

@media (max-width:860px), (max-height:500px) and (pointer:coarse) {
  .header .icon-btn, .cv-indicators .term-btn, .cv-sides .btn { min-width:44px; min-height:44px; }
  .bottom-nav { padding-inline:max(2px,env(safe-area-inset-left)) max(2px,env(safe-area-inset-right)); }
  .sidebar { max-height:calc(100dvh - var(--header-h)); padding-bottom:calc(70px + env(safe-area-inset-bottom)); }
  #scoutHost .chat-form { padding-bottom:12px; }
  #scoutHost .chat-head { padding-top:12px; }
  .cv-chain select, .sym-search input, #scoutHost input, .ol-form input,
  .screener-form input, .screener-form select, .wl-form input { font-size:max(16px,1em); min-height:44px; }
  .cv-chain .table-wrap { scrollbar-gutter:auto; }
  .cv-pulse .rh-head, .cv-stamp { align-items:center; }
  .cv-stamp a { display:inline-flex; align-items:center; min-height:44px; }
}
@media (max-width:400px) { .header .mkt { display:none; } }
@media (max-height:500px) and (pointer:coarse) {
  .header, .tape { position:relative; top:auto; }
  .bottom-nav button { min-height:44px; }
}
@media(max-width:400px) {
  :root[data-theme="dark"] .header .brand-name { font-size:calc(16px * var(--ts,1.1)); }
  .header .brand-text { display:flex; }
  .header .brand-wrap { gap:1px; }
  .header .brand { gap:3px; }
}
@media(min-width:861px) and (max-height:500px) and (pointer:coarse) {
  .bottom-nav { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); position:fixed; inset:auto 0 0; z-index:45;
    padding-bottom:env(safe-area-inset-bottom); border-top:1px solid var(--border); background:var(--bg-2); }
  .bottom-nav button { display:flex; align-items:center; justify-content:center; gap:6px; border:0; color:var(--muted); background:transparent; }
  .bottom-nav svg { width:18px; height:18px; }
  .bottom-nav button.active { color:var(--accent-text); }
}
.sd { display:grid; gap:16px; }
.sd-boards { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.sd-controls { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.sd [aria-pressed="true"] { border-color:var(--accent); color:var(--accent-text); background:var(--accent-soft); }
.sd .rh-card button { margin:3px; }
.sd h2,.sd h3 { margin:0 0 8px; }
.sd .rh-card>.sd-boards { margin-top:18px; }
.sd-metrics { margin:0; }
.sd-metrics div { display:flex; justify-content:space-between; gap:12px; padding:8px 0; border-bottom:1px solid var(--border); }
.sd-metrics dd { margin:0; font-weight:700; font-variant-numeric:tabular-nums; }
.sd summary { cursor:pointer; }
@media(max-width:650px) { .sd-boards { grid-template-columns:1fr; } .sd-controls>* { min-height:44px; } }

/* Narrow phones: keep the ChartVanta name and index tiles readable without
   the stock-search control covering the brand or index prices leaving their cards. */
@media (max-width: 360px) {
  :root[data-theme="dark"] .header .brand-name,
  .header .brand-name { font-size: calc(12px * var(--ts, 1.1)); letter-spacing: -.07em; }
  .header .brand-sub { display: none; }
  .header .brand svg { width: 20px; height: 20px; }
  .cv-indices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Strategy Desk keeps long metrics and input fields inside the page on small screens. */
.sd, .sd-history, .sd-boards > *, .sd .rh-card { min-width:0; }
.sd { grid-template-columns:minmax(0,1fr); }
.sd-history { display:grid; grid-template-columns:minmax(0,1fr); gap:12px; }
.sd-intro p { max-width:68ch; }
.sd-more > summary { font-weight:700; min-height:44px; }
.sd-more .rh-card { margin-top:12px; }
.sd-control-label { display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
.sd-controls :is(input,select) { min-width:0; max-width:100%; }
.sd-controls input { flex:1 1 200px; }
.sd-metrics dt { min-width:0; overflow-wrap:anywhere; }
.sd-metrics dd { flex-shrink:0; text-align:right; }
.sd p { overflow-wrap:anywhere; }
@media(max-width:650px) { .sd-boards { grid-template-columns:minmax(0,1fr); } }
.home-shortcuts { display:flex; flex-wrap:wrap; gap:8px; }
.home-shortcuts .btn { min-height:44px; }

.nav-scrim { display:none; }
.nav-disclosure { border:0; background:transparent; width:100%; text-align:start; cursor:pointer; }
.nav-disclosure .nav-chevron { margin-inline-start:auto; display:grid; place-items:center; }
.nav-disclosure .nav-chevron svg { width:13px; height:13px; transition:transform .16s ease; }
.nav-group.open .nav-chevron svg { transform:rotate(180deg); }
@media (min-width:861px) {
  body.nav-folded .nav-disclosure .nav-chevron { display:none; }
}
@media (max-width:860px) {
  .sidebar:not(.open) { visibility:hidden; }
  .sidebar .nav-item, .sidebar .nav-sub { min-height:44px; }
  .sidebar .nav-subs { margin-inline-start:20px; }
  .sidebar.open + .nav-scrim {
    display:block; position:fixed; inset:var(--header-h) 0 0; z-index:49; width:100%;
    border:0; background:rgba(2, 8, 15, .52);
  }
  .header:has(#menuBtn[aria-expanded="true"]) #menuBtn { color:var(--accent-text); }
}

.header .ask-steady-launcher {
  display:inline-flex; align-items:center; gap:5px; min-height:38px; padding-inline:8px;
  color:var(--accent-text); background:var(--accent-soft); border-color:var(--border-strong);
  font-weight:750; white-space:nowrap;
}
.header .ask-steady-launcher svg { width:17px; height:17px; flex:none; }
@media (max-width:860px) {
  .header .ask-steady-launcher, .cc-dashboard-links .btn { min-height:44px; }
}
@media (max-width:440px) {
  .header .ask-steady-launcher { padding-inline:7px; font-size:13px; }
  .header .ask-steady-launcher svg { display:none; }
}
