/* at1 dashboard styling.
 *
 * Colour comes from a validated palette, used by role:
 *   - buy / sell and up / down candles use the reserved STATUS colours
 *     (good #0ca30c, critical #d03b3b) and always ship with an arrow glyph and
 *     a text label, so colour never carries the meaning alone.
 *   - the moving-average lines use categorical slots 1/2/5/7 (blue, orange,
 *     magenta, violet). The green family is deliberately skipped so no line can
 *     be mistaken for the bullish status colour.
 *   - grid, axes and band fills stay in chrome ink so the data sits on top.
 *
 * Dark is the default and is its own selected set of steps (not a flipped light
 * theme); the light theme below is the documented light column.
 */

:root {
  color-scheme: dark;

  --surface-1: #1a1a19;          /* chart surface */
  --plane: #0d0d0d;              /* page behind the cards */
  --surface-2: #151514;          /* panel / card surface */
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --series-1: #3987e5;   /* EMA 9    */
  --series-2: #d95926;   /* EMA 21   */
  --series-3: #d55181;   /* EMA 50   */
  --series-4: #9085e9;   /* EMA 200  */
  --series-5: #c98500;   /* VWAP     */

  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --surface-2: #ffffff;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #e87ba4;
  --series-4: #4a3aa7;
  --series-5: #eda100;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--plane);
  color: var(--text-primary);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 356px;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
}

/* --- header ---------------------------------------------------------------- */

