/* ============================================================
   Portfolio Tracker — dark theme
   ============================================================ */

:root {
  --bg: #07090d;
  --bg-elev: #0e1218;
  --bg-card: #11161f;
  --bg-card-hi: #161c27;
  --border: #1f2632;
  --border-hi: #2a3343;
  --text: #e7ebf3;
  --text-dim: #9aa3b2;
  --muted: #6a7383;

  --accent: #5dd6a3;
  --accent-2: #4ea4ff;
  --accent-3: #c084fc;
  --warn: #f5c45e;

  --green: #2bd17e;
  --green-soft: rgba(43,209,126,0.12);
  --red: #ff5d6c;
  --red-soft: rgba(255,93,108,0.12);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --grid-gap: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, #11202f 0%, transparent 60%),
              radial-gradient(900px 500px at 110% -20%, #1a1230 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */
/* Grid: brand on left (auto), NIFTY in the middle (1fr, centred), controls on right (auto).
   No more breadcrumbs — brand-click + back-button-in-hero handle navigation. */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(7,9,13,0.7);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 50;
  gap: 16px;
}
.btn-icon { display: inline-block; }
.btn .btn-text { margin-left: 4px; }

a.brand { text-decoration: none; color: inherit; cursor: pointer; transition: opacity .12s ease; }
a.brand:hover { opacity: 0.85; }

/* The header center groups the global Stocks⇄MF toggle with the NIFTY pill,
   so both market context and book context sit "at the top" together. */
.topbar-center {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; min-width: 0;
}
.index-bar { display: flex; align-items: center; min-width: 0; }
.ix-item {
  display: inline-flex; align-items: baseline; gap: 10px;
  padding: 5px 14px; border-radius: 999px;
  border: 1px solid var(--border-hi);
  background: var(--bg-card);
  white-space: nowrap;
}
.ix-item .ix-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim);
}
.ix-item .ix-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.ix-item .ix-change { font-size: 12px; font-variant-numeric: tabular-nums; }
.ix-item .ix-pct {
  font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.ix-item.pos .ix-change, .ix-item.pos .ix-pct { color: var(--green); }
.ix-item.neg .ix-change, .ix-item.neg .ix-pct { color: var(--red); }
.ix-item.pos .ix-pct { background: var(--green-soft); }
.ix-item.neg .ix-pct { background: var(--red-soft); }
.ix-loading { font-size: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: 0.01em; }
.brand-logo { width: 26px; height: 26px; display: block; }
/* Wordmark uses the same green→blue→purple sweep as the hexagon mark next
   to it. Diagonal direction matches the growth tick inside the logo. */
.brand-name {
  background: linear-gradient(120deg, #5dd6a3 0%, #4ea4ff 50%, #c084fc 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

/* ---------- News / Corporate actions list ---------- */
.news-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.news-row {
  display: grid;
  grid-template-columns: 90px 130px 90px 1fr auto;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-size: 13px;
  align-items: center;
}
.news-row:hover { background: var(--bg-card-hi); border-color: var(--border-hi); }
.news-row .nr-date { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.news-row .nr-when { font-size: 11px; color: var(--text-dim); }
.news-row .nr-sym { font-weight: 700; }
.news-row .nr-company { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.news-row .nr-cat {
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  background: var(--bg-card-hi); color: var(--text-dim);
  border: 1px solid var(--border);
  text-align: center; min-width: 70px;
}
.news-row .nr-cat.dividend { color: var(--green); border-color: rgba(43,209,126,0.4); background: var(--green-soft); }
.news-row .nr-cat.bonus    { color: var(--accent-2); border-color: rgba(78,164,255,0.4); background: rgba(78,164,255,0.10); }
.news-row .nr-cat.buyback  { color: var(--accent-3); border-color: rgba(192,132,252,0.4); background: rgba(192,132,252,0.10); }
.news-row .nr-cat.split    { color: var(--warn); border-color: rgba(245,196,94,0.4); background: rgba(245,196,94,0.10); }
.news-row .nr-cat.rights   { color: #ffa3d1; border-color: rgba(255,163,209,0.4); background: rgba(255,163,209,0.10); }
.news-row .nr-cat.meeting  { color: #7be0ff; border-color: rgba(123,224,255,0.4); background: rgba(123,224,255,0.10); }
.news-row .nr-cat.merger   { color: var(--red); border-color: rgba(255,93,108,0.4); background: var(--red-soft); }
.news-row .nr-cat.result   { color: #c084fc; border-color: rgba(192,132,252,0.4); background: rgba(192,132,252,0.10); }
.news-row .nr-purpose { color: var(--text); }
.news-row .nr-extra { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.news-empty { padding: 24px; text-align: center; color: var(--text-dim); font-size: 13px; }

@media (max-width: 720px) {
  /* Stack news rows vertically on mobile */
  .news-row {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "date cat"
      "sym sym"
      "purpose purpose"
      "extra extra";
    gap: 4px 10px;
  }
  .news-row .nr-date    { grid-area: date; }
  .news-row .nr-cat     { grid-area: cat; justify-self: end; }
  .news-row .nr-sym-wrap { grid-area: sym; display: flex; gap: 8px; align-items: baseline; }
  .news-row .nr-purpose { grid-area: purpose; }
  .news-row .nr-extra   { grid-area: extra; }
}

/* ---------- Equity curve controls ---------- */
.curve-controls {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: center;
}
.ctrl-group {
  display: inline-flex; gap: 2px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.ctrl-chip {
  padding: 5px 11px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s ease, color .1s ease;
}
.ctrl-chip:hover { color: var(--text); }
.ctrl-chip.active {
  background: var(--bg-card-hi);
  color: var(--accent);
}
/* Date window: the two inputs always show the exact window in effect (a
   preset chip fills them in); editing either one makes the window custom. */
.ctrl-dates { align-items: center; gap: 4px; padding: 2px 4px; }
.ctrl-date {
  background: transparent; border: none; border-radius: 6px;
  color: var(--text); font-family: inherit; font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em; padding: 4px 6px; cursor: pointer;
  color-scheme: dark; font-variant-numeric: tabular-nums;
}
.ctrl-date:hover { color: var(--accent); }
.ctrl-date:focus { outline: none; background: var(--bg-card-hi); color: var(--accent); }
.ctrl-date::-webkit-calendar-picker-indicator { opacity: 0.55; cursor: pointer; }
.ctrl-arrow { color: var(--muted); font-size: 11px; }
.ctrl-pdf { color: var(--accent); border-left: 1px solid var(--border); border-radius: 0 6px 6px 0; margin-left: 2px; }
.ctrl-pdf:hover { background: var(--bg-card-hi); }
.curve-stats .cs-note { flex-basis: 100%; color: var(--muted); font-size: 11px; }
.curve-stats {
  display: flex; gap: 16px; flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 12px; color: var(--text-dim);
}
.curve-stats .cs-item { display: inline-flex; gap: 6px; align-items: baseline; }
.curve-stats .cs-val { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.curve-stats .cs-val.pos { color: var(--green); }
.curve-stats .cs-val.neg { color: var(--red); }
.curve-empty {
  padding: 32px 16px; text-align: center; color: var(--text-dim);
  background: var(--bg-elev); border: 1px dashed var(--border-hi);
  border-radius: 10px;
}
.curve-empty code {
  background: var(--bg-card-hi); padding: 2px 8px; border-radius: 6px;
  font-size: 12px; color: var(--accent);
}

/* ---------- Kebab (three-dots) menu ---------- */
/* Lives anywhere a hero/card needs secondary actions without cluttering the
   primary surface. The trigger is a 36px chip; the dropdown is right-aligned
   so it never falls off-screen when used in the top-right of a section. */
.kebab-wrap { position: relative; display: inline-block; }
.kebab-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-hi);
  background: var(--bg-card);
  color: var(--text);
  font-size: 20px; line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.kebab-btn:hover { background: var(--bg-card-hi); border-color: var(--accent); color: var(--accent); }
.kebab-btn.open { background: var(--bg-card-hi); border-color: var(--accent); color: var(--accent); }

.kebab-menu {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  box-shadow: 0 16px 32px rgba(0,0,0,0.6);
  min-width: 200px;
  padding: 5px;
  z-index: 80;
  animation: kebab-fade-in .12s ease;
}
@keyframes kebab-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.kebab-item {
  width: 100%;
  padding: 9px 12px;
  border-radius: 7px;
  background: transparent;
  border: none;
  color: var(--text);
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background .1s ease;
}
.kebab-item:hover { background: var(--bg-card-hi); }
.kebab-item.danger { color: var(--red); }
.kebab-item.danger:hover { background: rgba(255,93,108,0.10); }
.kebab-item .kicon {
  font-size: 13px;
  width: 18px;
  text-align: center;
  opacity: 0.85;
  flex-shrink: 0;
}
.kebab-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

/* Hero title with optional back button alongside */
.hero-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.back-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-hi);
  background: var(--bg-card);
  color: var(--text);
  font-size: 18px; line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .12s ease, border-color .12s ease;
}
.back-btn:hover { background: var(--bg-card-hi); border-color: var(--accent); color: var(--accent); }
.back-btn.small { width: 28px; height: 28px; font-size: 14px; border-radius: 8px; }
.back-btn.hidden { display: none; }

/* Sub-card head w/ inline title + back button */
.sub-card.sector-card { display: flex; flex-direction: column; }
.sector-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sector-head h3 { margin: 0; }

/* "Not calculated — data not fetched" marker (asset split couldn't be resolved). */
.info-dot { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; cursor: help; }
.info-dot.err { color: var(--red); font-weight: 600; }
.info-dot.err.solo, .info-dot.warn.solo { margin-left: 4px; }
/* "Needs re-fetch" marker (fund split computed by the old, un-netted method). */
.info-dot.warn { color: var(--warn); font-weight: 600; }

/* Exact-value legend under an allocation donut — the precise ₹ per slice and
   its % of the total, footed by the total itself, so the split can be checked
   by hand against the headline figure. */
.alloc-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12px; }
.alloc-table th, .alloc-table td { padding: 5px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.alloc-table th { font-size: 10px; font-weight: 500; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.alloc-table .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.alloc-table tfoot td { font-weight: 700; border-bottom: none; color: var(--text); }
.alloc-table td:first-child { color: var(--text); }
.alloc-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }

/* ---------- Tags (portfolio pages only) ---------- */
/* "Tag in focus" banner under a portfolio's title — present only while a tag
   narrows the page, with the way back to the entire portfolio. */
.tag-focus {
  display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap;
  margin: -8px 0 18px; padding: 10px 14px;
  border: 1px solid rgba(78,164,255,0.55); border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(78,164,255,0.10), rgba(78,164,255,0.02)), var(--bg-card);
  box-shadow: 0 0 0 1px rgba(78,164,255,0.18) inset;
}
.tag-focus-main { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; min-width: 0; flex: 1; }
.tag-focus-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--accent-2); white-space: nowrap;
}
.tag-focus-note { font-size: 12px; color: var(--text-dim); }

.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border-hi); background: var(--bg-elev);
  color: var(--text-dim); font-size: 12px; font-weight: 600; font-family: inherit;
  line-height: 1.5; white-space: nowrap;
}
button.tag-chip { cursor: pointer; transition: border-color .12s ease, color .12s ease, background .12s ease; }
button.tag-chip:hover { color: var(--text); border-color: var(--accent-2); }
.tag-chip.on {
  color: #eaf3ff; border-color: var(--accent-2);
  background: rgba(78,164,255,0.22);
}
/* Read-only chips inside table rows — compact, click to focus the portfolio
   on the tag (or, on the tag already in focus, to show all of it again). */
.tag-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.tag-chip.mini {
  padding: 0 7px; font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
  cursor: pointer; color: #9fc7ff; border-color: rgba(78,164,255,0.35); background: rgba(78,164,255,0.08);
}
.tag-chip.mini:hover { border-color: var(--accent-2); color: #eaf3ff; }
.tag-chip.mini.on { background: rgba(78,164,255,0.25); color: #eaf3ff; }
.holdings td.sym .sym-cell { display: inline-flex; flex-direction: column; align-items: flex-start; }

/* Chip editor (tag modal + Add Holding / Add Fund). */
.tag-input { display: grid; gap: 6px; }
.tag-input-box {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  background: var(--bg-elev); border: 1px solid var(--border-hi);
  border-radius: 8px; padding: 6px 8px; min-height: 42px; cursor: text;
}
.tag-input-box:focus-within { border-color: var(--accent); }
.tag-input-chips { display: contents; }
.tag-chip.edit { color: var(--text); border-color: rgba(78,164,255,0.45); background: rgba(78,164,255,0.12); padding-right: 4px; }
.tag-x {
  border: none; background: transparent; color: var(--text-dim); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 4px; border-radius: 999px;
}
.tag-x:hover { color: var(--red); }
.field .tag-input-text, .tag-input-text {
  flex: 1; min-width: 120px; border: none; background: transparent; padding: 4px 2px;
  color: var(--text); font-size: 14px; font-family: inherit;
}
.tag-input-text:focus { outline: none; }
.tag-input-text:disabled { cursor: not-allowed; }
.tag-input-meta { display: flex; justify-content: space-between; gap: 8px; }
.tag-input-suggest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chip.suggest { font-size: 11px; padding: 2px 9px; }
.manage-tags td { vertical-align: middle; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 8px var(--muted);
}
.status-dot.live { background: var(--green); box-shadow: 0 0 10px rgba(43,209,126,0.7); }
.status-dot.closed { background: var(--warn); box-shadow: 0 0 10px rgba(245,196,94,0.6); }

/* Privacy mode — active state on toggle button + a subtle border tint on body */
#privacy-btn.active { color: var(--warn); border-color: rgba(245,196,94,0.4); }
body.privacy-mode .topbar { border-bottom-color: rgba(245,196,94,0.25); }

/* ---------- Main / hero ---------- */
main { padding: 22px 28px 80px; max-width: 1500px; margin: 0 auto; }
.hero {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.hero h1 {
  font-size: 26px; margin: 0 0 4px;
  background: linear-gradient(120deg, #fff 30%, #b8c4d9 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border-hi);
  background: var(--bg-card-hi);
  color: var(--text);
  padding: 9px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform .06s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { background: #1d2532; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent) 0%, #2da985 100%);
  color: #06120c;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); border-color: rgba(255,93,108,0.4); }
.btn.danger:hover { background: rgba(255,93,108,0.12); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-card-hi); }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* ---------- User tabs ---------- */
/* Grid: tabs container is 1fr (gets all remaining space) with min-width:0
   so it can shrink and let its child horizontally scroll. Add User column
   is auto so it always reserves exactly its own width. */
.user-tabs-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.user-tabs {
  display: flex; gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 4px;
}
.user-tabs::-webkit-scrollbar { height: 4px; }
.user-tabs::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }
.user-tab { flex: 0 0 auto; }      /* never shrink — width determined by content */
#add-user-btn { flex-shrink: 0; }  /* button never gets squeezed */

/* The "Overall" tab is visually distinct from a user — different gradient,
   accent border, and a divider on its right separating it from the user list. */
.user-tab.overall {
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.18), rgba(78, 164, 255, 0.10));
  border-color: rgba(192, 132, 252, 0.42);
  color: var(--text);
  position: relative;
}
.user-tab.overall .tab-name { color: var(--accent-3); }
.user-tab.overall .tab-sub  { color: var(--text-dim); }
.user-tab.overall.active {
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.30), rgba(78, 164, 255, 0.15));
  border-color: var(--accent-3);
  box-shadow: 0 0 0 1px rgba(192, 132, 252, 0.35) inset;
}
.user-tab-divider {
  width: 1px; flex: 0 0 1px;
  background: var(--border-hi);
  margin: 0 6px;
  align-self: stretch;
}

/* Overall hero — purple wash to reinforce the "this is not a user" framing */
.overall-hero h1 {
  background: linear-gradient(120deg, #fff 30%, var(--accent-3) 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.user-tab {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer; transition: all .12s ease;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-width: 140px;
}
.user-tab:hover { color: var(--text); border-color: var(--border-hi); background: var(--bg-card-hi); }
.user-tab.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(93,214,163,0.12), rgba(93,214,163,0.02));
  border-color: rgba(93,214,163,0.5);
}
.user-tab .tab-name { font-size: 13px; }
.user-tab .tab-sub { font-size: 11px; color: var(--text-dim); font-weight: 500; display: flex; gap: 6px; align-items: center; }
.user-tab .tab-sub .pct { font-weight: 600; }
.user-tab .tab-sub .pct.pos { color: var(--green); }
.user-tab .tab-sub .pct.neg { color: var(--red); }

/* ---------- Section toggle (Stocks ⇄ Mutual Funds) ---------- */
/* A global segmented control in the header that re-frames the whole dashboard.
   Stocks are tracked in the green/purple palette; Mutual Funds lean blue so
   the active segment's accent always tells you which book you're looking at. */
.section-toggle {
  display: inline-flex; gap: 2px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}
.section-toggle .seg {
  padding: 7px 14px; border-radius: 8px; border: none;
  background: transparent; color: var(--text-dim);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; white-space: nowrap;
  transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}
.section-toggle .seg:hover { color: var(--text); }
.section-toggle .seg.active {
  background: var(--bg-card-hi); color: var(--accent);
  box-shadow: 0 0 0 1px rgba(93,214,163,0.35) inset;
}
/* Funds book → blue accent, mirroring the .mf-hero title sweep. */
.section-toggle .seg.active[data-section="mf"] {
  color: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(78,164,255,0.40) inset;
}

/* MF hero title gets a blue sweep to mirror the section's accent. */
.mf-hero h1 {
  background: linear-gradient(120deg, #fff 30%, #9fc7ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* MF portfolio cards: blue framing (vs the purple equity portfolio cards). */
.portfolios-grid.mf .entity-card {
  background: linear-gradient(160deg, rgba(78,164,255,0.07) 0%, #11161f 60%);
  border-color: rgba(78,164,255,0.30);
  box-shadow: 0 1px 0 rgba(78,164,255,0.06), 0 6px 20px rgba(0,0,0,0.35);
}
.portfolios-grid.mf .entity-card::before {
  background: linear-gradient(180deg, var(--accent-2), rgba(78,164,255,0.2));
}
.portfolios-grid.mf .entity-card:hover {
  border-color: rgba(78,164,255,0.65);
  box-shadow: 0 12px 32px rgba(78,164,255,0.18), 0 4px 12px rgba(0,0,0,0.4);
}
.portfolios-grid.mf .entity-card .ec-title {
  background: linear-gradient(120deg, #fff 30%, #bcdcff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Net worth book → gold accent, distinct from stocks (green) and funds (blue). */
.section-toggle .seg.active[data-section="networth"] {
  color: var(--warn);
  box-shadow: 0 0 0 1px rgba(245,196,94,0.40) inset;
}
.nw-hero h1 {
  background: linear-gradient(120deg, #fff 30%, #f5d98e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Net-worth asset-class cards: gold framing. */
.portfolios-grid.nw .entity-card {
  background: linear-gradient(160deg, rgba(245,196,94,0.07) 0%, #11161f 60%);
  border-color: rgba(245,196,94,0.30);
  box-shadow: 0 1px 0 rgba(245,196,94,0.06), 0 6px 20px rgba(0,0,0,0.35);
}
.portfolios-grid.nw .entity-card::before {
  background: linear-gradient(180deg, var(--warn), rgba(245,196,94,0.2));
}
.portfolios-grid.nw .entity-card:hover {
  border-color: rgba(245,196,94,0.65);
  box-shadow: 0 12px 32px rgba(245,196,94,0.18), 0 4px 12px rgba(0,0,0,0.4);
}
.portfolios-grid.nw .entity-card .ec-title {
  background: linear-gradient(120deg, #fff 30%, #f5d98e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Net-worth summary card: big current-value headline + today's move badge. */
.nw-summary-card { border-color: rgba(245,196,94,0.22); }
.nw-summary-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.nw-headline .label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 6px;
}
.nw-value {
  font-size: 34px; font-weight: 800; line-height: 1.05; letter-spacing: -0.01em;
  background: linear-gradient(120deg, #fff 35%, #f5d98e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nw-summary-head .ec-day-badge { align-self: center; }
.nw-day-val { font-weight: 700; }
.nw-summary-card .stat-grid { margin-bottom: 0; }
/* Exact net worth under the rounded headline — grey, like a stat tile's sub. */
.nw-exact {
  margin-top: 6px; font-size: 13px; color: var(--text-dim);
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
}
.nw-exact:empty { display: none; }
.entity-card .ec-exact { font-size: 12px; color: var(--text-dim); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* Fund cell: name on top + a small plan/option tag underneath. */
.mf-scheme { display: inline-flex; flex-direction: column; gap: 2px; min-width: 0; }
.mf-scheme .mf-name { font-weight: 600; white-space: normal; }
.mf-scheme .mf-tag {
  font-size: 10px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}
.holdings td.sym .mf-scheme { vertical-align: top; }

/* Chosen-scheme confirmation block inside the Add Fund modal. */
.chosen-scheme {
  background: var(--bg-elev); border: 1px solid var(--border-hi);
  border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px;
}
.chosen-scheme .cs-line { font-size: 13px; }
.chosen-scheme .cs-meta { color: var(--text-dim); font-size: 11px; }
.chosen-scheme .cs-nav { font-size: 12px; margin-top: 2px; }

/* ---------- Stat grid ---------- */
.stat-grid {
  display: grid; gap: var(--grid-gap);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 22px;
}
.stat {
  background: linear-gradient(180deg, var(--bg-card) 0%, #0d1219 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat::after {
  content: ''; position: absolute; inset: -1px;
  background: linear-gradient(135deg, transparent 60%, rgba(93,214,163,0.06));
  pointer-events: none; border-radius: var(--radius);
}
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 10px; }
.stat .value-row {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.stat .pct {
  font-size: 16px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px;
  background: rgba(255,255,255,0.04);
}
.stat.pos .value, .stat.pos .pct { color: var(--green); }
.stat.neg .value, .stat.neg .pct { color: var(--red); }
.stat.pos .pct { background: var(--green-soft); }
.stat.neg .pct { background: var(--red-soft); }
.stat .sub { margin-top: 6px; font-size: 12px; color: var(--text-dim); }
.stat.compact .value { font-size: 20px; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.card-head h2 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: 0.01em; }
.muted { color: var(--text-dim); }
.muted.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- 2-col ---------- */
.two-col {
  display: grid; gap: var(--grid-gap);
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  margin-bottom: 22px;
}
.two-col .card { margin-bottom: 0; }

/* ---------- Chart wrappers ---------- */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 380px; }

/* ---------- Bare section (heading + content, no card chrome) ---------- */
/* Used when a section needs to read as its own thing rather than be lumped in
   with the "Analysis"-style data cards below it. Currently the Portfolios
   block uses this — the portfolio cards inside carry their own visual weight
   via the purple accent so they don't need an outer container. */
.section-bare { margin-bottom: 22px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
  padding: 0 2px;
}
.section-head h2 {
  font-size: 15px; margin: 0; font-weight: 600;
  letter-spacing: 0.01em;
}

/* ---------- Users grid ---------- */
.users-grid, .portfolios-grid {
  display: grid; gap: var(--grid-gap);
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.entity-card {
  background: linear-gradient(160deg, var(--bg-card-hi), #0d121b);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
  position: relative; overflow: hidden;
}
.entity-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hi);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* Portfolio cards get the same purple framing as the Overall chip — different
   enough from the dark "analysis" cards beneath that you can't mistake the
   two regions, but consistent with the rest of the portfolio-domain palette. */
.portfolios-grid .entity-card {
  background: linear-gradient(160deg, rgba(192, 132, 252, 0.07) 0%, #11161f 60%);
  border-color: rgba(192, 132, 252, 0.30);
  box-shadow: 0 1px 0 rgba(192, 132, 252, 0.06), 0 6px 20px rgba(0,0,0,0.35);
}
.portfolios-grid .entity-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent-3), rgba(192, 132, 252, 0.2));
  opacity: 0.85;
}
.portfolios-grid .entity-card:hover {
  border-color: rgba(192, 132, 252, 0.65);
  box-shadow: 0 12px 32px rgba(192, 132, 252, 0.18), 0 4px 12px rgba(0,0,0,0.4);
}
.portfolios-grid .entity-card .ec-title {
  background: linear-gradient(120deg, #fff 30%, #d8b4fe 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.entity-card .ec-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.entity-card .ec-meta { font-size: 12px; color: var(--text-dim); margin-bottom: 14px; }
.entity-card .ec-value-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.entity-card .ec-value { font-size: 22px; font-weight: 700; }
.entity-card .ec-day { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.entity-card .ec-pnl { font-size: 13px; margin-top: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.entity-card .ec-pnl-row { display: flex; gap: 6px; align-items: baseline; }
.entity-card .pill {
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--green-soft); color: var(--green);
}
.entity-card .pill.neg { background: var(--red-soft); color: var(--red); }
.entity-card .pill.tiny { font-size: 10px; padding: 2px 6px; }
.entity-card .ec-foot { font-size: 11px; color: var(--muted); margin-top: 14px; display: flex; gap: 12px; flex-wrap: wrap; }

/* Day-change badge — large + colored — glanceable */
.ec-day-badge {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 6px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 700;
  margin-top: 10px;
}
.ec-day-badge .lbl { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; opacity: 0.75; }
.ec-day-badge.pos { background: var(--green-soft); color: var(--green); border: 1px solid rgba(43,209,126,0.35); }
.ec-day-badge.neg { background: var(--red-soft);   color: var(--red);   border: 1px solid rgba(255,93,108,0.35); }
.ec-day-badge.flat { background: var(--bg-elev); color: var(--text-dim); border: 1px solid var(--border); }

/* ---------- Holdings table ---------- */
.table-wrap { overflow-x: auto; }
table.holdings {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.holdings th, .holdings td {
  padding: 12px 10px; border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap;
}
.holdings th {
  font-weight: 500; color: var(--text-dim); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.holdings td.r, .holdings th.r { text-align: right; font-variant-numeric: tabular-nums; }
.holdings tr.row { cursor: pointer; transition: background .1s ease; }
.holdings tr.row:hover { background: var(--bg-card-hi); }

/* Sortable column headers */
.holdings th.sortable { cursor: pointer; user-select: none; position: relative; }
.holdings th.sortable:hover { color: var(--text); }
.holdings th.sortable .sort-ind {
  display: inline-block; width: 0; height: 0; margin-left: 4px;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  vertical-align: middle; opacity: 0.3;
}
.holdings th.sortable.sort-asc .sort-ind {
  border-bottom: 5px solid var(--accent); opacity: 1;
}
.holdings th.sortable.sort-desc .sort-ind {
  border-top: 5px solid var(--accent); opacity: 1;
}
.holdings th.sortable.sort-asc, .holdings th.sortable.sort-desc { color: var(--text); }
.holdings .sym { font-weight: 600; }
.holdings .ex { font-size: 10px; color: var(--muted); margin-left: 6px; }
.pos-num { color: var(--green); }
.neg-num { color: var(--red); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 8px;
  width: 28px; height: 28px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-hi); background: var(--bg-card-hi); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }
.icon-btn.accent:hover { color: var(--accent); border-color: var(--accent); }

/* Dual value (price + pct) in a single cell */
.dual { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.dual .pct { font-size: 11px; opacity: 0.85; }

/* Collapsible analysis sub-card */
.card.collapsible { padding-top: 16px; }
.sub-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.sub-card h3 { font-size: 13px; font-weight: 600; margin: 0 0 12px; color: var(--text-dim); }

/* Autocomplete dropdown */
.suggest-wrap { position: relative; }
.suggest-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
  background: var(--bg-card); border: 1px solid var(--border-hi);
  border-radius: 8px; margin-top: 4px;
  max-height: 240px; overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.suggest-item {
  padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item.active { background: var(--bg-card-hi); }
.suggest-item .si-main { display: flex; flex-direction: column; min-width: 0; }
.suggest-item .si-ticker { font-weight: 600; font-size: 13px; }
.suggest-item .si-name { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item .si-ex { font-size: 10px; color: var(--muted); border: 1px solid var(--border); padding: 2px 6px; border-radius: 4px; }
.suggest-empty { padding: 12px; color: var(--text-dim); font-size: 12px; text-align: center; }

/* Daily Movers card */
.movers-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.movers-col {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.movers-col h3 {
  font-size: 12px; font-weight: 600; margin: 0 0 10px;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim);
  display: flex; align-items: center; gap: 8px;
}
.movers-col h3 .accent-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.movers-col.gain h3 .accent-dot { background: var(--green); box-shadow: 0 0 6px rgba(43,209,126,0.6); }
.movers-col.lose h3 .accent-dot { background: var(--red);   box-shadow: 0 0 6px rgba(255,93,108,0.6); }
.movers-col.big  h3 .accent-dot { background: var(--accent-2); box-shadow: 0 0 6px rgba(78,164,255,0.6); }
.movers-list { display: flex; flex-direction: column; gap: 6px; }
.mover-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  padding: 6px 8px; border-radius: 8px; font-size: 13px;
  transition: background .1s ease;
}
.mover-row:hover { background: var(--bg-card-hi); }
.mover-row .m-sym { font-weight: 600; }
.mover-row .m-ctx { font-size: 10px; color: var(--muted); display: block; font-weight: 500; }
.mover-row .m-price { font-variant-numeric: tabular-nums; color: var(--text-dim); text-align: right; }
.mover-row .m-pct {
  font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 2px 8px; border-radius: 999px; font-size: 12px;
}
.mover-row .m-pct.pos { background: var(--green-soft); color: var(--green); }
.mover-row .m-pct.neg { background: var(--red-soft);   color: var(--red); }
.movers-empty { font-size: 12px; color: var(--text-dim); padding: 6px 8px; }

/* Stale LTP indicator — shown when live fetch failed and we're serving
   the last-known price from the persistent cache. */
.stale-flag {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  opacity: 0.75;
  cursor: help;
  color: var(--warn);
}

/* Unresolved holding badge */
.sym-warn {
  display: inline-block; font-size: 10px; font-weight: 600;
  background: rgba(245,196,94,0.15); color: var(--warn);
  border: 1px solid rgba(245,196,94,0.4);
  padding: 1px 6px; border-radius: 4px; margin-left: 6px;
}

/* Sell preview block */
.sell-preview {
  background: var(--bg-elev);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  padding: 12px 14px;
  display: grid; gap: 6px;
}
.sell-preview .row { display: flex; justify-content: space-between; font-size: 13px; }
.sell-preview .row .lbl { color: var(--text-dim); }
.sell-preview .pnl-row { font-size: 15px; font-weight: 700; padding-top: 6px; border-top: 1px dashed var(--border); margin-top: 4px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,7,12,0.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border-hi);
  border-radius: var(--radius); width: min(440px, 92vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 20px; display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.field input, .field select {
  background: var(--bg-elev); border: 1px solid var(--border-hi);
  color: var(--text); padding: 10px 12px; border-radius: 8px; font-size: 14px;
  font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.help { font-size: 11px; color: var(--muted); }

/* ---------- In-modal toggle switch (e.g. Add Holding → target/stop-loss) ---------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.switch-text { display: grid; gap: 3px; }
.switch-title { font-size: 13px; color: var(--text); }
.switch { position: relative; flex: 0 0 auto; width: 42px; height: 24px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch-slider { position: absolute; inset: 0; border-radius: 999px; background: var(--border-hi); transition: background .16s ease; pointer-events: none; }
.switch-slider::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .16s ease;
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.alert-fields { display: grid; gap: 12px; margin-top: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card-hi); border: 1px solid var(--border-hi);
  padding: 10px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow); z-index: 200;
}

/* ---------- Login page ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-shell { width: min(420px, 100%); }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo { width: 56px; height: 56px; margin-bottom: 14px; }
.login-brand h1 {
  font-size: 30px; margin: 0 0 6px; letter-spacing: 0.01em;
  background: linear-gradient(120deg, #5dd6a3 0%, #4ea4ff 50%, #c084fc 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.login-brand .muted { font-size: 13px; }
.login-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 12px 16px; font-size: 14px;
  background: linear-gradient(135deg, #fff, #ececec); color: #1a1a1a;
  border: none;
}
.login-btn:hover { filter: brightness(1.04); }
.login-btn svg { display: block; }
.login-footer { font-size: 11px; margin-top: 16px; text-align: center; }
.login-error {
  background: var(--red-soft); color: var(--red);
  border: 1px solid rgba(255,93,108,0.4);
  padding: 10px 14px; border-radius: 10px;
  font-size: 13px; margin-bottom: 16px;
}
.login-notconfigured {
  background: var(--bg-elev); border: 1px dashed var(--border-hi);
  border-radius: 10px; padding: 16px;
  font-size: 13px; color: var(--text-dim);
}
.login-notconfigured h3 { color: var(--warn); font-size: 14px; margin: 0 0 8px; }
.login-notconfigured ul { margin: 8px 0; padding-left: 20px; }
.login-notconfigured code { background: var(--bg-card-hi); padding: 1px 6px; border-radius: 4px; color: var(--accent); font-size: 12px; }

/* ---------- Loader overlay ---------- */
/* Shown while route() is fetching/rendering — blocks the main content so
   the user can't double-fire navigation. The topbar stays interactive on
   purpose: brand-click and tab-click should still respond even if the
   previous render hasn't finished. */
.loader {
  position: fixed; inset: 56px 0 0 0;   /* below topbar */
  background: rgba(7, 9, 13, 0.45);
  backdrop-filter: blur(2px);
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
}
.loader.hidden { display: none; }
.spinner {
  width: 38px; height: 38px;
  border: 3px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  border-radius: 50%;
  animation: spinner-spin .85s linear infinite;
}
@keyframes spinner-spin { to { transform: rotate(360deg); } }
.toast.err { border-color: var(--red); color: var(--red); }
.toast.ok { border-color: var(--green); color: var(--green); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 40px 20px; color: var(--text-dim);
}
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 6px; }

/* ============================================================
   Responsive — tablet & mobile
   ============================================================ */

/* --- Tablet (max 900px) --- */
@media (max-width: 900px) {
  main { padding: 18px 18px 64px; }
  .topbar { padding: 12px 18px; }
  .hero h1 { font-size: 22px; }
}

/* --- Mobile (max 720px): big restructure --- */
@media (max-width: 720px) {
  /* Topbar: brand (left) + dot/icon controls (right) share row 1. Row 2 is a
     dedicated full-width band for the Stocks⇄MF toggle stacked over the NIFTY
     pill — keeping both "at the top" with finger-sized tap targets and no
     horizontal overflow on a narrow phone. */
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand controls"
      "center center";
    padding: 10px 14px;
    gap: 8px 10px;
  }
  .brand {
    grid-area: brand;
    justify-self: start;
    padding: 2px 0;
  }
  .topbar-center {
    grid-area: center;
    flex-direction: column; align-items: stretch;
    gap: 8px; width: 100%;
  }
  .topbar-center .section-toggle { display: flex; width: 100%; }
  .topbar-center .section-toggle .seg { flex: 1; text-align: center; }
  .index-bar { justify-content: center; }
  .topbar-right { grid-area: controls; gap: 6px; justify-self: end; }
  .topbar .btn-text { display: none; }    /* icon-only controls on mobile */
  .topbar .btn { padding: 8px 10px; }
  .brand-name { font-size: 13px; }
  .ix-item { padding: 4px 12px; font-size: 12px; }
  .ix-item .ix-price { font-size: 13px; }

  main { padding: 12px 12px 64px; }

  /* --- Tag-in-focus banner: compact; the way back spans the width. --- */
  .tag-focus { margin: -2px 0 12px; padding: 8px 10px; gap: 8px; }
  .tag-focus-label { font-size: 10px; }
  .tag-focus-note { font-size: 11px; }
  .tag-focus .btn { width: 100%; }
  .nw-exact { font-size: 12px; margin-top: 4px; }
  .entity-card .ec-exact { font-size: 10.5px; }
  .holdings td.sym .sym-cell { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
  .tag-chips { margin-top: 0; }

  /* --- Hero compact: title row + kebab beside it --- */
  .hero {
    gap: 8px;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    margin-bottom: 14px;
  }
  .hero h1 { font-size: 18px; }
  .hero .muted { font-size: 11px; }
  .hero-title { flex: 1; min-width: 0; }
  .hero-actions { flex-shrink: 0; width: auto; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .back-btn { width: 32px; height: 32px; font-size: 15px; }
  .section-toggle .seg { padding: 6px 9px; font-size: 11px; }

  /* --- User tabs: hide "+ Add User" on mobile entirely. Setting up new
       users is a desktop action; mobile users live in the daily-view. --- */
  .user-tabs-bar {
    grid-template-columns: 1fr;
    gap: 8px; padding-bottom: 8px;
    margin-bottom: 14px;
  }
  #add-user-btn { display: none; }
  .user-tab { min-width: 108px; padding: 7px 11px; }
  .user-tab .tab-name { font-size: 12.5px; }
  .user-tab .tab-sub { font-size: 10.5px; }

  /* --- Stat tiles: 2-up grid on mobile + tighter typography so 6 tiles
       become 3 rows instead of 6. All info preserved, half the height. --- */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat::after { display: none; }   /* drop the inner gradient sheen — frees up paint */
  .stat .label { font-size: 9.5px; margin-bottom: 4px; letter-spacing: 0.06em; }
  .stat .value-row { gap: 6px; flex-wrap: wrap; }
  .stat .value { font-size: 16px; }
  .stat .pct { font-size: 11px; padding: 1px 6px; }
  .stat .sub { font-size: 10px; margin-top: 2px; }

  /* --- Portfolio + user cards: compress vertical paddings + font sizes. --- */
  .portfolios-grid, .users-grid { grid-template-columns: 1fr; gap: 10px; }
  .entity-card { padding: 12px 14px; }
  .portfolios-grid .entity-card::before { width: 2.5px; }   /* slimmer side stripe */
  .entity-card .ec-title { font-size: 14px; margin-bottom: 2px; }
  .entity-card .ec-meta { font-size: 10.5px; margin-bottom: 8px; }
  .entity-card .ec-value-row { gap: 8px; }
  .entity-card .ec-value { font-size: 17px; }
  .entity-card .pill { font-size: 11px; padding: 2px 7px; }
  .entity-card .ec-day-badge {
    margin-top: 6px;
    padding: 4px 9px;
    font-size: 12px;
    gap: 4px;
  }
  .entity-card .ec-day-badge .lbl { font-size: 9px; letter-spacing: 0.06em; }
  .entity-card .ec-pnl { gap: 4px; margin-top: 6px; }
  .entity-card .ec-pnl-row { font-size: 11.5px; gap: 5px; }
  .entity-card .pill.tiny { font-size: 9.5px; padding: 1px 5px; }
  .entity-card .ec-foot { font-size: 10px; gap: 10px; margin-top: 8px; }

  /* --- Daily Movers: 1-col stack, denser rows. --- */
  .movers-grid { grid-template-columns: 1fr; gap: 8px; }
  .movers-col { padding: 8px 10px; }
  .movers-col h3 { font-size: 10.5px; margin-bottom: 6px; }
  .mover-row { padding: 4px 5px; font-size: 11.5px; gap: 8px; }
  .mover-row .m-ctx { font-size: 9px; }
  .mover-row .m-price { font-size: 11px; }
  .mover-row .m-pct { font-size: 11px; padding: 1px 6px; }

  .two-col { grid-template-columns: 1fr; gap: 10px; }
  .sub-card { padding: 10px 12px; }
  .sub-card h3 { font-size: 11.5px; margin-bottom: 8px; }

  /* --- Cards: tighter padding so the same info fits in less screen. --- */
  .card { padding: 12px 12px; margin-bottom: 12px; }
  .card-head { flex-direction: column; align-items: flex-start; gap: 2px; margin-bottom: 10px; }
  .card-head h2 { font-size: 13px; }
  .section-bare { margin-bottom: 14px; }
  .section-head { margin-bottom: 10px; }
  .section-head h2 { font-size: 13px; }

  /* --- Charts: a bit shorter on mobile so the page above stays scannable. --- */
  .chart-wrap { height: 220px; }
  .chart-wrap.tall { height: 280px; }

  /* News rows already mobile-aware, just tighten paddings. */
  .news-row { padding: 8px 10px; gap: 3px 8px; }
  .news-row .nr-date { font-size: 12px; }
  .news-row .nr-purpose { font-size: 12px; }

  /* --- Tables → card-per-row pattern --- */
  /* Header row becomes a horizontal scrolling chip bar so sort stays accessible. */
  table.holdings { display: block; }
  table.holdings thead {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    scrollbar-width: thin;
  }
  table.holdings thead::-webkit-scrollbar { height: 4px; }
  table.holdings thead tr {
    display: inline-flex;
    gap: 6px;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
  }
  table.holdings thead th {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 10px;
    background: var(--bg-card);
    color: var(--text-dim);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: left;
    white-space: nowrap;
  }
  table.holdings thead th.sortable.sort-asc,
  table.holdings thead th.sortable.sort-desc {
    background: var(--bg-card-hi);
    border-color: var(--accent);
    color: var(--text);
  }
  /* Suppress the empty action-column header on mobile (no sort target) */
  table.holdings thead th:not(.sortable) { display: none; }
  table.holdings tbody { display: block; }
  table.holdings tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    background: var(--bg-card-hi);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  table.holdings tr.row { cursor: pointer; }
  table.holdings td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
    padding: 1px 0;
    text-align: left !important;
    white-space: normal;
    font-size: 11.5px;
    gap: 6px;
  }
  /* Each cell gets its label rendered before the value */
  table.holdings td::before {
    content: attr(data-label);
    color: var(--text-dim);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
  }
  /* Cells with empty data-label hide the label entirely */
  table.holdings td[data-label=""]::before { content: none; }
  /* The "sym" cell spans both columns and sits at the top of the card */
  table.holdings td.sym {
    grid-column: 1 / -1;
    font-size: 13px;
    font-weight: 700;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
    justify-content: flex-start;
    gap: 8px;
  }
  table.holdings td.sym .ex { font-size: 9.5px; margin-left: 4px; }
  /* The action cell (data-label="") also spans both columns and sits at bottom */
  table.holdings td[data-label=""]:last-child {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding-top: 5px;
    margin-top: 2px;
    border-top: 1px solid var(--border);
  }
  /* Dual values stay compact */
  .dual { align-items: flex-end; }
  .dual .pct { font-size: 10px; }

  /* --- Modal tightening --- */
  .modal { width: 95vw; max-width: 95vw; border-radius: 12px; }
  .modal-body { padding: 16px; gap: 10px; }
  .field input, .field select { padding: 10px; font-size: 14px; }
  .modal-actions .btn { flex: 1; }
}

/* --- Very small (max 380px) — single-column stat tiles, even tighter --- */
@media (max-width: 380px) {
  .topbar { padding: 8px 10px; gap: 4px 8px; }
  main { padding: 10px 10px 64px; }
  .brand-name { font-size: 12px; }
  /* Below 380 we run out of room for 2-col tiles — back to one column. */
  .stat-grid { grid-template-columns: 1fr; }
  .stat .value { font-size: 18px; }
  .user-tab { min-width: 100px; padding: 6px 9px; }
  .entity-card { padding: 10px 12px; }
  .entity-card .ec-value { font-size: 16px; }
  table.holdings tr { padding: 10px; }
  table.holdings td { font-size: 11px; }
}

/* ---------- Alerts manager ---------- */
.alerts-view { max-width: 720px; margin: 0 auto; }
.alerts-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.alerts-head h2 { font-size: 18px; margin: 0; font-weight: 600; }
.alerts-card { padding: 16px 18px; margin-bottom: 16px; }
.alerts-card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); margin: 0 0 12px; font-weight: 600; }
#alerts-form { display: grid; gap: 12px; }
#alerts-form .btn.primary { justify-self: start; margin-top: 4px; }
#al-scope { display: grid; gap: 12px; }
.alert-row { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.alert-row:first-child { border-top: none; }
.alert-main { min-width: 0; }
.alert-label { font-size: 14px; font-weight: 600; }
.alert-cond { font-size: 12px; margin-top: 2px; }
.alert-actions { display: flex; gap: 8px; flex-shrink: 0; }
.alerts-health { font-size: 13px; }

/* --- Transaction lots + import (XIRR feature) --- */
/* Wider modal so many transactions get room; header stays put while the list scrolls. */
.modal.wide { width: min(720px, 95vw); }
.lots-scroll {
  margin-top: 8px;
  max-height: min(52vh, 440px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.lots-scroll .lots-table { margin-top: 0; }
.lots-table { width: 100%; margin-top: 8px; }
.lots-table th, .lots-table td { padding: 9px 12px; }
.lots-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-card);
  box-shadow: inset 0 -1px 0 var(--border);
}
.lots-table tbody tr:last-child td { border-bottom: none; }
#modal-form textarea {
  width: 100%; box-sizing: border-box; font-family: inherit; font-size: 13px;
  padding: 8px; border-radius: 8px; resize: vertical;
}
.import-result { margin-top: 10px; font-size: 12px; color: var(--muted); max-height: 180px; overflow: auto; }
.lots-toolbar { margin-top: 10px; display: flex; justify-content: space-between; align-items: center; }
.lots-count { font-size: 12px; }
