/* ============================================================================
   Family Wealth — design system ported from Zerodha Kite / Coin
   ========================================================================== */

:root {
  /* brand */
  --blue: #387ed1;
  --blue-dark: #2f6fbb;
  --blue-tint: #eef5fd;
  --green: #4caf50;
  --green-tint: #eef8ef;
  --red: #ff5722;
  --red-tint: #fdf0ec;
  --orange: #f5a623;
  --purple: #8e63d1;

  /* surfaces */
  --bg: #f9f9f9;
  --surface: #ffffff;
  --surface-2: #fbfbfb;
  --surface-3: #f5f5f5;

  /* ink */
  --ink: #444444;
  --ink-strong: #303030;
  --ink-mute: #9b9b9b;
  --ink-faint: #b9b9b9;

  /* lines */
  --line: #eaeaea;
  --line-soft: #f4f4f4;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 2px 10px rgba(0, 0, 0, .07);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .13);

  --radius: 3px;
  --radius-lg: 6px;
  --header-h: 56px;
  --nav-h: 58px;
  --maxw: 1180px;
}

[data-theme="dark"] {
  --blue: #4184f3;
  --blue-dark: #5a95f5;
  --blue-tint: #1b2942;
  --green: #4caf50;
  --green-tint: #16291a;
  --red: #ff5722;
  --red-tint: #2c1913;

  --bg: #191919;
  --surface: #212121;
  --surface-2: #262626;
  --surface-3: #2d2d2d;

  --ink: #cfcfcf;
  --ink-strong: #ededed;
  --ink-mute: #8a8a8a;
  --ink-faint: #6d6d6d;

  --line: #333333;
  --line-soft: #2a2a2a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 2px 10px rgba(0, 0, 0, .5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mo-extra { display: none; }  /* only surfaces in the collapsed mobile row */
.dec { font-size: .84em; opacity: .62; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.mute { color: var(--ink-mute); }
.hide { display: none !important; }

/* ============================ screens ==================================== */

.screen { display: none; }
.screen.active { display: block; }

/* ---------------------------- 1. lock screen ---------------------------- */

#screen-lock.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(56, 126, 209, .10), transparent 62%),
    var(--bg);
  padding: 24px 16px;
}

.lock-card {
  width: 100%;
  max-width: 336px;
  text-align: center;
}

.lock-logo {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  padding: 8px;
  object-fit: contain;
}

.lock-title {
  margin: 18px 0 2px;
  font-size: 21px;
  font-weight: 600;
  color: var(--ink-strong);
  letter-spacing: -.2px;
}

.lock-sub {
  margin: 0 0 26px;
  font-size: 13px;
  color: var(--ink-mute);
}

.pin-dots {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 10px;
  height: 14px;
}

.pin-dots i {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-faint);
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

.pin-dots i.on {
  background: var(--blue);
  border-color: var(--blue);
  transform: scale(1.14);
}

.pin-msg {
  height: 18px;
  font-size: 12.5px;
  color: var(--red);
  margin-bottom: 18px;
}

.shake { animation: shake .42s cubic-bezier(.36, .07, .19, .97); }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.key {
  height: 62px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-strong);
  border-radius: var(--radius-lg);
  font-size: 21px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-sm);
  transition: background .12s ease, transform .08s ease, border-color .12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.key:hover { background: var(--surface-3); }
.key:active { transform: scale(.96); background: var(--blue-tint); border-color: var(--blue); }
.key.ghost { background: transparent; border-color: transparent; box-shadow: none; font-size: 17px; color: var(--ink-mute); }
.key.ghost:hover { background: var(--surface-3); }

.lock-hint {
  margin-top: 22px;
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: .2px;
}

/* -------------------------- 2. profile picker --------------------------- */

#screen-profiles.active {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.pf-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 16px 56px;
}

.pf-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 34px;
}

.pf-brand img { width: 34px; height: 34px; }
.pf-brand span { font-size: 16px; font-weight: 600; color: var(--ink-strong); letter-spacing: -.2px; }

.pf-head { text-align: center; margin-bottom: 30px; }
.pf-head h2 { margin: 0 0 4px; font-size: 22px; font-weight: 600; color: var(--ink-strong); letter-spacing: -.3px; }
.pf-head p { margin: 0; font-size: 13px; color: var(--ink-mute); }

