/* =========================================================================
   Client Card v4 — extracted from
   design/_inbox/design_handoff_client_card/App Client Card Prototype v4.html
   (lines 276–1114 of the prototype's inline <style>).

   Skipped (already covered elsewhere):
   - :root tokens + dark-mode overrides → theme.css + index.css
   - global resets (*, html, body) → already in index.css
   - .app / .sidebar / .brand / .nav-link / .nav-footer / .side-user /
     .su-* / .logout-btn / .nav-meta → already in index.css
   - theme toolbar (.toolbar, .tb-group, .cp-*, .a11y-*) → theme.css
   - mobile sidebar drawer (.menu-btn, .nav-scrim, body.nav-open, .app
     grid override at 900px) → MindBalance has its own responsive shell

   Card structure (matches the v4 README's component breakdown):
   .client-header → .ch-main (identity + contact + billing identity)
                    .ch-status (hero scene + status info panel)
   .state-controls → DEMO ONLY; production derives state from data
   .pay → .axes (three flow axes) + .pay-detail (expandable)
   .card .stat-row → quick stats (sessions / cadence / next meeting)
   .body-grid → .timeline + .note-pad

   Load AFTER index.css and theme.css.
   ========================================================================= */

.client-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 22px;
}
@media (max-width: 1120px) {
  .client-header { grid-template-columns: 1fr; }
  .client-header .ch-status { flex-direction: row; }
  .client-header .ch-status .hero { width: 220px; height: auto; min-height: 150px; flex-shrink: 0; }
  .client-header .status-info { flex: 1; }
}
@media (max-width: 560px) {
  .client-header .ch-status { flex-direction: column; }
  .client-header .ch-status .hero { width: 100%; min-height: 130px; }
}
.ch-main {
  background: var(--bg-secondary);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex; flex-direction: column;
  min-width: 0;
}
.ch-top { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
/* On narrower viewports (a 13" laptop, or with the browser sidebar open) the
   avatar + identity column + action buttons stop fitting on one row. Keep the
   identity column usable so the next-appointment pill doesn't collapse; the
   action buttons wrap below instead of crushing it. */
@media (max-width: 1160px) {
  .ch-main#identTop .ident-meta { min-width: 240px; }
}
.ident-avatar {
  width: 56px; height: 56px;
  background: var(--lilac);
  border-radius: 58% 42% 53% 47% / 50% 56% 44% 50%;
  display: grid; place-items: center;
  color: hsl(40 10% 18%);
  font: 600 18px/1 var(--font-family);
  flex-shrink: 0;
}
.ident-meta { flex: 1; min-width: 0; }
.ident-name {
  font-size: 25px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; margin: 0;
  display: inline-flex; align-items: center; gap: 12px; row-gap: 7px; flex-wrap: wrap;
}
.ident-sub { font-size: 13.5px; color: var(--text-secondary); margin-top: 8px; }
.ident-sub .dot { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: var(--text-soft); opacity: 0.5; margin: 0 8px; vertical-align: middle; }

/* Status pill in the name row */
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px;
  font: 600 12px/1 var(--font-family);
  background: var(--bg-tertiary); color: var(--text-secondary);
  white-space: nowrap;
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-soft); flex-shrink: 0; }
.status-pill.calm  { background: var(--success-light); color: var(--success-color); }
.status-pill.calm  .dot { background: var(--success-color); }
.status-pill.idle  { background: hsl(208 30% 90%); color: hsl(208 26% 38%); }
.status-pill.idle  .dot { background: var(--sky); }
.status-pill.watch { background: var(--warning-light); color: var(--warning-color); }
.status-pill.watch .dot { background: var(--warning-color); }
.status-pill.late  { background: hsl(20 40% 90%); color: hsl(20 38% 38%); }
.status-pill.late  .dot { background: var(--clay); }
.status-pill.sleep { background: hsl(266 22% 90%); color: hsl(266 18% 42%); }
.status-pill.sleep .dot { background: var(--lilac); }
.calendar-code-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--accent-light);
  color: var(--accent-hover);
  font: 700 12px/1 var(--font-family);
  white-space: nowrap;
}

/* Contact strip */
.ch-contact {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--hairline);
}
.contact-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  background: var(--bg-primary);
  border: 1px solid var(--hairline);
  min-width: 0;
}
.contact-chip .ic {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--accent-light); color: var(--accent-hover);
}
.contact-chip .ic svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.contact-chip .lbl { font-size: 10.5px; color: var(--text-soft); letter-spacing: 0.02em; display: block; margin-bottom: 1px; }
.contact-chip .val { font-size: 13.5px; color: var(--text-primary); font-weight: 500; }
.contact-chip.pref .ic { background: hsl(266 22% 90%); color: hsl(266 18% 42%); }
.chip-body { display: inline-flex; flex-direction: column; min-width: 0; }

/* === Billing identity (invoice recipient) === */
.ch-billing {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--hairline);
}
.bill-ic {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--bg-tertiary); color: var(--text-secondary);
  transition: background var(--transition-base), color var(--transition-base);
}
.bill-ic svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.ch-billing[data-type="company"] .bill-ic,
.ch-billing[data-type="osek"]    .bill-ic { background: var(--accent-light); color: var(--accent-hover); }
.bill-view { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; min-width: 0; }
.bill-label { font-size: 11px; letter-spacing: 0.03em; color: var(--text-soft); }
.bill-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.bill-id {
  font-size: 12px; color: var(--text-secondary);
  background: var(--bg-tertiary); padding: 2px 10px; border-radius: 999px;
}
.ch-billing[data-type="company"] .bill-id,
.ch-billing[data-type="osek"]    .bill-id { background: var(--accent-light); color: var(--accent-hover); font-weight: 500; }

.bill-edit { display: none; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.ch-billing.editing .bill-view { display: none; }
.ch-billing.editing .bill-edit { display: flex; }
.bill-input, .bill-id-field input {
  font-family: inherit; font-size: 13px; color: var(--text-primary);
  background: var(--bg-primary); border: 1px solid var(--border-color);
  border-radius: 7px; padding: 5px 9px; outline: none;
}
.bill-input:focus, .bill-id-field input:focus { border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-light); }
.bill-input { width: 17ch; }
.bill-id-field { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-soft); }
.bill-id-field input { width: 12ch; direction: ltr; text-align: right; }
.bill-id-field.hidden { display: none; }

.invoice-prefs-view {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}
.invoice-pref-chip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 150px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--bg-primary);
}
.invoice-pref-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
}
.invoice-pref-value {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.invoice-pref-source {
  font-size: 11.5px;
  color: var(--text-soft);
}

.seg { display: inline-flex; background: var(--bg-tertiary); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; font-family: inherit; font-size: 12px; color: var(--text-secondary); padding: 5px 11px; border-radius: 999px; cursor: pointer; transition: background var(--transition-base), color var(--transition-base); }
.seg button.active { background: var(--bg-primary); color: var(--text-primary); box-shadow: var(--shadow-sm); font-weight: 600; }

/* Inline-edit inputs */
.chip-input {
  display: none;
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--text-primary); background: transparent;
  border: none; border-bottom: 1.5px solid var(--accent-color);
  padding: 1px 0 2px; outline: none; width: 15ch; max-width: 56vw;
}
.contact-chip[data-field="email"] .chip-input { width: 20ch; }
.contact-chip[data-field="pref"]  .chip-input { width: 22ch; max-width: 70vw; }
.contact-chip[data-field="phone"] .chip-input,
.contact-chip[data-field="email"] .chip-input { direction: ltr; text-align: right; }
.ch-contact.editing .contact-chip .val { display: none; }
.ch-contact.editing .chip-input { display: inline-block; }
.ch-contact.editing .contact-chip { background: var(--bg-secondary); border-color: var(--border-color); }

.chip-actions { display: flex; align-items: center; gap: 6px; align-self: center; }
.chip-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--hairline); background: var(--bg-primary);
  display: grid; place-items: center; cursor: pointer; color: var(--text-secondary);
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.chip-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }
.chip-btn:hover { background: var(--bg-secondary); color: var(--text-primary); border-color: var(--border-color); }
.chip-save, .chip-cancel { display: none; }
.chip-save { border-color: var(--accent-color); color: var(--accent-hover); background: var(--accent-light); }
.chip-save:hover { background: var(--accent-color); color: #fff; border-color: var(--accent-color); }
.editing .chip-edit { display: none; }
.editing .chip-save,
.editing .chip-cancel { display: grid; }

/* === Generic inline-edit primitives (identity + note) === */
.edit-actions { display: flex; align-items: center; gap: 6px; }
.ii { display: none; }
.editing .iv { display: none; }
.editing .ii { display: inline-block; }
.ii {
  font-family: inherit; color: var(--text-primary); background: var(--bg-primary);
  border: 1px solid var(--border-color); border-radius: 7px;
  padding: 2px 8px; outline: none; vertical-align: baseline; max-width: 100%;
}
.ii:focus { border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-light); }
.ii-name { font-size: 24px; font-weight: 500; letter-spacing: -0.02em; width: 11ch; }
.ident-sub .ii { font-size: 13px; width: 15ch; margin: 1px 0; }
.ident-sub .ii-sm { width: 8.5ch; }
.ii-select { appearance: auto; cursor: pointer; padding-inline-end: 22px; }
.ident-sub .ii-select { width: auto; min-width: 14ch; }
/* hide the separator dots while editing the sub-line */
.ch-top.editing .ident-sub .dot { display: none; }

/* === Edit-mode labels & hints (Claude Design — taller form,
   minimal in read mode, descriptive in edit mode) === */
.ii-field { display: inline-flex; align-items: baseline; gap: 6px; }
.ch-top.editing .ii-field { flex-direction: column; align-items: flex-start; gap: 2px; margin-block-end: 12px; }
.ii-label, .ii-hint { display: none; }
.ch-top.editing .ii-label {
  display: block;
  font: 600 11px/1.2 var(--font-family);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-block-end: 2px;
}
.ch-top.editing .ii-hint {
  display: block;
  font: 400 12px/1.4 var(--font-family);
  color: var(--text-soft);
  margin-block-start: 4px;
  max-width: 38ch;
}
.ident-edit-extras { display: none; }
.ch-top.editing .ident-edit-extras {
  display: block;
  margin-block-start: 14px; padding: 12px 14px;
  background: var(--accent-light); color: var(--accent-hover);
  border-radius: 8px;
  font: 400 13px/1.5 var(--font-family);
  max-width: 56ch;
}
.ch-top.editing .ident-edit-extras strong { font-weight: 700; }
.ch-top.editing .ident-edit-extras em { font-style: normal; font-weight: 600; }

/* Tenure + Session are derived from data, not user input — hide them
   (and their separators) in edit mode so the form only shows things the
   user can actually change. */
.ch-top.editing .ii-field-derived,
.ch-top.editing .ii-derived-sep { display: none; }

