@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── CSS variables ─────────────────────────────────────────────────────────── */
:root, html[data-theme="dark"] {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface2:  #1c2330;
  --surface3:  #21262d;
  --border:    #30363d;
  --border2:   #3d444d;
  --text:      #e6edf3;
  --muted:     #7d8590;
  --accent:    #4493f8;
  --accent2:   #2f81f7;
  --green:     #3fb950;
  --red:       #f85149;
  --amber:     #d29922;
  --purple:    #a371f7;
  --blue-dim:  rgba(68,147,248,.12);
  --green-dim: rgba(63,185,80,.12);
  --red-dim:   rgba(248,81,73,.12);
  --amber-dim: rgba(210,153,34,.12);
  --radius:    10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.55);
}

html[data-theme="light"] {
  --bg:        #f6f8fa;
  --surface:   #ffffff;
  --surface2:  #eaeef2;
  --surface3:  #f0f3f6;
  --border:    #d0d7de;
  --border2:   #bbc2cb;
  --text:      #1f2328;
  --muted:     #636c76;
  --accent:    #0969da;
  --accent2:   #0550ae;
  --green:     #1a7f37;
  --red:       #cf222e;
  --amber:     #9a6700;
  --purple:    #8250df;
  --blue-dim:  rgba(9,105,218,.08);
  --green-dim: rgba(26,127,55,.08);
  --red-dim:   rgba(207,34,46,.08);
  --amber-dim: rgba(154,103,0,.08);
  --radius:    10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.16);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }

/* ── Lucide icons ───────────────────────────────────────────────────────────── */
[data-lucide] { width: 15px; height: 15px; stroke-width: 2; flex-shrink: 0; vertical-align: middle; }
[data-theme="dark"]  .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark  { display: none; }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Header ────────────────────────────────────────────────────────────────── */
.app-header {
  background: rgba(22,27,34,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border), var(--shadow-sm);
}
html[data-theme="light"] .app-header { background: rgba(255,255,255,.92); }
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-brand-text { display: flex; flex-direction: column; gap: 1px; }
.header-brand-name { font-size: 1.05rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; line-height: 1.2; }
.header-tagline { font-size: .68rem; color: var(--muted); font-weight: 400; letter-spacing: .01em; }
.header-brand .logo-icon { font-size: 1.25rem; flex-shrink: 0; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-user { font-size: 0.8rem; color: var(--muted); }
.header-user span { color: var(--text); font-weight: 600; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px; border-radius: 8px; border: none; font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all .18s; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; box-shadow: 0 2px 8px rgba(68,147,248,.3); }
.btn-primary:hover { opacity: .9; box-shadow: 0 4px 14px rgba(68,147,248,.4); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.col-toggle-btn { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; font-size: 0.78rem; background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; transition: color .15s, border-color .15s, background .15s; white-space: nowrap; }
.col-toggle-btn:hover { background: var(--surface2); color: var(--text); }
.col-toggle-btn.active { color: var(--text); }
.col-toggle-pill { display: inline-block; width: 30px; height: 16px; border-radius: 8px; background: var(--border); position: relative; transition: background .22s; flex-shrink: 0; }
.col-toggle-pill::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform .22s, background .22s; }
.col-toggle-btn.active .col-toggle-pill { background: rgba(68,147,248,.35); }
.col-toggle-btn.active .col-toggle-pill::after { transform: translateX(14px); background: var(--accent); }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid transparent; }
.btn-danger:hover { border-color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 0.95rem; padding: 4px 6px; border-radius: 6px; transition: color .15s, background .15s; }
.btn-icon:hover { color: var(--text); background: var(--surface2); }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px 24px; }
.card-title { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 12px; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.73rem; font-weight: 700; letter-spacing: .02em; }
.badge.bullish  { background: var(--green-dim); color: var(--green); border: 1px solid rgba(63,185,80,.25); }
.badge.bearish  { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(248,81,73,.25); }
.badge.neutral  { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(210,153,34,.25); }

/* ── Color helpers ─────────────────────────────────────────────────────────── */
.positive { color: var(--green); }
.negative { color: var(--red); }
.muted    { color: var(--muted); }

/* ── Page layout ───────────────────────────────────────────────────────────── */
.page { padding: 24px 28px; max-width: 1800px; margin: 0 auto; }