.pf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(238px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 810px;
}

.pf-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px 20px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  overflow: hidden;
}

.pf-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent);
}

.pf-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.pf-av {
  width: 62px;
  height: 62px;
  margin: 4px auto 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .5px;
  background: var(--accent);
}

.pf-name { font-size: 16px; font-weight: 600; color: var(--ink-strong); }

.pf-rel {
  font-size: 11.5px;
  color: var(--ink-mute);
  margin: 2px auto 14px;
  max-width: 210px;
  min-height: 30px;
  line-height: 1.42;
}

.pf-val-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-faint); }
.pf-val { font-size: 20px; font-weight: 500; color: var(--ink-strong); font-variant-numeric: tabular-nums; margin-top: 1px; }
.pf-chg { font-size: 12px; margin-top: 2px; font-variant-numeric: tabular-nums; }

.pf-meta {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line-soft);
}

.chip {
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--surface-3);
  color: var(--ink-mute);
  white-space: nowrap;
}

.pf-foot { text-align: center; font-size: 11.5px; color: var(--ink-faint); padding-bottom: 24px; }

/* ------------------------------ 3. header ------------------------------- */

.hdr {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
}

.hdr-brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.hdr-brand img { width: 28px; height: 28px; }
.hdr-brand b { font-size: 14px; font-weight: 600; color: var(--ink-strong); letter-spacing: -.1px; }

.ticker {
  display: flex;
  gap: 20px;
  overflow: hidden;
  flex: 1;
  min-width: 0;
  /* the strip is allowed to run out of room — fade the cut instead of chopping */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 34px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 34px), transparent);
}

.tk {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
  font-size: 11.5px;
}

.tk .tk-n { color: var(--ink-mute); }
.tk .tk-p { font-size: 12.5px; color: var(--ink-strong); font-variant-numeric: tabular-nums; }
.tk .tk-c { font-variant-numeric: tabular-nums; }

.hdr-right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }

.livepill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 10px 4px 8px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-mute);
  white-space: nowrap;
}

.livepill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex-shrink: 0;
}

.livepill.loading .dot { background: var(--orange); animation: pulse 1.1s infinite; }
.livepill.live .dot { background: var(--green); animation: pulse 2.4s infinite; }
.livepill.stale .dot { background: var(--ink-faint); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .28; }
}

.iconbtn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-mute);
  border-radius: var(--radius);
  transition: background .12s, color .12s, border-color .12s;
}

.iconbtn:hover { background: var(--surface-3); color: var(--ink-strong); border-color: var(--ink-faint); }
.iconbtn svg { width: 15px; height: 15px; }
.iconbtn.spin svg { animation: spin .8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.userchip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 20px;
  transition: border-color .12s, background .12s;
}

.userchip:hover { border-color: var(--ink-faint); background: var(--surface-3); }

.userchip .av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  background: var(--accent, var(--blue));
}

.userchip .nm { font-size: 12.5px; color: var(--ink-strong); font-weight: 500; }
.userchip svg { width: 10px; height: 10px; color: var(--ink-faint); }

/* ------------------------------ 4. layout ------------------------------- */

.main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 18px calc(var(--nav-h) + 34px);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* summary hero — modelled on the Kite holdings summary block */

.hero {
  padding: 20px 22px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr 1.15fr;
  gap: 10px;
  align-items: stretch;
}

.hero-cell { padding-right: 22px; border-right: 1px solid var(--line-soft); }
.hero-cell:last-child { border-right: 0; padding-right: 0; }

.hero-lbl {
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-bottom: 3px;
  letter-spacing: .1px;
}

.hero-big {
  font-size: 27px;
  font-weight: 300;
  color: var(--ink-strong);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.5px;
  line-height: 1.22;
}

.hero-sub { font-size: 12px; color: var(--ink-mute); font-variant-numeric: tabular-nums; margin-top: 2px; }

.hero-split { display: flex; gap: 26px; }
.hero-split > div { flex: 1; }

.hero-mid { font-size: 19px; font-weight: 400; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }

/* allocation bar */

.alloc { padding: 15px 22px 17px; margin-bottom: 14px; }