/* Calendar-code: the chip stays as the read-mode view; an inline input
   appears in edit mode (max 6 digits). Override the chip's JS-set
   inline-flex so it disappears while editing. */
.ii-calcode { width: 7ch; text-align: center; font-weight: 600; }
.ch-top.editing #identCalendarCode { display: none !important; }
.ch-top.editing .ident-name { flex-wrap: wrap; row-gap: 10px; }
.ch-top.editing .ident-sub {
  flex-wrap: wrap; row-gap: 4px; align-items: flex-start;
}

/* (single-note inline editor removed — superseded by the notes-history
   composer block further down. Migration 033 ships the underlying
   client_notes table.) */

.ident-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ch-top.editing .ident-actions .icon-btn,
.ch-top.editing .ident-actions .primary-btn { display: none; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid; place-items: center;
  transition: color var(--transition-base), border-color var(--transition-base), background var(--transition-base);
}
.icon-btn:hover { color: var(--text-primary); border-color: var(--border-color); background: var(--bg-primary); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.primary-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  background: var(--ink); color: var(--ink-inv);
  border: none; border-radius: 999px;
  font: 500 13px/1 var(--font-family);
  cursor: pointer;
  transition: background var(--transition-base), transform var(--transition-base);
}
.primary-btn:hover { background: var(--ink-soft); transform: translateY(-1px); }

/* === Status panel (compact, lives in the header) === */
.ch-status {
  background: var(--bg-secondary);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
}

/* === Hero — animated sea scene, now a compact tile === */
.hero {
  position: relative;
  width: 100%;
  height: 138px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 45%, var(--sky-3) 70%, var(--sky-4) 100%);
  overflow: hidden;
  transition: background 1.2s ease;
}
/* compact wave geometry to fit the short tile */
.hero .wave-band { height: 34px; }
.hero .wave-back  { bottom: 30px; }
.hero .wave-mid   { bottom: 15px; }
.hero .wave-front { bottom: 0; }

.status-info {
  padding: 14px 18px 16px;
  display: flex; flex-direction: column; gap: 4px;
  flex: 1;
}
.status-caption {
  font: 600 14.5px/1.35 var(--font-family);
  color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.status-caption .swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--success-color); flex-shrink: 0; }
.status-foot { font-size: 12px; color: var(--text-soft); line-height: 1.5; margin-top: 2px; }
.status-money {
  display: flex; align-items: baseline; gap: 10px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--hairline);
}
.status-money .sm-label { font-size: 11.5px; color: var(--text-soft); }
.status-money .sm-amount {
  font-family: var(--font-serif); font-style: italic; font-size: 28px; line-height: 1;
  color: var(--text-primary);
}
.status-money .sm-amount.alert { color: var(--warning-color); }
.status-cta {
  margin-top: 12px; display: block; width: 100%;
  border: 1px solid var(--text-primary); background: var(--text-primary); color: var(--bg-primary);
  border-radius: 999px; padding: 10px 14px;
  font: 500 13px/1 var(--font-family); cursor: pointer;
  transition: opacity var(--transition-base);
}
.status-cta:hover { opacity: 0.85; }
.status-cta.ghost { background: transparent; color: var(--text-primary); border: 1px dashed var(--border-color); }
.hero .scene { position: absolute; inset: 0; }
.hero .scene svg { width: 100%; height: 100%; display: block; }

/* Sun */
@keyframes breathe { 0%,100% { transform: scale(1); filter: brightness(1); } 50% { transform: scale(1.04); filter: brightness(1.05); } }
.sun { transform-origin: 640px 130px; animation: breathe 6.5s ease-in-out infinite; }

/* Bird */
@keyframes bird-fly {
  0%   { transform: translate(-80px, 0); opacity: 0; }
  8%   { opacity: 1; }
  50%  { transform: translate(420px, -22px); opacity: 1; }
  92%  { opacity: 1; }
  100% { transform: translate(880px, -8px); opacity: 0; }
}
.bird { animation: bird-fly 18s linear infinite; transform-origin: center; }
@keyframes wing { 0%,100% { d: path('M0,0 q6,-6 12,0 q6,-6 12,0'); } 50% { d: path('M0,0 q6,4 12,0 q6,4 12,0'); } }

/* Waves — two stacked copies translate to make seamless loop */
.wave-band { position: absolute; left: 0; right: 0; height: 60px; pointer-events: none; }
.wave-band svg { width: 200%; height: 100%; }
.wave-back  { bottom: 60px; opacity: 0.55; animation: wave-shift 14s linear infinite; }
.wave-mid   { bottom: 30px; opacity: 0.75; animation: wave-shift 9s linear infinite; }
.wave-front { bottom: 0;    opacity: 1;    animation: wave-shift 6s linear infinite; }
@keyframes wave-shift { from { transform: translateX(0); } to { transform: translateX(-50%); } }
/* RTL flips translation visually but doesn't affect this — we want consistent direction */

/* Boat */
@keyframes bob {
  0%,100% { transform: translateY(0) rotate(-1.5deg); }
  50%     { transform: translateY(-6px) rotate(1.5deg); }
}
.boat { transform-origin: center bottom; animation: bob 4.4s ease-in-out infinite; }

/* Pebbles (debt state) */
@keyframes float-peb {
  0%,100% { transform: translateY(0) rotate(0deg); }
  50%     { transform: translateY(-5px) rotate(3deg); }
}
.pebbles { opacity: 0; transition: opacity 1s ease; }
.pebble  { animation: float-peb 5.5s ease-in-out infinite; transform-origin: center; }
.pebble:nth-child(2) { animation-duration: 6.2s; animation-delay: -1s; }
.pebble:nth-child(3) { animation-duration: 5s;   animation-delay: -2.4s; }
.pebble:nth-child(4) { animation-duration: 6.8s; animation-delay: -3.1s; }

/* Rain (overdue state) */
@keyframes raindrop {
  0%   { transform: translateY(-10px); opacity: 0; }
  20%  { opacity: 0.6; }
  100% { transform: translateY(180px); opacity: 0; }
}
.rain { opacity: 0; transition: opacity 1s ease; }
.rain line { animation: raindrop 1.6s linear infinite; transform-origin: top; }

/* Cloud (overdue) */
.cloud { opacity: 0; transition: opacity 1s ease; transform: translateX(0); animation: cloud-drift 40s linear infinite; }
@keyframes cloud-drift {
  0%   { transform: translateX(-40px); }
  100% { transform: translateX(120px); }
}

/* Scene + wave-band fade for biome switching */
.hero .scene, .hero .wave-band { transition: opacity 0.9s ease; }

/* Scroll-note (waiting to bill) */
@keyframes scroll-bob {
  0%,100% { transform: translateY(0) rotate(-3deg); }
  50%     { transform: translateY(-8px) rotate(3deg); }
}
@keyframes scroll-glow {
  0%,100% { opacity: 0.4; }
  50%     { opacity: 0.7; }
}
.scroll-note { opacity: 0; transition: opacity 0.9s ease; transform-origin: center; animation: scroll-bob 4.5s ease-in-out infinite; }
.scroll-note .glow { animation: scroll-glow 3s ease-in-out infinite; }

/* === Desert biome (dormant) === */
.biome-desert {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: none;
}
.biome-desert svg { width: 100%; height: 100%; display: block; }

@keyframes star-twinkle {
  0%,100% { opacity: 0.4; }
  50%     { opacity: 1; }
}
.star { animation: star-twinkle 3.2s ease-in-out infinite; transform-origin: center; }

@keyframes moon-glow {
  0%,100% { filter: drop-shadow(0 0 6px rgba(244,229,200,0.4)); }
  50%     { filter: drop-shadow(0 0 14px rgba(244,229,200,0.7)); }
}
.moon { animation: moon-glow 6s ease-in-out infinite; }

@keyframes z-float {
  0%   { opacity: 0; transform: translateY(0); }
  25%  { opacity: 0.95; }
  100% { opacity: 0; transform: translateY(-36px); }
}
.z { transform-origin: center; }
.z.z1 { animation: z-float 4.5s ease-out infinite; }
.z.z2 { animation: z-float 4.5s ease-out infinite; animation-delay: 1.5s; }
.z.z3 { animation: z-float 4.5s ease-out infinite; animation-delay: 3.0s; }

/* === State variants === */
/* 1) Sailing — active, has upcoming session, paid up */
.hero[data-state="sailing"] { background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 45%, var(--sky-3) 70%, var(--sky-4) 100%); }
.hero[data-state="sailing"] .bird { opacity: 1; }

/* 2) Idle — active, no upcoming session, paid up */
.hero[data-state="idle"] { background: linear-gradient(180deg,
    color-mix(in srgb, var(--sky-1), var(--mood-overcast) 16%) 0%,
    color-mix(in srgb, var(--sky-2), var(--mood-overcast) 16%) 45%,
    color-mix(in srgb, var(--sky-3), var(--mood-overcast) 20%) 70%,
    color-mix(in srgb, var(--sky-4), var(--mood-overcast) 22%) 100%); }
.hero[data-state="idle"] .bird { opacity: 0; }
.hero[data-state="idle"] .wave-front { animation-duration: 14s; }
.hero[data-state="idle"] .wave-mid   { animation-duration: 20s; }
.hero[data-state="idle"] .wave-back  { animation-duration: 26s; }
.hero[data-state="idle"] .boat       { animation-duration: 9s; }
.hero[data-state="idle"] .sun        { opacity: 0.85; }

/* 3) ToBill — sessions awaiting receipt by therapist */
.hero[data-state="tobill"] { background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 45%, var(--sky-3) 70%, var(--sky-4) 100%); }
.hero[data-state="tobill"] .bird { opacity: 0; }
.hero[data-state="tobill"] .scroll-note { opacity: 1; }
.hero[data-state="tobill"] .boat { animation-duration: 5s; }

/* 4) Pending — receipts issued, due date in future */
.hero[data-state="pending"] { background: linear-gradient(180deg,
    color-mix(in srgb, var(--sky-1), var(--mood-warn) 14%) 0%,
    color-mix(in srgb, var(--sky-2), var(--mood-warn) 12%) 45%,
    color-mix(in srgb, var(--sky-3), var(--mood-cool) 12%) 70%,
    color-mix(in srgb, var(--sky-4), var(--mood-cool) 14%) 100%); }
.hero[data-state="pending"] .bird    { opacity: 0; }
.hero[data-state="pending"] .pebbles { opacity: 1; }
.hero[data-state="pending"] .cloud   { opacity: 0.5; }
.hero[data-state="pending"] .wave-front { animation-duration: 7s; }
.hero[data-state="pending"] .boat       { animation-duration: 4.4s; }

/* 5) Drizzle — light overdue (a week or two) */
.hero[data-state="drizzle"] { background: linear-gradient(180deg,
    color-mix(in srgb, var(--sky-1), var(--mood-cool) 26%) 0%,
    color-mix(in srgb, var(--sky-2), var(--mood-cool) 24%) 45%,
    color-mix(in srgb, var(--sky-3), var(--mood-cool) 28%) 70%,
    color-mix(in srgb, var(--sky-4), var(--mood-storm) 24%) 100%); }