/* ── Stats bar ─────────────────────────────────────────────────────────────── */
.stats-bar { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; flex: 1; min-width: 130px; cursor: pointer; transition: border-color .18s, box-shadow .18s, transform .18s; user-select: none; position: relative; overflow: hidden; text-align: center; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: var(--radius) var(--radius) 0 0; }
.stat-card.total::before { background: linear-gradient(90deg, var(--accent), var(--purple)); }
.stat-card.bull::before  { background: linear-gradient(90deg, var(--green), #56d364); }
.stat-card.bear::before  { background: linear-gradient(90deg, var(--red), #ff7b72); }
.stat-card.neutral-s::before { background: linear-gradient(90deg, var(--amber), #e3b341); }
.stat-card:hover { border-color: var(--border2); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.stat-card.total .stat-value  { color: var(--text); }
.stat-card.bull  .stat-value  { color: var(--green); }
.stat-card.bear  .stat-value  { color: var(--red); }
.stat-card.neutral-s .stat-value { color: var(--amber); }
.stat-card.total.active  { border-color: var(--accent);  box-shadow: 0 0 0 2px rgba(68,147,248,.2), var(--shadow-sm); }
.stat-card.bull.active   { border-color: var(--green);   box-shadow: 0 0 0 2px rgba(63,185,80,.2), var(--shadow-sm); }
.stat-card.bear.active   { border-color: var(--red);     box-shadow: 0 0 0 2px rgba(248,81,73,.2), var(--shadow-sm); }
.stat-card.neutral-s.active { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(210,153,34,.2), var(--shadow-sm); }

/* ── Toolbar ───────────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-title { font-size: 1rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.toolbar-query { flex: 1; min-width: 180px; }
.refresh-info { font-size: 0.75rem; color: var(--muted); }

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-container { overflow: auto; max-height: calc(100vh - 260px); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; min-width: 1400px; }
thead th {
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 11px 14px;
  box-shadow: inset 0 -1px 0 var(--border);
  white-space: nowrap;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
}
thead th.num { text-align: right; }
thead th[data-sort] { cursor: pointer; user-select: none; }
thead th[data-sort]:hover { color: var(--text); background: var(--surface3); }
thead th[data-sort]::after { content: ' ↕'; opacity: .2; font-size: .85em; }
thead th[data-sort].sort-asc::after { content: ' ↑'; opacity: 1; color: var(--accent); }
thead th[data-sort].sort-desc::after { content: ' ↓'; opacity: 1; color: var(--accent); }
tbody tr { border-bottom: 1px solid var(--border); transition: background .12s, box-shadow .12s; cursor: pointer; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 11px 14px; font-size: 0.85rem; white-space: nowrap; }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody td.actions { text-align: right; opacity: 0; transition: opacity .15s; }
tbody tr:hover td.actions { opacity: 1; }

/* ── Ticker cell ───────────────────────────────────────────────────────────── */
.ticker-badge { display: inline-block; background: var(--blue-dim); color: var(--accent); font-weight: 700; font-size: 0.8rem; padding: 3px 9px; border-radius: 6px; border: 1px solid rgba(68,147,248,.2); letter-spacing: .02em; }
.company-name { display: block; min-width: 160px; max-width: 360px; white-space: normal; word-break: break-word; line-height: 1.35; color: var(--text); }

/* ── Price change ──────────────────────────────────────────────────────────── */
.price-main { font-weight: 700; font-variant-numeric: tabular-nums; }
.change-chip { font-size: 0.72rem; margin-left: 6px; padding: 1px 5px; border-radius: 4px; font-weight: 600; }
.change-chip.positive { background: var(--green-dim); color: var(--green); }
.change-chip.negative { background: var(--red-dim); color: var(--red); }

/* ── Input icon wrapper (login / register pages) ────────────────────────────── */
.input-icon-wrap { position: relative; }
.input-icon-wrap input { padding-left: 36px; width: 100%; box-sizing: border-box; }
.input-prefix-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); pointer-events: none; }

/* ── Loading / skeleton ─────────────────────────────────────────────────────── */
.loading-row td { padding: 24px; text-align: center; color: var(--muted); }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -400px 0 } 100% { background-position: 400px 0 } }
.skel { display: inline-block; height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%); background-size: 400px 100%; animation: shimmer 1.4s ease infinite; }
.skel-xs { width: 28px; } .skel-sm { width: 56px; } .skel-md { width: 90px; } .skel-lg { width: 150px; }
.skeleton-row td { padding: 10px 12px; }
.skeleton-card { pointer-events: none; }

/* ── Zone proximity ──────────────────────────────────────────────────────────── */
.zone-proximity-badge { display: inline-block; font-size: .63rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: middle; letter-spacing: .04em; line-height: 1.6; }
.zone-proximity-badge.demand { background: rgba(63,185,80,.15); color: var(--green); border: 1px solid rgba(63,185,80,.3); }
.zone-proximity-badge.supply { background: rgba(248,81,73,.15); color: var(--red);   border: 1px solid rgba(248,81,73,.3); }
.zone-proximity-badge.with-conf { font-size: .55rem; padding: 1px 5px; }
.conf-sub { display: block; font-size: .5rem; font-weight: 600; color: var(--purple); letter-spacing: .01em; line-height: 1.4; }
tr.near-demand { box-shadow: inset 3px 0 0 var(--green), inset 0 0 0 1px rgba(63,185,80,.08); }
tr.near-supply { box-shadow: inset 3px 0 0 var(--red),   inset 0 0 0 1px rgba(248,81,73,.08); }
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state .empty-icon { font-size: 2.5rem; display: block; margin-bottom: 12px; }
.error-row td { color: var(--red); font-size: 0.82rem; }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border: 1px solid var(--border2); border-radius: 14px; padding: 28px 32px; width: 420px; max-width: 92vw; box-shadow: var(--shadow-lg); animation: slideUp .2s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.modal h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; letter-spacing: -.01em; }
.modal p { font-size: 0.82rem; color: var(--muted); margin-bottom: 20px; line-height: 1.5; }
.modal-form input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text); font-size: 0.9rem; outline: none; transition: border-color .2s, box-shadow .2s; margin-bottom: 14px; }
.modal-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--blue-dim); }
.modal-form input::placeholder { color: var(--muted); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-error { font-size: 0.82rem; color: var(--red); margin-bottom: 12px; min-height: 18px; }

/* ── Ticker queue chips ────────────────────────────────────────────────────── */
.ticker-chips { display: none; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; min-height: 38px; }
.ticker-chips.has-items { display: flex; }
.tq-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 3px 4px 3px 10px; font-size: 0.8rem; color: var(--text); }
.tq-chip-name { color: var(--muted); font-size: 0.75rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tq-chip-remove { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0 5px; border-radius: 50%; transition: color .15s, background .15s; }
.tq-chip-remove:hover { color: var(--red); background: var(--red-dim); }

/* ── Search dropdown ───────────────────────────────────────────────────────── */
.search-wrap { position: relative; margin-bottom: 16px; }
.search-wrap input { margin-bottom: 0; }
.search-results { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; z-index: 20; overflow: hidden; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.search-result-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.focused { background: var(--surface2); }
.sri-ticker { font-weight: 700; font-size: 0.8rem; color: var(--accent); background: var(--blue-dim); padding: 2px 8px; border-radius: 5px; flex-shrink: 0; }
.sri-name { font-size: 0.85rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sri-exch { font-size: 0.73rem; color: var(--muted); flex-shrink: 0; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface); border: 1px solid var(--border2); border-radius: 10px; padding: 12px 18px; font-size: 0.84rem; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-md); animation: slideIn .22s cubic-bezier(.22,1,.36,1); min-width: 270px; max-width: 380px; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }

/* ── Stock detail page ─────────────────────────────────────────────────────── */
.back-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.hero { display: flex; align-items: flex-start; gap: 24px; flex-wrap: wrap; margin-bottom: 24px; }
.hero-price { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.hero-change { font-size: 1rem; margin-top: 6px; }
.hero-meta { font-size: 0.82rem; color: var(--muted); margin-top: 6px; }
.hero-info h1 { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.hero-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip { display: inline-block; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 10px; font-size: 0.75rem; color: var(--muted); }

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); font-size: 0.88rem; font-weight: 500; padding: 10px 20px; cursor: pointer; transition: color .15s, border-color .15s; margin-bottom: -1px; white-space: nowrap; flex-shrink: 0; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Grid layouts ──────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-4 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ── Key metric item ───────────────────────────────────────────────────────── */
.kv { }
.kv .kv-label { font-size: 0.73rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.kv .kv-value { font-size: 1rem; font-weight: 600; color: var(--text); }
.kv .kv-value.big { font-size: 1.2rem; }

/* ── Pivot table ───────────────────────────────────────────────────────────── */
.pivot-table { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 0; }
.pivot-table thead tr { border-bottom: 2px solid var(--border); }
.pivot-table thead th { font-size: 0.7rem; color: var(--text); background: none; text-transform: uppercase; letter-spacing: .04em; padding: 0 6px 10px; text-align: center; font-weight: 700; }
.pivot-table thead th:first-child { text-align: left; padding-left: 0; width: 72px; }
.pivot-table tbody td { padding: 10px 6px; text-align: center; font-size: 0.95rem; font-weight: 700; border-top: 1px solid var(--border); }
.pivot-table tbody td:first-child { text-align: left; padding-left: 0; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; width: 72px; }
.pivot-table .pt-daily   { color: var(--accent); }
.pivot-table .pt-weekly  { color: var(--success); }
.pivot-table .pt-monthly { color: var(--warning); }
.pivot-table .pt-r { color: var(--green); }
.pivot-table .pt-p { color: var(--accent); }
.pivot-table .pt-s { color: var(--red); }
.pivot-table .pt-dist { font-size: 0.6rem; opacity: 0.55; font-weight: 400; }

/* ── Technical signal row ──────────────────────────────────────────────────── */
.signal-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.signal-row:last-child { border-bottom: none; }
.signal-row .sig-label { font-size: 0.85rem; color: var(--muted); }
.signal-row .sig-value { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.sig-badge { font-size: 0.75rem; font-weight: 600; padding: 2px 10px; border-radius: 20px; }
.sig-badge.bull { background: var(--green-dim); color: var(--green); }
.sig-badge.bear { background: var(--red-dim);   color: var(--red); }
.sig-badge.neut { background: rgba(210,153,34,.12); color: var(--amber); }

/* ── RSI gauge ─────────────────────────────────────────────────────────────── */
.rsi-bar { height: 8px; background: linear-gradient(to right, var(--green), var(--amber), var(--red)); border-radius: 4px; position: relative; margin: 10px 0; }
.rsi-bar .rsi-marker { position: absolute; top: -4px; width: 16px; height: 16px; background: #fff; border: 2px solid var(--border); border-radius: 50%; transform: translateX(-50%); }

/* ── Chart container ───────────────────────────────────────────────────────── */
.chart-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; min-width: 0; overflow: hidden; }
.chart-box .chart-title { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
/* Plotly modebar dark theme */
.modebar { background: var(--surface2) !important; border-radius: 6px !important; }
.modebar-btn path { fill: var(--muted) !important; }
.modebar-btn:hover path { fill: var(--text) !important; }
.modebar-btn.active path { fill: var(--accent) !important; }

/* ── Description ───────────────────────────────────────────────────────────── */
.company-desc { font-size: 0.85rem; color: var(--muted); line-height: 1.7; margin-top: 10px; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.company-desc.expanded { -webkit-line-clamp: unset; }
.desc-toggle { font-size: 0.78rem; color: var(--accent); cursor: pointer; margin-top: 6px; display: inline-block; }

/* ── Tooltip ───────────────────────────────────────────────────────────────── */
.global-tip {
  position: absolute;
  background: #1c2330;
  border: 1px solid #30363d;
  color: #e6edf3;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 400;
  max-width: 240px;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
  white-space: normal;
  text-transform: none;
  letter-spacing: 0;
}
.global-tip.visible { opacity: 1; }
[data-tip] { cursor: help; }

/* ── Section heading ───────────────────────────────────────────────────────── */
.section-heading { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 12px; }

/* ── Sentiment row border ──────────────────────────────────────────────────── */
tbody tr.row-bull    { box-shadow: inset 3px 0 0 var(--green); }
tbody tr.row-bear    { box-shadow: inset 3px 0 0 var(--red); }
tbody tr.row-neutral { box-shadow: inset 3px 0 0 var(--amber); }
tbody tr.row-bull:hover    { background: rgba(63,185,80,.05); }
tbody tr.row-bear:hover    { background: rgba(248,81,73,.05); }
tbody tr.row-neutral:hover { background: rgba(210,153,34,.04); }

/* ── Prev OHLC column toggle ───────────────────────────────────────────────── */
table.hide-prev .col-prev { display: none; }

/* ── Tools dropdown ────────────────────────────────────────────────────────── */
.tools-dropdown { position: relative; }
.tools-menu { display: none; position: absolute; top: calc(100% + 8px); right: 0; background: var(--surface); border: 1px solid var(--border2); border-radius: 10px; min-width: 170px; box-shadow: var(--shadow-lg); z-index: 100; overflow: hidden; animation: slideUp .15s ease; }
.tools-menu.open { display: block; }
.tools-menu a { display: flex; align-items: center; gap: 10px; padding: 10px 16px; font-size: 0.84rem; color: var(--text); text-decoration: none; transition: background .1s; white-space: nowrap; }
.tools-menu a:hover { background: var(--surface2); }
.tools-menu button { display: flex; align-items: center; gap: 10px; padding: 10px 16px; font-size: 0.84rem; color: var(--text); background: none; border: none; border-top: 1px solid var(--border); width: 100%; text-align: left; cursor: pointer; white-space: nowrap; transition: background .1s; }
.tools-menu button:hover { background: var(--surface2); }

/* ── News drawer ───────────────────────────────────────────────────────────── */
.news-drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 300; display: none; }
.news-drawer-overlay.open { display: block; }
.news-drawer { position: fixed; top: 0; right: 0; height: 100%; width: 420px; max-width: 95vw; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease; z-index: 301; }
.news-drawer-overlay.open .news-drawer { transform: translateX(0); }
.news-drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: .95rem; }
.news-drawer .news-section { flex: 1; overflow-y: auto; padding: 16px 20px; gap: 10px; }

/* ── Drag to reorder ───────────────────────────────────────────────────────── */
.spark-cell { padding: 11px 14px; vertical-align: middle; }
.sector-filter-select { display: inline-block; font-size: .68rem; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 0 3px; cursor: pointer; outline: none; max-width: 72px; }
.sector-filter-select:focus { border-color: var(--accent); }
.sector-filter-select option { background: var(--surface); }
.drag-handle { cursor: grab; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.drag-handle:active { cursor: grabbing; }
tbody tr.dragging { opacity: .4; }
tbody tr.drag-over { box-shadow: inset 4px 0 0 var(--accent), 0 2px 0 var(--accent); }

/* ── Tag chips ─────────────────────────────────────────────────────────────── */

/* ── Tag filter chips in toolbar ───────────────────────────────────────────── */

/* ── Mobile cards ──────────────────────────────────────────────────────────── */
.cards-container { display: none; flex-direction: column; gap: 10px; }
.stock-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; transition: background .15s, transform .15s, box-shadow .15s; box-shadow: var(--shadow-sm); }
.stock-card:hover { background: var(--surface2); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.stock-card.row-bull    { border-left: 3px solid var(--green); }
.stock-card.row-bear    { border-left: 3px solid var(--red); }
.stock-card.row-neutral { border-left: 3px solid var(--amber); }
.sc-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.sc-left { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.sc-company { width: 100%; font-size: .82rem; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-right { text-align: right; flex-shrink: 0; }
.sc-price { font-size: 1.05rem; font-weight: 700; }
.sc-change { font-size: .78rem; margin-top: 2px; }
.sc-bottom { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sc-meta { font-size: .75rem; color: var(--muted); }
.error-card { display: flex; align-items: center; gap: 10px; }

@media (max-width: 700px) {
  .table-container { display: none; }
  .cards-container { display: flex; }
  .app-header { padding: 0 12px; height: auto; min-height: 56px; flex-wrap: wrap; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .header-right { flex-wrap: wrap; gap: 6px; }
  .page { padding: 12px; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar-query { order: 10; max-width: 100%; flex-basis: 100%; }
}

/* ── Market state tag ──────────────────────────────────────────────────────── */
.market-tag { display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; vertical-align: middle; letter-spacing: .04em; }
.market-tag.pre    { background: rgba(210,153,34,.18); color: var(--amber); border: 1px solid rgba(210,153,34,.35); }
.market-tag.ah     { background: rgba(68,147,248,.15); color: var(--accent); border: 1px solid rgba(68,147,248,.3); }
.market-tag.closed { background: rgba(125,133,144,.12); color: var(--muted); border: 1px solid rgba(125,133,144,.3); }

/* ── Period selector buttons ───────────────────────────────────────────────── */
.period-btns { display: flex; gap: 4px; }
.period-btn { background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 0.75rem; font-weight: 600; padding: 3px 10px; cursor: pointer; transition: color .15s, background .15s, border-color .15s; }
.period-btn:hover { color: var(--text); border-color: var(--text); }
.period-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Note / Alert action icons ─────────────────────────────────────────────── */
.btn-icon { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 0.9rem; padding: 2px 5px; border-radius: 4px; transition: color .15s, background .15s; }
.btn-icon:hover { color: var(--text); background: var(--surface2); }
.btn-icon.active { color: var(--accent); }

/* ── Note modal textarea ───────────────────────────────────────────────────── */
#note-textarea { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text); font-size: 0.88rem; line-height: 1.6; outline: none; resize: vertical; transition: border-color .2s; font-family: inherit; }
#note-textarea:focus { border-color: var(--accent); }
#note-textarea::placeholder { color: var(--muted); }

/* ── Alert bell ────────────────────────────────────────────────────────────── */
.alert-bell-btn { position: relative; }
.alert-badge { position: absolute; top: 2px; right: 2px; background: var(--red); color: #fff; font-size: 0.6rem; font-weight: 700; min-width: 14px; height: 14px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; padding: 0 3px; line-height: 1; }

/* ── Alerts modal ──────────────────────────────────────────────────────────── */
.alert-form-row { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.alert-form-row input, .alert-form-row select { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text); font-size: 0.85rem; outline: none; transition: border-color .2s; }
.alert-form-row input:focus, .alert-form-row select:focus { border-color: var(--accent); }
.alert-form-row select { cursor: pointer; }
.alerts-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; margin-bottom: 12px; }
.alert-item { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 0.82rem; }
.alert-item-desc { flex: 1; color: var(--text); }

/* ── News section ──────────────────────────────────────────────────────────── */
/* ── Demand & Supply Zones ─────────────────────────────────────────────────── */
.zones-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 10px; margin-bottom: 24px; }
.zone-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid; border-radius: 8px; padding: 12px 14px; overflow: hidden; }
.zone-card.demand { border-left-color: var(--green); }
.zone-card.supply { border-left-color: var(--red); }
.zone-card.tested { opacity: 0.6; }
.zone-type { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; display: flex; align-items: center; gap: 4px; min-width: 0; }
.zone-card.demand .zone-type { color: var(--green); }
.zone-card.supply .zone-type { color: var(--red); }
.zone-range { font-size: .92rem; font-weight: 700; margin-bottom: 4px; }
.zone-meta { font-size: .75rem; color: var(--muted); }
.zone-badge { font-size: .49rem; padding: 1px 4px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.zone-badge.fresh { background: rgba(63,185,80,.15); color: var(--green); }
.zone-badge.tested { background: rgba(210,153,34,.12); color: var(--amber); }
.zone-formed { display: flex; align-items: center; gap: 4px; font-size: .73rem; color: var(--muted); }
.zone-ts-icon { font-size: .7rem; opacity: .7; }
.zone-ago { font-size: .7rem; color: var(--muted); opacity: .75; }
.confluence-badge { font-size: .45rem; padding: 1px 4px; border-radius: 4px; font-weight: 700; background: rgba(163,113,247,.18); color: var(--purple); border: 1px solid rgba(163,113,247,.35); white-space: nowrap; letter-spacing: .01em; line-height: 1.5; flex-shrink: 0; }
.zone-pattern { font-size: .49rem; padding: 1px 5px; border-radius: 4px; font-weight: 700; background: rgba(139,148,158,.12); color: var(--muted); border: 1px solid rgba(139,148,158,.25); white-space: nowrap; letter-spacing: .04em; }

/* ── Key Statistics + Analyst rating side by side ──────────────────────────── */
.ks-row { display: flex; gap: 16px; align-items: stretch; }
.ks-card { flex: 1; min-width: 0; }
.ks-table { width: 100%; border-collapse: collapse; min-width: 0; }
.ks-table tr { border-bottom: 1px solid var(--border); }
.ks-table tr:last-child { border-bottom: none; }
.ks-label { font-size: 0.78rem; color: var(--muted); padding: 8px 0; width: 50%; }
.ks-val { font-size: 0.92rem; font-weight: 700; text-align: right; padding: 8px 0; }
.analyst-card { display: flex; align-items: flex-start; gap: 20px; }
.analyst-chart-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
.analyst-right { flex: 1; min-width: 130px; }
.ar-badge { font-size: .8rem; font-weight: 700; padding: 5px 14px; border-radius: 20px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.ar-strong-buy  { background: rgba(63,185,80,.18);  color: #3fb950; border: 1px solid rgba(63,185,80,.4);  }
.ar-buy         { background: rgba(63,185,80,.10);  color: #3fb950; border: 1px solid rgba(63,185,80,.25); }
.ar-hold        { background: rgba(210,153,34,.12); color: #d2992d; border: 1px solid rgba(210,153,34,.3); }
.ar-sell        { background: rgba(248,81,73,.10);  color: #f85149; border: 1px solid rgba(248,81,73,.25); }
.ar-strong-sell { background: rgba(248,81,73,.18);  color: #f85149; border: 1px solid rgba(248,81,73,.4);  }
.ar-count { font-size: .72rem; color: var(--muted); }
.ar-legend { display: flex; flex-direction: column; gap: 3px; }
.ar-legend-row { display: flex; align-items: center; gap: 6px; font-size: .82rem; }
.ar-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ar-leg-label { flex: 1; color: var(--muted); }
.ar-leg-val { font-weight: 700; color: var(--text); min-width: 20px; text-align: right; }

/* ── Swing Point Support & Resistance ──────────────────────────────────────── */
.swing-levels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 24px; }
.sl-group-label { grid-column: 1 / -1; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 4px; padding-bottom: 2px; border-bottom: 1px solid var(--border); }
.swing-level-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid; border-radius: 8px; padding: 10px 14px; }
.swing-level-card.support    { border-left-color: rgba(63,185,80,.7); }
.swing-level-card.resistance { border-left-color: rgba(248,81,73,.7); }
.sl-type  { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.swing-level-card.support    .sl-type { color: var(--green); }
.swing-level-card.resistance .sl-type { color: var(--red); }
.sl-price { font-size: .9rem; font-weight: 700; margin-bottom: 4px; }
.sl-meta  { font-size: .73rem; color: var(--muted); }
.section-sub { font-size: .7rem; font-weight: 400; color: var(--muted); text-transform: none; letter-spacing: 0; margin-left: 6px; }

.news-section { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.news-item { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; text-decoration: none; transition: background .12s, border-color .15s; }
.news-item:hover { background: var(--surface2); border-color: var(--accent); }
.news-title { font-size: 0.88rem; color: var(--text); line-height: 1.45; margin-bottom: 4px; }
.news-meta { font-size: 0.75rem; color: var(--muted); }

/* ── Query bar ─────────────────────────────────────────────────────────────── */
.query-result-wrap { margin-bottom: 12px; }
.query-input-wrap { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 7px 12px; transition: border-color .15s, box-shadow .15s; box-shadow: var(--shadow-sm); }
.query-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--blue-dim), var(--shadow-sm); }
.query-icon { font-size: 1rem; background: linear-gradient(135deg, #7c3aed, var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; flex-shrink: 0; line-height: 1; }
.query-input-wrap input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: .875rem; min-width: 0; }
.query-input-wrap input::placeholder { color: var(--muted); }
.query-result { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; font-size: .82rem; flex-wrap: wrap; box-shadow: var(--shadow-sm); }
.query-suggestions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.suggestion-chip { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; color: var(--muted); font-size: .75rem; font-weight: 500; padding: 4px 12px; cursor: pointer; transition: color .15s, border-color .15s, background .15s; font-family: inherit; white-space: nowrap; }
.suggestion-chip:hover { color: var(--accent); border-color: var(--accent); background: var(--blue-dim); }
.query-label { color: var(--text); flex: 1; }
.query-analysis-text { color: var(--text); line-height: 1.55; flex: 1; }
.query-error { color: var(--red); flex: 1; }
.query-clear { background: none; border: 1px solid var(--border); color: var(--muted); cursor: pointer; font-size: .78rem; padding: 2px 8px; border-radius: 6px; flex-shrink: 0; transition: all .15s; }
.query-clear:hover { color: var(--text); background: var(--surface2); border-color: var(--border2); }
.query-ai-badge { display: inline-block; font-size: .63rem; font-weight: 700; background: linear-gradient(135deg, #7c3aed, #4493f8); color: #fff; padding: 1px 6px; border-radius: 4px; vertical-align: middle; letter-spacing: .04em; margin-left: 4px; box-shadow: 0 1px 4px rgba(124,58,237,.3); }
