/* Phone skin ("Calm"). Everything here lives inside the phone media query, so the desktop and tablet layouts are exactly what they were.
   World: a white page, ink text, hairlines instead of cards, one green for the one main action, and green and red only for a gain and a loss.
   No aurora, no glass, no gradients, no shadows beyond the two floating bars' hairlines. The bottom bar is four plain items; search lives in the top bar.
   Selectors start with `html body` so they win over the island stylesheet, which loads later. */
@media (max-width: 760px) {
  html body { --m-solid: #FFFFFF; --m-inset: #F4F6F5; --m-line: #E3E8E5; --m-handle: rgba(15, 23, 42, .2); --m-scrim: rgba(15, 23, 42, .42); --m-accent: #0B5E3F; --m-on-accent: #FFFFFF; }
  html.dark body { --m-solid: #151F2B; --m-inset: #151F2B; --m-line: #223142; --m-handle: rgba(255, 255, 255, .25); --m-scrim: rgba(2, 6, 12, .6); --m-accent: #22C55E; --m-on-accent: #06210F; }

  html body .sb {
    --sb-canvas: #FFFFFF; --sb-sheet: #FFFFFF; --sb-sunk: #F4F6F5; --sb-sunk2: #E9EDEB; --sb-line: #E3E8E5; --sb-elev1: none; --sb-elev2: 0 1px 2px rgba(15, 23, 42, .08);
    --m-r: 16px;
    -webkit-tap-highlight-color: transparent;
  }
  html body.dark .sb, html.dark body .sb, html body .dark .sb, html body .sb.dark { --sb-canvas: #0E1620; --sb-sheet: #0E1620; --sb-sunk: #151F2B; --sb-sunk2: #1B2735; --sb-line: #223142; --sb-elev2: 0 1px 2px rgba(0, 0, 0, .5); }

  /* ---------- canvas ---------- */
  html body, html.hero-on body { background: #FFFFFF !important; }
  html.dark body, html.dark.hero-on body { background: #0E1620 !important; }
  html body .sb-app { padding: 0 16px; background: transparent; }
  html body .sb-main { padding-bottom: 96px; }
  html body main#main-content { padding-inline: 0; }

  /* ---------- top bar: search first, then alerts, add, me; flat, with one hairline ---------- */
  html body .sb-top { margin: 0 -16px; padding: 10px 16px; gap: 8px; flex-wrap: nowrap; background: var(--sb-sheet); border-bottom: 1px solid var(--sb-line); }
  html body .sb-top-title { display: none; }
  html body .sb-back { height: 44px; width: 44px; border-radius: 50%; background: transparent; border: 0; }
  html body .sb-search { flex: 1 1 auto; width: auto; min-width: 0; height: 44px; padding: 0 14px; justify-content: flex-start; gap: 10px; border-radius: 12px; background: var(--sb-sunk); border: 0; box-shadow: none; color: var(--sb-muted); font-size: 14px; }
  html body .sb-search .tx { display: inline; margin-inline-end: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  html body .sb-search kbd { display: none; }
  html body .sb-iconbtn, html body .sb-avbtn { width: 44px; height: 44px; border-radius: 50%; background: transparent; border: 0; box-shadow: none; }
  html body #sb-top-settings, html body #refresh-prices-btn { display: none; }
  html body .sb-addbtn { background: var(--m-accent); border-color: transparent; color: var(--m-on-accent); box-shadow: none; }
  html body .sb-addbtn svg { stroke-width: 2.4; }
  html body .sb-top .sb-pal { inset-inline: 16px; top: calc(100% + 6px); border-radius: var(--m-r); background: var(--m-solid); border: 1px solid var(--sb-line); box-shadow: var(--sb-elev2); }

  /* ---------- the bottom bar: four plain items on a hairline ---------- */
  html body .sb-tabbar {
    display: flex; position: fixed; inset-inline: 0; bottom: 0; margin: 0; z-index: 50; padding: 6px 8px max(8px, env(safe-area-inset-bottom)); gap: 0; align-items: stretch; border-radius: 0;
    background: var(--sb-sheet); border: 0; border-top: 1px solid var(--sb-line); box-shadow: none;
  }
  html body .sb-tabbar .sb-ri { flex: 1 1 0; min-width: 0; min-height: 52px; gap: 3px; padding: 6px 2px; border-radius: 12px; font-size: 12px; font-weight: 700; color: var(--sb-muted); background: transparent; }
  html body .sb-tabbar .sb-ri svg { width: 23px; height: 23px; stroke-width: 1.8; }
  html body .sb-tabbar .sb-ri[aria-current=page], html body .sb-tabbar .sb-ri.on, html body .sb-tabbar .sb-ri[aria-selected=true] { color: var(--sb-ink); font-weight: 900; background: transparent; box-shadow: none; }
  html body .sb-fab { display: none !important; }
  html body .sb-more { inset-inline: 8px; bottom: calc(100% + 8px); min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 10px; border-radius: var(--m-r); background: var(--m-solid); border: 1px solid var(--sb-line); box-shadow: var(--sb-elev2); }
  html body .sb-more[hidden] { display: none; }
  html body .sb-more-i { flex-direction: column; justify-content: center; gap: 6px; min-height: 72px; padding: 10px 4px; border-radius: 12px; background: var(--sb-sunk); font-size: 13px; text-align: center; }
  html body .sb-more-i svg { width: 24px; height: 24px; }

  /* ---------- sections: hairlines instead of cards ---------- */
  html body .sb-card, html body .sb-app .glass-panel, html body .isl .isl-card, html body .isl .isl-cx, html body .sb-bento > *, html body .isl .hm, html body .hw-panel {
    background: transparent !important; border: 0 !important; border-bottom: 1px solid var(--sb-line) !important; border-radius: 0 !important; box-shadow: none !important; padding: 18px 0 !important;
  }
  html body .sb-session, html body .sb-band-ctrl { background: var(--sb-sunk) !important; border: 0 !important; border-radius: 14px !important; box-shadow: none !important; }
  html body .sb-card .glass-panel, html body .sb-card .sb-box, html body .sb-lg .glass-panel .glass-panel, html body .sb-stat, html body .isl .isl-tile {
    background: var(--sb-sunk) !important; border: 0 !important; box-shadow: none !important; border-radius: 14px !important;
  }
  html body .sb h2 { font-size: 17px; font-weight: 900; letter-spacing: 0; }
  html body .sb-stat { padding: 14px 16px; }
  html body .sb-stat .k { font-size: 12px; }
  html body .sb-stat .v { font-size: 20px; }
  html body #v2-mini-summary { border-radius: 12px !important; padding: 10px 14px !important; background: var(--sb-sunk) !important; border: 0 !important; box-shadow: none !important; }

  /* ---------- the welcome: the total is just a big number on the page ---------- */
  html body .sb-welcome { display: grid; gap: 12px; padding: 18px 0 14px !important; border: 0 !important; border-radius: 0 !important; background: none !important; box-shadow: none !important; }
  html body .sb-welcome .hw-title { font-size: 18px; }
  html body .sb-welcome .hw-state { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; background: var(--sb-sunk); }
  html body .sb-welcome .hw-stats { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 14px; padding: 0; background: none; border: 0; box-shadow: none; }
  html body .sb-welcome .hw-stats > div:first-child { flex: 1 1 100%; }
  html body .sb-welcome .hw-stats .k { font-size: 12.5px; color: var(--sb-muted); }
  html body .sb-welcome .hw-stats > div:first-child .v { font-size: clamp(30px, 10vw, 42px); line-height: 1.1; letter-spacing: -.01em; }
  html body .sb-welcome .hw-stats .v { white-space: nowrap; }
  html body .sb-welcome .hw-stats > div { min-width: 0; }
  html body .sb-welcome .hw-sep { display: none; }
  html body .sb-welcome .hw-card { background: var(--sb-sunk) !important; border: 0 !important; border-radius: 16px !important; box-shadow: none !important; padding: 14px 16px 6px; }
  html body .sb-welcome .hw-card-v { display: none; }

  /* the trend card keeps its chart, on the page */
  html body .hw-grid > .sb-band { border-radius: 0; border: 0; border-bottom: 1px solid var(--sb-line); background: none; box-shadow: none; padding-inline: 0; }
  html body .sb-band .sb-tabs-s button { min-height: 32px; }
  html body .sb-band .sb-tabs-s button[aria-pressed=true] { background: var(--sb-ink); color: var(--sb-sheet); }
  html body .sb-band-ctrl { flex-wrap: wrap; justify-content: space-between; gap: 8px; }
  html body .sb-band-ctrl > * { max-width: 100%; }

  /* ---------- doors, segments, chips, buttons ---------- */
  html body .sb-door { border-radius: 0; background: none; border: 0; border-bottom: 1px solid var(--sb-line); box-shadow: none; padding-inline: 0; }
  html body .sb-door .top .sb-well, html body .sb-well { color: var(--sb-ink); background: var(--sb-sunk); box-shadow: none; }
  html body .sb-door .top .sb-well { width: 36px; height: 36px; border-radius: 50%; }
  html body .sb-door .v { font-size: 19px; }
  html body .sb-seg, html body .sb-tabs-s { border-radius: 999px; background: var(--sb-sunk); }
  html body .sb-chips button, html body .sb-pillbtn { min-height: 40px; border-radius: 999px; background: var(--sb-sunk); border: 0; }
  html body .sb-btn { height: 44px; padding: 0 18px; border-radius: 12px; background: var(--m-accent); color: var(--m-on-accent); box-shadow: none; }
  html body .sb-btn.ghost { background: var(--sb-sunk); color: var(--sb-ink); border: 0; box-shadow: none; }
  html body #toast-container { bottom: 84px !important; }

  /* ---------- the stock heat map and the sector map keep their own layouts; here they only lose their cards ---------- */
  html body .isl .hm-hero, html body .isl .hm-panel { border-radius: 14px; }

  /* ---------- lab: the head is plain text, the figures a two-by-two ---------- */
  html body .isl .lab-head, html body #strategylab-tab .sl-head { position: relative; border-radius: 0; padding: 18px 0; color: var(--sb-ink); border: 0; background: none; box-shadow: none; }
  html body .isl .lab-head .lab-title, html body #strategylab-tab .sl-title { font-size: 24px !important; font-weight: 900; color: var(--sb-ink) !important; }
  html body .isl .lab-head .lab-note, html body #strategylab-tab .sl-head p { color: var(--sb-ink2); font-size: 14px; }
  html body .isl .isl-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  html body .isl .isl-metric { padding: 14px; border-radius: 14px; background: var(--sb-sunk); border: 0; display: grid; gap: 2px; align-content: start; }
  html body .isl .isl-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  html body .isl .isl-actions .isl-bx, html body .isl .isl-bx, html body .isl .button--secondary { inline-size: 100%; justify-content: center; min-height: 48px; border-radius: 12px; background: var(--sb-sunk); border: 0; box-shadow: none; font-weight: 800; }
  html body .isl .isl-ax { border-radius: 14px; background: var(--sb-sunk); border: 0; }
  html body #strategylab-tab .sl-card { border-radius: 0; background: none; border: 0; border-bottom: 1px solid var(--sb-line); box-shadow: none; }
  html body #strategylab-tab .sl-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

  /* ---------- every inner page: the title sits in the top bar next to the back button ---------- */
  html body .sb-top:has(.sb-back:not([hidden])) .sb-top-title { display: block; position: static; inline-size: auto; block-size: auto; margin: 0; overflow: hidden; clip-path: none; flex: 1 1 auto; min-width: 0; }
  html body .sb-top:has(.sb-back:not([hidden])) .sb-crumb { display: none; }
  html body .sb-top:has(.sb-back:not([hidden])) h1 { font-size: 18px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html body .sb-top:has(.sb-back:not([hidden])) .sb-search { flex: 0 0 44px; width: 44px; padding: 0; justify-content: center; background: transparent; }
  html body .sb-top:has(.sb-back:not([hidden])) .sb-search .tx { display: none !important; }
  html body .sb-top:has(.sb-back:not([hidden])) #alerts-bell-btn, html body .sb-top:has(.sb-back:not([hidden])) .sb-avbtn { display: none; }
  html body #v2-mini-summary { margin-block-end: 14px; font-size: 13px; }

  /* ---------- fields and sliders ---------- */
  html body .sb input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), html body .sb select, html body .sb textarea {
    min-height: 48px; border-radius: 12px; background: var(--sb-sunk); border: 1px solid transparent; font-size: 16px; padding-inline: 14px; color: var(--sb-ink);
  }
  html body .sb textarea { padding-block: 12px; }
  html body .sb input:focus-visible, html body .sb select:focus-visible, html body .sb textarea:focus-visible { outline: 2px solid var(--m-accent); outline-offset: 1px; background: var(--sb-sheet); }
  html body .sb input[type=range] { accent-color: var(--m-accent); }
  html body .sb input[type=checkbox], html body .sb input[type=radio] { accent-color: var(--m-accent); inline-size: 20px; block-size: 20px; }

  /* ---------- cash card, tables, calendar bars ---------- */
  html body .sb-wcard { border-radius: 16px; border: 0; color: var(--sb-ink); background: var(--sb-sunk) !important; box-shadow: none !important; }
  html body .isl .table-root, html body .isl .table__scroll-container, html body .isl [class*=table-wrap] { border-radius: 14px; background: var(--sb-sunk); }
  html body .isl .table__header { background: var(--sb-sunk2); }
  html body .sb-mbars svg g:not(:nth-of-type(3n+1)) > text { display: none; }
  html body #pg-head { padding: 0; background: none; border: 0; box-shadow: none; }
  html body #pg-head .pg-desc { margin: 0; font-size: 14px; line-height: 1.7; color: var(--sb-ink2); }

  html body #strategylab-tab .sl-root .sl-head .sl-title, html body #strategylab-tab .sl-root .sl-head h2 { color: var(--sb-ink) !important; }
  html body #strategylab-tab .sl-root .sl-head, html body #strategylab-tab .sl-root .sl-head * { text-shadow: none; }
  html body #strategylab-tab .sl-root .sl-head p, html body #strategylab-tab .sl-root .sl-head .sl-sub { color: var(--sb-ink2) !important; }

  /* ---------- the rest of the pages: KPI tiles, table frames, empty states, signal rows and notes lose their frames ---------- */
  html body .pg-kpi, html body .isl .sg-hl-card, html body .isl .isl-empty, html body #strategylab-tab .sl-msg, html body #strategylab-tab .sl-disclaimer {
    background: var(--sb-sunk) !important; border: 0 !important; border-radius: 14px !important; box-shadow: none !important; background-image: none !important;
  }
  html body .isl .isl-table-wrap, html body .isl .table-root, html body .isl .table__scroll-container { border: 0 !important; border-radius: 14px !important; box-shadow: none !important; background: var(--sb-sunk) !important; }
  html body .isl .sg-row { background: none !important; border: 0 !important; border-bottom: 1px solid var(--sb-line) !important; border-radius: 0 !important; box-shadow: none !important; padding-inline: 0 !important; }
  html body .sb-lg .sb-box, html body .sb-lg .sb-well-card { box-shadow: none !important; }

  /* ---------- account and settings rows ---------- */
  html body .sb-profile { border-radius: var(--m-r); }
  html body .sb-set { border-radius: 14px; }
  html body .sb-pill2, html body .sb-chip { border-radius: 999px; }

  /* ---------- dialogs: every window rises from the bottom as a plain sheet ---------- */
  html body .fixed.inset-0[class*="z-"] { background: var(--m-scrim) !important; }
  html body .fixed.inset-0[class*="z-"] > div:not([class*="pointer-events-none"]) {
    position: fixed !important; inset-inline: 0 !important; inset-block-end: 0 !important; margin: 0 !important; inline-size: 100%; max-inline-size: none !important; max-block-size: min(92dvh, 780px); overflow-y: auto !important; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    border-radius: 20px 20px 0 0 !important; border: 0 !important; border-top: 1px solid var(--sb-line) !important; background: var(--m-solid) !important;
    box-shadow: none !important; padding: 28px 18px max(20px, env(safe-area-inset-bottom)) !important;
  }
  html body .fixed.inset-0[class*="z-"] > div:not([class*="pointer-events-none"])::before { content: ""; position: absolute; inset-block-start: 10px; inset-inline-start: calc(50% - 22px); inline-size: 44px; block-size: 5px; border-radius: 999px; background: var(--m-handle); }
  html body .fixed.inset-0[class*="z-"] > div > button[class*="top-4"], html body .fixed.inset-0[class*="z-"] > div .justify-between > button { inline-size: 44px; block-size: 44px; border-radius: 50%; background: var(--sb-sunk); display: grid; place-items: center; }
  html body .fixed.inset-0[class*="z-"] h2 { font-size: 19px; font-weight: 900; }
  html body .modal__backdrop { background: var(--m-scrim) !important; }
  html body .modal__container { align-items: flex-end !important; padding: 0 !important; }
  html body .modal__dialog { display: flex !important; flex-direction: column; overflow: hidden !important; }
  html body .modal__dialog .modal__header, html body .modal__dialog .modal__footer { flex: none; }
  html body .modal__dialog .modal__body { flex: 1 1 auto; min-block-size: 0; max-block-size: none !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-block-end: max(16px, env(safe-area-inset-bottom)); }
  html body .isl-modal { overflow-y: auto !important; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  html body .modal__dialog, html body .isl-modal { position: fixed !important; inset-inline: 0 !important; inset-block-end: 0 !important; max-block-size: min(92dvh, 780px) !important; overflow-y: auto; inline-size: 100% !important; max-inline-size: none !important; margin: 0 !important; border-radius: 20px 20px 0 0 !important; border: 0 !important; border-top: 1px solid var(--sb-line) !important; background: var(--m-solid) !important; box-shadow: none !important; }
  html body .isl-modal-layer { align-items: flex-end !important; padding: 0 !important; background: var(--m-scrim) !important; }
  html body :is(.v2-btn-primary, .button--primary) { min-block-size: 48px; border-radius: 12px; background: var(--m-accent) !important; color: var(--m-on-accent) !important; box-shadow: none; font-weight: 800; }
  html body .v2-row { display: flex; align-items: center; gap: 14px; min-block-size: 60px; padding: 8px 0; border-radius: 0; background: none; border: 0; border-bottom: 1px solid var(--sb-line); text-align: start; }
  html body .v2-row-ico { inline-size: 40px; block-size: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--sb-ink); background: var(--sb-sunk); box-shadow: none; }
  html body .v2-row-txt b { font-size: 15px; font-weight: 900; display: block; }
  html body .v2-row-txt small { font-size: 12.5px; color: var(--sb-muted); }
  html body :is(.fixed.inset-0[class*="z-"], .modal__dialog, .isl-modal) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea) { min-block-size: 48px; border-radius: 12px; background: var(--sb-sunk) !important; border: 1px solid transparent !important; font-size: 16px; }
  html body #update-banner { inset-block-end: 76px !important; }
  html body #update-banner, html body .isl-toast { border-radius: 14px; background: var(--m-solid) !important; border: 1px solid var(--sb-line) !important; box-shadow: var(--sb-elev2) !important; }

  html body .modal__header { display: flex !important; flex-direction: row !important; align-items: center; justify-content: space-between; gap: 12px; padding-block-end: 8px; text-align: start; }
  html body .modal__heading { font-size: 19px; font-weight: 900; margin: 0; }
  html body .modal__close-trigger { position: static !important; flex: none; inline-size: 44px; block-size: 44px; border-radius: 50%; background: var(--sb-sunk); display: grid; place-items: center; }
  html body:has(.modal__backdrop) #update-banner, html body:has(.fixed.inset-0[class*="z-"]:not(.hidden)) #update-banner { display: none !important; }
}

/* ---- audit pass: readable text, 44px targets, calm motion (phone only) ---- */
@media (max-width: 760px) {
  html body :is(.mab-btn span, .v2-tile-label, .v2-ring .v2-ring-num small, .tv-fallback-badge, .more-tile, .cp-kbd) { font-size: 12px; }
  html body :is(.sb-band .sb-tabs-s button, .sb-chips button, .sb-pillbtn) { min-height: 44px; }
  html body .sb-band .sb-tabs-s { gap: 4px; }
  @media (prefers-reduced-motion: reduce) {
    html body :is(.sb-tabbar, .sb-more, .modal__dialog, .isl-modal, .sb-tabbar *, .sb-more *, .modal__dialog *) { transition-duration: .01ms !important; animation: none !important; }
  }
}

/* Nothing may widen the page sideways on a phone (a long label or an absolute tooltip used to push the whole layout aside). */
@media (max-width: 760px) {
    html, body { overflow-x: clip; max-inline-size: 100%; }
    .isl svg, .isl img, .isl canvas { max-inline-size: 100%; }
}
