/* ═══════════════════════════════════════════════════════════════════
   THEME — iOS 26 / Liquid Glass design system, every screen size.
   Loaded after glisse.css and styles.css (the older base it overrides).

   Shared rules first; phone-only rules in the (max-width: 720px) block;
   desktop layout in the (min-width: 721px) block at the end.

   Controls are Glisse components (github.com/0kzh/glisse) rendered on the
   server and hydrated in the browser. True lensing only renders in
   Chromium; WebKit (every iOS browser) shows Glisse's frosted fallback.

   Type scale = iOS default Dynamic Type: Large Title 34/41 bold ·
   Title 2 22 · Title 3 20 semibold · Headline 17 semibold · Body 17 ·
   Subhead 15 · Footnote 13 · Caption 12.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* SF Pro on Apple devices; Android/others fall back to their own system UI. */
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;
  /* SF Pro Rounded for money — the voice of Wallet and Fitness. */
  --font-num: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  --ios-label: #1c1c1e;
  --ios-label-2: #57514a;          /* secondary label, AA on the warm canvas */
  --ios-sep: rgba(60, 60, 67, 0.16);
  --ios-fill: rgba(118, 118, 128, 0.12);
  --ios-press: #e5e5ea;
  --ios-red: #d1242f;
  --ios-radius: 16px;

  --tabbar-h: 50px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ios-label);
}

/* Money in the rounded face, tabular so columns of figures line up. */
.balance-card__amount, .txn__amount, .stat__value, .flow__value, .ov-biz__cash,
.split-legend__value, .home-card__total, .loan-row__amount, .spend__total,
.spend__amt, .txf-amount__input, .txf-amount__cur, .month-table__value,
.ov-biz__stat strong, .hero-cash-stat__value, .txn__balance, .m-nav__sub strong {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

/* ── Canvas ───────────────────────────────────────────────────────────
   No floating blobs on a phone (native apps don't have them). The
   business colour lives in a soft wash behind the large title instead —
   still instantly recognisable, and it scrolls away with the content. */
.biz-blobs { display: none; }
body { background: var(--bg); }
body::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: calc(300px + var(--safe-top));
  background: linear-gradient(180deg, var(--biz-soft, transparent) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}
body[data-biz="overview"]::before {
  background: linear-gradient(120deg, rgba(232,167,0,.14), rgba(95,158,54,.12) 50%, rgba(234,88,12,.12));
}

/* ── Large titles ─────────────────────────────────────────────────── */
.home-head { align-items: flex-end; margin-top: 6px; }
.home-head__date {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ios-label-2);
}
.home-head__title,
.m-large-title,
.txf-top__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 41px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ios-label);
}
.txf-top__title { font-size: 28px; line-height: 34px; }
.home-head__chev { display: inline-block; color: var(--biz-deep); margin-top: 6px; }
.home-head__switch:active { opacity: 0.55; }

/* ── Entries header ──────────────────────────────────────────────── */
.section-hero--all,
.panel-card > .panel-card__header { display: none; }

.m-nav { display: block; margin-top: 2px; }
.m-nav__bar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.m-nav__tools { display: flex; gap: 4px; }
.m-nav__sub { margin: 2px 0 0; font-size: 15px; color: var(--ios-label-2); }
.m-nav__sub strong { color: var(--ios-label); font-weight: 600; }

.m-biz-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px 0 10px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ios-label);
  font: 600 15px/1 var(--font-body);
  cursor: pointer;
}
.m-biz-pill__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--biz-accent); }
.m-biz-pill:active { opacity: 0.55; }

.m-icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--biz-deep, var(--ios-label));
  cursor: pointer;
}
.m-icon-btn:active { opacity: 0.4; }

/* Active-filter chips stay, but compact */
.filter-strip { padding: 0; margin: 0; border: 0; gap: 8px; }
.filter-strip__label { display: none; }
.filter-chip { min-height: 32px; font-size: 13px; }