.hero[data-state="drizzle"] .bird    { opacity: 0; }
.hero[data-state="drizzle"] .pebbles { opacity: 1; }
.hero[data-state="drizzle"] .rain    { opacity: 0.55; }
.hero[data-state="drizzle"] .cloud   { opacity: 0.8; }
.hero[data-state="drizzle"] .sun     { opacity: 0.7; }
.hero[data-state="drizzle"] .wave-front { animation-duration: 5s; }
.hero[data-state="drizzle"] .boat       { animation-duration: 3.8s; }

/* 6) Storm — significantly overdue (30+ days) */
.hero[data-state="storm"] { background: linear-gradient(180deg,
    color-mix(in srgb, var(--sky-1), var(--mood-storm) 46%) 0%,
    color-mix(in srgb, var(--sky-2), var(--mood-storm) 44%) 45%,
    color-mix(in srgb, var(--sky-3), var(--mood-storm) 50%) 70%,
    color-mix(in srgb, var(--sky-4), var(--mood-storm) 56%) 100%); }
.hero[data-state="storm"] .bird    { opacity: 0; }
.hero[data-state="storm"] .pebbles { opacity: 1; }
.hero[data-state="storm"] .rain    { opacity: 1; }
.hero[data-state="storm"] .cloud   { opacity: 1; }
.hero[data-state="storm"] .sun     { opacity: 0.3; }
.hero[data-state="storm"] .wave-front { animation-duration: 3.5s; }
.hero[data-state="storm"] .wave-mid   { animation-duration: 5s; }
.hero[data-state="storm"] .boat       { animation-duration: 2.6s; }

/* 7) Sleeping — dormant client, desert night */
.hero[data-state="sleeping"] { background: linear-gradient(180deg, #2D3550 0%, #4A4264 45%, #7A6A85 75%, #B89B95 100%); }
.hero[data-state="sleeping"] .scene,
.hero[data-state="sleeping"] .wave-band { opacity: 0; }
.hero[data-state="sleeping"] .biome-desert { opacity: 1; }

/* Status caption swatch colors (driven by state class set in JS) */
.status-caption.calm  .swatch { background: var(--success-color); }
.status-caption.idle  .swatch { background: var(--sky); }
.status-caption.watch .swatch { background: var(--warning-color); }
.status-caption.late  .swatch { background: var(--clay); }
.status-caption.storm .swatch { background: hsl(28 25% 38%); }
.status-caption.sleep .swatch { background: var(--lilac); }

/* Prototype controls bar — below the hero */
.state-controls {
  margin-top: 14px;
  display: flex; align-items: center; gap: 12px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  overflow-x: auto;
}
.state-controls-label {
  font: 500 11px/1 var(--font-family);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-soft);
  padding-inline-start: 8px; padding-inline-end: 4px;
  white-space: nowrap;
}
.state-switch {
  display: flex; gap: 2px;
  flex-wrap: nowrap;
}
.state-switch button {
  border: none; background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font: 500 12.5px/1 var(--font-family);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-base), color var(--transition-base);
}
.state-switch button:hover { color: var(--text-primary); }
.state-switch button.active { background: var(--ink); color: var(--ink-inv); }

/* ===== Payment model — three flow axes ===== */
.pay-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.pay-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0; color: var(--text-primary); }
.pay-sub { font-size: 13px; color: var(--text-soft); }
.pay-recipient {
  margin-inline-start: auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-secondary);
  background: var(--bg-secondary); border: 1px solid var(--hairline);
  padding: 5px 12px; border-radius: 999px;
}
.pay-recipient svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.pay-recipient.company { background: var(--accent-light); border-color: transparent; color: var(--accent-hover); font-weight: 500; }

.axes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.axis {
  background: var(--bg-secondary); border: 1px solid var(--hairline);
  border-radius: var(--radius-md); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 9px;
  border-top: 3px solid var(--hairline);
}
.axis.have   { border-top-color: var(--success-color); }
.axis.expect { border-top-color: var(--sky); }
.axis.wait   { border-top-color: var(--clay); }
.axis.wait.is-paused { border-top-color: var(--text-soft); background: var(--bg-tertiary); }

.axis-top { display: flex; align-items: center; gap: 9px; }
.axis-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; background: var(--bg-tertiary); color: var(--text-secondary); }
.axis.have .axis-ic   { background: var(--success-light); color: var(--success-color); }
.axis.expect .axis-ic { background: hsl(208 30% 90%); color: hsl(208 26% 38%); }
.axis.wait .axis-ic   { background: hsl(28 45% 90%); color: var(--warning-color); }
.axis-ic svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.axis-label { font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-soft); font-weight: 600; }
.axis-amount { font-family: var(--font-serif); font-style: italic; font-size: 34px; line-height: 1; color: var(--text-primary); }
.axis.have .axis-amount { color: var(--success-color); }
.axis.wait .axis-amount { color: hsl(20 38% 42%); }
.axis.wait.is-paused .axis-amount { color: var(--text-soft); }
.axis-line { font-size: 12.5px; color: var(--text-secondary); line-height: 1.45; }
.axis-arr { font-size: 12px; color: var(--text-soft); line-height: 1.5; margin-top: auto; padding-top: 9px; }
.axis-arr .ok   { color: var(--success-color); font-weight: 600; }
.axis-arr .bad  { color: var(--clay); font-weight: 600; }
.axis-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.src-tag { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.src-tag::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.src-tag.private { background: var(--accent-light); color: var(--accent-hover); }
.src-tag.inst    { background: hsl(208 30% 90%); color: hsl(208 26% 38%); }

.axis-pkg { margin-top: 2px; }
.pkg-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.pkg-row span:last-child { color: var(--text-primary); font-weight: 600; }
.pkg-bar { height: 6px; border-radius: 999px; background: var(--bg-tertiary); overflow: hidden; }
.pkg-bar span { display: block; height: 100%; background: var(--success-color); border-radius: 999px; transition: width 0.4s ease; }
.pkg-foot { font-size: 11px; color: var(--text-soft); margin-top: 6px; }

/* waiting chip — gentle gradations; raw days only on hover */
.wait-chip { font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 999px; cursor: help; display: inline-flex; align-items: center; gap: 6px; }
.wait-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.wait-chip.none   { background: var(--success-light); color: var(--success-color); }
.wait-chip.due    { background: var(--bg-tertiary); color: var(--text-secondary); }
.wait-chip.little { background: var(--warning-light); color: var(--warning-color); }
.wait-chip.while  { background: hsl(28 46% 88%); color: hsl(20 42% 40%); }
.wait-chip.long   { background: hsl(18 44% 88%); color: hsl(14 48% 38%); }
.wait-chip.paused { background: var(--bg-tertiary); color: var(--text-soft); }

/* Expandable detail */
.pay-detail { margin-top: 16px; background: var(--bg-secondary); border: 1px solid var(--hairline); border-radius: var(--radius-md); overflow: hidden; }
.detail-toggle { width: 100%; display: flex; align-items: center; gap: 12px; padding: 15px 20px; background: transparent; border: 0; cursor: pointer; font-family: inherit; text-align: start; }
.dt-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.dt-hint { font-size: 12px; color: var(--text-soft); margin-inline-end: auto; }
.detail-toggle .chev { width: 18px; height: 18px; stroke: var(--text-soft); fill: none; stroke-width: 2; transition: transform var(--transition-base); }
.pay-detail.open .detail-toggle .chev { transform: rotate(180deg); }
.detail-body { display: none; padding: 0 20px 10px; }
.pay-detail.open .detail-body { display: block; }

.dgroup { padding: 16px 0; border-top: 1px solid var(--hairline); }
.dgroup:first-child { border-top: 0; padding-top: 4px; }
.dgroup-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.dgroup-title { font-size: 13px; font-weight: 600; margin: 0; color: var(--text-primary); display: inline-flex; align-items: center; gap: 8px; }
.dgroup-title::before { content: ''; width: 8px; height: 8px; border-radius: 50%; }
.dgroup.wait   .dgroup-title::before { background: var(--clay); }
.dgroup.expect .dgroup-title::before { background: var(--sky); }
.dgroup.have   .dgroup-title::before { background: var(--success-color); }
.dgroup-note { font-size: 12px; color: var(--text-soft); }

.ditems { display: flex; flex-direction: column; gap: 10px; }
.ditem {
  display: grid; grid-template-columns: 60px 1fr auto; gap: 14px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--bg-primary);
}
.ditem.warm  { background: hsl(28 50% 97%); border-color: hsl(28 38% 89%); }
.ditem.muted { background: var(--bg-tertiary); opacity: 0.9; }
.ditem.legacy-debt { background: hsl(43 36% 96%); border-color: hsl(43 32% 84%); }
.ditem.alert { background: hsl(18 46% 96%); border: 1px solid hsl(18 40% 86%); grid-template-columns: 1fr auto; }
.di-date { font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; line-height: 1.3; }
.di-date strong { display: block; font-size: 13px; color: var(--text-primary); font-weight: 600; }
.di-main { min-width: 0; }
.di-title { font-size: 13.5px; color: var(--text-primary); font-weight: 500; }
.di-title .warn-ic { color: var(--clay); }
.ditem .di-badge {
  display: inline-flex;
  align-items: center;
  margin-inline-start: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: middle;
}
.ditem .di-badge.legacy { background: hsl(43 40% 88%); color: hsl(43 38% 32%); }
.di-meta { font-size: 11.5px; color: var(--text-soft); margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.wait-mini { cursor: help; color: var(--clay); font-weight: 500; }
.doc-chip { font-size: 10.5px; padding: 2px 8px; border-radius: 999px; font-weight: 500; }
.doc-chip.none   { background: transparent; color: var(--text-soft); border: 1px dashed var(--border-color); }
.doc-chip.issued { background: hsl(43 40% 88%); color: hsl(43 38% 32%); }
.doc-chip.sent   { background: var(--success-light); color: var(--success-color); }
.di-right { display: flex; align-items: center; gap: 12px; }
.di-amount { font-size: 14px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.di-amount.warm { color: hsl(20 38% 42%); }
.di-amount.good { color: var(--success-color); }
.di-fore { font-size: 11px; color: var(--text-soft); }
.di-btn { border: 1px solid var(--hairline); background: var(--bg-secondary); color: var(--text-secondary); padding: 7px 12px; border-radius: 999px; font: 500 12px/1 var(--font-family); cursor: pointer; white-space: nowrap; transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base); }
.di-btn:hover { background: var(--ink); color: var(--ink-inv); border-color: var(--ink); }
.di-btn.primary { background: var(--accent-color); color: var(--bg-primary); border-color: var(--accent-color); }
.di-btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.wait-empty { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border: 1px solid var(--success-light); border-radius: var(--radius-sm); font-size: 13px; color: var(--success-color); background: var(--success-light); }
.wait-empty svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }

