/* ============================================================
   Paper Desk - design system
   Idea: graph paper and a bank passbook. Navy ink on cool paper,
   a highlighter-yellow accent, green/red only for profit and loss.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --font-display: 'Bricolage Grotesque', 'IBM Plex Sans', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --paper: #F3F6FB;
  --surface: #FFFFFF;
  --surface-2: #F7F9FD;
  --grid: #DCE4EF;
  --ink: #0F1B3D;
  --ink-2: #45516D;
  --ink-3: #6F7B95;
  --line: #D6DEEA;
  --hl: #FFD23F;
  --hl-deep: #F2C21B;
  --on-hl: #1A1500;
  --up: #0B8F63;
  --down: #D93844;
  --warn: #B87800;
  --up-bg: #E3F6EE;
  --down-bg: #FCE8EA;
  --warn-bg: #FFF3CF;
  --focus: #3556E0;
  --shadow: 0 1px 0 rgba(15, 27, 61, .04), 0 12px 28px -16px rgba(15, 27, 61, .25);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

:root[data-theme="dark"] {
  --paper: #0B1224;
  --surface: #111A31;
  --surface-2: #18223E;
  --grid: #18233F;
  --ink: #E9EEFA;
  --ink-2: #A9B5CE;
  --ink-3: #7F8CA8;
  --line: #25304D;
  --up: #2FD394;
  --down: #FF6F78;
  --warn: #F2B84B;
  --up-bg: rgba(47, 211, 148, .14);
  --down-bg: rgba(255, 111, 120, .14);
  --warn-bg: rgba(242, 184, 75, .14);
  --focus: #8DA2FF;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 14px 30px -16px rgba(0, 0, 0, .7);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0B1224;
    --surface: #111A31;
    --surface-2: #18223E;
    --grid: #18233F;
    --ink: #E9EEFA;
    --ink-2: #A9B5CE;
    --ink-3: #7F8CA8;
    --line: #25304D;
    --up: #2FD394;
    --down: #FF6F78;
    --warn: #F2B84B;
    --up-bg: rgba(47, 211, 148, .14);
    --down-bg: rgba(255, 111, 120, .14);
    --warn-bg: rgba(242, 184, 75, .14);
    --focus: #8DA2FF;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 14px 30px -16px rgba(0, 0, 0, .7);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.015em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.7rem, 1.25rem + 1.8vw, 2.3rem); }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
a { color: var(--ink); text-decoration-color: var(--hl-deep); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.lede { color: var(--ink-2); font-size: 1.0625rem; max-width: 58ch; margin: 10px 0 0; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }

.ic { width: 20px; height: 20px; flex: none; }

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px;
  border: 1px solid transparent; border-radius: 10px;
  font-weight: 600; font-size: 1rem; line-height: 1;
  text-decoration: none; white-space: nowrap;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), background-color .2s, border-color .2s;
}
.btn-primary { background: var(--hl); color: var(--on-hl); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .16); }
.btn-primary:hover { background: var(--hl-deep); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); box-shadow: none; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-3); background: var(--surface-2); }
.btn-ghost:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 16px; font-size: .92rem; }
.btn-lg { min-height: 52px; padding: 0 28px; font-size: 1.05rem; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading .btn-label { opacity: 0; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--ink-2);
  transition: background-color .2s, color .2s, transform .12s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .ic-sun { display: none; }
:root[data-theme="dark"] .icon-btn .ic-sun { display: block; }
:root[data-theme="dark"] .icon-btn .ic-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .ic-sun { display: block; }
  :root:not([data-theme="light"]) .icon-btn .ic-moon { display: none; }
}

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .9rem; font-weight: 500; margin-bottom: 6px; }
.control { position: relative; }
.field input {
  width: 100%; height: 48px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .2s, box-shadow .2s;
}
.field input::placeholder { color: var(--ink-3); }
.field input:hover { border-color: var(--ink-3); }
.field input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.field.has-error input { border-color: var(--down); }
.field-hint { margin: 6px 0 0; font-size: .85rem; color: var(--ink-3); }
.field-error { margin: 6px 0 0; font-size: .85rem; color: var(--down); font-weight: 500; }
.control .reveal {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 8px; color: var(--ink-3);
}
.control .reveal:hover { color: var(--ink); background: var(--surface-2); }
.reveal .ic-hide { display: none; }
.reveal.is-on .ic-hide { display: block; }
.reveal.is-on .ic-show { display: none; }
.control input[type="password"], .control input[data-revealed] { padding-right: 48px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.meter { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.meter i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); transition: background-color .25s; }
.meter .meter-text { flex: none; width: 64px; margin-left: 8px; font-size: .78rem; color: var(--ink-3); text-align: right; }
.meter[data-score="1"] i:nth-child(-n+1) { background: var(--down); }
.meter[data-score="2"] i:nth-child(-n+2) { background: var(--warn); }
.meter[data-score="3"] i:nth-child(-n+3) { background: var(--up); }
.meter[data-score="4"] i { background: var(--up); }

.check { margin: 4px 0 18px; }
.check label { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--ink); flex: none; }
.check.has-error label { color: var(--ink); }

.aside-link { margin: -4px 0 18px; text-align: right; font-size: .9rem; }
.switch { margin: 22px 0 0; text-align: center; color: var(--ink-2); font-size: .95rem; }

.alert {
  padding: 12px 14px; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 10px;
  font-size: .92rem; background: var(--surface-2);
  animation: drop .35s var(--ease) both;
  transition: opacity .3s, transform .3s;
}
.alert a { font-weight: 600; }
.alert-error { background: var(--down-bg); border-color: color-mix(in srgb, var(--down) 35%, transparent); }
.alert-ok { background: var(--up-bg); border-color: color-mix(in srgb, var(--up) 35%, transparent); }
.alert.is-hiding { opacity: 0; transform: translateY(-6px); }

.notice { display: flex; gap: 14px; padding: 16px; margin-bottom: 18px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.notice p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.notice-ic { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--hl); color: var(--on-hl); }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; display: block; }

/* ---------- Ruled definition lists (passbook style) ---------- */
.ruled { margin: 0; }
.ruled > div { display: grid; grid-template-columns: minmax(104px, 36%) 1fr; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.ruled > div:first-child { border-top: 0; }
.ruled dt { color: var(--ink-2); font-size: .92rem; }
.ruled dd { margin: 0; font-weight: 500; }
.ruled.tight > div { grid-template-columns: 1fr auto; align-items: baseline; gap: 12px; padding: 10px 0; }
.ruled.tight dd { text-align: right; }
.ruled.wide > div { grid-template-columns: 210px 1fr; padding: 18px 0; }
.ruled.wide dt { color: var(--ink); font-weight: 600; font-size: 1rem; }
.ruled.wide dd { font-weight: 400; color: var(--ink-2); }

/* ---------- Graph paper ---------- */
.grid-paper { position: relative; isolation: isolate; }
.grid-paper::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px; background-position: -1px -1px;
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
  mask-image: linear-gradient(to bottom, #000 55%, transparent);
}

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); }
.auth-main { display: flex; flex-direction: column; padding: 18px 20px 24px; background: var(--surface); }
.auth-top { display: flex; align-items: center; justify-content: space-between; }
.auth-card { width: 100%; max-width: 440px; margin: auto; padding: 36px 0 28px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .lede { margin: 6px 0 26px; font-size: 1rem; }
.auth-foot { margin: 0; text-align: center; font-size: .82rem; color: var(--ink-3); }
.auth-side { display: none; }
@media (min-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .auth-main { padding: 24px 48px 28px; }
  .auth-side { display: flex; align-items: center; justify-content: center; position: relative; isolation: isolate; border-left: 1px solid var(--line); padding: 48px; }
  .auth-side::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 32px 32px; background-position: -1px -1px;
  }
  .auth-side-inner { width: 100%; max-width: 400px; padding: 26px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
  .auth-side-inner h2 { margin-bottom: 8px; }
}

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 24px; padding: 22px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.side .brand { padding: 0 10px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; text-decoration: none; transition: background-color .15s, color .15s; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.is-active { background: var(--surface-2); color: var(--ink); }
.nav-link.is-active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--hl); }
.nav-link.is-soon { opacity: .6; cursor: default; }
.nav-link.is-soon:hover { background: none; color: var(--ink-2); }
.nav-link em { margin-left: auto; padding: 1px 8px; font-style: normal; font-size: .72rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-3); }
.nav-button { width: 100%; background: none; border: 0; text-align: left; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.who { display: flex; align-items: center; gap: 10px; padding: 6px 10px 10px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--hl); color: var(--on-hl); font-weight: 700; font-family: var(--font-display); }
.who-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.who-text strong { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text small { color: var(--ink-3); }
.side-theme { margin: 4px 0 0 10px; }

.topbar, .tabbar { display: none; }
.main-col { min-width: 0; }
.main { width: 100%; max-width: 1120px; padding: 34px 40px 64px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 14px 24px; margin-bottom: 24px; }
.page-head .lede { margin-top: 6px; font-size: 1rem; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: .84rem; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.pill.is-live i { background: var(--up); animation: pulse 2s ease-out infinite; }
.pill.is-warn { background: var(--warn-bg); }
.pill.is-warn i { background: var(--warn); }

/* ---------- Dashboard: live NIFTY / SENSEX prices ---------- */
.pill[hidden] { display: none; }
.idx-strip { display: flex; gap: 10px; }
.idx { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.idx-name { font-size: .72rem; font-weight: 600; letter-spacing: .05em; color: var(--ink-3); }
.idx-px { font-size: 1.2rem; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.idx-chg { font-size: .8rem; white-space: nowrap; }
.idx.is-idle .idx-px { color: var(--ink-2); }
@media (min-width: 900px) {
  .dash-head { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; }
  .dash-head .pills { justify-content: flex-end; }
}
@media (max-width: 899px) {
  .dash-head { flex-direction: column; align-items: stretch; }
  .dash-head .pills { order: 2; }
  .dash-head .idx-strip { order: 3; }
  .dash-head .idx { flex: 1 1 0; }
}

/* ---------- Passbook strip ---------- */
.passbook { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.pb-cell { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border-left: 1px solid var(--line); min-width: 0; }
.pb-cell:first-child { border-left: 0; }
.pb-label { font-size: .86rem; color: var(--ink-2); }
.pb-value { font-size: clamp(1.15rem, .9rem + 1vw, 1.65rem); font-weight: 600; letter-spacing: -.01em; overflow-wrap: anywhere; }
.pb-sub { font-size: .78rem; color: var(--ink-3); }
.pb-total { box-shadow: inset 0 -3px 0 var(--hl); }

/* ---------- Panels ---------- */
.panel { margin-bottom: 20px; padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel h2 { margin-bottom: 8px; font-size: 1.05rem; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.empty { color: var(--ink-2); }
.empty p { margin: 0 0 6px; }
.empty strong { color: var(--ink); }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.activity li:first-child { border-top: 0; }
.act-main { display: flex; flex-direction: column; min-width: 0; }
.act-main small { color: var(--ink-3); }
.act-amt { font-weight: 600; white-space: nowrap; }

/* ---------- Landing ---------- */
.land-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px clamp(16px, 4vw, 48px); }
.land-nav { display: flex; align-items: center; gap: 8px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: clamp(28px, 5vw, 64px); align-items: center; padding: clamp(28px, 6vw, 80px) clamp(16px, 4vw, 48px) clamp(40px, 7vw, 96px); }
.hero h1 { font-size: clamp(2.05rem, 1.2rem + 3.6vw, 3.6rem); line-height: 1.06; letter-spacing: -.025em; max-width: 17ch; }
.hero .lede { margin-top: 20px; font-size: 1.15rem; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

.ticket { width: 100%; max-width: 430px; justify-self: center; padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.ticket-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ticket-head strong { display: block; font-family: var(--font-display); font-size: 1.1rem; }
.ticket-head small { color: var(--ink-3); }
.tag { padding: 3px 10px; border-radius: 999px; background: var(--hl); color: var(--on-hl); font-size: .76rem; font-weight: 600; }
.spark { display: block; width: 100%; height: 88px; margin: 14px 0 6px; overflow: visible; }
.spark-line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-fill { fill: var(--grid); opacity: .55; stroke: none; }
.ticket[data-trend="up"] .spark-line { stroke: var(--up); }
.ticket[data-trend="down"] .spark-line { stroke: var(--down); }
.ticket-price { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; font-size: 2rem; font-weight: 600; }
.ticket-price [data-t-ltp] { padding: 0 6px; margin: 0 -6px; border-radius: 6px; }
.ticket-price .chg { font-size: .92rem; font-weight: 500; color: var(--ink-3); }
.ticket[data-trend="up"] .chg, .ticket[data-trend="up"] [data-t-pnl] { color: var(--up); }
.ticket[data-trend="down"] .chg, .ticket[data-trend="down"] [data-t-pnl] { color: var(--down); }
.tick-up { animation: flashUp .7s ease-out; }
.tick-down { animation: flashDown .7s ease-out; }
.ticket-note { margin: 12px 0 0; font-size: .8rem; color: var(--ink-3); }

.land-section { max-width: 980px; margin: 0 auto; padding: clamp(28px, 5vw, 64px) clamp(16px, 4vw, 48px); }
.land-section h2 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem); margin-bottom: 14px; }
.land-section .btn { margin-top: 24px; }
.tick-list { list-style: none; margin: 0; padding: 0; }
.tick-list li { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); font-size: 1.05rem; }
.tick-list li:first-child { border-top: 0; }
.tick-list .ic { color: var(--up); }
.land-foot { padding: 26px clamp(16px, 4vw, 48px); border-top: 1px solid var(--line); text-align: center; color: var(--ink-3); font-size: .85rem; }
.land-foot p { margin: 0 auto; max-width: 62ch; }

/* ---------- Motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes enter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }
@keyframes flashUp { from { background: var(--up-bg); } to { background: transparent; } }
@keyframes flashDown { from { background: var(--down-bg); } to { background: transparent; } }
.enter { animation: enter .55s var(--ease) both; }

html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }

/* ---------- Tablet and phone ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero h1 { max-width: 20ch; }
  .ruled.wide > div { grid-template-columns: 1fr; gap: 4px; padding: 16px 0; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: color-mix(in srgb, var(--paper) 90%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
  }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; color: var(--ink-3); font-size: .72rem; text-decoration: none; transition: color .15s; }
  .tab.is-active { color: var(--ink); box-shadow: inset 0 3px 0 var(--hl); font-weight: 600; }
  .tab.is-soon { opacity: .55; }
  .main { padding: 20px 16px calc(92px + env(safe-area-inset-bottom)); }
  .passbook { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pb-cell:nth-child(odd) { border-left: 0; }
  .pb-cell:nth-child(n+3) { border-top: 1px solid var(--line); }
  .pb-cell { padding: 16px; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .row-2 { grid-template-columns: minmax(0, 1fr); }
  .land-nav .btn-ghost { display: none; }
  .btn-lg { width: 100%; }
  .cta { flex-direction: column; }
  .ticket { padding: 18px; }
}

/* ---------- Funds ---------- */
.funds-top { align-items: start; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }

.capbar { margin-top: 18px; }
.capbar-track { height: 8px; overflow: hidden; border-radius: 4px; background: var(--line); }
.capbar-track i { display: block; height: 100%; border-radius: 4px; background: var(--hl-deep); transition: width .8s var(--ease); }
.capbar p { margin: 8px 0 0; font-size: .82rem; color: var(--ink-3); }

.field .amount-control input { padding-left: 34px; font-family: var(--font-mono); font-size: 1.1rem; font-weight: 500; }
.amount-control .prefix { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-family: var(--font-mono); color: var(--ink-2); pointer-events: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chip { padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: .9rem; font-weight: 500; color: var(--ink-2); transition: background-color .15s, border-color .15s, color .15s, transform .12s var(--ease); }
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip:active { transform: scale(.96); }
.chip.is-picked { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.after-line { margin: 0 0 16px; font-size: .92rem; color: var(--ink-2); }
.after-line strong { color: var(--ink); }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 0 0 12px; }
.f-item { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--ink-2); }
.f-item select, .f-item input { height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem; }
.f-item select:focus, .f-item input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.clear-link { align-self: center; font-size: .9rem; }

.statement .act-side { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.statement .act-side small { color: var(--ink-3); font-size: .78rem; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.pager-info { color: var(--ink-2); font-size: .9rem; }

@media (max-width: 560px) {
  .filters .f-item { flex: 1 1 130px; }
  .filters .f-item select, .filters .f-item input { width: 100%; }
}

/* ---------- Trading ---------- */
[hidden] { display: none !important; }
.label-like { display: block; margin-bottom: 6px; font-size: .9rem; font-weight: 500; }
.field label small { color: var(--ink-3); font-weight: 400; }

.trade { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: 20px; align-items: start; }
.trade .panel { margin-bottom: 0; }
.order-panel { position: sticky; top: 20px; }

.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); }
.seg-btn { min-height: 38px; padding: 0 20px; border-radius: 999px; font-weight: 600; font-size: .92rem; color: var(--ink-2); transition: background-color .18s var(--ease), color .18s; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-on { background: var(--ink); color: var(--paper); }
.seg-sm .seg-btn { min-height: 34px; padding: 0 16px; font-size: .88rem; }

.chain-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.spot { display: flex; align-items: baseline; gap: 10px; }
.spot strong { font-size: 1.5rem; letter-spacing: -.01em; }
.chain-meta { margin: 10px 0 12px; font-size: .88rem; color: var(--ink-2); }
.chain-meta strong { color: var(--ink); font-weight: 600; }
.chain-meta .sep { display: inline-block; width: 1px; height: 12px; margin: 0 10px; background: var(--line); vertical-align: -1px; }

.chain { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.chain-row { display: grid; grid-template-columns: 1fr 118px 1fr; align-items: stretch; border-top: 1px solid var(--line); }
.chain-row:first-child { border-top: 0; }
.chain-head { background: var(--surface-2); font-size: .8rem; font-weight: 600; color: var(--ink-2); text-align: center; }
.chain-head span { padding: 9px 6px; }
/* Full height: the table is as tall as its rows (+/-4 or +/-8 strikes), so it never needs its own scroll */
.chain-body { overflow: visible; }
.chain-empty { margin: 0; padding: 28px 16px; text-align: center; color: var(--ink-2); }
.chain-row .strike { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 0 5px; padding: 3px 4px; font-weight: 600; background: var(--surface-2); border-inline: 1px solid var(--line); font-size: .95rem; }
.chain-row .strike em { font-style: normal; font-family: var(--font-body); font-size: .68rem; font-weight: 600; padding: 0 6px; line-height: 1.5; border-radius: 999px; background: var(--hl); color: var(--on-hl); margin-top: 0; }
.chain-row.is-atm { background: color-mix(in srgb, var(--hl) 12%, transparent); }
.chain-row .px { min-height: 36px; padding: 0 10px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1rem; font-weight: 500; color: var(--ink); text-align: center; transition: background-color .12s; }
.chain-row .px:hover:not(:disabled) { background: var(--surface-2); }
.chain-row .px:active:not(:disabled) { background: var(--line); }
.chain-row .px:disabled { color: var(--ink-3); cursor: default; }
.chain-row .px.is-sel { background: var(--ink); color: var(--paper); }

.order-empty { color: var(--ink-2); }
.order-empty p { margin: 0 0 6px; }
.order-empty strong { color: var(--ink); }
.sel { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--hl); }
.sel-name { font-weight: 600; }
.sel-price { font-size: 1.15rem; font-weight: 600; }
.stepper { display: flex; align-items: stretch; }
.stepper button { width: 46px; border: 1px solid var(--line); background: var(--surface); font-size: 1.25rem; color: var(--ink); transition: background-color .12s; }
.stepper button:first-child { border-radius: 10px 0 0 10px; }
.stepper button:last-child { border-radius: 0 10px 10px 0; }
.stepper button:hover { background: var(--surface-2); }
.stepper input { text-align: center; border-radius: 0 !important; font-family: var(--font-mono); font-weight: 600; min-width: 0; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sum { margin: 4px 0 14px; }
.order-form .btn-lg { width: 100%; }
.order-form .btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.order-clear { margin-top: 8px; }
.toast { margin-bottom: 16px; }

.strip3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pos-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pos-list > .panel { grid-column: 1 / -1; }
.pos { padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); border-left: 4px solid var(--line); }
.pos-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.pos-head h3 { margin: 0; font-size: 1.05rem; }
.pos-sub { margin: 4px 0 0; font-size: .84rem; color: var(--ink-2); }
.chip-tag { margin-left: 6px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); font-size: .74rem; color: var(--ink-2); }
.pos-pnl { text-align: right; display: flex; flex-direction: column; }
.pos-pnl strong { font-size: 1.2rem; }
.pos-pnl small { font-size: .8rem; }
.pos-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.pos-grid dt { font-size: .74rem; color: var(--ink-3); }
.pos-grid dd { margin: 2px 0 0; font-weight: 500; }
.pos-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.pos-why { margin: 10px 0 0; font-size: .82rem; color: var(--warn); }
.pos:has(.pos-pnl.up) { border-left-color: var(--up); }
.pos:has(.pos-pnl.down) { border-left-color: var(--down); }
.pos .btn:disabled { opacity: .5; cursor: not-allowed; }

.dlg { width: min(420px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .45); }
.dlg::backdrop { background: rgba(8, 14, 30, .55); }
.dlg[open] { animation: dlg-in .22s var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.dlg-form { padding: 22px; }
.dlg-form h2 { margin: 0 0 4px; font-size: 1.15rem; }
.dlg-sub { margin: 0 0 16px; color: var(--ink-2); font-size: .92rem; }
.dlg-body { margin: 0 0 16px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

@media (max-width: 900px) {
  .trade { grid-template-columns: minmax(0, 1fr); }
  .order-panel { position: static; }
  .pos-list { grid-template-columns: minmax(0, 1fr); }
  .strip3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .strip3 .pb-cell:nth-child(n+3) { border-top: 0; }
  .strip3 .pb-cell:nth-child(odd) { border-left: 1px solid var(--line); }
  .strip3 .pb-cell:first-child { border-left: 0; }
}
@media (max-width: 560px) {
  .strip3 .pb-value { font-size: 1.05rem; }
  .strip3 .pb-sub { display: none; }
  .strip3 .pb-cell { padding: 14px 12px; }
  .pos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos-actions .btn { flex: 1 1 auto; }
}

/* button resets for trading controls */
.seg-btn, .chain-row .px { border: 0; background: transparent; cursor: pointer; font-family: inherit; }
.chain-row .px { font-family: var(--font-mono); }
.seg-btn.is-on, .chain-row .px.is-sel { background: var(--ink); }
.chain-row .px:hover:not(:disabled):not(.is-sel) { background: var(--surface-2); }

/* ---------- Reports and history ---------- */
a.seg-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; white-space: nowrap; }
a.seg-btn.is-on { color: var(--paper); }
.lede-sm { font-size: .85rem; color: var(--ink-3); }
.sub-h { margin: 16px 0 4px; font-size: .86rem; font-weight: 600; color: var(--ink-2); }
.sub-h:first-of-type { margin-top: 4px; }
.brk { list-style: none; margin: 0; padding: 0; }
.brk li { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.brk li:first-child { border-top: 0; }
.brk li small { grid-column: 1; color: var(--ink-3); font-size: .8rem; }
.brk li strong { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 600; }

.eq-wrap { padding: 4px 0 0; }
.eq { display: block; width: 100%; height: 220px; overflow: visible; }
.eq-zero { stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.eq-line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.eq-up .eq-line { stroke: var(--up); } .eq-up .eq-area { fill: var(--up-bg); }
.eq-down .eq-line { stroke: var(--down); } .eq-down .eq-area { fill: var(--down-bg); }
.eq-dot { fill: transparent; stroke: none; cursor: crosshair; }
.eq-dot:hover { fill: var(--ink); }

.cal-nav { display: flex; align-items: center; gap: 12px; }
.cal-nav strong { min-width: 110px; text-align: center; font-size: .95rem; }
.btn.is-off { opacity: .4; pointer-events: none; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dn { padding: 4px 0; text-align: center; font-size: .76rem; color: var(--ink-3); }
.cal-day { min-height: 62px; padding: 6px 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); display: flex; flex-direction: column; justify-content: space-between; gap: 4px; min-width: 0; }
.cal-d { font-size: .78rem; color: var(--ink-3); }
.cal-n { font-size: .78rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-day.is-up { background: color-mix(in srgb, var(--up) var(--a, 20%), var(--surface)); border-color: color-mix(in srgb, var(--up) 40%, var(--line)); }
.cal-day.is-down { background: color-mix(in srgb, var(--down) var(--a, 20%), var(--surface)); border-color: color-mix(in srgb, var(--down) 40%, var(--line)); }
.cal-day.is-up .cal-n { color: var(--up); } .cal-day.is-down .cal-n { color: var(--down); }
.cal-day.is-up .cal-d, .cal-day.is-down .cal-d { color: var(--ink-2); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th { padding: 8px 12px; text-align: left; font-size: .8rem; font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-top: 1px solid var(--line); white-space: nowrap; }
.tbl tbody tr:first-child td { border-top: 0; }
.tbl .r { text-align: right; }

.hist-sum { margin: 4px 0 8px; color: var(--ink-2); font-size: .92rem; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist-item { padding: 14px 0; border-top: 1px solid var(--line); }
.hist-item:first-child { border-top: 0; }
.hist-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.hist-top small { display: block; margin-top: 3px; color: var(--ink-3); font-size: .82rem; }
.hist-pnl { text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.hist-pnl strong { font-size: 1.05rem; }
.pend { margin-top: 3px; padding: 1px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); font-family: var(--font-body); font-size: .72rem; font-weight: 600; }
.hist-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin: 12px 0 0; }
.hist-grid dt { font-size: .72rem; color: var(--ink-3); }
.hist-grid dd { margin: 2px 0 0; font-size: .9rem; }

@media (max-width: 900px) {
  .hist-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page-head .seg { max-width: 100%; overflow-x: auto; }
}
@media (max-width: 560px) {
  .cal { gap: 4px; }
  .cal-day { min-height: 52px; padding: 5px 4px; border-radius: 8px; }
  .cal-n { font-size: .66rem; }
  .eq { height: 180px; }
  .seg-btn { padding: 0 14px; }
}

/* ---------- Admin, notifications, help ---------- */
.subtabs { display: flex; gap: 6px; margin: -8px 0 20px; overflow-x: auto; -webkit-overflow-scrolling: touch; border-bottom: 1px solid var(--line); }
.subtab { padding: 10px 14px; font-size: .92rem; font-weight: 500; color: var(--ink-2); text-decoration: none; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subtab:hover { color: var(--ink); }
.subtab.is-on { color: var(--ink); border-bottom-color: var(--hl-deep); font-weight: 600; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.tag-active { background: var(--up-bg); color: var(--up); border-color: transparent; }
.tag-pending { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.tag-blocked { background: var(--down-bg); color: var(--down); border-color: transparent; }
.muted { color: var(--ink-3); }
.f-item.grow { flex: 1 1 220px; }
.f-item.grow input { width: 100%; }
.f-item input[type="search"], .f-item input[type="text"] { height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.adjust { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.adjust .sub-h { margin: 0; }
.adjust input[type="text"], .adjust select { height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; width: 100%; }
.adjust-row { display: grid; grid-template-columns: 110px 1fr; gap: 10px; width: 100%; }
.settings-form { max-width: 520px; }
.field input[type="date"] { width: 100%; }
.badge { margin-left: auto; padding: 1px 8px; border-radius: 999px; background: var(--hl); color: var(--on-hl); font-style: normal; font-size: .72rem; font-weight: 700; }
.notes { list-style: none; margin: 0; padding: 0; }
.note { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0 14px 14px; border-top: 1px solid var(--line); border-left: 3px solid transparent; }
.note:first-child { border-top: 0; }
.note.is-new { border-left-color: var(--hl-deep); }
.note p { margin: 4px 0 0; color: var(--ink-2); font-size: .92rem; }
.note small { color: var(--ink-3); white-space: nowrap; font-size: .8rem; }
.faq details { border-top: 1px solid var(--line); padding: 4px 0; }
.faq details:first-child { border-top: 0; }
.faq summary { cursor: pointer; padding: 12px 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; font-size: 1.3rem; line-height: 1; color: var(--ink-3); transition: transform .2s var(--ease); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 0 0 14px; color: var(--ink-2); max-width: 70ch; }
.more-links li a { display: block; width: 100%; font-weight: 500; text-decoration: none; }
@media (max-width: 560px) { .note { flex-direction: column; gap: 4px; } .adjust-row { grid-template-columns: 96px 1fr; } }

/* ---------- Stop-loss and target controls ---------- */
.exits { margin: 0 0 16px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.exits-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.exits-head .label-like { margin: 0; }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--ink-2); cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--ink); }
.mini { margin: 10px 0 6px; font-size: .8rem; color: var(--ink-3); }
.exits .chips { margin: 0 0 4px; }
.exits .two-fields { margin-top: 10px; }
.exits .field { margin-bottom: 8px; }
.exits .field label { font-size: .82rem; }
.exit-sum { margin: 4px 0 0; font-size: .86rem; color: var(--ink-2); line-height: 1.5; }
.exit-sum strong { font-family: var(--font-mono); font-weight: 600; }

/* ---------- Placeholders (motion lives in motion.css) ---------- */
.sk { display: block; height: 18px; margin: 14px 12px; border-radius: 6px; background: var(--line); }
.sk-mid { margin-inline: 20px; }
.sk-row { align-items: center; }

/* ---------- Orders page ---------- */
.day-bar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin: 0 0 18px; }
.day-nav { display: flex; align-items: center; gap: 12px; }
.day-nav strong { min-width: 160px; text-align: center; font-size: .98rem; }
.day-pick { display: flex; align-items: flex-end; gap: 8px; }
.btn.is-off { opacity: .4; pointer-events: none; }

.ord-list { list-style: none; margin: 0; padding: 0; }
.ord { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 14px; row-gap: 8px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.ord:first-child { border-top: 0; }
.side-tag { display: inline-flex; align-items: center; justify-content: center; min-width: 56px; padding: 5px 10px; border-radius: 8px; font-size: .78rem; font-weight: 700; letter-spacing: .05em; }
.side-tag.is-buy { background: var(--ink); color: var(--paper); }
.side-tag.is-sell { background: var(--hl); color: var(--on-hl); }
.ord-main { display: flex; flex-direction: column; min-width: 0; }
.ord-main strong { overflow-wrap: anywhere; }
.ord-main small { margin-top: 2px; color: var(--ink-3); font-size: .82rem; }
.ord-side { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.ord-side strong { font-size: 1.05rem; }
.ord-side small { margin-top: 2px; color: var(--ink-3); font-size: .8rem; }
.ord-foot { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.ord-meta { color: var(--ink-2); font-size: .84rem; }
.ord-pl strong { font-size: 1.02rem; }
.ord-pl em { font-style: normal; font-size: .84rem; }
.ord-foot .chip-tag { margin-left: 0; }
.chip-open { border-color: color-mix(in srgb, var(--hl-deep) 55%, var(--line)); color: var(--ink); background: color-mix(in srgb, var(--hl) 22%, transparent); }
.ord-link { font-size: .86rem; }
.ord-foot .pend { margin-top: 0; }

.day-list { list-style: none; margin: 0; padding: 0; }
.day-list > li { border-top: 1px solid var(--line); }
.day-list > li:first-child { border-top: 0; }
.day { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 6px; border-radius: 10px; color: inherit; text-decoration: none; transition: background-color .15s; }
.day:hover { background: var(--surface-2); }
.day-main { display: flex; flex-direction: column; min-width: 0; }
.day-main small { margin-top: 2px; color: var(--ink-3); font-size: .84rem; }
.day-pnl { text-align: right; white-space: nowrap; }
.day-pnl strong { font-size: 1.05rem; }
.day-pnl small { color: var(--ink-3); font-size: .82rem; }

a.cal-day { color: inherit; text-decoration: none; }
a.cal-day.is-link { cursor: pointer; }
a.cal-day.is-link:hover { border-color: var(--ink-2); }
.cal-act { color: var(--ink-3); font-weight: 500; }

/* ---------- Account menu (top bar on phones and tablets) ---------- */
.top-actions { display: flex; align-items: center; gap: 8px; }
.acct { position: relative; }
.acct-btn { padding: 0; }
.avatar-sm { width: 30px; height: 30px; font-size: .85rem; }
.acct-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: min(240px, calc(100vw - 32px)); padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 44px -14px rgba(0, 0, 0, .35); }
.acct-menu[hidden] { display: none; }
.acct-who { display: flex; flex-direction: column; min-width: 0; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); line-height: 1.3; }
.acct-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-who small { color: var(--ink-3); }
.acct-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 10px; border: 0; border-radius: 10px; background: none; color: var(--ink); font: inherit; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; }
.acct-item:hover, .acct-item:focus-visible { background: var(--surface-2); }
.acct-item .ic { width: 20px; height: 20px; color: var(--ink-2); }
.acct-menu form { margin: 0; }
@keyframes acct-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) { .acct-menu:not([hidden]) { animation: acct-in .16s ease-out; transform-origin: top right; } }

.pend-short { display: none; }

/* ---------- Positions cards: full card on desktop, two rows on phones ---------- */
.pos-m, .pos-toggle, .pos-tag { display: none; }

@media (max-width: 640px) {
  /* Positions: row 1 = contract and profit or loss, row 2 = quantity, average price and live price.
     Tap a card to open the rest (stop-loss, target, Sell). */
  .pos-list { gap: 8px; }
  .pos { padding: 11px 14px 10px; border-radius: 14px; }
  .pos-head { align-items: baseline; gap: 10px; cursor: pointer; }
  .pos-left { min-width: 0; }
  .pos-head h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: .98rem; }
  .pos-tag { display: inline-block; margin-left: 0; padding: 1px 7px; font-size: .68rem; font-weight: 500; }
  .pos-sub, .pos-pnl small { display: none; }
  .pos-pnl strong { font-size: 1.02rem; white-space: nowrap; }
  .pos-m { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; margin-top: 3px; font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--ink-2); }
  .pos-m span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pos-toggle { display: inline-grid; place-items: center; width: 28px; height: 22px; padding: 0; border: 0; background: none; color: var(--ink-3); cursor: pointer; transition: transform .2s; }
  .pos.is-open .pos-toggle { transform: rotate(180deg); }
  .pos-more { display: none; margin-top: 8px; padding-top: 4px; border-top: 1px dashed var(--line); }
  .pos.is-open .pos-more { display: block; }
  .pos-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
  .pos-grid dt { font-size: .68rem; }
  .pos-grid dd { font-size: .84rem; }
  .pos-actions { gap: 8px; }
  .pos-actions .btn { min-height: 38px; }
  .pos-why { margin-top: 8px; }

  .side-tag { min-width: 42px; padding: 3px 6px; font-size: .7rem; }
  .pend-long { display: none; }
  .pend-short { display: inline; }
  .passbook.pb-compact .pb-sub { display: none; }
  .passbook.pb-compact .pb-cell { padding: 11px 14px; }
  .passbook.pb-compact .pb-value { font-size: 1.15rem; }
  .day-bar { align-items: stretch; gap: 8px; margin-bottom: 12px; }
  .day-nav { justify-content: space-between; }
  .day-nav strong { min-width: 0; font-size: .9rem; }
  .day-pick { width: 100%; }
  .day-pick .f-item { flex: 1; }
  .day-pick .f-item input { width: 100%; }
  .day-pick .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 359px) {
  .pos-m span:nth-child(2) { display: none; }
}

/* ---------- Orders: broker-style table on desktop, two-row cards on phones ---------- */
.otbl-wrap { margin: 0 -12px; overflow-x: auto; }
.otbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.otbl th { position: sticky; top: 0; padding: 9px 8px; text-align: left; font-size: .74rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.otbl th:first-child { border-top-left-radius: 8px; }
.otbl th:last-child { border-top-right-radius: 8px; }
.otbl td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.otbl tbody tr:last-child td { border-bottom: 0; }
.otbl tbody tr:hover td { background: var(--surface-2); }
.otbl .r { text-align: right; }
.otbl .o-time, .otbl .o-price, .otbl .o-val { white-space: nowrap; }
.otbl .o-time { font-size: .84rem; }
.otbl .o-name strong { font-weight: 600; white-space: nowrap; }
.otbl td small { display: block; margin-top: 2px; font-size: .74rem; color: var(--ink-3); white-space: nowrap; }
.otbl .o-pl { white-space: nowrap; }
.otbl .o-pl strong { font-size: .98rem; }
.otbl .o-pl small { font-size: .76rem; color: inherit; opacity: .85; }
.otbl .o-dash { color: var(--ink-3); }
.otbl .o-det { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; min-height: 52px; min-width: 130px; max-width: 170px; }
.otbl .o-det .chip-tag { margin-left: 0; white-space: nowrap; }
.otbl .o-det .pend { margin-top: 0; }
.otbl .o-meta { color: var(--ink-2); font-size: .82rem; }
.otbl .o-m2 { display: none; }
.otbl .side-tag { min-width: 50px; padding: 4px 8px; }
.otbl .st-short { display: none; }

@media (max-width: 1279px) {
  .otbl-wrap { margin: 0; overflow: visible; }
  .otbl, .otbl tbody { display: block; }
  .otbl thead { display: none; }
  .otbl tbody tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "side name price" "side m2 m2"; column-gap: 10px; row-gap: 3px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
  .otbl tbody tr:first-child { border-top: 0; }
  .otbl tbody tr:hover td { background: none; }
  .otbl td { padding: 0; border: 0; min-width: 0; }
  .otbl .o-time, .otbl .o-qty, .otbl .o-val, .otbl .o-pl, .otbl .o-det, .otbl .o-name small { display: none; }
  .otbl .o-side { grid-area: side; align-self: center; }
  .otbl .side-tag { min-width: 0; width: 30px; height: 30px; padding: 0; border-radius: 8px; font-size: .85rem; }
  .otbl .st-full { display: none; }
  .otbl .st-short { display: inline; }
  .otbl .o-name { grid-area: name; }
  .otbl .o-name strong { font-size: .92rem; white-space: normal; overflow-wrap: anywhere; }
  .otbl .o-price { grid-area: price; font-size: .95rem; font-weight: 600; }
  .otbl .o-m2 { grid-area: m2; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: .78rem; color: var(--ink-3); }
  .otbl .o-m2-l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .otbl .o-m2-r { flex: none; font-size: .88rem; }
  .otbl .o-m2-r em { font-style: normal; font-size: .76rem; }
  .otbl .o-open { font-weight: 600; color: var(--ink); }
  .otbl .o-dim { color: var(--ink-3); font-size: .78rem; }
}

/* Positions summary on phones: profit or loss gets the full first row, the other two share the second row */
@media (max-width: 560px) {
  .strip3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip3 .pb-cell:nth-child(n) { border-left: 0; border-top: 0; padding: 12px 14px; }
  .strip3 .pb-cell:nth-child(2) { border-left: 1px solid var(--line); }
  .strip3 .pb-total { grid-column: 1 / -1; order: -1; border-bottom: 1px solid var(--line); }
  .strip3 .pb-value { font-size: 1.15rem; white-space: nowrap; }
}

.passbook.pb-compact .pb-value { white-space: nowrap; }

/* ---------- Ledger (statement), trade history and monthly tables: table on desktop, two-row cards on phones ---------- */
:is(.ltbl, .htbl) { width: 100%; border-collapse: collapse; font-size: .92rem; }
:is(.ltbl, .htbl) th { padding: 9px 8px; text-align: left; font-size: .74rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
:is(.ltbl, .htbl) th:first-child { border-top-left-radius: 8px; }
:is(.ltbl, .htbl) th:last-child { border-top-right-radius: 8px; }
:is(.ltbl, .htbl) td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
:is(.ltbl, .htbl) tbody tr:last-child td { border-bottom: 0; }
:is(.ltbl, .htbl) tbody tr:hover td { background: var(--surface-2); }
:is(.ltbl, .htbl) .r { text-align: right; }
:is(.ltbl-wrap, .htbl-wrap) { margin: 0 -8px; overflow-x: auto; }
.ltbl .l-when, .ltbl .l-amt, .ltbl .l-bal, .htbl .h-when, .htbl .h-buy, .htbl .h-sell, .htbl .h-chg, .htbl .h-pl { white-space: nowrap; }
.ltbl .l-when, .htbl .h-when { font-size: .84rem; color: var(--ink-2); }
.ltbl td.l-note { color: var(--ink-2); font-size: .86rem; }
.ltbl .l-bal { color: var(--ink-2); }
.ltbl .l-bal-k { display: none; }
.htbl .h-name strong { font-weight: 600; white-space: nowrap; }
.htbl .h-how .chip-tag { font-size: .72rem; padding: 2px 7px; }
.htbl small { display: block; margin-top: 2px; font-size: .74rem; color: var(--ink-3); white-space: nowrap; }
.htbl .h-pl strong { display: block; font-size: .98rem; }
.htbl .h-pl .pend { display: inline-block; margin-top: 3px; white-space: normal; max-width: 96px; line-height: 1.25; text-align: right; }
.htbl .nw, .nw { white-space: nowrap; }
:is(.htbl) td, :is(.htbl) th { padding-inline: 6px; }
.htbl .chip-tag { margin-left: 0; white-space: nowrap; }
.htbl .h-m2, .mtbl .m-m2 { display: none; }
.l-when:empty::before { content: none; }

@media (max-width: 1279px) {
  .htbl-wrap { margin: 0; overflow: visible; }
  .htbl, .htbl tbody { display: block; }
  .htbl thead { display: none; }
  .htbl tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name pl" "m2 m2"; column-gap: 12px; row-gap: 4px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
  .htbl tbody tr:first-child { border-top: 0; }
  .htbl tbody tr:hover td { background: none; }
  .htbl td { padding: 0; border: 0; min-width: 0; }
  .htbl .h-when, .htbl .h-buy, .htbl .h-sell, .htbl .h-chg, .htbl .h-how, .htbl .h-name small { display: none; }
  .htbl .h-name { grid-area: name; }
  .htbl .h-name strong { font-size: .94rem; white-space: normal; overflow-wrap: anywhere; }
  .htbl .h-pl { grid-area: pl; display: flex; flex-direction: column; align-items: flex-end; }
  .htbl .h-pl strong { font-size: .95rem; white-space: nowrap; }
  .htbl .h-pl .pend { font-size: .66rem; white-space: nowrap; max-width: none; }
  .htbl .pend-long { display: none; }
  .htbl .pend-short { display: inline; }
  .htbl .h-m2 { grid-area: m2; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: .78rem; color: var(--ink-3); }
  .htbl .h-m2-l { min-width: 0; font-variant-numeric: tabular-nums; }
  .htbl .h-m2-r { flex: none; white-space: nowrap; }
}

@media (max-width: 760px) {
  .ltbl-wrap { margin: 0; overflow: visible; }
  .ltbl, .ltbl tbody { display: block; }
  .ltbl thead { display: none; }
  .ltbl tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "type amt" "when bal" "note note"; column-gap: 12px; row-gap: 3px; align-items: baseline; padding: 11px 0; border-top: 1px solid var(--line); }
  .ltbl tbody tr:first-child { border-top: 0; }
  .ltbl tbody tr:hover td { background: none; }
  .ltbl td { padding: 0; border: 0; min-width: 0; }
  .ltbl .l-type { grid-area: type; }
  .ltbl .l-type strong { font-size: .95rem; }
  .ltbl .l-amt { grid-area: amt; font-size: .95rem; }
  .ltbl .l-when { grid-area: when; font-size: .78rem; color: var(--ink-3); }
  .ltbl .l-bal { grid-area: bal; font-size: .78rem; color: var(--ink-3); }
  .ltbl .l-bal-k { display: inline; }
  .ltbl td.l-note { grid-area: note; font-size: .8rem; color: var(--ink-3); }
  .ltbl .l-note:empty { display: none; }
}

/* Monthly summary: same table on desktop, two-row cards on phones */
@media (max-width: 640px) {
  .mtbl, .mtbl tbody { display: block; }
  .mtbl thead { display: none; }
  .mtbl tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "month net" "m2 m2"; column-gap: 12px; row-gap: 3px; align-items: baseline; padding: 11px 0; border-top: 1px solid var(--line); }
  .mtbl tbody tr:first-child { border-top: 0; }
  .mtbl td { padding: 0; border: 0; }
  .mtbl td:nth-child(1) { grid-area: month; font-weight: 600; }
  .mtbl td:nth-child(2), .mtbl td:nth-child(3), .mtbl td:nth-child(4), .mtbl td:nth-child(5) { display: none; }
  .mtbl td:nth-child(6) { grid-area: net; }
  .mtbl .m-m2 { grid-area: m2; display: block; font-size: .78rem; color: var(--ink-3); text-align: left; }
}

/* Admin tables: each row becomes a small card on phones */
@media (max-width: 700px) {
  .tbl-stack, .tbl-stack tbody { display: block; }
  .tbl-stack thead { display: none; }
  .tbl-stack tbody tr { display: block; margin-bottom: 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
  .tbl-stack tbody tr:last-child { margin-bottom: 0; }
  .tbl-stack td { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 5px 0; border: 0; white-space: normal; text-align: right; }
  .tbl-stack td[data-label]::before { content: attr(data-label); font-family: var(--font-body); flex: none; color: var(--ink-3); font-size: .8rem; text-align: left; }
  .tbl-stack tbody tr td.ts-head { display: block; padding: 0 0 6px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); text-align: left; }
  .tbl-stack td.ts-head[data-label]::before { content: none; }
  .tbl-stack tbody tr td.ts-name { display: block; text-align: left; }
  .tbl-stack td.ts-name::before { content: none; }
  .tbl-stack td.ts-act { justify-content: flex-end; padding-top: 8px; }
}