.alloc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 11px;
}

.alloc-top h3 { margin: 0; font-size: 12.5px; font-weight: 500; color: var(--ink-strong); }
.alloc-top span { font-size: 11.5px; color: var(--ink-mute); }

.alloc-bar {
  display: flex;
  height: 9px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-3);
  gap: 2px;
}

.alloc-seg { transition: flex-grow .5s cubic-bezier(.4, 0, .2, 1), opacity .15s; cursor: pointer; }
.alloc-seg:hover { opacity: .78; }

.alloc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 13px;
}

.lg { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.lg i { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.lg .lg-n { color: var(--ink-mute); }
.lg .lg-v { color: var(--ink-strong); font-variant-numeric: tabular-nums; }
.lg .lg-p { color: var(--ink-faint); font-variant-numeric: tabular-nums; font-size: 11px; }

/* section toolbar */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.toolbar h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-strong);
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.toolbar h2 em { font-style: normal; font-size: 12px; color: var(--ink-mute); font-weight: 400; }

.search {
  margin-left: auto;
  position: relative;
  display: flex;
  align-items: center;
}

.search svg { position: absolute; left: 9px; width: 13px; height: 13px; color: var(--ink-faint); pointer-events: none; }

.search input {
  width: 210px;
  padding: 7px 10px 7px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--ink);
  font-family: inherit;
  outline: none;
  transition: border-color .14s, background .14s;
}

.search input:focus { border-color: var(--blue); background: var(--surface); }
.search input::placeholder { color: var(--ink-faint); }

/* per-tab stat strip */

.stats {
  display: flex;
  gap: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  flex-wrap: wrap;
}

.stat { padding-right: 26px; margin-right: 26px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.stat .s-l { font-size: 11px; color: var(--ink-mute); }
.stat .s-v { font-size: 15px; color: var(--ink-strong); font-variant-numeric: tabular-nums; font-weight: 400; }

/* ------------------------------ 5. table -------------------------------- */

.tablewrap { overflow-x: auto; }

table.hold {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* Not sticky on purpose: .tablewrap is an overflow container, so a sticky th
   would offset itself inside that box and sit on top of the first row. */
table.hold th {
  font-weight: 400;
  font-size: 11.5px;
  color: var(--ink-mute);
  text-align: right;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface);
  user-select: none;
  cursor: pointer;
}

table.hold th:first-child { text-align: left; padding-left: 16px; }
table.hold th:last-child { padding-right: 16px; }
table.hold th:hover { color: var(--ink-strong); }
table.hold th .sortmark { opacity: 0; margin-left: 3px; font-size: 9px; }
table.hold th.sorted .sortmark { opacity: 1; color: var(--blue); }

table.hold td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

table.hold td:first-child { text-align: left; padding-left: 16px; white-space: normal; }
table.hold td:last-child { padding-right: 16px; }
table.hold tbody tr { transition: background .1s; cursor: pointer; }
table.hold tbody tr:hover { background: var(--surface-2); }
table.hold tbody tr.open { background: var(--blue-tint); }
table.hold tbody tr:last-child td { border-bottom: 0; }

.inst-cell { display: flex; align-items: center; gap: 11px; }
.inst-text { min-width: 0; }
.inst-name { color: var(--ink-strong); font-size: 13px; }
.inst-sub { font-size: 11px; color: var(--ink-mute); margin-top: 1px; }

/* company mark — the monogram sits underneath and shows through whenever the
   remote image is still loading, missing, or blocked */
.ilogo {
  position: relative;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  overflow: hidden;
}

.ilogo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity .18s ease;
}

.ilogo img.on { opacity: 1; }

/* once a real logo is up, drop the tinted monogram behind it — most marks are
   transparent and would otherwise pick up the tint */
.ilogo.has-logo .mono { display: none; }

.mono {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .3px;
}