@media (max-width: 880px) { .axes { grid-template-columns: 1fr; } }
@media (max-width: 600px) {
  .ditem { grid-template-columns: 1fr auto; }
  .ditem .di-date { grid-column: 1 / -1; }
}

/* === Body grid === */
.body-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: 22px;
  margin-top: 24px;
}

/* Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 22px 24px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-soft); font-weight: 600; margin: 0; }
.card-link { font-size: 12px; color: var(--text-soft); text-decoration: none; }
.card-link:hover { color: var(--text-primary); }

/* Quick stats inside card */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { padding: 10px 0; }
.stat-label { font-size: 11px; color: var(--text-soft); letter-spacing: 0.04em; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-primary); }
.stat-value.serif { font-family: var(--font-serif); font-weight: 400; font-style: italic; font-size: 30px; }
.stat-foot { font-size: 12px; color: var(--text-soft); margin-top: 4px; }

/* Sessions timeline */
.timeline { position: relative; padding-inline-start: 18px; }
.timeline::before {
  content: '';
  position: absolute;
  inset-block: 6px;
  inset-inline-start: 5px;
  width: 1.5px;
  background: var(--hairline);
}
.tl-item {
  position: relative;
  padding-block: 10px;
  padding-inline-start: 14px;
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 12px;
  align-items: baseline;
}
.tl-item::before {
  content: '';
  position: absolute;
  inset-block-start: 18px;
  inset-inline-start: -4px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1.5px solid var(--accent-color);
}
.tl-item.upcoming::before { border-style: dashed; background: var(--bg-primary); }
.tl-date { font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.tl-text { font-size: 14px; color: var(--text-primary); line-height: 1.5; }
.tl-text .note { color: var(--text-soft); font-size: 13px; }
.tl-tag {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: var(--bg-tertiary); color: var(--text-secondary); font-weight: 500;
}
.tl-tag.paid   { background: var(--success-light); color: var(--success-color); }
.tl-tag.due    { background: var(--warning-light); color: var(--warning-color); }

/* Payments */
.pay-summary {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 18px;
}
.pay-amount { font-family: var(--font-serif); font-style: italic; font-size: 40px; line-height: 1; color: var(--text-primary); }
.pay-state {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 500;
}
.pay-state.paid { background: var(--success-light); color: var(--success-color); }
.pay-state.due  { background: var(--warning-light); color: var(--warning-color); }
.pay-state.late { background: hsl(28 30% 88%); color: hsl(28 30% 35%); }

.pay-row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 10px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 13.5px;
}
.pay-row:last-child { border-bottom: none; }
.pay-row .label { color: var(--text-primary); }
.pay-row .label small { display: block; color: var(--text-soft); font-size: 11.5px; margin-top: 2px; }
.pay-row .amt { color: var(--text-primary); font-variant-numeric: tabular-nums; font-weight: 500; }
.pay-row .tag {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: var(--bg-tertiary); color: var(--text-secondary); font-weight: 500;
}
.pay-row .tag.paid { background: var(--success-light); color: var(--success-color); }
.pay-row .tag.due  { background: var(--warning-light); color: var(--warning-color); }

.gentle-cta {
  margin-top: 14px;
  width: 100%;
  text-align: center;
  background: transparent;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  font: 500 13px/1 var(--font-family);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.gentle-cta:hover { background: var(--bg-primary); color: var(--text-primary); border-color: var(--border-color); }

/* Note pad — notes history (1:many). Each item carries its own date.
   Source: design/_inbox/design_handoff_client_card/ (v14 prototype). */
.note-pad {
  background: var(--bg-secondary);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 22px 24px;
}
.note-pad p { margin: 0; font-size: 14.5px; color: var(--text-secondary); line-height: 1.65; }
.note-pad p + p { margin-top: 10px; }

/* "+ הוספה" button in the card head */
.note-add-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--accent-hover); background: var(--accent-light);
  border: none; border-radius: 999px; padding: 6px 12px; cursor: pointer;
  transition: var(--transition-base);
}
.note-add-btn:hover { filter: brightness(0.97); }
.note-add-btn svg {
  width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2;
}

/* Composer (add a new note) — only visible while .adding */
.note-composer { display: none; margin-bottom: 16px; }
.note-pad.adding .note-composer { display: block; }
.note-pad.adding .note-add-btn { opacity: 0.45; pointer-events: none; }
.note-composer textarea {
  width: 100%; box-sizing: border-box; font-family: inherit;
  font-size: 14.5px; color: var(--text-secondary); line-height: 1.6;
  background: var(--bg-primary); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 11px 13px; outline: none;
  resize: vertical; min-height: 78px;
}
.note-composer textarea:focus {
  border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-light);
}
.note-composer-actions { display: flex; gap: 8px; margin-top: 10px; }
.note-composer-actions button {
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  border-radius: 999px; padding: 7px 16px; cursor: pointer;
  border: 1px solid transparent; transition: var(--transition-base);
}
.nc-save { background: var(--accent-color); color: var(--ink-inv); }
.nc-save:hover { background: var(--accent-hover); }
.nc-cancel { background: transparent; color: var(--text-soft); border-color: var(--border-color); }
.nc-cancel:hover { background: var(--bg-tertiary); }

/* Note list */
.notes-list { display: flex; flex-direction: column; }
.note-item {
  position: relative;
  padding: 14px 0;
  border-top: 1px solid var(--hairline);
}
.note-item:first-child { border-top: none; padding-top: 2px; }
.note-item-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 5px;
}
.note-item-date {
  font-size: 11.5px; color: var(--text-soft);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.note-item-text {
  margin: 0; font-size: 14.5px; color: var(--text-secondary);
  line-height: 1.6; white-space: pre-wrap;
}
.note-del {
  flex-shrink: 0; inline-size: 24px; block-size: 24px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-soft); border-radius: 50%; cursor: pointer;
  opacity: 0; transition: opacity var(--transition-base),
    background var(--transition-base), color var(--transition-base);
}
.note-item:hover .note-del,
.note-item:focus-within .note-del { opacity: 1; }
.note-del:hover:not(:disabled) { background: var(--warning-light); color: var(--warning-color); }
.note-del[disabled] { cursor: default; }
.note-del svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.note-item.pending { opacity: 0.55; }
.note-item.pending .note-item-date { font-style: italic; }
.notes-empty { font-size: 13.5px; color: var(--text-soft); padding: 8px 0; }

/* === Billing tracking card === */
.billing-card .card-head {
  align-items: flex-start; flex-direction: column; gap: 14px;
  margin-bottom: 18px;
}
.billing-head-row {
  display: flex; align-items: center; gap: 16px;
  width: 100%; flex-wrap: wrap;
}
.billing-head-row > .card-title { margin-inline-end: auto; }
.billing-mode {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--text-soft);
}
.mode-toggle {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--bg-primary); border: 1px solid var(--hairline);
  border-radius: 999px;
}
.mode-toggle button {
  border: 0; background: transparent;
  padding: 5px 12px; font: 500 12px/1 var(--font-family);
  color: var(--text-secondary); border-radius: 999px; cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base);
}
.mode-toggle button.active { background: var(--text-primary); color: var(--bg-primary); }

.billing-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  padding: 16px 18px; background: var(--bg-primary);
  border-radius: var(--radius-sm); border: 1px solid var(--hairline);
  margin-bottom: 6px;
}
.bs-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-inline-end: 8px; border-inline-end: 1px solid var(--hairline); }
.bs-cell:last-child { border-inline-end: 0; }
.bs-label { font-size: 10.5px; color: var(--text-soft); letter-spacing: 0.04em; text-transform: uppercase; }
.bs-value {
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text-primary); font-variant-numeric: tabular-nums;
}
.bs-value.serif { font-family: var(--font-serif); font-weight: 400; font-style: italic; font-size: 28px; line-height: 1; }
.bs-value.alert { color: var(--warning-color); }
.bs-value.late  { color: hsl(20 38% 40%); }
.bs-value.muted { color: var(--text-soft); }

.billing-rows { display: flex; flex-direction: column; padding-top: 6px; }
.brow {
  display: grid;
  grid-template-columns: 78px minmax(0,1.1fr) minmax(0,1.4fr) auto auto;
  gap: 14px; align-items: center;
  padding: 14px 4px;
  border-bottom: 1px solid var(--hairline);
}
.brow:last-child { border-bottom: 0; }
.brow.late { background: linear-gradient(90deg, hsla(20, 40%, 90%, 0.4), transparent 70%); }
.brow.partial { background: linear-gradient(90deg, hsla(28, 45%, 92%, 0.45), transparent 70%); }

.b-date { font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; line-height: 1.4; }
.b-date strong { display: block; font-size: 13.5px; color: var(--text-primary); font-weight: 600; letter-spacing: -0.01em; }
.b-session { font-size: 13.5px; color: var(--text-primary); }
.b-session small { display: block; font-size: 11.5px; color: var(--text-soft); margin-top: 2px; }

.b-doc { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 9px; min-width: 0; }
.b-doc .doc-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--bg-tertiary); color: var(--text-secondary); }
.b-doc .doc-icon svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.b-doc.kind-receipt .doc-icon { background: var(--success-light); color: var(--success-color); }
.b-doc.kind-invoice .doc-icon { background: hsl(43 40% 88%); color: hsl(43 38% 32%); }
.b-doc.kind-internal .doc-icon { background: var(--bg-tertiary); color: var(--text-soft); }
.b-doc.kind-none .doc-icon { background: transparent; color: var(--text-soft); border: 1px dashed var(--border-color); }
.b-doc-text { min-width: 0; }
.b-doc-text strong { display: block; font-weight: 600; color: var(--text-primary); font-size: 13px; letter-spacing: -0.005em; }
.b-doc-text small { display: block; font-size: 11px; color: var(--text-soft); margin-top: 1px; }
.b-doc.empty .b-doc-text strong { color: var(--text-soft); font-weight: 500; font-style: italic; }

.b-amount { text-align: end; font-variant-numeric: tabular-nums; line-height: 1.3; }
.b-amount strong { font-size: 14px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.b-amount small { display: block; font-size: 11px; color: var(--text-soft); font-weight: 400; margin-top: 2px; }
.b-amount.partial strong { color: hsl(28 38% 40%); }
.b-amount.partial small { color: hsl(28 30% 45%); }

.b-status { display: flex; align-items: center; gap: 8px; }
.pill {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
}
.pill::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: 0.6;
}
.pill.paid     { background: var(--success-light); color: var(--success-color); }
.pill.partial  { background: hsl(28 50% 92%); color: hsl(28 38% 38%); }
.pill.late     { background: hsl(20 40% 90%); color: hsl(20 38% 38%); }
.pill.pending  { background: var(--warning-light); color: var(--warning-color); }
.pill.awaiting { background: hsl(43 35% 88%); color: hsl(43 38% 30%); }

