/* Patient portal prototype. Same look as the public site (clinic-site/) and the checkout
   portal: white main colour, the logo blue #087f9b as the accent, white frosted glass,
   DM Serif Display + Plus Jakarta Sans, no helper text. Phone first; the bottom tab bar
   moves into the top bar from 900px. */

:root {
  --brand: #087f9b;
  --brand-lift: #1593b0;
  --brand-deep: #066c84;
  --brand-ink: #06637a;
  --brand-night: #054f61;
  --wash: #edf7fa;
  --line: rgba(8, 127, 155, 0.14);
  --line-strong: rgba(8, 127, 155, 0.28);

  --good: #1f8f6f;
  --good-wash: #e6f5ef;
  --due: #b86e0b;
  --due-wash: #fdf1dd;
  --muted-wash: #eef2f3;
  --owe: #c53b30;
  --owe-lift: #e0574b;
  --owe-wash: #fdeeec;
  --owe-line: rgba(197, 59, 48, 0.28);

  --page: #f6fafb;
  --ink: #0b3a47;
  --ink-2: #3d5f69;
  --ink-3: #567580;

  --glass-fill: linear-gradient(160deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0.72) 60%, rgba(255, 255, 255, 0.84) 100%);
  --glass-blur: blur(22px) saturate(160%);
  --glass-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 0 0 1px var(--line), 0 20px 40px -26px rgba(8, 80, 100, 0.32);

  --radius: 24px;
  --radius-sm: 16px;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --serif: "DM Serif Display", Georgia, serif;
  --sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

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

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { flex: none; }
:focus-visible { outline: 3px solid rgba(8, 127, 155, 0.45); outline-offset: 3px; border-radius: 12px; }
[hidden] { display: none !important; }

/* Line icons share one stroke recipe. */
.tab svg, .btn svg, .field-icon, .field-eye svg, .signin-help svg, .account-link svg,
.chip svg, .icon, .row-chev, .receipt-chev {
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

.backdrop {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1000px 640px at 0% -12%, rgba(18, 167, 196, 0.15), transparent 60%),
    radial-gradient(900px 700px at 110% 115%, rgba(8, 127, 155, 0.12), transparent 60%),
    linear-gradient(180deg, #fbfdfe 0%, var(--page) 100%);
}

.glass {
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius);
}

