:root {
  --bg: #0f1419;
  --panel: #1a2029;
  --panel2: #222b36;
  --line: #2c3744;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #ff6a00;     /* Zerodha orange */
  --green: #2ecc71;
  --red: #ff5c5c;
  --blue: #3aa0ff;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; }
.topbar nav { display: flex; gap: 18px; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--text); text-decoration: none; }
.topbar .status { margin-left: auto; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; letter-spacing: .5px; }
.badge-paper { background: rgba(58,160,255,.15); color: var(--blue); border: 1px solid var(--blue); }
.badge-live { background: rgba(255,92,92,.15); color: var(--red); border: 1px solid var(--red); }

.container { max-width: 1080px; margin: 22px auto; padding: 0 18px; }
.footer { text-align: center; color: var(--muted); padding: 24px; font-size: 12px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 18px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } }

.auth-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.big { font-size: 20px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.tbl td.r, .tbl th.r { text-align: right; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line); }

.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; font-size: 14px; color: #fff;
}
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-primary { background: var(--accent); }
.btn-paper { background: var(--blue); }
.btn-live { background: var(--red); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn:hover { filter: brightness(1.08); text-decoration: none; }

.order-form label { display: block; margin: 10px 0; color: var(--muted); font-size: 13px; }
.order-form input, .order-form select {
  display: block; width: 100%; margin-top: 4px; padding: 9px 10px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}
.order-form .row { display: flex; gap: 12px; }
.order-form .row label { flex: 1; }
.checkbox { display: flex !important; align-items: center; gap: 8px; }
.checkbox input { width: auto !important; margin: 0 !important; }

.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; }
.flash-success { background: rgba(46,204,113,.12); border: 1px solid var(--green); }
.flash-error { background: rgba(255,92,92,.12); border: 1px solid var(--red); }

.log {
  background: #0b0f14; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; font: 12px/1.5 "Cascadia Code", Consolas, monospace; color: #b8c4d0;
  white-space: pre-wrap; max-height: 320px; overflow: auto; margin: 0;
}
/* Portfolio summary strip */
.summary-card { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; }
.summary-item {
  flex: 1; min-width: 150px; padding: 8px 14px;
  border-right: 1px solid var(--line);
}
.summary-item:last-child { border-right: 0; }
.summary-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.summary-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.summary-pnl .summary-value { font-size: 24px; }
.summary-pct { font-size: 0.7em; font-weight: 600; opacity: 0.85; }
@media (max-width: 760px) {
  .summary-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-item:last-child { border-bottom: 0; }
}

/* Price-change tick flash on live cells */
@keyframes tickUp   { from { background: rgba(46,204,113,.35); } to { background: transparent; } }
@keyframes tickDown { from { background: rgba(255,92,92,.35); } to { background: transparent; } }
.tick-up   { animation: tickUp .8s ease-out; }
.tick-down { animation: tickDown .8s ease-out; }

.confirm-card { max-width: 460px; margin: 30px auto; }
.confirm-tbl th { width: 130px; text-transform: none; }
.confirm-actions { display: flex; gap: 12px; margin-top: 16px; }
.login-card { max-width: 360px; margin: 60px auto; }
.strategy-controls { margin: 14px 0; }

/* "How to use this page" walkthrough box */
.guide {
  background: rgba(58,160,255,.06); border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 18px;
}
.guide summary {
  cursor: pointer; padding: 12px 16px; font-weight: 600; color: var(--blue);
  list-style: none; user-select: none;
}
.guide summary::-webkit-details-marker { display: none; }
.guide summary::before { content: "▸ "; }
.guide[open] summary::before { content: "▾ "; }
.guide[open] summary { border-bottom: 1px solid var(--line); }
.guide-body { padding: 12px 18px; font-size: 13px; color: var(--text); }
.guide-body ol, .guide-body ul { margin: 6px 0; padding-left: 22px; }
.guide-body li { margin: 6px 0; }
.guide-body code { background: var(--bg); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.guide-body .tip { color: var(--muted); }

/* Stock search + favorite chips (Favorites / General pages) */
.search-wrap { margin: 6px 0 4px; }
.search-input {
  width: 100%; padding: 11px 12px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 14px;
}
.search-results { margin-top: 10px; }
.search-results .muted { padding: 6px 2px; }
.chips { margin: 8px 0 4px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 20px; padding: 5px 12px; font-size: 13px;
}
.chip form { display: inline; margin: 0; }
.chip .x {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0;
}
.chip .x:hover { color: var(--red); }
.btn-fav { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); }
.tag-buy { color: var(--green); border-color: var(--green); }
.tag-sell { color: var(--red); border-color: var(--red); }

/* Hover tooltips (driven by data-tip; see initTooltips in app.js) */
.tooltip {
  position: fixed; z-index: 1000; max-width: 300px;
  background: #0b0f14; color: var(--text);
  border: 1px solid var(--accent); border-radius: 8px;
  padding: 8px 11px; font-size: 12px; line-height: 1.45;
  pointer-events: none; box-shadow: 0 6px 22px rgba(0,0,0,.55);
}
[data-tip] { cursor: help; }
.btn[data-tip], a[data-tip], summary[data-tip], .chip .x[data-tip] { cursor: pointer; }
label[data-tip] { cursor: help; }
/* subtle hint that a label has help text */
.order-form label[data-tip] > :first-child,
.order-form label[data-tip] { border-bottom: none; }
th[data-tip], .summary-label[data-tip] { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }

/* Glossary */
.glossary-cat { margin: 22px 0 10px; font-size: 14px; color: var(--accent); text-transform: uppercase; letter-spacing: .6px; }
.terms { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .terms { grid-template-columns: 1fr; } }
.term {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
.term-name { font-weight: 700; margin-bottom: 5px; }
.term-def { font-size: 13px; color: var(--text); }
.term-eg { font-size: 12px; color: var(--muted); margin-top: 7px; }
.term-eg b { color: var(--blue); }
.glossary-empty { color: var(--muted); padding: 16px 2px; }