.mono.in   { background: rgba(56, 126, 209, .11); color: #387ed1; }
.mono.us   { background: rgba(123, 97, 217, .12); color: #7b61d9; }
.mono.mf   { background: rgba(245, 166, 35, .14); color: #c07d0a; }
.mono.bond { background: rgba(18, 170, 181, .13); color: #0f8f99; }

[data-theme="dark"] .mono.in   { background: rgba(65, 132, 243, .16); color: #6ba4f7; }
[data-theme="dark"] .mono.us   { background: rgba(142, 99, 209, .18); color: #a98ae0; }
[data-theme="dark"] .mono.mf   { background: rgba(245, 166, 35, .16); color: #e0a83f; }
[data-theme="dark"] .mono.bond { background: rgba(18, 170, 181, .18); color: #35c2cc; }

/* inline-block, not a flex child, so a long bond name keeps its badge on the
   same line instead of orphaning it onto the next one */
.exch {
  display: inline-block;
  margin-left: 6px;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--surface-3);
  color: var(--ink-mute);
  letter-spacing: .3px;
  font-weight: 500;
  line-height: 1.5;
  vertical-align: 1px;
  white-space: nowrap;
}

.exch.nse { background: var(--blue-tint); color: var(--blue); }
.exch.aaa { background: var(--green-tint); color: var(--green); }
.exch.sov { background: #fff4e0; color: #c8860d; }

[data-theme="dark"] .exch.sov { background: #33280f; color: var(--orange); }

.flash-up { animation: flashUp .9s ease-out; }
.flash-dn { animation: flashDn .9s ease-out; }

@keyframes flashUp {
  0% { background: rgba(76, 175, 80, .26); }
  100% { background: transparent; }
}

@keyframes flashDn {
  0% { background: rgba(255, 87, 34, .26); }
  100% { background: transparent; }
}

.ltp-live { position: relative; }
.ltp-fallback { color: var(--ink-mute); }
.ltp-fallback::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-faint);
  margin-left: 5px;
  vertical-align: 2px;
}

/* expanded detail row */

tr.detail > td {
  background: var(--surface-2);
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 14px 24px;
  padding: 14px 0 16px;
}

.detail-grid div { text-align: left; }
.detail-grid .d-l { font-size: 10.5px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .4px; }
.detail-grid .d-v { font-size: 13px; color: var(--ink-strong); font-variant-numeric: tabular-nums; margin-top: 1px; }

/* totals row */

tfoot td {
  padding: 11px 12px;
  text-align: right;
  font-size: 13px;
  color: var(--ink-strong);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

tfoot td:first-child { text-align: left; padding-left: 16px; color: var(--ink-mute); font-size: 12px; }
tfoot td:last-child { padding-right: 16px; }

.empty { padding: 46px 16px; text-align: center; color: var(--ink-mute); font-size: 13px; }

/* ---------------------------- 6. bottom nav ----------------------------- */

.bnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -1px 12px rgba(0, 0, 0, .06);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}

.bnav-in {
  max-width: var(--maxw);
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.nb {
  position: relative;
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-mute);
  font-size: 11px;
  transition: color .14s;
  padding: 0 4px;
}

.nb svg { width: 20px; height: 20px; stroke-width: 1.6; }
.nb:hover { color: var(--ink-strong); }
.nb.on { color: var(--blue); }

.nb::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 46px;
  height: 2.5px;
  background: var(--blue);
  border-radius: 0 0 3px 3px;
  transition: transform .2s cubic-bezier(.4, 0, .2, 1);
}

.nb.on::after { transform: translateX(-50%) scaleX(1); }
.nb .cnt { font-size: 9.5px; color: var(--ink-faint); }

/* ------------------------------ 7. modal -------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, .42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fade .16s ease;
}

@keyframes fade { from { opacity: 0; } }

.modal-card {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 380px;
  overflow: hidden;
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.2);
}

@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }

.modal-hd {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-strong);
}

.sw {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 18px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  text-align: left;
  transition: background .12s;
}

.sw:hover { background: var(--surface-2); }

.sw .av {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.sw .nm { font-size: 13.5px; color: var(--ink-strong); font-weight: 500; }
.sw .rl { font-size: 11.5px; color: var(--ink-mute); }
.sw .vl { margin-left: auto; text-align: right; font-size: 13px; color: var(--ink-strong); font-variant-numeric: tabular-nums; }
.sw.on { background: var(--blue-tint); }

.modal-ft { padding: 11px 18px; display: flex; justify-content: flex-end; gap: 8px; }

.btn {
  padding: 7px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  transition: background .12s;
}

.btn:hover { background: var(--surface-3); }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-dark); border-color: var(--blue-dark); }

/* ------------------------------ 8. misc --------------------------------- */

.notice {
  margin: 0 0 14px;
  padding: 11px 15px;
  border-radius: var(--radius);
  background: #fff8e6;
  border: 1px solid #f3e0b0;
  color: #8a6414;
  font-size: 12.5px;
  line-height: 1.55;
}

[data-theme="dark"] .notice { background: #2b2412; border-color: #4a3d18; color: #e0bd6a; }

.notice code {
  background: rgba(0, 0, 0, .07);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11.5px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.foot {
  text-align: center;
  font-size: 11px;
  color: var(--ink-faint);
  padding: 20px 16px 4px;
  line-height: 1.7;
}

.skel {
  display: inline-block;
  height: .85em;
  width: 62px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--line-soft) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  vertical-align: middle;
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* --------------------------- 9. responsive ------------------------------ */

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 0; padding: 16px; }
  .hero-cell { border-right: 0; padding-right: 0; padding-bottom: 13px; margin-bottom: 13px; border-bottom: 1px solid var(--line-soft); }
  .hero-cell:last-child { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }
  .hero-big { font-size: 25px; }
  .ticker { display: none; }
  .search input { width: 100%; }
  .search { width: 100%; margin-left: 0; }
  .toolbar { padding: 12px 14px; }
  .main { padding: 14px 12px calc(var(--nav-h) + 26px); }
  .stats { gap: 0; }
  .stat { padding-right: 16px; margin-right: 16px; }
  .stat .s-v { font-size: 14px; }
}

@media (max-width: 620px) {
  .hdr { padding: 0 12px; gap: 10px; }
  .hdr-brand b { display: none; }
  .livepill .txt { display: none; }
  .livepill { padding: 5px; }
  .userchip .nm { max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* table collapses into Kite-mobile style rows */
  table.hold thead { display: none; }
  table.hold, table.hold tbody, table.hold tr, table.hold td { display: block; width: 100%; }

  table.hold tbody tr {
    border-bottom: 1px solid var(--line-soft);
    padding: 11px 14px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 3px 10px;
    align-items: baseline;
  }

  table.hold tbody tr.detail { display: block; padding: 0 14px; }
  table.hold td { border: 0; padding: 0; }
  table.hold td[data-m="name"] { grid-row: 1; grid-column: 1; padding: 0; }
  table.hold td[data-m="val"] { grid-row: 1; grid-column: 2; text-align: right; font-size: 14px; color: var(--ink-strong); }
  table.hold td[data-m="qty"] { grid-row: 2; grid-column: 1; text-align: left; font-size: 11.5px; color: var(--ink-mute); }
  table.hold td[data-m="pnl"] { grid-row: 2; grid-column: 2; text-align: right; font-size: 12.5px; }
  table.hold td[data-m="ltp"] { grid-row: 3; grid-column: 1; text-align: left; font-size: 11.5px; color: var(--ink-mute); }
  table.hold td[data-m="day"] { grid-row: 3; grid-column: 2; text-align: right; font-size: 11.5px; }
  table.hold td[data-m="x"] { display: none; }

  table.hold tbody tr .inst-name { font-size: 13.5px; }
  /* line the stacked metadata up under the name, past the logo chip */
  table.hold tbody td[data-m="qty"],
  table.hold tbody td[data-m="ltp"] { padding-left: 41px; }

  tfoot { display: block; }
  tfoot tr { display: flex; justify-content: space-between; gap: 10px; }
  tfoot td { border-top: 1px solid var(--line); }
  tfoot td[data-m="x"] { display: none; }
  tfoot td[data-m="pnl"] { padding-left: 0; }

  .mo-extra { display: inline; }

  /* the four-across stat strip wraps badly on a phone — make it a clean 2×2 */
  .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; padding: 13px 14px; }
  .stat { border-right: 0; margin-right: 0; padding-right: 0; }
  .stat:nth-child(odd) { border-right: 1px solid var(--line); padding-right: 14px; }

  .pf-grid { grid-template-columns: 1fr; max-width: 400px; }
  .nb span.lbl { font-size: 10px; }
}