.screen { display: none; min-height: 100dvh; }
.screen.is-active { display: block; animation: screen-in 0.5s var(--ease-out); }
@keyframes screen-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
/* Opacity only: a transform on the screen would trap the fixed tab bar while it animates. */
.app-screen.is-active { animation-name: fade; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px;
  font-weight: 700; font-size: 15px; letter-spacing: 0.01em;
  transition: transform 0.18s var(--ease-out), box-shadow 0.25s, background 0.25s, color 0.25s;
}
.btn svg { width: 19px; height: 19px; }
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-primary {
  color: #fff; min-height: 56px; font-size: 16px;
  background: linear-gradient(180deg, var(--brand-lift), var(--brand));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 14px 28px -14px rgba(8, 127, 155, 0.7);
}
.btn-soft { color: var(--brand-ink); background: var(--wash); box-shadow: inset 0 0 0 1px var(--line); }
.btn-soft:hover { background: #e2f2f6; }
.btn-quiet { color: var(--ink-2); background: rgba(11, 58, 71, 0.05); }
.btn-icon { width: 48px; padding: 0; }

.spinner {
  display: none; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
.is-loading .spinner { display: block; }
.is-loading .btn-label { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sign in ─────────────────────────────────────────────────────────── */
.signin {
  width: min(100%, 440px); margin: 0 auto;
  padding: calc(48px + env(safe-area-inset-top, 0px)) 20px calc(32px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center;
  min-height: 100dvh; justify-content: center;
}
.signin-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.signin-mark { width: 44px; height: 96px; color: var(--brand); animation: mark-in 0.9s var(--ease-out) both; }
@keyframes mark-in { from { opacity: 0; transform: translateY(10px) scale(0.94); } to { opacity: 1; transform: none; } }
.wordmark {
  margin: 0; text-align: center; font-family: var(--serif); font-size: 22px; color: var(--ink); line-height: 1.1;
}
.wordmark span {
  display: block; margin-top: 6px; font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--brand);
}
.signin-title { margin: 34px 0 18px; font-family: var(--serif); font-weight: 400; font-size: 40px; line-height: 1; letter-spacing: -0.01em; }

.signin-card { width: 100%; padding: 22px 20px 20px; }
.field-label { display: block; margin: 0 0 8px 4px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.field {
  position: relative; display: flex; align-items: center; margin-bottom: 16px;
  border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: box-shadow 0.2s, background 0.2s;
}
.field:focus-within { background: #fff; box-shadow: inset 0 0 0 2px var(--brand), 0 0 0 5px rgba(8, 127, 155, 0.1); }
.field.is-invalid { box-shadow: inset 0 0 0 2px #c2553a; }
.field-icon { position: absolute; left: 15px; width: 20px; height: 20px; color: var(--ink-3); pointer-events: none; }
.field input::placeholder { color: rgba(86, 117, 128, 0.55); font-weight: 600; }
.field input {
  width: 100%; min-height: 54px; padding: 0 52px 0 46px; border: 0; background: transparent;
  font-size: 17px; font-weight: 600; outline: none; border-radius: var(--radius-sm);
}
.field-eye {
  position: absolute; right: 4px; width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; color: var(--ink-3);
}
.field-eye svg { width: 20px; height: 20px; }
.form-error { margin: -4px 4px 14px; font-size: 14px; font-weight: 600; color: #b3452c; }
.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.signin-help {
  margin-top: 22px; display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--brand-ink);
}
.signin-help svg { width: 18px; height: 18px; }
.signin-help:hover { background: var(--wash); }

/* ── App shell ───────────────────────────────────────────────────────── */
/* Staff preview (eye button in the physio app): a dark bar keeps it obvious this is not the
   patient themself. It sits above the top bar, which moves down under it. */
.preview-bar {
  position: sticky; top: 0; z-index: 35;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; padding: env(safe-area-inset-top, 0px) 12px 0 16px;
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
}
.preview-bar-text { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.preview-bar-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-bar svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.preview-bar-end {
  flex: none; min-height: 34px; padding: 0 14px; border-radius: 999px;
  background: #fff; color: var(--ink); font-size: 13px; font-weight: 800;
}
.is-preview .topbar { top: calc(44px + env(safe-area-inset-top, 0px)); height: 64px; padding-top: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  height: calc(64px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 16px 0;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 1px 0 var(--line);
}
.topbar-brand { display: grid; place-items: center; width: 44px; height: 44px; color: var(--brand); }
.topbar-brand svg { width: 20px; height: 44px; }
.avatar-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  font-size: 14px; font-weight: 800; letter-spacing: 0.02em; color: #fff;
  background: linear-gradient(160deg, var(--brand-lift), var(--brand-deep));
  box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--line-strong);
}

.tabbar {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + var(--safe-b));
  width: min(calc(100% - 24px), 440px); height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px; gap: 2px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  box-shadow: inset 0 1px 0 #fff, 0 0 0 1px var(--line), 0 18px 40px -16px rgba(8, 80, 100, 0.38);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 20px; font-size: 11.5px; font-weight: 700; color: var(--ink-3);
  transition: color 0.25s, background 0.25s;
}
.tab svg { width: 23px; height: 23px; transition: transform 0.35s var(--spring); }
.tab.is-active { color: var(--brand); background: var(--wash); }
.tab.is-active svg { transform: translateY(-1px) scale(1.06); }

.app {
  width: min(100%, 560px); margin: 0 auto;
  padding: 18px 16px calc(var(--tabbar-h) + 40px + var(--safe-b));
}
.view { display: none; }
.view.is-active { display: block; }
.view.is-active > * { animation: rise 0.55s var(--ease-out) both; }
.view.is-active > *:nth-child(2) { animation-delay: 0.05s; }
.view.is-active > *:nth-child(3) { animation-delay: 0.1s; }
.view.is-active > *:nth-child(4) { animation-delay: 0.15s; }
.view.is-active > *:nth-child(5) { animation-delay: 0.2s; }
.view.is-active > *:nth-child(n+6) { animation-delay: 0.25s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.page-head { margin: 6px 4px 18px; }
.page-title { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1.05; letter-spacing: -0.01em; }
.page-date { margin: 6px 0 0; font-size: 14px; font-weight: 600; color: var(--ink-3); }

.section-title {
  margin: 28px 4px 12px; font-family: var(--serif); font-weight: 400; font-size: 23px; line-height: 1.1;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.section-title .count { font-family: var(--sans); font-size: 13px; font-weight: 700; color: var(--ink-3); }

.card { padding: 18px; margin-bottom: 14px; }
.label { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink-3); }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.01em; white-space: nowrap;
}
.chip svg { width: 13px; height: 13px; stroke-width: 2.6; }
.chip-brand { color: var(--brand-ink); background: var(--wash); }
.chip-good { color: var(--good); background: var(--good-wash); }
.chip-due { color: var(--due); background: var(--due-wash); }
.chip-muted { color: var(--ink-3); background: var(--muted-wash); }
.chip-owe { color: var(--owe); background: var(--owe-wash); box-shadow: inset 0 0 0 1px var(--owe-line); font-variant-numeric: tabular-nums; }

/* ── Balance card ────────────────────────────────────────────────────── */
.balance {
  position: relative; overflow: hidden; display: block; width: 100%; text-align: left;
  padding: 20px 20px 18px; margin-bottom: 14px; border-radius: 28px; color: #fff;
  background:
    radial-gradient(420px 220px at 100% 0%, rgba(255, 255, 255, 0.18), transparent 60%),
    linear-gradient(140deg, #13a0bf 0%, var(--brand) 48%, var(--brand-night) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 26px 44px -26px rgba(8, 127, 155, 0.85);
}
.balance-mark { position: absolute; right: -8px; top: -26px; width: 104px; height: 226px; color: rgba(255, 255, 255, 0.09); pointer-events: none; }
.balance-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.balance-label { margin: 0; font-size: 16px; font-weight: 800; color: #fff; }
.balance-state {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 800; background: rgba(255, 255, 255, 0.17); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}
.balance-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.balance-state.is-due { color: #ffc6bf; }
.balance-state.is-good { color: #a6f0d2; }
.balance-amount {
  margin: 14px 0 2px; font-family: var(--serif); font-size: 54px; line-height: 1; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.balance-amount small { font-size: 0.5em; margin-left: 2px; opacity: 0.8; }
.balance-sign { font-family: var(--sans); font-weight: 500; font-size: 0.72em; margin-right: 2px; position: relative; top: -0.08em; }
.balance-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.2); font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, 0.85);
}
.balance-foot strong { color: #fff; font-weight: 800; }
.balance-go { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; color: #fff; }
.balance-go .icon { width: 18px; height: 18px; }
a.balance { transition: transform 0.2s var(--ease-out); }
a.balance:active { transform: scale(0.985); }
.balance-hold { padding: 18px 20px; margin-bottom: 14px; display: flex; gap: 12px; align-items: flex-start; font-weight: 600; color: var(--ink-2); }

/* ── Next session ────────────────────────────────────────────────────── */
.next-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.next-when { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 12px 0 16px; }
.next-day { margin: 0; font-family: var(--serif); font-size: 31px; line-height: 1.02; }
.next-day span { display: block; font-size: 0.62em; color: var(--ink-2); }
.next-time { margin: 0; text-align: right; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; color: var(--brand-ink); font-variant-numeric: tabular-nums; line-height: 1; }
.next-time small { display: block; margin-top: 4px; font-size: 12px; font-weight: 700; letter-spacing: 0; color: var(--ink-3); }
.who { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 18px; background: rgba(237, 247, 250, 0.7); box-shadow: inset 0 0 0 1px var(--line); }
.who-photo { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; object-position: 50% 18%; box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--line-strong); background: var(--wash); }
.who-initials { display: grid; place-items: center; font-size: 15px; font-weight: 800; color: var(--brand-ink); }
.who-name { margin: 0; font-weight: 800; }
.who-type { margin: 1px 0 0; font-size: 14px; font-weight: 600; color: var(--ink-3); }
.next-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 14px; }
.next-actions .btn { padding: 0 12px; font-size: 14px; }
.empty { padding: 22px 18px; text-align: center; color: var(--ink-3); font-weight: 600; }
.empty .icon { width: 30px; height: 30px; color: var(--brand); opacity: 0.6; display: block; margin: 0 auto 8px; }

/* ── Tiles ───────────────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.tile { display: flex; flex-direction: column; gap: 10px; padding: 16px; min-height: 172px; transition: transform 0.2s var(--ease-out); }
.tile:active { transform: scale(0.98); }
.tile-head { display: flex; align-items: center; justify-content: space-between; }
.tile-head .icon { width: 18px; height: 18px; color: var(--ink-3); }
.tile-big { margin: auto 0 0; font-family: var(--serif); font-size: 40px; line-height: 1; }
.tile-big small { font-family: var(--sans); font-size: 14px; font-weight: 700; color: var(--ink-3); margin-left: 4px; }
.tile-sub { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink-3); }
.ring { --p: 0; position: relative; width: 74px; height: 74px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .ring-track { stroke: var(--wash); }
.ring .ring-fill { stroke: var(--brand); stroke-linecap: round; transition: stroke-dashoffset 1.1s var(--ease-out); }
.ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--serif); font-size: 26px; }
.bars { display: flex; align-items: flex-end; gap: 5px; height: 46px; }
.bars span { flex: 1; min-height: 4px; border-radius: 4px; background: linear-gradient(180deg, var(--brand-lift), var(--brand)); transform-origin: bottom; animation: grow 0.8s var(--ease-out) both; }
.bars span.is-zero { background: var(--wash); }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ── Sessions ────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { padding: 14px 12px; text-align: center; border-radius: 20px; }
.stat-num { margin: 0; font-family: var(--serif); font-size: 30px; line-height: 1; }
.stat-label { margin: 6px 0 0; font-size: 12.5px; font-weight: 700; color: var(--ink-3); }

.heat { padding: 18px 16px 16px; }
.heat-grid { display: grid; grid-template-columns: 26px repeat(var(--weeks), 1fr); gap: 5px; margin-top: 14px; }
.heat-day { font-size: 10.5px; font-weight: 700; color: var(--ink-3); line-height: 1; display: grid; align-items: center; }
.heat-cell { aspect-ratio: 1; border-radius: 6px; background: rgba(8, 127, 155, 0.06); }
.heat-cell.is-attended { background: linear-gradient(160deg, var(--brand-lift), var(--brand)); box-shadow: 0 3px 8px -4px rgba(8, 127, 155, 0.8); }
.heat-cell.is-owe { background: linear-gradient(160deg, var(--owe-lift), var(--owe)); box-shadow: 0 3px 8px -4px rgba(197, 59, 48, 0.8); }
.heat-cell.is-cancelled { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(86, 117, 128, 0.45); }
.heat-cell.is-upcoming { background: transparent; box-shadow: inset 0 0 0 2px var(--brand); }
.heat-cell.is-today { outline: 2px solid rgba(8, 127, 155, 0.35); outline-offset: 1px; }
.heat-cell.is-future { background: rgba(8, 127, 155, 0.025); }
.heat-legend { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 14px; font-size: 12px; font-weight: 700; color: var(--ink-3); }
.heat-legend span { display: inline-flex; align-items: center; gap: 6px; }
.heat-legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

.list { display: grid; gap: 10px; }
.month-label { margin: 18px 4px 8px; font-size: 13px; font-weight: 800; letter-spacing: 0.04em; color: var(--ink-3); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 20px; }
.datebox {
  flex: none; width: 52px; height: 56px; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--wash); box-shadow: inset 0 0 0 1px var(--line); color: var(--brand-ink);
}
.datebox b { font-family: var(--serif); font-weight: 400; font-size: 23px; line-height: 1; }
.datebox span { margin-top: 3px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.row.is-cancelled .datebox { background: var(--muted-wash); color: var(--ink-3); }
.row-main { flex: 1; min-width: 0; }
.row-title { margin: 0; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.is-cancelled .row-title { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.row-sub { margin: 2px 0 0; display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-3); white-space: nowrap; overflow: hidden; }
.row-sub img, .row-sub .mini-initials { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; object-position: 50% 18%; flex: none; }
.row-sub .mini-initials { display: grid; place-items: center; background: var(--wash); color: var(--brand-ink); font-size: 9px; font-weight: 800; }
.row-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.row-time { font-size: 14px; font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.more-btn { margin-top: 12px; }

/* ── Charges and unpaid ──────────────────────────────────────────────── */
/* A past visit with charges: tap to see each charge, paid or not. Unpaid ones are red. */
.srow, .uitem { border-radius: 20px; }
.srow > summary { list-style: none; cursor: pointer; }
.srow > summary::-webkit-details-marker { display: none; }
.srow .row { border-radius: 20px; }
.row-chev { width: 18px; height: 18px; color: var(--ink-3); transition: transform 0.3s var(--ease-out); margin-left: -4px; }
.srow[open] .row-chev { transform: rotate(180deg); }
.srow.is-owe, .uitem {
  box-shadow: inset 4px 0 0 var(--owe), inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 0 0 1px var(--owe-line), 0 20px 40px -26px rgba(120, 30, 20, 0.28);
}
.srow.is-owe .datebox, .datebox.is-owe { background: var(--owe-wash); color: var(--owe); box-shadow: inset 0 0 0 1px var(--owe-line); }
.srow-body { padding: 0 14px 12px; }
.srow[open] .srow-body { animation: rise 0.35s var(--ease-out); }

.mlines { border-top: 1px dashed var(--line-strong); }
.ml {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 9px 2px;
  font-size: 14px; font-weight: 700; color: var(--ink-2);
}
.ml + .ml { border-top: 1px solid rgba(8, 127, 155, 0.08); }
.ml-label { min-width: 0; }
.ml-label small { display: block; margin-top: 1px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.ml-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.ml-side b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.ml.is-owe .ml-label { color: var(--ink); }
.ml.is-owe .ml-side b { color: var(--owe); }
.ml-status { font-size: 12px; font-weight: 800; }
.ml-status.is-owe { color: var(--owe); }
.ml-status.is-paid { color: var(--good); }
.ml-status.is-covered { display: inline-flex; align-items: center; gap: 5px; color: var(--brand-ink); }
.ml-status.is-covered .icon { width: 14px; height: 14px; }
.ml-total { margin-top: 2px; border-top: 1px solid var(--line-strong) !important; font-size: 15px; font-weight: 800; color: var(--ink); }
.ml-total.is-owe .ml-label, .ml-total.is-owe .ml-side b { color: var(--owe); }
.ml-total.is-paid { color: var(--good); }
.ml-total .icon { width: 18px; height: 18px; color: var(--good); }

.owe-amount { flex: none; font-size: 17px; font-weight: 800; color: var(--owe); font-variant-numeric: tabular-nums; }
.section-title.is-owe .count { color: var(--owe); }

.unpaid-card { padding-bottom: 12px; }
.urows { margin-top: 8px; }
.urow { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 2px; }
.urow + .urow { border-top: 1px solid rgba(8, 127, 155, 0.08); }
.urow-date { padding: 7px 0; border-radius: 12px; text-align: center; font-size: 12.5px; font-weight: 800; color: var(--owe); background: var(--owe-wash); box-shadow: inset 0 0 0 1px var(--owe-line); }
.urow-title { min-width: 0; font-weight: 800; }
.urow-title small { display: block; margin-top: 1px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.urow b { font-weight: 800; color: var(--owe); font-variant-numeric: tabular-nums; }
.unpaid-card .btn { margin-top: 8px; }

/* ── Payments ────────────────────────────────────────────────────────── */
.receipt { border-radius: 20px; overflow: hidden; }
.receipt summary {
  list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer;
}
.receipt summary::-webkit-details-marker { display: none; }
.receipt-icon { flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--brand); background: var(--wash); box-shadow: inset 0 0 0 1px var(--line); }
.receipt-icon .icon { width: 21px; height: 21px; }
.receipt .row-title { display: block; }
.receipt-amount { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }
.receipt-chev { width: 18px; height: 18px; color: var(--ink-3); transition: transform 0.3s var(--ease-out); }
.receipt[open] .receipt-chev { transform: rotate(180deg); }
.receipt-body { padding: 0 14px 14px 70px; }
.receipt-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px dashed var(--line-strong); font-size: 14px; font-weight: 600; color: var(--ink-2); }
.receipt-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.receipt-line.is-total { border-top-style: solid; font-weight: 800; color: var(--ink); }
.receipt-meta { margin: 6px 0 0; font-size: 12.5px; font-weight: 700; color: var(--ink-3); }

/* ── Insurance ───────────────────────────────────────────────────────── */
.plan { padding: 20px 18px 18px; }
.plan-head { display: flex; align-items: center; gap: 12px; }
.plan-logo {
  flex: none; width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; padding: 9px;
  background: linear-gradient(150deg, var(--brand-lift), var(--brand-deep)); box-shadow: 0 10px 20px -12px rgba(8, 127, 155, 0.8);
}
.plan-logo img { width: 100%; height: 100%; object-fit: contain; }
.plan-logo span { color: #fff; font-family: var(--serif); font-size: 24px; }
.plan-name { margin: 0; font-family: var(--serif); font-size: 24px; line-height: 1.05; }
.plan-kind { margin: 3px 0 0; font-size: 13.5px; font-weight: 700; color: var(--ink-3); }
.plan-body { display: flex; align-items: center; gap: 20px; margin: 20px 0 18px; }
.plan-body .ring { width: 128px; height: 128px; }
.plan-body .ring circle { stroke-width: 11; }
.plan-body .ring-num { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 44px; line-height: 0.9; }
.plan-body .ring-num small { margin-top: 6px; font-family: var(--sans); font-size: 12px; font-weight: 800; color: var(--ink-3); }
.plan-facts { display: grid; gap: 12px; flex: 1; }
.fact { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; color: var(--ink-2); }
.fact b { font-family: var(--serif); font-weight: 400; font-size: 24px; color: var(--ink); min-width: 20px; }
.fact i { width: 11px; height: 11px; border-radius: 4px; flex: none; }
.fact i.is-used { background: linear-gradient(160deg, var(--brand-lift), var(--brand)); }
.fact i.is-left { box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.fact i.is-off { background: repeating-linear-gradient(-45deg, var(--muted-wash) 0 3px, #d9e1e4 3px 6px); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(22px, 1fr)); gap: 6px; }
.slot { height: 26px; border-radius: 8px; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.slot.is-used { box-shadow: none; background: linear-gradient(160deg, var(--brand-lift), var(--brand)); }
.slot.is-off { box-shadow: none; background: repeating-linear-gradient(-45deg, var(--muted-wash) 0 4px, #e2e8ea 4px 8px); }
.plan-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* ── Account sheet ───────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(6, 40, 50, 0.32); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade 0.25s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 70; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 480px); padding: 10px 18px calc(20px + var(--safe-b));
  border-radius: 28px 28px 0 0; background: rgba(255, 255, 255, 0.96);
  animation: sheet-in 0.38s var(--ease-out);
}
@keyframes sheet-in { from { transform: translate(-50%, 100%); } }
.sheet-grip { display: block; width: 40px; height: 5px; margin: 0 auto 16px; border-radius: 99px; background: var(--line-strong); }
.account-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.account-avatar { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff; background: linear-gradient(160deg, var(--brand-lift), var(--brand-deep)); }
.account-name { margin: 0; font-family: var(--serif); font-size: 24px; line-height: 1.1; }
.account-user { margin: 2px 0 0; font-size: 14px; font-weight: 600; color: var(--ink-3); }
.account-links { display: grid; gap: 6px; margin-bottom: 14px; }
.account-link { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 16px; font-weight: 700; background: rgba(237, 247, 250, 0.7); box-shadow: inset 0 0 0 1px var(--line); }
.account-link svg { width: 20px; height: 20px; color: var(--brand); }

.toast {
  position: fixed; z-index: 80; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px));
  transform: translate(-50%, calc(-100% - 40px)); max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 700; color: #fff;
  background: rgba(6, 63, 78, 0.92); box-shadow: 0 16px 30px -16px rgba(0, 0, 0, 0.5);
  visibility: hidden; transition: transform 0.4s var(--ease-out), visibility 0s 0.4s; pointer-events: none;
}
.toast.is-on { transform: translate(-50%, 0); visibility: visible; transition: transform 0.4s var(--ease-out); }

/* ── Larger screens ──────────────────────────────────────────────────── */
@media (min-width: 900px) {
  .is-preview .tabbar { top: 54px; }
  .topbar { padding: 0 28px; height: 72px; }
  .tabbar {
    top: 10px; bottom: auto; width: 520px; height: 52px; padding: 5px; border-radius: 999px;
    grid-template-columns: repeat(4, 1fr);
    box-shadow: inset 0 1px 0 #fff, 0 0 0 1px var(--line), 0 10px 24px -18px rgba(8, 80, 100, 0.4);
  }
  .tab { flex-direction: row; gap: 7px; font-size: 14px; border-radius: 999px; }
  .tab svg { width: 19px; height: 19px; }
  .app { width: min(100%, 1040px); padding: 34px 28px 60px; }
  .page-title { font-size: 44px; }

  .home-grid {
    display: grid; grid-template-columns: 1.05fr 1fr; gap: 0 18px; align-items: start;
    grid-template-areas: "balance next" "unpaid tiles";
  }
  .home-grid > .balance, .home-grid > .balance-hold { grid-area: balance; }
  .home-grid > .unpaid-card { grid-area: unpaid; }
  .home-grid > .next { grid-area: next; }
  .home-grid > .tiles { grid-area: tiles; }

  .split { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; align-items: start; }
  .split .section-title:first-child { margin-top: 0; }
  .plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 18px; }
  /* The tab bar sits at the top here, so messages rise from the bottom instead. */
  .toast { top: auto; bottom: 24px; transform: translate(-50%, calc(100% + 40px)); }
  .toast.is-on { transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}
