/* Client senior citizen hain — isliye bade fonts, saaf contrast, kam chamak.
   Koi CSS framework nahi; poora bundle ~4 KB. */

:root {
  --bg: #0e1116;
  --panel: #161b22;
  --line: #262d38;
  --text: #e6edf3;
  --dim: #8b98a8;
  --up: #16a34a;
  --down: #dc2626;
  --accent: #3b82f6;
  --warn: #b45309;
  --hover: #1f2733;
  --on-bg: #1b2a44;
  --on-text: #ffffff;
  --chart-bg: #0e1116;
  --chart-grid: #1b212b;
  --skeleton: #1c232e;
  --tog-a: #2563eb;   /* column toggle — neela */
  --tog-b: #ea580c;   /* column toggle — narangi */
  color-scheme: dark;
}

/* ☀ Light mode (Dipesh, 26 Sep: "dark mode aur light mode dono") */
:root[data-theme="light"] {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #111827;
  --dim: #5b6575;
  --up: #15803d;
  --down: #b91c1c;
  --accent: #2563eb;
  --warn: #b45309;
  --hover: #eef2f7;
  --on-bg: #dbe7ff;
  --on-text: #1e3a8a;
  --chart-bg: #ffffff;
  --chart-grid: #eef1f5;
  --skeleton: #e7ebf1;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.hidden { display: none !important; }

/* ── roz-connect banner ─────────────────────────────────────────── */
.session-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--warn);
  color: #fff;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 500;
}
.session-bar button {
  background: #fff;
  color: var(--warn);
  border: 0;
  padding: 6px 18px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.link-btn {
  background: none;
  border: 1px solid var(--line, #333);
  color: inherit;
  font-size: 12px;
  padding: 2px 8px;
  margin-left: 8px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.8;
}
.session-bar button.ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
header h1 { margin: 0; font-size: 20px; letter-spacing: -0.2px; }
.feed-tag { font-size: 13px; color: var(--dim); display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; justify-content: flex-end; }

/* live badge — har 15 sec ka nishaan */
.live-badge { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.live-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; display: inline-block; }
.live-badge.ok .dot { background: #16a34a; }
.live-badge.stale .dot { background: #f59e0b; }
.live-badge.stale { color: #f59e0b; }
.live-badge.err .dot { background: #dc2626; }
.live-badge.closed .dot { background: #64748b; }
.live-badge.err { color: #f87171; }
.live-badge .dot.beat { animation: beat 0.9s ease-out; }
@keyframes beat {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.9); transform: scale(1.4); }
  100% { box-shadow: 0 0 0 10px rgba(22, 163, 74, 0); transform: scale(1); }
}
/* price badla to ek pal ke liye rang */
.flash-up { animation: flashUp 0.9s ease-out; }
.flash-down { animation: flashDown 0.9s ease-out; }
@keyframes flashUp { 0% { background: rgba(22, 163, 74, 0.45); } 100% { background: transparent; } }
@keyframes flashDown { 0% { background: rgba(220, 38, 38, 0.45); } 100% { background: transparent; } }
.delay { margin-left: 8px; opacity: 0.8; }

main {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: calc(100vh - 62px);
}

/* ── sidebar ────────────────────────────────────────────────────── */
aside {
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
}
aside h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--dim);
  margin: 22px 0 10px;
}

.search-wrap { position: relative; }
#search {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}
#search:focus { outline: none; border-color: var(--accent); }

.results {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  max-height: 340px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  z-index: 20;
}
.results div {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.results div:hover { background: var(--hover); }
.results .ex { color: var(--dim); font-size: 12px; }

.watchlist { list-style: none; margin: 0; padding: 0; }
.watchlist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}
.watchlist li:hover { background: var(--panel); }
.watchlist li.on { background: var(--panel); border-color: var(--accent); }
.wl-name { font-weight: 600; }
.wl-ex { font-size: 11px; color: var(--dim); margin-left: 6px; font-weight: 400; }
.wl-right { text-align: right; }
.wl-price { font-variant-numeric: tabular-nums; }
.wl-chg { font-size: 12px; font-variant-numeric: tabular-nums; }
.wl-del {
  border: 0;
  background: none;
  color: var(--dim);
  cursor: pointer;
  font-size: 18px;
  padding: 0 2px 0 10px;
  line-height: 1;
}
.wl-del:hover { color: var(--down); }

.empty { color: var(--dim); font-size: 14px; }
.up { color: var(--up); }
.down { color: var(--down); }

/* ── chart ──────────────────────────────────────────────────────── */
.chart-panel { display: flex; flex-direction: column; padding: 14px 18px; min-width: 0; }

/* toolbar — layout / chart type / timeframe */
.toolbar { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.tb-group { display: flex; gap: 6px; flex-wrap: wrap; }
.tb-group button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--dim);
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  min-width: 42px;
}
.tb-group button.wide { min-width: auto; }
.tb-group button.on { color: var(--on-text); border-color: var(--accent); background: var(--on-bg); }
.tb-ranges { margin-left: auto; }

/* grid — client ki #1 maang: ek screen par kai chart */
.grid { flex: 1; display: grid; gap: 12px; min-height: 0; }
.grid-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.grid-2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.pane {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 10px 12px 6px;
  min-width: 0;
  min-height: 0;
  cursor: pointer;
}
.pane.focused { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pane-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pane-name { font-size: 16px; font-weight: 700; }
.pane-meta { color: var(--dim); font-size: 12px; margin-top: 1px; }
.pane-price { text-align: right; }
.pane-chart { flex: 1; min-height: 140px; margin-top: 6px; }
.pane-msg { color: var(--dim); font-size: 12px; padding: 4px 1px 0; }

.sym-name { font-size: 20px; font-weight: 700; }
.sym-meta { color: var(--dim); font-size: 13px; margin-top: 2px; }
.price { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.change { font-size: 13px; font-variant-numeric: tabular-nums; }

/* compare — sab symbols ek chart par, 0% se naape hue */
.compare-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.compare-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.legend .lg { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

.chart { flex: 1; min-height: 320px; margin-top: 10px; }
.chart-msg { color: var(--dim); font-size: 13px; padding: 8px 2px; }

.hint { color: var(--dim); font-size: 12px; margin: 2px 0 8px; }

@media (max-width: 860px) {
  main { grid-template-columns: 1fr; height: auto; }
  aside { border-right: 0; border-bottom: 1px solid var(--line); }
  /* phone par side-by-side nahi chalta — neeche-neeche kar do */
  .grid-2, .grid-4 { grid-template-columns: 1fr; grid-template-rows: none; }
  .pane-chart { min-height: 220px; }
  .chart { min-height: 320px; }
  .tb-ranges { margin-left: 0; }
}

/* ── header: view tabs + theme ─────────────────────────────────── */
.head-left { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.views { display: flex; gap: 4px; }
.views button, .theme-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--dim);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.views button.on { color: var(--on-text); background: var(--on-bg); border-color: var(--accent); font-weight: 600; }
.theme-btn { font-size: 13px; padding: 4px 10px; }

/* watchlist 1-2-3 (sidebar) */
.wl-tabs { display: flex; gap: 4px; margin: 16px 0 4px; flex-wrap: wrap; }
.wl-tabs button {
  flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--dim);
  padding: 6px 4px; border-radius: 6px; cursor: pointer; font-size: 12px; white-space: nowrap;
}
.wl-tabs button.on { color: var(--on-text); background: var(--on-bg); border-color: var(--accent); }

/* NSE / BSE — hamesha naam ke saath (Dipesh, 26 Sep) */
.ex-badge {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.4px;
  padding: 1px 5px; border-radius: 4px; margin-left: 6px; vertical-align: 2px;
  border: 1px solid var(--line); color: var(--dim);
}
.ex-badge.NSE { color: #2563eb; border-color: rgba(37, 99, 235, 0.45); }
.ex-badge.BSE { color: #d97706; border-color: rgba(217, 119, 6, 0.45); }
.ex-badge.INDEX { color: #7c3aed; border-color: rgba(124, 58, 237, 0.45); }

/* ── Screener (26 Sep — Bina ma'am ka sketch) ───────────────────── */
.screener { display: flex; flex-direction: column; height: calc(100vh - 62px); padding: 12px 18px; gap: 10px; min-width: 0; }
.sc-bar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.sc-bar .tb-group button { padding: 6px 12px; font-size: 13px; }
.sc-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.sc-liquid { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.sc-bar2 { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.sc-search { width: 320px; max-width: 100%; }
.sc-search input {
  width: 100%; padding: 8px 12px; font-size: 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}
.sc-search input:focus { outline: none; border-color: var(--accent); }
.sc-search .results { top: 42px; }

/* loading dikhna chahiye (Dipesh: "user must see it") */
.sc-status { flex: 1; min-width: 240px; font-size: 13px; color: var(--dim); }
.sc-status .bar { height: 4px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.sc-status .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.3s; }
.sc-status.done .bar { display: none; }
.sc-status.err { color: var(--down); }

.sc-table-wrap { flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.sc-table { border-collapse: collapse; width: 100%; min-width: 1120px; font-size: 14px; }
.sc-table th {
  position: sticky; top: 0; z-index: 2; background: var(--panel); color: var(--dim);
  font-weight: 600; font-size: 12px; text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.sc-table th.sort { cursor: pointer; user-select: none; }
.sc-table th.sort.active { color: var(--text); }
.sc-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sc-table tr:hover td { background: var(--hover); }
.sc-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sc-table td.ltp { font-weight: 700; font-size: 15px; }
.sc-name { font-weight: 700; white-space: nowrap; cursor: pointer; }
.sc-name:hover { color: var(--accent); }
.sc-empty { padding: 30px; text-align: center; color: var(--dim); }

.tog { display: inline-flex; gap: 2px; margin-left: 6px; vertical-align: middle; }
.tog b {
  font-weight: 600; font-size: 11px; padding: 2px 7px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--line); color: var(--dim); background: transparent;
}
.tog.c0 b.on { background: var(--tog-a); border-color: var(--tog-a); color: #fff; }
.tog.c1 b.on { background: var(--tog-b); border-color: var(--tog-b); color: #fff; }

.spark { width: 150px; height: 44px; cursor: zoom-in; display: block; position: relative; }
.spark.d1 { width: 170px; }
.spark svg { display: block; }
.spark .up { color: var(--up); }
.spark .down { color: var(--down); }
.spark .since {
  position: absolute; left: 2px; bottom: 1px; font-size: 10px; line-height: 1.2; color: var(--dim);
  background: var(--panel); padding: 0 4px; border-radius: 3px; opacity: 0.92; pointer-events: none;
}
.spark.loading {
  border-radius: 4px; cursor: default;
  background: linear-gradient(90deg, var(--skeleton) 0%, var(--panel) 50%, var(--skeleton) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
.spark.failed { display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 12px; cursor: default; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.act-btn {
  background: none; border: 1px solid var(--line); color: var(--dim); border-radius: 6px;
  width: 28px; height: 26px; cursor: pointer; font-size: 16px; line-height: 1;
}
.act-btn:hover { color: var(--accent); border-color: var(--accent); }
.act-btn.del:hover { color: var(--down); border-color: var(--down); }

.menu {
  position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); padding: 4px; min-width: 190px;
}
.menu button {
  display: flex; justify-content: space-between; width: 100%; background: none; border: 0; color: var(--text);
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; text-align: left;
}
.menu button:hover { background: var(--hover); }
.menu button[disabled] { color: var(--dim); cursor: default; }

/* bada chart / details — popup */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(1000px, 100%);
  max-height: 92vh; overflow: auto; padding: 14px 16px;
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: 1px solid var(--line); color: var(--dim); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 14px; }
.modal-chart { height: 420px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.modal-actions button {
  background: var(--on-bg); color: var(--on-text); border: 1px solid var(--accent);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 13px;
}
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 16px; font-size: 14px; margin: 6px 0 12px; }
.facts span { color: var(--dim); display: block; font-size: 12px; }
.depth { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.depth th, .depth td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.depth td { height: 31px; } /* khaali level bhi poori line */
.depth th { color: var(--dim); font-size: 12px; font-weight: 600; }
.depth .bid { color: var(--up); } .depth .ask { color: var(--down); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 14px;
}

@media (max-width: 860px) {
  .screener { height: auto; padding: 10px; }
  .sc-table-wrap { max-height: 75vh; }
  .sc-search { width: 100%; }
}

/* ── login page (22 Oct) — bade akshar, ek hi box ─────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px 24px; display: flex; flex-direction: column; gap: 8px;
}
.login-box h1 { margin: 0; font-size: 26px; }
.login-sub { margin: 0 0 12px; color: var(--dim); }
.login-box label { font-size: 15px; color: var(--dim); margin-top: 6px; }
.login-box input {
  width: 100%; box-sizing: border-box; font-size: 18px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.login-box input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pw-wrap { display: flex; gap: 6px; }
.pw-wrap button { background: var(--bg); color: var(--dim); border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; cursor: pointer; font-size: 14px; }
#loginBtn {
  margin-top: 16px; font-size: 18px; font-weight: 600; padding: 12px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer;
}
#loginBtn:disabled { opacity: 0.6; cursor: wait; }
.login-err { min-height: 1.5em; margin: 6px 0 0; color: var(--down); font-weight: 600; }