/* ── Ledger: inset grouped list ──────────────────────────────────── */
.panel, .panel-card {
  padding: 0;
  margin: 0;
  background: transparent;
  box-shadow: none;
  border: 0;
  border-radius: 0;
}
.txn-list { background: transparent; border-radius: 0; gap: 0; }

.txn-day {
  margin: 0;
  padding: 18px 16px 6px;
  border: 0;
  font: 600 13px/18px var(--font-body);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ios-label-2);
}
.txn-day:first-child { padding-top: 4px; }

.txn {
  display: block;
  padding: 0;
  gap: 0;
  border: 0;
  background: #fff;
  overflow: hidden;
  position: relative;
  transform: none !important;
}
.txn:hover { background: #fff; }
/* Grouped corners: first row after a day header, and the last row of a day. */
.txn-day + .txn { border-top-left-radius: var(--ios-radius); border-top-right-radius: var(--ios-radius); }
.txn:has(+ .txn-day), .txn:last-child { border-bottom-left-radius: var(--ios-radius); border-bottom-right-radius: var(--ios-radius); }
/* Hairline separators, inset to the text like iOS (not under the icon). */
.txn + .txn::before {
  content: "";
  position: absolute;
  top: 0; left: 64px; right: 0;
  height: 0.5px;
  background: var(--ios-sep);
  z-index: 2; /* above the row's face, which is its own layer (z-index 1) */
}
.txn.is-archived { opacity: 1; }
.txn.is-archived .txn__face { opacity: 0.55; }

/* Swipe-to-act: the row's face slides left over its actions. Driven by touch
   (Entries.jsx → useSwipeRows) with a transform on the one row being touched.
   It used to be a horizontal scroller per row: 180 rows meant 180 compositor
   layers, and every scroll frame under the glass tab bar re-checked them all. */
.txn__swipe {
  position: relative;
  display: flex;
  overflow: hidden;
  touch-action: pan-y;
}

.txn__face {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 0 0 100%;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 11px 16px 12px;
  background: #fff;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color 120ms ease;
}
.txn__face:active { background: var(--ios-press); }
.txn__face:focus-visible { outline: 2px solid var(--biz-accent); outline-offset: -2px; }
.txn__swipe.is-swiping .txn__face { will-change: transform; transition: none; }
.txn__swipe.is-settling .txn__face { transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1); }