.b-action { display: flex; gap: 6px; align-items: center; }
.b-btn {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--hairline); background: var(--bg-primary);
  padding: 6px 11px; border-radius: 999px;
  font: 500 12px/1 var(--font-family); color: var(--text-secondary);
  cursor: pointer; white-space: nowrap;
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.b-btn:hover { background: var(--text-primary); color: var(--bg-primary); border-color: var(--text-primary); }
.b-btn svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.b-btn.primary { background: var(--accent-color); color: var(--bg-primary); border-color: var(--accent-color); }
.b-btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.b-btn.soon { opacity: 0.55; cursor: help; }
.b-btn.soon:hover { background: var(--bg-primary); color: var(--text-secondary); border-color: var(--hairline); }
.b-btn .badge-soon {
  font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-soft); margin-inline-start: 2px;
}

.billing-footnote {
  margin-top: 14px;
  padding: 11px 14px;
  background: var(--bg-primary);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 12.5px; color: var(--text-secondary); line-height: 1.55;
}
.billing-footnote svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; flex-shrink: 0; margin-top: 2px; opacity: 0.7; }
.billing-footnote strong { color: var(--text-primary); font-weight: 600; }

/* === Per-session billing cards === */
.bsession-list { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }

/* Consolidated (monthly) invoice banner */
.group-invoice {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 22px;
  margin: 16px 0 4px;
  background: hsl(43 55% 96%);
  border: 1px solid hsl(43 45% 80%);
  border-radius: var(--radius-md);
  position: relative;
}
.gi-icon {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: hsl(43 45% 85%); color: hsl(43 38% 28%);
  flex-shrink: 0;
}
.gi-icon svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.gi-body { flex: 1; min-width: 0; }
.gi-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary); margin: 0;
  letter-spacing: -0.01em;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.gi-title .num { color: hsl(43 38% 28%); font-variant-numeric: tabular-nums; }
.gi-title .total {
  font-family: var(--font-serif); font-style: italic; font-weight: 400;
  font-size: 22px; color: hsl(43 38% 24%); letter-spacing: -0.01em;
}
.gi-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 5px; }
.gi-sub strong { color: var(--text-primary); font-weight: 500; }
.gi-actions { display: flex; gap: 8px; flex-shrink: 0; }
.gi-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid hsl(43 45% 75%);
  background: var(--bg-secondary);
  color: hsl(43 38% 28%);
  font: 500 12.5px/1 var(--font-family);
  cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base);
}
.gi-btn:hover { background: hsl(43 50% 90%); }
.gi-btn.primary {
  background: hsl(43 38% 28%); color: hsl(43 55% 96%);
  border-color: hsl(43 38% 28%);
}
.gi-btn.primary:hover { background: hsl(43 38% 22%); }
.gi-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.7; }

@media (max-width: 700px) {
  .group-invoice { flex-direction: column; align-items: flex-start; }
  .gi-actions { width: 100%; }
  .gi-btn { flex: 1; justify-content: center; }
}

.bsession {
  background: var(--bg-primary);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  border-inline-start: 4px solid var(--hairline);
  position: relative;
}
.bsession.paid     { border-inline-start-color: var(--success-color); }
.bsession.partial  { border-inline-start-color: hsl(28 45% 55%); background: hsl(28 50% 97%); }
.bsession.late     { border-inline-start-color: var(--clay);         background: hsl(20 45% 97%); }
.bsession.pending  { border-inline-start-color: var(--warning-color); }
.bsession.awaiting { border-inline-start-color: var(--butter);       background: hsl(43 50% 98%); }

.bsession-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 14px;
}
.bsession-title {
  font-size: 16px; font-weight: 600; color: var(--text-primary);
  margin: 0; letter-spacing: -0.01em; line-height: 1.3;
}
.bsession-date {
  font-size: 12px; color: var(--text-soft);
  font-variant-numeric: tabular-nums; margin-top: 5px;
}
.bsession-pills {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end;
  flex-shrink: 0;
}

.bsession-alert {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  background: hsl(20 50% 93%);
  color: hsl(20 50% 32%);
  display: flex; align-items: flex-start; gap: 9px;
  line-height: 1.5;
}
.bsession-alert.warn { background: var(--warning-light); color: var(--warning-color); }
.bsession-alert.info { background: var(--success-light); color: var(--success-color); }
.bsession-alert svg {
  width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8;
  flex-shrink: 0; margin-top: 2px;
}
.bsession-alert strong { font-weight: 600; }

.bsession-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 8px;
}
.bstat {
  background: var(--bg-secondary);
  padding: 12px 14px;
  text-align: center;
  display: flex; flex-direction: column; gap: 5px;
}
.bstat-label {
  font-size: 11px; color: var(--text-soft);
  letter-spacing: 0.02em;
}
.bstat-value {
  font-size: 16px; font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.bstat-value.alert { color: var(--clay); }
.bstat-value.warn  { color: var(--warning-color); }
.bstat-value.good  { color: var(--success-color); }
.bstat-value.muted { color: var(--text-soft); font-weight: 500; }

.bsession-terms {
  font-size: 12.5px;
  color: var(--text-soft);
  margin: 14px 0 14px;
  display: flex; gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}
.bsession-terms strong { color: var(--text-secondary); font-weight: 500; }

.bsession-action {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  background: var(--accent-color); color: var(--bg-primary);
  border: 0; border-radius: var(--radius-sm);
  padding: 12px;
  font: 500 13.5px/1 var(--font-family);
  cursor: pointer;
  transition: background var(--transition-base);
}
.bsession-action:hover { background: var(--accent-hover); }
.bsession-action svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.bsession-action.ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--hairline);
}
.bsession-action.ghost:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.bsession-action.warn {
  background: var(--warning-color);
}
.bsession-action.warn:hover { background: hsl(28 35% 42%); }

.bsession-actions-row { display: flex; gap: 8px; }
.bsession-actions-row .bsession-action { flex: 1; }

.bsession-receipts {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-color);
}
.bsession-receipts-title {
  font-size: 11px; color: var(--text-soft);
  letter-spacing: 0.04em; margin-bottom: 8px;
  text-transform: uppercase;
}
.bsession-receipt-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 5px 0;
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.bsession-receipt-row .method { color: var(--text-primary); }
.bsession-receipt-row .amt { color: var(--success-color); font-weight: 500; }
.bsession-receipt-row.refund .amt { color: var(--clay); }

@media (max-width: 700px) {
  .bsession { padding: 16px 16px; }
  .bsession-head { flex-direction: column; gap: 10px; }
  .bsession-pills { justify-content: flex-start; }
  .bsession-stats { grid-template-columns: repeat(3, 1fr); }
  .bstat { padding: 10px 6px; }
  .bstat-value { font-size: 14px; }
  .bsession-actions-row { flex-direction: column; }
}

/* Aside slimmer summary */
.aside-status {
  background: var(--bg-secondary);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 20px 22px;
}
.aside-status .stat-amount {
  font-family: var(--font-serif); font-style: italic;
  font-size: 36px; line-height: 1; color: var(--text-primary);
}
.aside-status .stat-foot { margin-top: 8px; font-size: 12.5px; color: var(--text-secondary); }
.aside-status .stat-cta {
  margin-top: 14px; display: block; width: 100%;
  border: 1px solid var(--text-primary); background: var(--text-primary); color: var(--bg-primary);
  border-radius: 999px; padding: 10px 14px;
  font: 500 13px/1 var(--font-family); cursor: pointer;
  transition: opacity var(--transition-base);
}
.aside-status .stat-cta:hover { opacity: 0.85; }
.aside-status .stat-cta.ghost {
  background: transparent; color: var(--text-primary);
  border: 1px dashed var(--border-color);
}

@media (max-width: 1100px) {
  .brow { grid-template-columns: 70px 1fr 1fr auto; row-gap: 6px; }
  .brow .b-action { grid-column: 1 / -1; justify-content: flex-end; padding-top: 2px; }
}
@media (max-width: 700px) {
  .billing-summary { grid-template-columns: repeat(2, 1fr); }
  .bs-cell:nth-child(2) { border-inline-end: 0; }
  .brow { grid-template-columns: 1fr auto; gap: 8px; }
  .brow .b-date    { grid-column: 1; grid-row: 1; }
  .brow .b-amount  { grid-column: 2; grid-row: 1; }
  .brow .b-session { grid-column: 1 / -1; }
  .brow .b-doc     { grid-column: 1 / -1; }
  .brow .b-status  { grid-column: 1 / -1; }
}

/* === Mobile nav (hamburger drawer) === */

/* =========================================================================
   MindBalance addition: scheduled appointments card next to the quick stats.
   Not in the v4 prototype — added per product decision (Phase C2).
   ========================================================================= */
.cc-card-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .cc-card-row { grid-template-columns: 1fr; }
}

.upcoming-card .card-head { margin-bottom: 14px; }
.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.upcoming-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md, 12px);
  transition: background var(--transition-base), border-color var(--transition-base);
}
.upcoming-item:hover {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}
.up-date {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
  border-inline-end: 1px solid var(--hairline);
  padding-inline-end: 12px;
}
.up-day {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
}
.up-time {
  font-size: 11.5px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.up-body { min-inline-size: 0; }
.up-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
}
.up-note {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 3px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.upcoming-empty {
  font-size: 13px;
  color: var(--text-soft);
  text-align: center;
  padding: 18px 0;
  font-style: italic;
}

/* Empty-state fallback inside detail groups (waitItems / expectItems / haveItems) */
.ditem.empty {
  background: transparent;
  border: 1px dashed var(--hairline);
  color: var(--text-soft);
  font-style: italic;
  text-align: center;
  padding: 14px;
}

/* Wait axis renders with a calmer tone when there's nothing waiting */
.axis.wait.wait-empty .axis-amount { color: var(--success-color); }

/* Timeline upcoming item gets a slightly different highlight */
.tl-item.upcoming .tl-tag {
  background: var(--accent-light);
  color: var(--accent-hover);
}

/* =========================================================================
   Breadcrumb (page-level, used at the top of the client card).
   Lines 194–198 + 270–273 of the v4 prototype CSS — missed in the first
   extraction pass because they were intermingled with the theme toolbar
   rules. Without these, the chevron <svg> renders unbounded and balloons
   to fill the page.
   ========================================================================= */
.cc-page .breadcrumb {
  font-size: 13px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.cc-page .breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
}
.cc-page .breadcrumb a:hover { color: var(--text-primary); }
.cc-page .breadcrumb svg {
  inline-size: 12px;
  block-size: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
}

/* =========================================================================
   Client Card v5 — unified identity editor + next appointment + ledger.
   This layer intentionally overrides the v4 payment axes while keeping the
   existing hero scene and notes/billing mount styling intact.
   ========================================================================= */
.ch-main#identTop {
  padding: 22px 24px;
}
.ch-main#identTop .ie,
.ch-main#identTop .derived-row,
.ch-main#identTop .cc-edit-fields,
.ch-main#identTop .cc-edit-panels,
.ch-main#identTop .cc-editbar,
.ch-main#identTop .ident-edit-extras {
  display: none;
}
/* Per-field inline editing. Clicking a value edits just that field in place
   (save on blur/Enter, Escape cancels) via an ad-hoc control (.cc-inline-input).
   The affordance (pointer + hover) is scoped to exactly the editable fields so
   the rest of the card doesn't look falsely tappable. */