header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand { font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.brand span {
  display: block; font-weight: 400; font-size: 10.5px;
  color: var(--text-muted); letter-spacing: .06em; text-transform: uppercase;
}

#instrument { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
#instrument .name { font-weight: 600; font-size: 15px; }
#instrument .sym { color: var(--text-muted); font-size: 11px; }
#instrument .ltp { font-size: 19px; font-weight: 650; }
#instrument .chg { font-weight: 600; }

.spacer { flex: 1 1 auto; }

.tf-row { display: flex; gap: 4px; background: var(--plane); padding: 3px; border-radius: 8px; }
.tf-row button {
  border: 0; background: transparent; color: var(--text-secondary);
  font: inherit; padding: 5px 10px; border-radius: 6px; cursor: pointer;
}
.tf-row button:hover { color: var(--text-primary); background: var(--border); }
.tf-row button[aria-pressed="true"] { background: var(--series-1); color: #fff; font-weight: 600; }

.ghost-btn {
  border: 1px solid var(--border); background: transparent; color: var(--text-secondary);
  font: inherit; padding: 6px 11px; border-radius: 7px; cursor: pointer;
}
.ghost-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }

/* --- main / panes --------------------------------------------------------- */

main { padding: 12px; min-width: 0; overflow-y: auto; max-height: calc(100vh - 56px); }

.verdict-card {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 4px solid var(--text-muted);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px;
}
.verdict-card[data-tone="buy"] { border-left-color: var(--good); }
.verdict-card[data-tone="sell"] { border-left-color: var(--critical); }
.verdict-card[data-tone="hold"] { border-left-color: var(--warning); }

.verdict-main { display: flex; align-items: center; gap: 12px; }
.verdict-label { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.verdict-glyph { font-size: 22px; line-height: 1; }
.verdict-score { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.verdict-score strong { font-size: 17px; color: var(--text-primary); }

.tally { display: flex; gap: 14px; }
.tally div { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tally b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

.score-meter { flex: 1 1 200px; min-width: 180px; }
.score-meter .track {
  position: relative; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, var(--critical), var(--grid) 50%, var(--good));
}
.score-meter .needle {
  position: absolute; top: -3px; width: 3px; height: 14px; border-radius: 2px;
  background: var(--text-primary); box-shadow: 0 0 0 2px var(--surface-2);
}
.score-meter .scale {
  display: flex; justify-content: space-between; margin-top: 4px;
  color: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums;
}

.panes { display: flex; flex-direction: column; gap: 8px; }

figure.pane {
  margin: 0; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
figure.pane figcaption {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  color: var(--text-secondary); font-size: 11.5px;
}
figure.pane figcaption .title {
  font-weight: 650; color: var(--text-primary); font-size: 12px;
  text-transform: uppercase; letter-spacing: .05em;
}
.legend { display: flex; gap: 13px; flex-wrap: wrap; align-items: center; }
.legend .key { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend .swatch { width: 11px; height: 2.5px; border-radius: 2px; flex: none; }
.legend .swatch.dot { width: 8px; height: 8px; border-radius: 50%; }
.legend .val { font-variant-numeric: tabular-nums; color: var(--text-primary); }
.chart-host { width: 100%; }

.pane-toggles { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 8px; }
.pane-toggles label {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-secondary); cursor: pointer; user-select: none;
}
.pane-toggles input { accent-color: var(--series-1); margin: 0; }

/* --- info cards ----------------------------------------------------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; margin-top: 12px; }
.card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; min-width: 0;
}
.card h2 {
  margin: 0 0 9px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted); font-weight: 650;
}
.card.wide { grid-column: 1 / -1; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.event-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.event-list li { display: flex; gap: 8px; align-items: flex-start; color: var(--text-secondary); }
.event-list .glyph { flex: none; width: 15px; text-align: center; font-weight: 700; }
.event-list li[data-tone="up"] .glyph { color: var(--good); }
.event-list li[data-tone="down"] .glyph { color: var(--critical); }
.event-list li[data-tone="flat"] .glyph { color: var(--warning); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--border); }
tr.group-head td {
  color: var(--text-muted); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .06em; font-weight: 650; padding-top: 11px; border-bottom-color: var(--axis);
}

/* Signal chips: colour + glyph + word, never colour alone. */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px;
  border-radius: 999px; font-size: 10.5px; font-weight: 650; white-space: nowrap;
  border: 1px solid transparent;
}
.chip[data-sig="Buy"], .chip[data-sig="BUY"] { color: var(--good); border-color: var(--good); }
.chip[data-sig="STRONG BUY"] { color: #fff; background: var(--good); border-color: var(--good); }
.chip[data-sig="Sell"], .chip[data-sig="SELL"] { color: var(--critical); border-color: var(--critical); }
.chip[data-sig="STRONG SELL"] { color: #fff; background: var(--critical); border-color: var(--critical); }
.chip[data-sig="Neutral"], .chip[data-sig="HOLD"] { color: var(--warning); border-color: var(--warning); }
.chip[data-sig="n/a"], .chip[data-sig="NO DATA"], .chip[data-sig="WAIT"] { color: var(--text-muted); border-color: var(--axis); }

.bar-cell { position: relative; height: 5px; background: var(--grid); border-radius: 3px; overflow: hidden; }
.bar-cell i { position: absolute; top: 0; bottom: 0; }

/* --- right panel ---------------------------------------------------------- */

aside {
  background: var(--surface-2); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; max-height: calc(100vh - 56px);
}

.panel-modes { display: flex; padding: 10px 12px 0; gap: 6px; }
.panel-modes button {
  flex: 1; border: 1px solid var(--border); background: transparent;
  color: var(--text-secondary); font: inherit; font-weight: 600;
  padding: 7px; border-radius: 8px; cursor: pointer;
}
.panel-modes button[aria-pressed="true"] { background: var(--series-1); border-color: var(--series-1); color: #fff; }

.panel-controls { padding: 10px 12px; display: grid; gap: 8px; }
.panel-controls select, .panel-controls input {
  width: 100%; background: var(--plane); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; font: inherit;
}
.panel-controls input::placeholder { color: var(--text-muted); }
.panel-note { color: var(--text-muted); font-size: 11px; padding: 0 12px 6px; }

.watchlist { overflow-y: auto; flex: 1; padding: 0 8px 14px; }
.wl-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
  padding: 8px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; align-items: center;
}
.wl-row:hover { background: var(--border); }
.wl-row[aria-selected="true"] { border-color: var(--series-1); background: var(--border); }
.wl-row .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-row .sub { color: var(--text-muted); font-size: 10.5px; grid-column: 1; }
.wl-row .px { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.wl-row .pct { text-align: right; font-variant-numeric: tabular-nums; font-size: 11px; }
.wl-row .chip { grid-column: 2; justify-self: end; }
.up { color: var(--good); }
.down { color: var(--critical); }
.flat { color: var(--text-muted); }

/* --- options view --------------------------------------------------------- */

.oc-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.oc-head select { background: var(--plane); color: var(--text-primary); border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; font: inherit; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
}
.stat .label { color: var(--text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 3px; }
.stat .sub { color: var(--text-secondary); font-size: 11px; }

tr.atm { background: rgba(250, 178, 25, .10); }
tr.atm td { font-weight: 650; }
td.oi { position: relative; }
/* OI depth bar sits behind the number: magnitude you can scan down the column. */
td.oi i {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 60%; opacity: .22; border-radius: 2px;
}
td.oi.ce i { background: var(--critical); right: auto; }
td.oi.pe i { background: var(--good); }
td.oi span { position: relative; }

/* --- target planner ------------------------------------------------------- */

.tp-form { display: flex; gap: 9px 14px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.tp-form label {
  display: grid; gap: 4px; color: var(--text-muted);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
}
.tp-form select, .tp-form input {
  background: var(--plane); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 7px; padding: 6px 9px; font: inherit; font-size: 13px;
}
.tp-form input { width: 104px; font-variant-numeric: tabular-nums; }
.tp-form button { padding: 7px 14px; }

/* The picked row is the one the ticket on your broker terminal should match. */
tr.tp-pick { background: rgba(57, 135, 229, .10); }
tr.tp-pick td { font-weight: 650; }
tr.tp-out td { color: var(--text-muted); }

.tp-marks { display: flex; gap: 5px; flex-wrap: wrap; }
.tp-mark {
  border: 1px solid var(--axis); border-radius: 999px; padding: 1px 7px;
  font-size: 10.5px; color: var(--text-secondary); white-space: nowrap;
}
.tp-mark[data-kind="spot"] { border-color: var(--series-1); color: var(--series-1); }
.tp-mark[data-kind="stop"] { border-color: var(--critical); color: var(--critical); }
.tp-mark[data-kind="target"] { border-color: var(--good); color: var(--good); }

/* --- option bench --------------------------------------------------------- */

.tp-hint { margin: 2px 0 12px; color: var(--text-muted); font-size: 11.5px; }
.tp-hint b { color: var(--text-secondary); }

/* Moneyness always ships as the word ITM / ATM / OTM; the colour only reinforces
   an ordering the text already carries. */
.chip[data-mny="ITM"] { color: var(--good); border-color: var(--good); }
.chip[data-mny="ATM"] { color: var(--warning); border-color: var(--warning); }
.chip[data-mny="OTM"] { color: var(--text-secondary); border-color: var(--axis); }

.bn-sub { font-size: 10.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.bn-actions { display: flex; gap: 5px; margin-top: 3px; }
.bn-actions button {
  border: 1px solid var(--border); background: transparent; color: var(--text-muted);
  font: inherit; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; cursor: pointer;
}
.bn-actions button:hover { color: var(--text-primary); border-color: var(--text-muted); }
.bn-actions button[data-act="drop"]:hover { color: var(--critical); border-color: var(--critical); }

/* The columns that belong to the reward:risk currently in focus, tinted as one
   block so it is obvious which numbers move when that selector changes. */
td.bn-focus, th.bn-focus { background: rgba(57, 135, 229, .10); }
td.bn-keep { font-weight: 650; }

.banner {
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 4px solid var(--warning); border-radius: var(--radius);
  padding: 11px 14px; color: var(--text-secondary); margin-bottom: 12px;
}
.banner b { color: var(--text-primary); }

.disclaimer {
  grid-column: 1 / -1; padding: 9px 16px; color: var(--text-muted);
  font-size: 11px; border-top: 1px solid var(--border); background: var(--surface-2);
}

.loading { padding: 30px; text-align: center; color: var(--text-muted); }
.error {
  border-left-color: var(--critical); background: var(--surface-2);
  border: 1px solid var(--border); border-left: 4px solid var(--critical);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px;
}

@media (max-width: 1080px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  aside { max-height: none; border-left: 0; border-top: 1px solid var(--border); }
  main { max-height: none; }
}