.txn__swipe-actions {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  display: flex;
  visibility: hidden;
}
.txn__swipe.is-swiping .txn__swipe-actions,
.txn__swipe.is-settling .txn__swipe-actions,
.txn__swipe.is-open .txn__swipe-actions { visibility: visible; }
.txn__swipe-actions form { display: flex; margin: 0; }
.txn__swipe-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 78px;
  border: 0;
  color: #fff;
  font: 600 13px/1 var(--font-body);
  cursor: pointer;
}
.txn__swipe-btn--archive { background: #636366; }
.txn__swipe-btn--delete { background: var(--ios-red); }
.txn__swipe-btn:active { filter: brightness(0.88); }

/* Inline action buttons live in the sheet and the swipe tray on phones. */
.txn .txn__actions { display: none !important; }

/* Row content */
.txn__main { gap: 12px; align-items: center; }
.txn__icon { width: 36px; height: 36px; }
.txn__icon svg { width: 17px; height: 17px; }
.txn__title { font: 600 16px/21px var(--font-body); letter-spacing: -0.01em; }
.txn__sub { margin-top: 2px; gap: 4px 6px; font-size: 13px; }
.txn__type, .txn__status { padding: 1px 7px; font-size: 12px; }
.txn__amount { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.txn__amount--out { color: var(--ios-label); }
.txn__balance { margin-top: 2px; font-size: 12px; font-weight: 500; color: var(--ios-label-2); }
.txn__amount-suffix { font-size: 12px; }

/* Secondary lines align with the title (icon 36 + gap 12). */
.txn__vendor, .txn__note, .txn__tags, .txn__loan-origin { margin-left: 48px !important; }
.txn__vendor { font-size: 15px; font-weight: 400; color: var(--ios-label); }
.txn__vendor-label { color: var(--ios-label-2); margin-right: 4px; }
.txn__note {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: 15px;
  line-height: 20px;
  color: var(--ios-label);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.txn__tags { gap: 4px; }
.txn__tag { padding: 2px 8px; font-size: 12px; }
.txn__loan-origin { font-size: 12px; padding: 2px 8px; }

/* ── Sheets (iOS action-sheet style) ─────────────────────────────── */
.app-dialog.m-sheet::before { display: none; }
.m-sheet__title {
  margin: 0;
  padding: 14px 16px 10px;
  border-radius: 14px 14px 0 0;
  background: #fff;
  border-bottom: 0.5px solid var(--ios-sep);
  text-align: center;
  font: 600 13px/18px var(--font-body);
  color: var(--ios-label-2);
}
.m-sheet__title + .m-actions { border-top-left-radius: 0; border-top-right-radius: 0; }

.m-actions {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
}
.m-actions__item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 18px;
  border: 0;
  border-top: 0.5px solid var(--ios-sep);
  background: transparent;
  color: var(--biz-deep, var(--ios-label));
  font: 400 17px/22px var(--font-body);
  text-align: left;
  cursor: pointer;
  width: 100%;
}
.m-actions__item:first-child { border-top: 0; }
.m-actions__item:active { background: var(--ios-press); }
.m-actions__item--danger { color: var(--ios-red); }
.m-actions__item svg { flex-shrink: 0; }
.m-actions__label { flex: 1; }
.m-actions__check { color: var(--biz-deep, var(--ios-label)); }
.m-actions form { display: contents; }
.m-actions__cancel {
  width: 100%;
  min-height: 56px;
  margin-top: 8px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: var(--biz-deep, var(--ios-label));
  font: 600 17px/22px var(--font-body);
  cursor: pointer;
}
.m-actions__cancel:active { background: var(--ios-press); }

.biz-sheet .m-actions__item { color: var(--ios-label); }
.biz-sheet__badge {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--b-accent, var(--ios-label));
  color: #1F1813;
  font: 700 13px/1 var(--font-body);
}
.biz-sheet [data-biz="vendex-djow"] .biz-sheet__badge { color: #fff; font-size: 11px; }
.biz-sheet__badge--all { background: var(--ios-label); color: #fff; }

/* Entry detail card inside the sheet: the row, with the note in full. */
.txn-sheet__card {
  margin-bottom: 8px;
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
}
.txn-sheet__card .txn__face { flex: none; padding: 16px; cursor: default; gap: 8px; }
.txn-sheet__card .txn__face:active { background: #fff; }
.txn-sheet__card .txn__title { font-size: 20px; line-height: 25px; }
.txn-sheet__card .txn__amount { font-size: 22px; }
.txn-sheet__card .txn__note { -webkit-line-clamp: unset; display: block; }
.txn-sheet__date { margin: 0 0 0 48px; font-size: 13px; color: var(--ios-label-2); }

/* ── Dashboard & overview ────────────────────────────────────────── */
.balance-card { border-radius: 22px; padding: 20px; }
.balance-card__amount { font-size: clamp(34px, 10vw, 42px); font-weight: 700; letter-spacing: -0.02em; }
.balance-card__label, .balance-card__founder { font-size: 15px; }
.flow { border-radius: 14px; }
.quick-action__label { font-size: 12px; font-weight: 600; }

.home-card, .ov-biz {
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(35, 30, 20, 0.05);
}
.home-card__title, .ov-section__title { font: 700 20px/25px var(--font-display); letter-spacing: 0; }
.home-card__head { margin-bottom: 12px; }


.stat { border-radius: 16px; padding: 14px; }
.stat__label { font-size: 13px; }
.stat__value { font-size: 22px; font-weight: 700; }

/* Recent / loans: plain rows inside the card, iOS separators. */
.txn-list--compact .txn { background: transparent; border-radius: 0 !important; }
.txn-list--compact .txn + .txn::before { left: 48px; }
.txn-list--compact .txn--link { padding: 10px 0; display: block; }
.txn-list--compact .txn--link:active { background: var(--ios-press); }
.loan-row { padding: 10px 0; border-radius: 0; }
.loan-row:active { background: var(--ios-press); }

/* ── Forms ───────────────────────────────────────────────────────── */
.txf-top { margin-top: 4px; }
.txf-top__back { background: rgba(255,255,255,.8); box-shadow: none; }
.txf-types { border-radius: 16px; }
.txf-amount, .txf-list { border-radius: 16px; }
.txf-row { min-height: 50px; }
.txf-row__label { font-weight: 400; }
.txf-row__input, .txf-row__textarea { font-size: 17px; }
.txf-chip span { min-height: 38px; font-size: 15px; }
.txf-group__title {
  font: 600 13px/18px var(--font-body);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ios-label-2);
  margin-left: 16px;
}
.txf-save__btn { min-height: 50px; border-radius: 14px; font-size: 17px; }
.txf-save__cancel { font-size: 17px; font-weight: 400; color: var(--biz-deep, var(--ios-label)); }

/* ── Global press feedback: iOS dims, it doesn't shrink ──────────── */
.pill-action:active, .button:active, .quick-action:active .quick-action__icon,
a.stat:active, .ov-biz:active, .txf-type:active, .txf-chip:active span {
  transform: none;
  opacity: 0.6;
}

/* Icon colours keyed off the type class, wherever a row is rendered. */
.txn-sheet__card.txn--payment .txn__icon { background: #dcf3e3; color: #116631; }
.txn-sheet__card.txn--expense .txn__icon { background: #fbe1e1; color: #b91c1c; }
.txn-sheet__card.txn--cashout .txn__icon { background: #f8e6cf; color: #8a3f07; }
.txn-sheet__card.txn--loan    .txn__icon { background: #e1e8fb; color: #1d4ed8; }

/* The segmented control already shows the type filter; don't repeat it as
   a chip, and drop the strip entirely when that's the only filter. */
.filter-chip[data-key="entryType"] { display: none; }
.filter-strip:not(:has(.filter-chip[data-key]:not([data-key="entryType"]))) { display: none; }

/* The colour wash fades out instead of ending in an edge. */
body::before {
  -webkit-mask-image: linear-gradient(180deg, #000 35%, transparent);
  mask-image: linear-gradient(180deg, #000 35%, transparent);
}


/* ═══ Phone only ═════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  /* ── Safe areas & page frame ──────────────────────────────────────── */
  .main-content {
    padding: calc(var(--safe-top) + 8px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
    gap: 16px;
  }
  body.no-tabbar .main-content { padding-bottom: calc(96px + var(--safe-bottom)); }


  /* ── Compact title bar (appears on scroll) ───────────────────────── */
  .m-compact {
    display: flex;
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 120;
    height: calc(44px + var(--safe-top));
    padding-top: var(--safe-top);
    align-items: center;
    justify-content: center;
    background: #f2f2f7;
    border-bottom: 0.5px solid var(--ios-sep);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
  }
  .m-compact__title { font-size: 17px; font-weight: 600; color: var(--ios-label); }
  body.is-compact .m-compact { opacity: 1; transform: none; pointer-events: auto; }


  .app-dialog.m-sheet {
    inset: auto 0 0 0;
    width: 100%;
    max-width: none;
    max-height: 88dvh;
    margin: 0;
    padding: 8px 8px calc(8px + var(--safe-bottom));
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow-y: auto;
  }

  /* Confirm sheets keep their own look but get iOS metrics. */
  .app-dialog:not(.m-sheet) {
    border-radius: 14px 14px 0 0;
    padding-bottom: calc(16px + var(--safe-bottom));
  }


  .txf-save {
    padding: 10px 16px calc(10px + var(--safe-bottom));
    background: #f2f2f7;
    border-top: 0.5px solid var(--ios-sep);
  }

}

/* ═══════════════════════════════════════════════════════════════════
   iOS SYSTEM PALETTE
   Neutral grouped background (#F2F2F7) like Settings and Wallet; each
   business keeps its colour as the tint and the wash behind the title.
   ═══════════════════════════════════════════════════════════════════ */
:root {
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --bg-soft: #f2f2f7;
  --bg-muted: #e5e5ea;
  --line: rgba(60, 60, 67, 0.12);
  --line-strong: rgba(60, 60, 67, 0.22);
  --text: #1c1c1e;
  --text-soft: #636366;        /* secondary label, 5.9:1 on white */
  --text-dim: #6c6c70;
  --ios-label: #1c1c1e;
  --ios-label-2: #636366;
  --ios-press: #e5e5ea;
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --tabbar-h: 70px;
}
body { background: var(--bg); color: var(--ios-label); font-size: 17px; }

/* ── Glisse theming: business tint on every control ─────────────────── */
body {
  --lg-fill: var(--biz-deep, #1c1c1e);
  --lg-tab-selected: var(--biz-deep, #1c1c1e);
  --lg-on: #34c759;
}
body[data-biz="overview"] { --lg-fill: #1c1c1e; --lg-tab-selected: #1c1c1e; }
/* Hydration containers add no box of their own. */
/* React mounts into #root; it must not become a layout box. */
#root { display: contents; }
.island { display: contents; }

.gl-badge {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: #1f1813;
  font: 700 12px/1 var(--font-body);
  letter-spacing: -0.02em;
}
.lg-menu-item .gl-badge { width: 22px; height: 22px; font-size: 11px; border-radius: 6px; }

/* Glisse buttons that reuse older classes: Glisse's geometry wins. */
.home-head__add.lg-button,
.balance-card__details.lg-button,
.txf-save__cancel.lg-button,
.m-biz-pill.lg-button {
  height: 40px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  font: 600 15px/1 var(--font-body);
  box-shadow: inset 0 0 0 0.5px var(--lg-edge), 0 1px 3px var(--lg-drop);
  transform: none;
}
.home-head__add.lg-button { background-color: var(--lg-button-fill); color: #fff; gap: 6px; }
.balance-card__details.lg-button { background-color: rgba(255, 255, 255, 0.16); color: #fff; box-shadow: inset 0 0 0 0.5px rgba(255,255,255,.18); }
.m-biz-pill.lg-button { gap: 6px; padding: 0 12px 0 10px; color: var(--ios-label); background-color: var(--lg-glass); }
.txf-save__cancel.lg-button { color: var(--ios-label); background-color: var(--lg-glass); }

/* Form primary action fills the bar beside Cancel. */
#save-control .lg-button { flex: 1; height: 50px; border-radius: 25px; font: 600 17px/1 var(--font-body); }
.txf-save { gap: 12px; }

/* Segmented controls: centred rows that fit their container. */
#scope-control, #type-control { display: flex; justify-content: center; }
.entries-search { display: flex; justify-content: center; margin: 0; }
.entries-search .lg-input { max-width: none; height: 44px; border-radius: 22px; }
.entries-search .lg-input input { font-size: 17px; }

/* Filters sheet: label + Glisse switch on one row */
.toggle--switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }

/* ── Dynamic Island notice ──────────────────────────────────────────
   A black capsule that springs open from a pill the size of the island,
   shows the message, then tucks back up. A web app can't draw inside
   the hardware island, so it sits just below it. */
.flash-toast { display: none !important; }
.island-toast {
  position: fixed;
  top: calc(var(--safe-top, 0px) + 10px);
  left: 50%;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 440px);
  min-height: 46px;
  padding: 6px 8px 6px 10px;
  border-radius: 999px;
  background: #000;
  color: #fff;
  font: 600 15px/1.25 var(--font-body);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  transform: translateX(-50%);
  view-transition-name: island;
  animation: island-open 560ms var(--spring) both, island-close 420ms ease-in 3.8s forwards;
}
.island-toast.has-action { animation: island-open 560ms var(--spring) both, island-close 420ms ease-in 7s forwards; }
.island-toast__icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #30d158;
  color: #000;
}
.island-toast__msg { flex: 1; min-width: 0; padding-right: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.island-toast__form { margin: 0; }
.island-toast__undo {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: var(--biz-on-dark, #fff);
  font: 600 15px/1 var(--font-body);
  cursor: pointer;
}
.island-toast__undo:active { opacity: 0.6; }
@keyframes island-open {
  0%   { clip-path: inset(0 calc(50% - 62px) round 999px); opacity: 0.5; transform: translateX(-50%) translateY(-6px) scale(0.92); }
  60%  { opacity: 1; }
  100% { clip-path: inset(0 0 round 999px); opacity: 1; transform: translateX(-50%); }
}
@keyframes island-close {
  to { clip-path: inset(0 calc(50% - 62px) round 999px); opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.9); visibility: hidden; }
}

/* Pull to refresh as an island capsule */
.ptr__disc {
  display: inline-flex;
  width: auto;
  height: 36px;
  gap: 6px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: #000;
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}
.ptr__label { font: 600 13px/1 var(--font-body); white-space: nowrap; }
.ptr.is-ready .ptr__disc { color: #fff; }
.ptr.is-loading .ptr__disc svg { display: none; }
.ptr.is-loading .ptr__disc::after { width: 14px; height: 14px; border-width: 2px; border-color: rgba(255,255,255,.25); border-top-color: #fff; order: -1; }

/* Ledger rows open their detail sheet on every screen size. */
.txn .txn__actions { display: none !important; }

/* ═══ Phone: floating Liquid Glass tab bar ═══════════════════════════ */
@media (max-width: 720px) {
  .mobile-tab-bar { display: none !important; }
  .tab-dock {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: max(12px, calc(var(--safe-bottom) - 10px));
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    view-transition-name: tabbar;
    pointer-events: none;
  }
  .tab-dock > * { pointer-events: auto; }
  .tab-dock .lg-tab-bar { --lg-tab-width: min(76px, calc((100vw - 32px - 70px - 8px) / 3)); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), inset 0 0 0 0.5px var(--lg-edge); }
  .tab-dock .lg-tab-bar[style*="--lg-tabs:5"] { --lg-tab-width: calc((100vw - 32px - 8px) / 5); }
  .tab-dock__add.lg-button {
    flex-shrink: 0;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  }
  body[data-biz="sawa9ly"] .tab-dock__add { --lg-fill: #e8a700; color: #1f1813; }

  #scope-control .lg-segmented { --lg-tab-width: calc((100vw - 32px) / 5); }
  #type-control .lg-segmented { --lg-tab-width: calc((100vw - 32px) / 4); }
  #period-control .lg-segmented { --lg-tab-width: calc((100vw - 64px) / 4); }
  .home-card__head:has(#period-control) { flex-direction: column; align-items: stretch; gap: 12px; }

  .m-compact {
    background: rgba(242, 242, 247, 0.72);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    backdrop-filter: blur(20px) saturate(1.8);
  }
}

/* ═══ Desktop & tablet ═══════════════════════════════════════════════ */
@media (min-width: 721px) {
  .tab-dock, .m-compact { display: none !important; }

  /* Floating glass sidebar */
  .app-shell { display: block; }
  .sidebar.sb {
    position: fixed;
    top: 16px;
    bottom: 16px;
    left: 16px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    width: 232px;
    height: auto;
    padding: 14px 10px;
    border-radius: 26px;
    overflow-y: auto;
    --lg-blur: 24px;
    --lg-glass: rgba(255, 255, 255, 0.62);
    box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 10px 40px rgba(0, 0, 0, 0.08);
  }
  .main-content {
    margin-left: 264px;
    padding: 32px 40px 48px;
    max-width: 1240px;
    gap: 20px;
  }

  .sb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 12px;
    color: var(--ios-label);
    font: 700 17px/1.2 var(--font-display);
  }
  .sb-heading {
    margin: 12px 0 4px;
    padding: 0 10px;
    font: 600 13px/18px var(--font-body);
    color: var(--ios-label-2);
  }
  .sb-list { display: flex; flex-direction: column; gap: 2px; }
  .sb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 40px;
    padding: 5px 10px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--ios-label);
    font: 400 15px/1.2 var(--font-body);
    text-align: left;
    cursor: pointer;
    transition: background-color 140ms ease;
  }
  .sb-item:hover { background: rgba(118, 118, 128, 0.1); }
  .sb-item.is-active { background: rgba(118, 118, 128, 0.16); font-weight: 600; }
  .sb-item--plain.is-active { color: var(--biz-deep, var(--ios-label)); }
  .sb-badge {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--b-accent, #1c1c1e);
    color: #1f1813;
    font: 700 12px/1 var(--font-body);
  }
  .sb-item[data-biz="vendex-djow"] .sb-badge { color: #fff; font-size: 11px; }
  .sb-badge--all { background: #1c1c1e; color: #fff; }
  .sb-badge--all svg { width: 16px; height: 16px; }
  .sb-icon { display: grid; place-items: center; width: 28px; height: 28px; color: var(--biz-deep, var(--ios-label)); }
  .sb-signout { margin: auto 0 0; padding-top: 12px; }
  .sb-signout .sb-item { color: var(--ios-label-2); }

  /* Large titles and toolbars */
  .home-head__chev { display: none; }
  .m-biz-pill { display: none !important; }
  .m-nav__bar { justify-content: flex-end; min-height: 40px; }
  .home-head__title, .m-large-title { font-size: 34px; line-height: 41px; }
  #scope-control, .entries-search { justify-content: flex-start; }
  .entries-search .lg-input { max-width: 420px; }

  /* Sheets become centred cards */
  .app-dialog.m-sheet {
    width: min(420px, 92vw);
    max-width: none;
    margin: auto;
    padding: 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }
  .app-dialog.m-sheet::backdrop { background: rgba(0, 0, 0, 0.32); }

  /* Ledger: the same grouped list, wider rows */
  .txn__face { padding: 12px 20px; }
  .txn__face:hover { background: #f7f7f9; }
  .txn + .txn::before { left: 68px; }

  /* Forms centred like a macOS sheet */
  .txf-page { max-width: 560px; }
  .txf-save { position: static; padding: 0; background: none; border: 0; }
}

/* Tablet: the sidebar folds to icons. */
@media (min-width: 721px) and (max-width: 1100px) {
  .sidebar.sb { width: 68px; padding: 14px 8px; flex-direction: column; }
  .sb .sb-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .sb-item, .sb-brand { justify-content: center; padding: 6px; }
  .sb-heading { height: 1px; margin: 8px 6px; background: var(--line); }
  .main-content { margin-left: 100px; padding: 28px 28px 40px; }
}

/* Tab bar legibility: Glisse's default glass is 60% white with a 3px blur,
   so busy rows read straight through and fight the labels. iOS keeps bar
   labels readable with a stronger frost; the lens refraction still shows
   at the edges in Chromium. The + circle matches the bar's 60px height. */
@media (max-width: 720px) {
  /* Set on the glass layer itself: Glisse defines --lg-glass there. */
  .tab-dock .lg-tab-bar .lg-tab-bar-glass { --lg-glass: rgba(250, 250, 252, 0.8); --lg-blur: 14px; }
  .tab-dock__add.lg-button { width: 60px; height: 60px; }
  .m-compact { --lg-blur: 14px; }
}

/* Smallest phones (iPhone SE 1st gen): keep the flow figures inside their pills. */
@media (max-width: 340px) {
  .flow__value { font-size: 0.875rem; }
  .balance-card__flow .flow { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .balance-card__flow .flow__icon { width: 28px; height: 28px; }
  .balance-card__flow .flow__icon svg { width: 16px; height: 16px; }
}

/* Load/save failure screen (React app error boundary). */
.app-error { margin: 18vh auto 0; max-width: 420px; text-align: center; display: grid; gap: 12px; justify-items: center; }

/* Navigation in progress: a hairline in the business colour across the top.
   Delayed, so fast page changes (most of them) never show it. */
.nav-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2.5px; z-index: 400;
  background: var(--biz-accent, #1c1c1e); transform-origin: 0 50%;
  animation: nav-progress 1.6s cubic-bezier(0.2, 0.7, 0.2, 1) 180ms both;
  pointer-events: none;
}
@keyframes nav-progress { from { transform: scaleX(0); opacity: 1; } to { transform: scaleX(0.85); opacity: 1; } }

/* Long ledgers: rows far off screen skip layout and paint until scrolled
   near. `auto` remembers each row's real height once it has rendered, so the
   scrollbar doesn't jump. */
.entry-table .txn { content-visibility: auto; contain-intrinsic-size: auto 84px; }

/* ═══ Business carousel (dashboard) ══════════════════════════════════
   One balance card per business in a native scroll-snap track: swipe to
   switch business, like accounts in a banking app. Each card carries its
   own colours, so the neighbour sliding in is already in its business's
   colour before the page follows. */
.bc-wrap { margin-bottom: 4px; }
.biz-carousel {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  /* Room for the cards' drop shadow, which the track would otherwise cut
     off in a hard line. The shadow is tightened to fit (below). */
  padding-bottom: 40px;
  margin-bottom: -36px;
}
.biz-carousel::-webkit-scrollbar { display: none; }
.bc-card {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  box-shadow: 0 12px 26px rgba(35, 30, 20, 0.2);
}
.bc-card[hidden] { display: none; }
.bc-card[data-biz="sawa9ly"]     { --biz-accent: #E8A700; --biz-on-dark: #FFC93C; --bc-badge-ink: #1f1813; }
.bc-card[data-biz="trendzy"]     { --biz-accent: #5F9E36; --biz-on-dark: #A8D672; --bc-badge-ink: #fff; }
.bc-card[data-biz="vendex"]      { --biz-accent: #EA580C; --biz-on-dark: #FF9A5A; --bc-badge-ink: #fff; }
.bc-card[data-biz="vendex-djow"] { --biz-accent: #7C3AED; --biz-on-dark: #C4B5FD; --bc-badge-ink: #fff; }
.bc-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  margin-right: 8px;
  border-radius: 7px;
  background: var(--biz-accent);
  color: var(--bc-badge-ink, #fff);
  font: 700 11px/1 var(--font-body);
  letter-spacing: 0.02em;
  vertical-align: 1px;
}

/* Page dots: the current business stretches into a pill in its colour. */
.biz-dots { display: flex; justify-content: center; gap: 2px; margin-top: 2px; }
.biz-dots button {
  display: grid;
  place-items: center;
  height: 24px;
  padding: 0 4px;
  border: 0;
  background: none;
  cursor: pointer;
}
.biz-dots button::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 4px;
  background: rgba(60, 60, 67, 0.22);
  transition: width 260ms var(--spring), background-color 260ms ease;
}
.biz-dots button.is-on::before { width: 20px; background: var(--b-accent); }

@media (max-width: 720px) {
  /* Edge to edge, with the neighbouring cards peeking in at both sides so
     the swipe is discoverable. */
  .biz-carousel {
    gap: 8px;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 18px;
    padding-right: 18px;
    scroll-padding: 0 18px;
  }
}

/* Page changes on phones fade with Web Animations (ui/app/motion.js) —
   opacity only, run off the main thread, including the background when the
   business changes. Nothing here animates per-frame repaints. */

@media (prefers-reduced-motion: reduce) {
  .biz-dots button::before { transition: none; }
}
@media (max-width: 360px) {
  /* Smallest phones: badge, label and Details on one line. */
  .bc-card .balance-card__label { white-space: nowrap; font-size: 0.875rem; }
  .bc-card .balance-card__details { padding: 0 8px 0 12px; font-size: 0.875rem; }
}