.ch-main#identTop:not(.editing) #identNameView,
.ch-main#identTop:not(.editing) #contactPhoneView,
.ch-main#identTop:not(.editing) #contactEmailView,
.ch-main#identTop:not(.editing) #contactPrefView,
.ch-main#identTop:not(.editing) #identCalendarCode,
.ch-main#identTop:not(.editing) #identFreqView,
.ch-main#identTop:not(.editing) #identLocationView,
.ch-main#identTop:not(.editing) #billNameView,
.ch-main#identTop:not(.editing) #billIdView,
.invoice-pref-chip.cc-editable {
  cursor: pointer;
  border-radius: 8px;
  transition: background var(--transition-base, 0.15s ease);
}
.ch-main#identTop:not(.editing) #identNameView:hover,
.ch-main#identTop:not(.editing) #contactPhoneView:hover,
.ch-main#identTop:not(.editing) #contactEmailView:hover,
.ch-main#identTop:not(.editing) #contactPrefView:hover,
.ch-main#identTop:not(.editing) #identCalendarCode:hover,
.ch-main#identTop:not(.editing) #identFreqView:hover,
.ch-main#identTop:not(.editing) #identLocationView:hover,
.ch-main#identTop:not(.editing) #billNameView:hover,
.ch-main#identTop:not(.editing) #billIdView:hover,
.invoice-pref-chip.cc-editable:hover {
  background: var(--bg-secondary, hsl(40 12% 95%));
  box-shadow: 0 0 0 3px var(--bg-secondary, hsl(40 12% 95%));
}

/* Ad-hoc inline control inserted next to the value being edited. */
.cc-inline-input {
  font: inherit;
  font-size: 14px;
  line-height: 1.3;
  padding: 5px 9px;
  border: 1.5px solid var(--accent, hsl(153 22% 45%));
  border-radius: 8px;
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #1c1c1c);
  min-width: 140px;
  max-width: 100%;
  box-sizing: border-box;
  outline: none;
}
textarea.cc-inline-input { width: 100%; resize: vertical; min-height: 48px; }
select.cc-inline-input { cursor: pointer; }

.ch-main#identTop.editing .iv { display: none !important; }
.ch-main#identTop.editing .ie { display: block; }
.ch-main#identTop.editing .field { display: flex; }
.ch-main#identTop.editing .derived-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.ch-main#identTop.editing .cc-edit-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  margin-top: 14px;
  /* Top-align the cells so a field with a longer hint (e.g. the calendar code)
     doesn't stretch its neighbours, and pin every control to one height so a
     bare <input> and a <select> render identically. */
  align-items: start;
}
.ch-main#identTop.editing .cc-edit-fields .field-input {
  height: 42px;
}
.ch-main#identTop.editing .cc-edit-panels {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}
.cc-edit-panel {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--bg-primary);
}
.cc-edit-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 14px;
  cursor: pointer;
  font: 700 13px/1.2 var(--font-family);
  color: var(--text-primary);
  list-style: none;
}
.cc-edit-panel summary::-webkit-details-marker {
  display: none;
}
.cc-edit-panel summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-inline-end: 1.5px solid currentColor;
  border-block-end: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--transition-base);
}
.cc-edit-panel[open] summary::after {
  transform: rotate(225deg);
}
.cc-edit-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  padding: 0 14px 14px;
}
.cc-field-wide {
  grid-column: 1 / -1;
}
.cc-field-wide textarea.field-input {
  min-height: 92px;
  resize: vertical;
}
.cc-preset-row,
.cc-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cc-preset-chip {
  border: 1px solid var(--hairline);
  background: var(--bg-primary);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.cc-preset-chip:hover {
  border-color: var(--accent-color);
  color: var(--text-primary);
}
.cc-preset-chip.is-active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #fff;
}
.cc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}
.cc-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-color);
}
/* Per-session rate paired with its currency selector on one line. */
.rate-currency-row { display: flex; gap: 8px; align-items: stretch; }
.rate-currency-row > input { flex: 1 1 auto; min-width: 0; }
.rate-currency-row > select { flex: 0 0 7rem; width: auto; }
.ch-main#identTop.editing .ident-edit-extras {
  display: block;
  margin-block-start: 14px;
  padding: 12px 14px;
  background: var(--accent-light);
  color: var(--accent-hover);
  border-radius: var(--radius-sm);
  font: 400 13px/1.5 var(--font-family);
}
.field {
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field-label {
  font: 600 11.5px/1 var(--font-family);
  color: var(--text-soft);
  letter-spacing: 0.02em;
}
.field-input {
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
  width: 100%;
  min-height: 42px;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.field-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.field-input.ltr,
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}
.field-input.ltr { text-align: right; }
.field-hint {
  font-size: 11px;
  color: var(--text-soft);
  line-height: 1.45;
}
.field.name-field {
  flex: 1 1 16ch;
  gap: 4px;
}
.field.name-field .field-input {
  font-size: 22px;
  font-weight: 500;
  padding-block: 6px;
}
.ident-name {
  display: flex;
  align-items: center;
  gap: 12px;
  row-gap: 8px;
  flex-wrap: wrap;
}
.ident-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 0;
}
.ident-sub > span { white-space: nowrap; }
.ident-sub .loc { display: inline-flex; align-items: center; gap: 6px; }
.ident-sub .loc-dot {
  inline-size: 7px;
  block-size: 7px;
  border-radius: 50%;
  background: var(--teal);
}
.ro-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-primary);
  border: 1px dashed var(--border-color);
  font-size: 12.5px;
  color: var(--text-secondary);
}
.ro-chip .ro-label {
  color: var(--text-soft);
  font-size: 11px;
}
.ro-chip .lock {
  inline-size: 12px;
  block-size: 12px;
  stroke: var(--text-soft);
  fill: none;
  stroke-width: 1.8;
}
.ghost-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font: 600 13px/1 var(--font-family);
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.ghost-edit-btn svg {
  inline-size: 15px;
  block-size: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
}
.ghost-edit-btn:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--accent-color);
}
.ch-main#identTop .ident-actions .icon-btn {
  width: 44px;
  height: 44px;
}
.ch-main#identTop .primary-btn {
  min-height: 44px;
}
.ch-main#identTop.editing .ch-contact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}
.ch-main#identTop.editing .contact-chip {
  display: block;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
}
.ch-main#identTop.editing .contact-chip .ic,
.ch-main#identTop.editing .contact-chip .lbl {
  display: none;
}
.ch-main#identTop.editing .chip-body {
  display: flex;
}
.ch-main#identTop.editing .ch-billing {
  align-items: flex-start;
}
.ch-main#identTop.editing .bill-view {
  display: none;
}
.ch-main#identTop.editing .bill-edit {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  flex: 1;
}
.bill-edit .seg-field {
  grid-column: 1 / -1;
}
.bill-id-field.hidden,
.ch-main#identTop.editing .bill-id-field.hidden {
  display: none;
}
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--bg-tertiary);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-secondary);
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base);
}
.seg button.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.cc-editbar {
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}
.ch-main#identTop.editing .cc-editbar { display: flex; }
/* Top save/cancel bar — mirrors the bottom .cc-editbar but sits in the header
   (.ident-actions, where the edit/action buttons are hidden during editing),
   so the user can commit or discard without scrolling the long edit form. */
.cc-editbar-top { display: none; align-items: center; gap: 8px; }
.ch-main#identTop.editing .ident-actions .cc-editbar-top { display: flex; }
.cc-editbar-top .btn-save,
.cc-editbar-top .btn-cancel { min-height: 38px; padding: 0 16px; font-size: 13px; }
.btn-save,
.btn-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  font: 600 14px/1 var(--font-family);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
}
.btn-save svg,
.btn-cancel svg {
  inline-size: 16px;
  block-size: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.btn-save { background: var(--accent-color); color: #fff; }
.btn-save:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-cancel {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-color: var(--border-color);
}
.btn-cancel:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.full-edit-link {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  font: 600 12.5px/1 var(--font-family);
  color: var(--accent-hover);
  text-decoration: none;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
}
.full-edit-link:hover { text-decoration: underline; }

.next-appt {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  margin-top: 12px;
  text-decoration: none;
  color: inherit;
  border-radius: 13px;
  max-width: 100%;
  transition: background var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base);
}
.next-appt .na-ic {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 9px;
}
.next-appt .na-ic svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
}
.next-appt .na-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.next-appt .na-when {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  white-space: nowrap;
}
.next-appt .na-sub {
  color: var(--text-soft);
  /* Keep the countdown on ONE line; ellipsize if the identity column is very
     narrow. A previous "wrap instead of overflow" rule (overflow-wrap:anywhere)
     rendered the text letter-by-letter (vertically) whenever the column
     collapsed on narrow screens (e.g. a 13" laptop with the browser sidebar
     open). Ellipsis degrades gracefully instead. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.next-appt .na-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success-color);
  display: none;
}
.next-appt.today {
  padding: 10px 16px 10px 13px;
  background: var(--accent-light);
  border: 1px solid color-mix(in oklab, var(--accent-color) 35%, transparent);
  box-shadow: 0 6px 16px -10px color-mix(in oklab, var(--accent-color) 60%, transparent);
}
.next-appt.today:hover { transform: translateY(-1px); }
.next-appt.today .na-ic {
  width: 34px;
  height: 34px;
  background: var(--accent-color);
  color: #fff;
}
.next-appt.today .na-ic svg { width: 18px; height: 18px; }
.next-appt.today .na-when,
.next-appt.today .na-sub {
  color: var(--accent-hover);
}
.next-appt.today .na-live {
  display: inline-block;
  background: var(--accent-hover);
  animation: na-pulse 2.4s ease-in-out infinite;
}
.next-appt.tomorrow {
  padding: 8px 14px 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--hairline);
}
.next-appt.tomorrow .na-ic {
  width: 30px;
  height: 30px;
  background: var(--bg-primary);
  color: var(--text-secondary);
}
.next-appt.soon {
  padding: 6px 12px 6px 8px;
  background: transparent;
  border: 1px solid var(--hairline);
}
.next-appt.soon .na-ic,
.next-appt.far .na-ic {
  background: transparent;
  color: var(--text-soft);
}
.next-appt.soon .na-body,
.next-appt.far .na-body {
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
}
.next-appt.far {
  padding: 4px;
  gap: 8px;
  background: transparent;
  border: 0;
}
@keyframes na-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.78); }
}
@media (prefers-reduced-motion: reduce) {
  .next-appt .na-live { animation: none; }
}

.ledger {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.ledger-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.ledger-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text-primary);
}
.ledger-sub {
  font-size: 13px;
  color: var(--text-soft);
}
.glance {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.glance-chip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 17px;
  border-radius: 15px;
  min-width: 132px;
  background: var(--bg-secondary);
  border: 1px solid var(--hairline);
}
.glance-chip .gc-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-soft);
}
.glance-chip .gc-value {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.glance-chip .gc-sub {
  font-size: 11.5px;
  color: var(--text-soft);
}
.glance-chip.danger { background: hsl(20 45% 95%); border-color: hsl(20 42% 87%); }
.glance-chip.danger .gc-label,
.glance-chip.danger .gc-value { color: var(--clay); }
.glance-chip.warn { background: var(--warning-light); border-color: color-mix(in oklab, var(--warning-color) 24%, transparent); }
.glance-chip.warn .gc-label,
.glance-chip.warn .gc-value { color: var(--warning-color); }
.glance-chip.good { background: var(--success-light); border-color: color-mix(in oklab, var(--success-color) 24%, transparent); }
.glance-chip.good .gc-label,
.glance-chip.good .gc-value { color: var(--success-color); }
.period-card { padding: 20px 22px 22px; }
.period-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.period-headtext { display: flex; flex-direction: column; gap: 2px; }
.period-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}
.period-cap {
  font-size: 12.5px;
  color: var(--text-soft);
}
.period-picker {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 4px;
  max-inline-size: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: 999px;
}
.period-picker button {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 7px 14px;
  min-height: 44px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-base), color var(--transition-base);
}
.period-picker button.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.metrics {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}
.metric {
  border: 1px solid var(--hairline);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-primary);
}
.metric-row {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 116px 18px;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: inherit;
  font-family: inherit;
  transition: background var(--transition-base);
}
.metric-row:hover { background: var(--bg-tertiary); }
.metric .m-ic {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.metric .m-ic svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
}
.metric.tone-warn .m-ic { background: var(--warning-light); color: var(--warning-color); }
.metric.tone-good .m-ic { background: var(--success-light); color: var(--success-color); }
.metric .m-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.metric .m-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.metric .m-sub {
  font-size: 12px;
  color: var(--text-soft);
}
.metric .m-right {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: right;
}
.metric .m-value {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.metric.tone-warn .m-value { color: var(--clay); }
.metric.tone-good .m-value { color: var(--success-color); }
.metric .m-cum {
  font-size: 11.5px;
  color: var(--text-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.metric .m-chev {
  width: 17px;
  height: 17px;
  stroke: var(--text-soft);
  fill: none;
  stroke-width: 2;
  justify-self: center;
  transition: transform var(--transition-base);
}
.metric.open .m-chev { transform: rotate(180deg); }
.metric-drill {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-base);
}
.metric.open .metric-drill { max-height: 720px; }
.drill-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto 116px 18px;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-top: 1px solid var(--hairline);
  background: var(--bg-secondary);
}
.drill-item > * { grid-row: 1; }
.drill-item .di-date {
  grid-column: 1;
  font-size: 12px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.drill-item .di-title {
  grid-column: 2;
  font-size: 13.5px;
  color: var(--text-primary);
  font-weight: 500;
  min-width: 0;
}
.drill-item .di-amount {
  grid-column: 4;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.drill-item .di-badge {
  grid-column: 3;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.drill-item .di-badge.paid { background: var(--success-light); color: var(--success-color); }
.drill-item .di-badge.due { background: var(--warning-light); color: var(--warning-color); }
.drill-item .di-badge.legacy { background: hsl(43 40% 88%); color: hsl(43 38% 32%); }
.drill-item .di-badge.scheduled { background: hsl(208 30% 90%); color: hsl(208 26% 38%); }
.drill-item .di-badge.cancelled { background: color-mix(in srgb, var(--danger-color, #dc2626) 14%, transparent); color: var(--danger-color, #dc2626); }
/* Richer "waiting" states. */
.drill-item .di-badge.awaiting_payment,
.drill-item .di-badge.awaiting_monthly,
.drill-item .di-badge.unbilled { background: var(--warning-light); color: var(--warning-color); }
.drill-item .di-badge.link_sent { background: color-mix(in srgb, #2f6df6 15%, transparent); color: #2456c4; }
.drill-item .di-badge.overdue { background: color-mix(in srgb, var(--danger-color, #dc2626) 15%, transparent); color: var(--danger-color, #dc2626); }
.drill-item.dim { opacity: 0.62; }
/* Cancelled (deleted-in-Google) rows: muted + struck date, kept for the log. */
.drill-item.dim .di-title { text-decoration: line-through; }
/* Per-invoice summary row above its sessions in the "sessions in period" drill. */
.drill-inv-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; margin-block: 8px 2px; border-radius: 10px; background: var(--bg-secondary, #f3f0ea);
  border-inline-start: 3px solid var(--border-color); }
.drill-inv-summary.overdue { border-inline-start-color: var(--danger-color, #dc2626); }
.drill-inv-summary.link_sent { border-inline-start-color: #2f6df6; }
.drill-inv-summary.awaiting_payment { border-inline-start-color: var(--warning-color, #d08700); }
.drill-inv-summary.paid { border-inline-start-color: var(--success-color, #2e7d32); }
.drill-inv-summary .dis-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.drill-inv-summary .dis-info strong { font-size: 13px; font-weight: 800; }
.drill-inv-summary .dis-info span { font-size: 11.5px; color: var(--text-soft); }
.drill-inv-summary .dis-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.drill-inv-btn { border: 1px solid var(--border-color); background: var(--bg-primary); color: var(--text-primary);
  border-radius: 999px; padding: 5px 11px; font-size: 11.5px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.drill-inv-btn:hover { border-color: var(--text-secondary); }
.drill-item.nested { opacity: 0.82; padding-inline-start: 14px; }
.drill-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--text-soft);
  border-top: 1px solid var(--hairline);
  background: var(--bg-secondary);
}
.note-add-btn {
  min-height: 44px;
}

/* Charge Now modal */
.charge-now-entry {
  gap: 7px;
  min-inline-size: 128px;
}
.charge-now-entry svg {
  inline-size: 15px;
  block-size: 15px;
  flex-shrink: 0;
}
.charge-now-modal-content {
  max-block-size: 520px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.charge-now-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.charge-now-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.charge-now-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
}
.charge-now-document-type {
  font-size: 0.82rem;
  color: var(--text-soft);
  font-weight: 600;
}
.charge-now-list-head,
.charge-now-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 118px minmax(160px, 0.75fr);
  gap: 0.75rem;
  align-items: center;
}
.charge-now-list-head {
  padding: 0 1rem;
  font-size: 0.72rem;
  color: var(--text-soft);
  font-weight: 700;
}
.charge-now-review-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  /* Cap the rows so the "+ add line" button and total stay visible below a
     long session list instead of being buried under it. */
  max-block-size: 42vh;
  overflow-y: auto;
}
.charge-now-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 1rem 0;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 800;
}
.charge-now-group-head small {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: end;
}
.charge-now-row {
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-base), opacity var(--transition-base), box-shadow var(--transition-base);
}
.charge-now-row.is-muted {
  opacity: 0.55;
}
.charge-now-row.is-edited {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.charge-now-row.is-invalid {
  border-color: var(--warning-color);
}
.charge-now-row--legacy-debt {
  background: hsl(43 36% 96%);
  border-color: hsl(43 32% 84%);
}
.charge-now-row--legacy-debt.is-edited {
  border-color: hsl(42 57% 54%);
  box-shadow: 0 0 0 3px hsl(43 70% 90%);
}
.charge-now-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.charge-now-desc-main {
  min-width: 0;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.charge-now-desc-sub {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
  color: var(--text-soft);
  font-size: 0.75rem;
}
.charge-now-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 700;
}
.charge-now-disabled-hint {
  color: var(--warning-color);
  font-weight: 700;
}
.charge-now-amount,
.charge-now-reason {
  inline-size: 100%;
  min-inline-size: 0;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  outline: none;
}
.charge-now-amount {
  text-align: end;
  font-variant-numeric: tabular-nums;
}
.charge-now-amount:focus,
.charge-now-reason:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.charge-now-reason[hidden] {
  display: none;
}
.charge-now-legacy-receipt-note {
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: end;
}
.charge-now-adhoc-desc {
  inline-size: 100%;
  min-inline-size: 0;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  outline: none;
}
.charge-now-adhoc-desc:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.charge-now-remove {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font: 600 0.8rem var(--font-family);
  cursor: pointer;
  padding: 0.4rem;
  text-align: end;
}
.charge-now-remove:hover { color: var(--warning-color); }
.charge-now-add-row {
  align-self: start;
  background: transparent;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--accent-color);
  font: 600 0.85rem var(--font-family);
  cursor: pointer;
  padding: 0.5rem 0.85rem;
}
.charge-now-add-row:hover {
  background: var(--accent-light);
  border-color: var(--accent-color);
}
.charge-now-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background-color: var(--bg-tertiary);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-top: 0.15rem;
}
.charge-now-total-row span:first-child {
  font-weight: 700;
  color: var(--text-secondary);
}
#chargeNowReviewTotal {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-color);
  font-variant-numeric: tabular-nums;
}
.charge-now-total-split {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
}
.charge-now-total-split small {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 600;
}

.monthly-billing-card {
  max-inline-size: 1180px;
  width: 96vw;
  block-size: 92vh;
  display: flex;
  flex-direction: column;
}
.monthly-billing-content {
  flex: 1 1 auto;
  min-block-size: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* ---- Monthly billing review v2: full-height grid with expandable rows ---- */
.mb-sync-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
}
.mb-sync-banner svg { flex: 0 0 auto; inline-size: 18px; block-size: 18px; margin-block-start: 1px; }
.mb-sync-banner.is-ok {
  background: color-mix(in srgb, var(--success-color, #16a34a) 12%, transparent);
  color: var(--success-color, #16a34a);
  border: 1px solid color-mix(in srgb, var(--success-color, #16a34a) 32%, transparent);
}
.mb-sync-banner[hidden] { display: none; }
.mb-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.1rem 0 0.3rem;
}
.mb-month-nav__btn {
  inline-size: 30px;
  block-size: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 0;
}
.mb-month-nav__btn:disabled { opacity: 0.4; cursor: default; }
.mb-month-nav__label {
  min-inline-size: 140px;
  text-align: center;
  font-weight: 800;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
.mb-sync-banner.is-warn {
  background: color-mix(in srgb, var(--danger-color, #dc2626) 12%, transparent);
  color: var(--danger-color, #dc2626);
  border: 1px solid color-mix(in srgb, var(--danger-color, #dc2626) 40%, transparent);
}
.mb-sync-banner b { font-weight: 800; }

.mb-progress {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
}
.mb-progress[hidden] { display: none; }
.mb-progress-track {
  block-size: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-soft) 22%, transparent);
  overflow: hidden;
}
.mb-progress-fill {
  block-size: 100%;
  inline-size: 0%;
  border-radius: 999px;
  background: var(--accent-color);
  transition: inline-size 0.25s ease;
}
.mb-progress-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.mb-grid {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  overflow: hidden;
}
.mb-grid-head,
.mb-grid-row {
  display: grid;
  grid-template-columns: 34px 30px minmax(160px, 1fr) 78px 110px 120px 70px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
}
.mb-grid-head {
  background: var(--bg-secondary);
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border-color);
}
.mb-grid-head .mb-num,
.mb-grid-row .mb-num { text-align: center; font-variant-numeric: tabular-nums; }
.mb-grid-row {
  border-bottom: 1px solid var(--border-color);
  font-size: 0.88rem;
}
.mb-grid-row:last-child { border-bottom: 0; }
.mb-grid-row.is-muted { opacity: 0.45; }
.mb-grid-row.is-billed { background: color-mix(in srgb, var(--success-color, #16a34a) 8%, transparent); }
.mb-client-name { font-weight: 800; color: var(--text-primary); overflow-wrap: anywhere; }
.mb-client-name small { display: block; color: var(--text-soft); font-size: 0.74rem; font-weight: 600; }
.mb-client-name .mb-client-debt-summary { color: var(--accent-color); }
.mb-expand {
  inline-size: 26px; block-size: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-color); border-radius: 6px;
  background: var(--bg-secondary); color: var(--text-secondary); cursor: pointer;
  padding: 0;
}
.mb-expand svg { transition: transform 0.15s ease; }
.mb-expand[aria-expanded="true"] svg { transform: rotate(90deg); }
.mb-mixed { color: var(--warning-color); font-weight: 800; font-size: 0.8rem; }
.mb-row-status {
  font-size: 0.7rem; font-weight: 800; padding: 0.12rem 0.45rem; border-radius: 999px;
  background: var(--bg-tertiary); color: var(--text-soft); justify-self: start;
}
.mb-row-status.is-done { background: color-mix(in srgb, var(--success-color,#16a34a) 18%, transparent); color: var(--success-color,#16a34a); }
.mb-row-status.is-fail { background: color-mix(in srgb, var(--danger-color,#dc2626) 18%, transparent); color: var(--danger-color,#dc2626); }

.mb-sessions {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.25rem 0.9rem 0.5rem calc(0.9rem + 34px);
}
.mb-session {
  display: grid;
  grid-template-columns: 22px 1fr auto auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.2rem;
  border-bottom: 1px dashed var(--border-color);
  font-size: 0.84rem;
}
.mb-session:last-child { border-bottom: 0; }
.mb-session.is-waived { opacity: 0.55; }
.mb-session.is-waived .mb-session-when { text-decoration: line-through; }
.mb-session-when { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.mb-session-price { color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mb-session-tag { font-size: 0.7rem; font-weight: 800; color: var(--danger-color,#dc2626); white-space: nowrap; }
.mb-session-hint {
  margin: 0.1rem 0 0;
  padding-inline-start: calc(0.9rem + 34px);
  color: var(--text-soft); font-size: 0.74rem; font-weight: 600;
}
.mb-debts {
  margin-block-start: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
}
.mb-debts-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-block-end: 0.15rem;
  font-size: 0.82rem;
  font-weight: 850;
  color: var(--text-primary);
}
.mb-debts-head small,
.mb-debts > p {
  color: var(--text-soft);
  font-size: 0.74rem;
  font-weight: 650;
}
.mb-debts > p {
  margin: 0 0 0.35rem;
}
.mb-debt {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.42rem 0;
  border-top: 1px dashed var(--border-color);
  font-size: 0.83rem;
}
.mb-debt.is-disabled { opacity: 0.55; }
.mb-debt-main {
  min-width: 0;
}
.mb-debt-main strong,
.mb-debt-main small {
  display: block;
  overflow-wrap: anywhere;
}
.mb-debt-main small {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 650;
}
.mb-debt-price,
.mb-debt-total-note {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mb-debt-total-note {
  display: block;
  color: var(--accent-color);
  font-size: 0.7rem;
  font-weight: 800;
}
.monthly-billing-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.monthly-billing-doctype {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 700;
}
.monthly-billing-review-list {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}
.monthly-billing-table {
  width: 100%;
  min-width: 690px;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.monthly-billing-table th,
.monthly-billing-table td {
  padding: 0.78rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  text-align: start;
  vertical-align: middle;
}
.monthly-billing-table th {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--bg-secondary);
  white-space: nowrap;
}
.monthly-billing-table tr:last-child td {
  border-bottom: 0;
}
.monthly-billing-table tr.is-muted {
  opacity: 0.48;
}
.monthly-billing-table td:nth-child(2),
.monthly-billing-table td:nth-child(6),
.monthly-billing-table th:nth-child(2),
.monthly-billing-table th:nth-child(6) {
  text-align: center;
}
.monthly-billing-table td:nth-child(3),
.monthly-billing-table td:nth-child(4) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.monthly-billing-table td > strong {
  display: block;
  color: var(--text-primary);
  font-weight: 800;
  overflow-wrap: anywhere;
}
.monthly-billing-table td > small {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-soft);
  font-size: 0.74rem;
  font-weight: 600;
}
.monthly-billing-mixed {
  display: block;
  color: var(--warning-color);
  font-weight: 800;
}
.monthly-billing-total-row {
  margin-top: 0;
}
#monthlyBillingReviewTotal {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-color);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  .ch-top {
    flex-direction: column;
  }
  .ident-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .ident-actions .primary-btn,
  .ghost-edit-btn {
    flex: 1 1 150px;
    justify-content: center;
  }
  .charge-now-list-head {
    display: none;
  }
  .charge-now-row {
    grid-template-columns: 26px minmax(0, 1fr);
  }
  .charge-now-group-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.25rem;
  }
  .charge-now-group-head small {
    text-align: start;
  }
  .charge-now-amount,
  .charge-now-reason,
  .charge-now-legacy-receipt-note {
    grid-column: 2;
    text-align: start;
  }
  .ch-main#identTop.editing .cc-edit-fields,
  .cc-edit-panel-grid,
  .ch-main#identTop.editing .ch-contact,
  .ch-main#identTop.editing .bill-edit {
    grid-template-columns: 1fr;
  }
  .period-head { flex-direction: column; }
  .period-picker {
    width: 100%;
    border-radius: var(--radius-md);
  }
  .period-picker button { flex: 0 0 auto; }
  .metric-row {
    grid-template-columns: 34px minmax(0, 1fr) 88px 18px;
    gap: 10px;
    padding: 13px 12px;
  }
  .drill-item {
    grid-template-columns: 72px minmax(0, 1fr) auto 88px 18px;
    gap: 10px;
    padding: 13px 12px;
  }
}
@media (max-width: 420px) {
  .ch-main#identTop { padding: 18px 16px; }
  .client-header { gap: 14px; }
  .ident-name { font-size: 22px; }
  .period-card,
  .note-pad,
  .card { padding: 18px 16px; }
  .metric-row {
    grid-template-columns: minmax(0, 1fr) 88px 18px;
    gap: 8px;
  }
  .metric .m-ic { display: none; }
  .metric .m-right {
    grid-column: auto;
    text-align: right;
    padding-inline-start: 0;
  }
  .drill-item {
    grid-template-columns: 64px minmax(0, 1fr) auto 88px 18px;
    gap: 8px;
  }
  .drill-item .di-badge {
    padding-inline: 7px;
    font-size: 10.5px;
  }
}

/* =========================================================================
   Activity log table (clinic settings) — class-based replacement for the
   inline-styled table introduced in cd6f9b5. Picks up palette tokens so it
   themes alongside the rest of the app.
   ========================================================================= */
.activity-log-wrap { overflow-x: auto; }
.activity-log {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.activity-log thead tr { border-block-end: 1px solid var(--border-color); }
.activity-log th {
  text-align: start;
  padding: 8px 6px;
  color: var(--text-soft);
  font-weight: 600;
}
.activity-log tbody tr { border-block-end: 1px solid var(--hairline); }
.activity-log td {
  padding: 8px 6px;
  color: var(--text-secondary);
}
.activity-log td.al-when {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.activity-log td.al-op { color: var(--text-primary); }
.activity-log td.al-actor {
  color: var(--text-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
}
.activity-log-empty {
  padding: 12px;
  color: var(--text-soft);
  font-size: 13px;
}
.activity-log-empty.activity-log-err { color: var(--warning-color); }

/* ==========================================================================
   Invoice archive (client card) — issued documents with view/download/send
   ========================================================================== */
.inv-archive-card { margin-top: 16px; padding: 0; overflow: hidden; }
.iar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 18px 12px; }
.iar-toolbar { display: flex; align-items: center; gap: 10px; }
.iar-selectall { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700;
  color: var(--text-secondary); cursor: pointer; user-select: none; }
.iar-selectall input { accent-color: var(--accent-color, #5F715B); }
.iar-bulk { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--bg-secondary); border: 1px solid var(--hairline); border-radius: 999px;
  padding: 5px 8px 5px 14px; }
.iar-bulk > span { font-size: 12px; font-weight: 800; color: var(--text-primary); }
.iar-list { border-top: 1px solid var(--hairline); }
.iar-row { display: flex; align-items: center; gap: 12px; padding: 11px 18px;
  border-bottom: 1px solid var(--hairline); }
.iar-row:last-child { border-bottom: none; }
.iar-row.nofile { opacity: 0.65; }
.iar-check { flex: 0 0 auto; inline-size: 16px; block-size: 16px; accent-color: var(--accent-color, #5F715B); cursor: pointer; }
.iar-check:disabled { cursor: default; }
.iar-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.iar-main strong { font-size: 13px; font-weight: 800; color: var(--text-primary); }
.iar-main span { font-size: 11.5px; color: var(--text-soft); display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.iar-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 1px 8px;
  font-size: 10.5px; font-weight: 800; }
.iar-badge.paid { background: color-mix(in srgb, var(--success-color, #2e7d32) 14%, transparent); color: var(--success-color, #2e7d32); }
.iar-badge.issued { background: color-mix(in srgb, var(--warning-color, #d08700) 14%, transparent); color: var(--warning-color, #a16a00); }
.iar-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.iar-btn { border: 1px solid var(--border-color); background: var(--bg-primary); color: var(--text-primary);
  border-radius: 999px; padding: 5px 11px; font-size: 11.5px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.iar-btn:hover { border-color: var(--text-secondary); }
.iar-btn.send { border-color: color-mix(in srgb, var(--accent-color, #5F715B) 45%, transparent);
  color: var(--accent-color, #5F715B); }
.iar-btn.send:hover { background: color-mix(in srgb, var(--accent-color, #5F715B) 10%, transparent); }
.iar-nofile { font-size: 11.5px; color: var(--text-soft); font-style: italic; }
@media (max-width: 640px) {
  .iar-row { flex-wrap: wrap; }
  .iar-actions { inline-size: 100%; justify-content: flex-start; padding-inline-start: 28px; }
}
