/* =======================================================================
   Luna Care Studio — Design System
   Inspired by carestack-xi, refined with premium finance-product polish.
   Typography: DM Sans (UI) + DM Serif Display (display numbers & h1-h2).
   Solid colors only (no gradients). 4px grid. Subtle motion.
   ======================================================================= */

:root {
  color-scheme: light;

  /* ---------- Neutrals ---------- */
  --bg: #faf8f3;
  --surface: #ffffff;
  --surface-muted: #f4f2ec;
  --surface-sunken: #eeece5;
  --ink: #1a1612;
  --ink-2: #3a342d;
  --muted: #6b6560;
  --subtle: #9c958e;
  --border: #ebe6dd;
  --border-strong: #d9d1c3;
  --divider: #f0ebe2;

  /* ---------- Brand / Accent (sage from carestack-xi, refined) ---------- */
  --sage: #7a9e82;
  --sage-600: #5f8669;
  --sage-700: #4a6b52;
  --sage-ink: #2f4a37;
  --sage-soft: #edf2ee;
  --sage-soft-2: #dce7df;

  /* ---------- Status ---------- */
  --warn: #a36e13;
  --warn-ink: #7a5308;
  --warn-soft: #fbf0d4;
  --danger: #b85c38;
  --danger-ink: #8a3c1f;
  --danger-soft: #fbe4da;
  --info: #3a6ea5;
  --info-ink: #264a76;
  --info-soft: #e4edf7;
  --rose: #b46581;
  --rose-soft: #f6e3e9;

  /* ---------- Data colors ---------- */
  --data-1: #7a9e82;
  --data-2: #c4a574;
  --data-3: #b85c38;
  --data-4: #6f8caa;

  /* ---------- Typography ---------- */
  --font-display: "DM Serif Display", "Playfair Display", Georgia, serif;
  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;

  /* ---------- Shadows (elevation tokens) ---------- */
  --shadow-sm: 0 1px 2px rgba(26, 22, 18, 0.04);
  --shadow-md: 0 1px 3px rgba(26, 22, 18, 0.06), 0 1px 2px rgba(26, 22, 18, 0.04);
  --shadow-lg: 0 4px 20px rgba(26, 22, 18, 0.08);
  --shadow-xl: 0 12px 40px rgba(26, 22, 18, 0.10);
  --ring: 0 0 0 3px rgba(122, 158, 130, 0.25);

  /* ---------- Motion ---------- */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --t-fast: 150ms;
  --t-med: 200ms;
  --t-slow: 300ms;

  /* ---------- Radii ---------- */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;
}

/* =======================================================================
   Reset & base
   ======================================================================= */

* { box-sizing: border-box; }

html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  font-feature-settings: "ss01", "cv11";
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  min-width: 0;
}

img, svg, iframe, object, embed { max-width: 100%; }

p, span, strong, small, dt, dd, td, th, label, button, input, select, textarea {
  overflow-wrap: anywhere;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.15;
}

h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.5rem, 2.4vw, 2rem); }
h3 { font-size: 1.125rem; font-family: var(--font-sans); font-weight: 600; letter-spacing: -0.005em; }
h4 { font-size: 0.9375rem; font-family: var(--font-sans); font-weight: 600; }

p { margin: 0; }

a { color: var(--sage-700); text-decoration: none; }
a:hover { color: var(--sage-ink); }

::selection { background: var(--sage-soft-2); color: var(--sage-ink); }

/* =======================================================================
   Header
   ======================================================================= */

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: center;
  padding: 28px clamp(20px, 4vw, 56px) 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 2;
}

.app-header > div:first-child {
  display: grid;
  gap: 12px;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3.2vw, 2.625rem);
  line-height: 1;
  font-family: var(--font-display);
  color: var(--ink);
  letter-spacing: -0.015em;
}

.app-header img {
  width: 100%;
  height: min(20vw, 120px);
  min-height: 72px;
  max-width: 160px;
  object-fit: contain;
  border-radius: 0;
  box-shadow: none;
}

.header-stat {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 4px;
}

.header-stat div {
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
}

.header-stat .given-birth-stat { margin-top: 0; }

.header-stat span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
}

.header-stat strong {
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
}

/* =======================================================================
   Shell & sidebar navigation
   ======================================================================= */

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
  min-width: 0;
  background: var(--bg);
}

.tabs {
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 2px;
  min-height: calc(100vh - 1px);
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
  min-width: 0;
}

.mobile-menu-toggle { display: none; }

.tab, .tab-dropdown, .mobile-menu-toggle {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background-color: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.tab:hover, .tab-dropdown:hover, .mobile-menu-toggle:hover {
  background-color: var(--surface-muted);
  color: var(--ink);
}

.tab.active,
.tab-group:has(.tab.active) .tab-dropdown {
  background-color: var(--sage-soft);
  color: var(--sage-ink);
  font-weight: 600;
}

.tab.active::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 14px;
  margin-right: 10px;
  margin-left: -4px;
  vertical-align: -2px;
  border-radius: 999px;
  background: var(--sage-600);
}

.tab-group { position: relative; }

.tab-dropdown {
  position: relative;
  padding-right: 32px;
}

.tab-dropdown::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-70%) rotate(45deg);
  opacity: 0.5;
}

.tab-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
}

.tab-group:hover .tab-menu,
.tab-group.open .tab-menu,
.tab-group:focus-within .tab-menu {
  display: grid;
  gap: 2px;
}

.tab-menu .tab {
  padding: 7px 10px;
  font-size: 0.8125rem;
}

/* =======================================================================
   Main layout
   ======================================================================= */

main {
  padding: 32px clamp(20px, 3.5vw, 48px) 56px;
  min-width: 0;
  background: var(--bg);
}

.view { display: none; }
.view.active {
  display: block;
  animation: fadeIn var(--t-slow) var(--ease-out) both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-heading {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.section-heading > div:first-child { min-width: 0; }

.section-heading h2 {
  margin: 4px 0 0;
  font-family: var(--font-display);
  letter-spacing: -0.015em;
}

.eyebrow {
  margin: 0;
  color: var(--sage-700);
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.subhead {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.muted, .field label, th, .summary-card > span,
.next-due-card span, .pricing-card span, .tax-card span,
.statement-head span, .advisor-message span, .header-stat span,
.summary-card strong span, .summary-card strong em,
.summary-card strong .balance-line, .summary-card strong .collected-line,
.summary-card strong .goal-note, .summary-card strong .referral-fee-note,
.statement-card dt, .statement-card dd small,
.advisor-tool-head p, .next-due-card p, .pricing-card p,
.tax-card p, .loan-card p, .calendar-card p {
  color: var(--muted);
}

/* =======================================================================
   Buttons
   ======================================================================= */

.primary-button,
.secondary-button,
.tiny-button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}

.primary-button {
  padding: 9px 16px;
  background: var(--ink);
  border-color: var(--ink);
  color: #fffdf7;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.primary-button:hover {
  background: var(--sage-700);
  border-color: var(--sage-700);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.primary-button:active { transform: translateY(0); }

.primary-button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.secondary-button, .secondary-link {
  padding: 9px 14px;
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink-2);
  font-size: 0.8125rem;
  font-weight: 500;
}

.secondary-button:hover, .secondary-link:hover {
  background: var(--surface-muted);
  border-color: var(--border-strong);
  color: var(--ink);
}

.tiny-button {
  padding: 5px 10px;
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink-2);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--r-xs);
}

.tiny-button:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.hidden { display: none !important; }

/* =======================================================================
   Cards — unified base
   ======================================================================= */

.summary-card,
.next-due-card,
.pricing-card,
.tax-card,
.loan-card,
.loan-entry-card,
.calendar-card,
.statement-card,
.advisor-chat-section,
.social-strategy-section,
.birth-capacity-section,
.expense-category-section,
.profit-loss-chart-card,
.quickbooks-report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-med) var(--ease), border-color var(--t-med) var(--ease);
}

.summary-card:hover,
.next-due-card:hover,
.pricing-card:hover,
.tax-card:hover,
.loan-card:hover,
.calendar-card:hover,
.statement-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

/* =======================================================================
   Summary cards (dashboard)
   ======================================================================= */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.summary-card {
  position: relative;
  display: grid;
  gap: 12px;
  min-height: 148px;
  padding: 20px;
  overflow: hidden;
}

.summary-card > span {
  display: inline-flex;
  align-items: center;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  margin-top: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.75rem, 2.8vw, 2.4rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.summary-card strong .goal-amount,
.summary-card strong .balance-total,
.summary-card strong .collected-total {
  display: block;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.75rem, 2.8vw, 2.4rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.summary-card strong .goal-note,
.summary-card strong .balance-line,
.summary-card strong .collected-line,
.summary-card strong .referral-fee-note,
.summary-card strong em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 400;
  font-style: normal;
  line-height: 1.4;
}

.summary-card strong .referral-fee-note { color: var(--danger); }

.summary-card strong span {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 400;
}

.summary-card strong .balance-breakdown,
.summary-card strong .collected-breakdown {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--divider);
}

/* Progress bars */
.summary-card strong .goal-progress {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.summary-card strong .goal-progress-track,
.loan-progress-track {
  position: relative;
  display: block;
  width: 100%;
  height: 20px;
  margin: 0;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}

.summary-card strong .goal-progress-fill,
.loan-progress-fill {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--sage-600);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: width var(--t-slow) var(--ease);
}

.summary-card strong .goal-progress-left,
.loan-progress-left {
  position: absolute;
  inset: 0 12px 0 auto;
  display: flex;
  align-items: center;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

/* =======================================================================
   Next-due (dashboard)
   ======================================================================= */

.next-due-section { margin-bottom: 36px; }

.next-due-section > div:first-child { margin-bottom: 16px; }
.next-due-section h2 {
  font-family: var(--font-display);
  margin-top: 4px;
  font-size: clamp(1.375rem, 2.2vw, 1.75rem);
  letter-spacing: -0.01em;
}

.next-due-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.next-due-card {
  position: relative;
  min-height: 120px;
  padding: 18px 18px 18px 22px;
  border-radius: var(--r-lg);
}

.next-due-card::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 20px;
  bottom: 20px;
  width: 3px;
  border-radius: 999px;
  background: var(--sage-600);
}

.next-due-card:nth-child(2)::before { background: var(--warn); }
.next-due-card:nth-child(3)::before { background: var(--rose); }

.next-due-card span {
  display: block;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.next-due-card strong {
  display: block;
  margin-top: 10px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.375rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.next-due-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.4;
}

/* =======================================================================
   Tax section
   ======================================================================= */

.tax-section { margin-bottom: 36px; }

.tax-section h3 {
  margin-bottom: 14px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.tax-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.tax-card {
  position: relative;
  padding: 18px 18px 18px 22px;
}

.tax-card::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 18px;
  bottom: 18px;
  width: 3px;
  border-radius: 999px;
  background: var(--warn);
}

.tax-card strong {
  display: block;
  margin-top: 6px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.tax-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.tax-due-date {
  color: var(--ink-2);
  font-weight: 600;
}

/* =======================================================================
   Loan section
   ======================================================================= */

.loan-section { margin-bottom: 36px; }

.loan-section > h3 {
  margin-bottom: 14px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.loan-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.loan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.loan-entry-card {
  padding: 20px;
}

.loan-entry-card h4 {
  margin: 0 0 16px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ink);
}

.loan-card {
  position: relative;
  height: 100%;
  padding: 20px 20px 20px 24px;
}

.loan-card::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 20px;
  bottom: 20px;
  width: 3px;
  border-radius: 999px;
  background: var(--sage-600);
}

.loan-card.featured::before { background: var(--data-2); }

.loan-card strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.625rem;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.loan-card p {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.4;
}

.loan-progress-track { margin: 14px 0 10px; }

/* Moveable section */
.moveable-section {
  position: relative;
  z-index: 2;
  transition: box-shadow var(--t-med) var(--ease);
}

.moveable-section h3 { cursor: move; user-select: none; }

.moveable-section.is-moving {
  z-index: 10;
  box-shadow: var(--shadow-xl);
}

/* =======================================================================
   Forms — entry, expense, payment
   ======================================================================= */

.entry-form,
.expense-form,
.client-payment-form,
.loan-payment-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  align-items: end;
  margin-bottom: 20px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.loan-payment-form {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.loan-payment-form .field:nth-child(3),
.loan-payment-form .field:nth-child(4),
.loan-payment-form button {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field label {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.field input,
.field select,
.field textarea,
.search,
.advisor-chat-form input,
.social-strategy-form input,
.birth-capacity-form input[type="date"] {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  transition:
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}

.field input[type="file"] {
  padding: 6px 10px;
  font-size: 0.8125rem;
  cursor: pointer;
}

.field textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.search:hover {
  border-color: var(--ink-2);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search:focus,
.advisor-chat-form input:focus,
.social-strategy-form input:focus,
.birth-capacity-form input[type="date"]:focus {
  outline: none;
  border-color: var(--sage-600);
  box-shadow: var(--ring);
}

.full-row { grid-column: 1 / -1; }

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin: 0;
}

.search {
  max-width: 320px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.8125rem;
  color: var(--ink-2);
}

.inline-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--sage-600);
  cursor: pointer;
}

/* =======================================================================
   Tables
   ======================================================================= */

.table-wrap {
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.table-wrap.large { max-height: 70vh; }
.table-wrap.no-scroll { overflow: visible; }

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.no-scroll table {
  min-width: 0;
  table-layout: fixed;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--divider);
  text-align: left;
  vertical-align: top;
  font-size: 0.8125rem;
  font-weight: 400;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  color: var(--ink-2);
  background: var(--surface);
}

tbody tr { transition: background var(--t-fast) var(--ease); }
tbody tr:hover td { background: var(--surface-muted); }
tbody tr:hover th:first-child { background: var(--surface-muted); }

tr:last-child td { border-bottom: 0; }

.table-actions {
  display: flex;
  gap: 4px;
}

/* Client/lead/backup tables — scrollable data grids */
#clients .table-wrap.large,
#backup-clients .table-wrap.large,
#leads .table-wrap.large {
  max-width: 100%;
  max-height: min(72vh, 760px);
}

#clients table,
#backup-clients table,
#leads table {
  width: max-content;
  min-width: 1720px;
  table-layout: auto;
}

#clients th, #clients td,
#backup-clients th, #backup-clients td,
#leads th, #leads td {
  max-width: 170px;
  padding: 10px 12px;
  font-size: 0.75rem;
  line-height: 1.35;
  white-space: nowrap;
}

#clients th, #backup-clients th, #leads th {
  font-size: 0.65rem;
  letter-spacing: 0.05em;
}

#clients th:first-child, #clients td:first-child,
#backup-clients th:first-child, #backup-clients td:first-child,
#leads th:first-child, #leads td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 92px;
  background: var(--surface);
}

#clients th:first-child, #backup-clients th:first-child, #leads th:first-child {
  z-index: 4;
  background: var(--surface-muted);
}

#clients th:last-child, #clients td:last-child,
#backup-clients th:last-child, #backup-clients td:last-child,
#leads th:last-child, #leads td:last-child {
  position: sticky;
  right: 0;
  z-index: 3;
  min-width: 112px;
  background: var(--surface);
  box-shadow: -1px 0 0 var(--border);
}

#clients th:last-child, #backup-clients th:last-child, #leads th:last-child {
  z-index: 5;
  background: var(--surface-muted);
}

#clients td:nth-child(5),
#backup-clients td:nth-child(5),
#leads td:nth-child(5) {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#clients td:nth-child(15),
#backup-clients td:nth-child(15) {
  max-width: 240px;
  white-space: normal;
}

#clients td:nth-child(16),
#backup-clients td:nth-child(16),
#leads td:nth-child(16) {
  text-align: center;
}

#clients .table-actions,
#backup-clients .table-actions,
#leads .table-actions {
  display: table-cell;
  white-space: nowrap;
}

#clients .table-actions .tiny-button,
#backup-clients .table-actions .tiny-button,
#leads .table-actions .tiny-button {
  display: inline-flex;
  min-height: 28px;
  margin-right: 4px;
  padding: 4px 8px;
  font-size: 0.6875rem;
}

/* =======================================================================
   Status pills
   ======================================================================= */

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--sage-soft);
  color: var(--sage-ink);
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.status-pill.paid {
  background: var(--surface-sunken);
  color: var(--muted);
}

.status-pill.overdue {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.status-pill.due-soon {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

/* =======================================================================
   Expenses — category summary
   ======================================================================= */

.expense-category-section {
  margin-top: 20px;
  padding: 20px;
}

.expense-category-section .statement-head {
  margin-bottom: 16px;
}

.expense-category-section .statement-head h3 {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
}

.expense-category-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.expense-category-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease);
}

.expense-category-row:hover { background: var(--surface-sunken); }

.expense-category-row span {
  color: var(--ink-2);
  font-size: 0.8125rem;
  font-weight: 500;
}

.expense-category-row strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.expense-category-row.total {
  grid-column: 1 / -1;
  background: var(--sage-soft);
  border-color: var(--sage-soft-2);
}

.expense-category-row.total span { color: var(--sage-ink); font-weight: 600; }
.expense-category-row.total strong { color: var(--sage-ink); font-weight: 700; }

.soulshine-section { margin-top: 32px; }

.soulshine-section h3 {
  margin-bottom: 14px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
}

.soulshine-table-wrap table {
  min-width: 0;
  table-layout: fixed;
}

.soulshine-table-wrap th,
.soulshine-table-wrap td {
  padding: 10px 12px;
  font-size: 0.8125rem;
}

/* =======================================================================
   Advisor (pricing + chat + social + birth capacity)
   ======================================================================= */

.pricing-section { margin-bottom: 32px; }
.pricing-section .section-heading { margin-bottom: 14px; padding-bottom: 0; border: 0; }
.pricing-section > h3 {
  margin-bottom: 14px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.pricing-card {
  position: relative;
  min-height: 170px;
  padding: 20px 20px 20px 24px;
}

.pricing-card::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 20px;
  bottom: 20px;
  width: 3px;
  border-radius: 999px;
  background: var(--data-4);
}

.pricing-card:nth-child(2)::before { background: var(--data-2); }
.pricing-card:nth-child(3)::before { background: var(--data-3); }
.pricing-card.featured::before { background: var(--sage-600); }

.pricing-card.featured {
  background: var(--sage-soft);
  border-color: var(--sage-soft-2);
}

.pricing-card span {
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pricing-card strong {
  display: block;
  margin-top: 10px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.625rem;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.pricing-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.45;
}

.advisor-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  align-items: start;
  margin-bottom: 32px;
}

.advisor-chat-section,
.social-strategy-section {
  display: grid;
  grid-auto-rows: min-content;
  gap: 14px;
  margin-bottom: 0;
  padding: 20px;
  min-width: 0;
}

.advisor-chat-log {
  display: grid;
  gap: 10px;
  min-height: 240px;
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: none;
}

.advisor-message {
  max-width: min(88%, 560px);
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: none;
}

.advisor-user {
  justify-self: end;
  background: var(--sage-soft);
  border-color: var(--sage-soft-2);
}

.advisor-bot { background: var(--surface); }

.advisor-message span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.advisor-message p {
  margin: 0;
  color: var(--ink);
  font-size: 0.875rem;
  line-height: 1.5;
}

.advisor-chat-form,
.social-strategy-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 0;
}

.advisor-chat-form input,
.social-strategy-form input {
  min-height: 38px;
}

.advisor-tool-head { display: grid; gap: 4px; }
.advisor-tool-head h3 {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
}
.advisor-tool-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.birth-capacity-section {
  display: grid;
  gap: 14px;
  margin: 20px 0 28px;
  padding: 20px;
}

.birth-capacity-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
}

.birth-capacity-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.birth-capacity-form .inline-check {
  min-height: 38px;
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.birth-capacity-result {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.birth-capacity-result h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.birth-capacity-result p,
.birth-capacity-result li {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.875rem;
  line-height: 1.5;
}

.birth-capacity-result ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
}

.birth-capacity-verdict {
  color: var(--sage-ink);
  font-weight: 600;
}

.birth-capacity-verdict.caution { color: var(--warn-ink); }
.birth-capacity-verdict.full { color: var(--danger-ink); }

/* =======================================================================
   Calendar
   ======================================================================= */

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.calendar-card {
  position: relative;
  min-height: 220px;
  padding: 20px;
}

.calendar-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  height: 3px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--sage-600);
}

.calendar-card.caution::before { background: var(--warn); }
.calendar-card.full::before { background: var(--danger); }

.calendar-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.calendar-card-head h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  margin: 0;
}

.calendar-card-head span {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--sage-soft);
  color: var(--sage-ink);
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.calendar-card.caution .calendar-card-head span {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

.calendar-card.full .calendar-card-head span {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.calendar-card p {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

.calendar-card ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.calendar-card li {
  display: grid;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--divider);
  font-size: 0.875rem;
}

.calendar-card li span {
  color: var(--muted);
  font-size: 0.8125rem;
}

.calendar-card li.calendar-lead strong { color: var(--warn-ink); }

.calendar-card li.calendar-lead em {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warn);
}

.calendar-card li.calendar-backup-client strong,
.calendar-card li.calendar-backup-client span {
  color: var(--info-ink);
}

.calendar-card li .calendar-backup {
  color: var(--rose);
  font-style: italic;
  font-weight: 500;
}

.calendar-card li .calendar-notes {
  color: var(--danger);
  font-size: 0.8125rem;
  line-height: 1.45;
}

/* =======================================================================
   PDF viewer + statements
   ======================================================================= */

.pdf-viewer {
  width: 100%;
  min-height: 76vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.statement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.statement-card {
  padding: 22px;
}

.statement-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider);
}

.statement-head h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.statement-head span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.statement-card dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.statement-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--divider);
}

.statement-card dl div:first-child { border-top: 0; padding-top: 0; }

.statement-card dt {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.statement-card dd {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
}

.statement-card dd small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 400;
}

.expense-breakdown {
  display: grid;
  gap: 4px;
  min-width: 180px;
  margin: 8px 0 0;
  padding: 0;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 400;
  list-style: none;
}

.expense-breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.expense-breakdown li span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  line-height: 1.4;
}

.expense-breakdown li span:last-child {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.statement-total {
  color: var(--ink);
  font-family: var(--font-display) !important;
  font-weight: 400 !important;
  font-size: 1.125rem !important;
  letter-spacing: -0.01em;
}

/* =======================================================================
   Profit & loss layout + chart
   ======================================================================= */

.profit-loss-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.5fr);
  gap: 16px;
  align-items: start;
}

.profit-loss-chart-card {
  position: sticky;
  top: 16px;
  padding: 20px;
}

.profit-loss-chart-card h3 {
  margin-bottom: 12px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
}

.profit-loss-chart {
  width: 100%;
  overflow-x: auto;
  padding: 4px 0;
}

.profit-loss-line-chart {
  display: block;
  width: 100%;
  min-width: 460px;
  height: auto;
}

.profit-loss-grid-line { stroke: var(--divider); stroke-width: 1; }
.profit-loss-area { fill: var(--sage-soft); fill-opacity: 0.6; }
.profit-loss-line {
  fill: none;
  stroke: var(--sage-600);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}
.profit-loss-line-chart circle {
  fill: var(--surface);
  stroke: var(--sage-600);
  stroke-width: 2;
}
.profit-loss-point-value {
  fill: var(--muted);
  font-family: var(--font-sans);
  font-size: 11px;
  text-anchor: middle;
}
.profit-loss-axis-label {
  fill: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  text-anchor: middle;
}

/* QuickBooks P&L report */
.quickbooks-report-card {
  overflow: hidden;
}

.quickbooks-report-head {
  padding: 24px 20px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.quickbooks-report-head span,
.quickbooks-report-head p {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
}

.quickbooks-report-head h3 {
  margin: 6px 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.quickbooks-report {
  max-height: 68vh;
  overflow: auto;
}

.quickbooks-table {
  min-width: 980px;
  width: 100%;
  border-collapse: collapse;
}

.quickbooks-table th,
.quickbooks-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
  text-align: right;
  white-space: nowrap;
  background: var(--surface);
}

.quickbooks-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-muted);
  color: var(--muted);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.quickbooks-table th:first-child,
.quickbooks-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 210px;
  background: var(--surface);
  text-align: left;
  font-family: var(--font-sans);
}

.quickbooks-table thead th:first-child {
  z-index: 3;
  background: var(--surface-muted);
}

.report-section-row th,
.report-section-row td {
  padding-top: 18px;
  border-bottom: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.report-total-row th,
.report-total-row td {
  border-top: 1px solid var(--border-strong);
  background: var(--surface-muted);
  font-weight: 600;
  color: var(--ink);
}

.report-grand-row th,
.report-grand-row td {
  border-top: 2px solid var(--ink);
  border-bottom: 2px double var(--ink);
  background: var(--sage-soft);
  font-family: var(--font-sans);
  font-weight: 700;
  color: var(--ink);
}

.report-grand-row td { font-family: var(--font-mono); }

/* =======================================================================
   Rates
   ======================================================================= */

.rates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

.rates-grid > section {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.rates-grid h3 {
  margin: 0 0 12px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ink);
}

.rate-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.rate-table-wrap table {
  min-width: 0;
  table-layout: fixed;
}

.rate-table-wrap th,
.rate-table-wrap td {
  padding: 8px 10px;
  font-size: 0.75rem;
}

.rate-table-wrap td {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.rate-table-wrap td:first-child {
  font-family: var(--font-sans);
}

/* Detail + rate items (generic) */
.detail-list, .rate-list {
  display: grid;
  gap: 8px;
}

.detail-item, .rate-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  font-size: 0.875rem;
}

/* =======================================================================
   Responsive
   ======================================================================= */

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 180px minmax(0, 1fr); }
  .tabs { padding: 16px 10px; }
  .tab, .tab-dropdown { padding: 7px 10px; font-size: 0.8125rem; }
}

@media (max-width: 820px) {
  .app-header {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 20px 16px 18px;
  }

  .app-header img {
    justify-self: flex-start;
    height: 72px;
    min-height: 64px;
  }

  .app-shell { grid-template-columns: 1fr; }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 0;
    padding: 10px 12px;
    background: var(--surface);
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .tab, .tab-dropdown {
    width: auto;
    padding: 6px 10px;
    font-size: 0.8125rem;
  }

  .tab.active::before { display: none; }

  .tab-group { flex: 0 0 auto; }

  .tab-menu .tab { text-align: left; }

  main { padding: 24px 16px 40px; }

  .section-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .summary-grid,
  .next-due-grid,
  .tax-grid,
  .pricing-grid,
  .loan-layout,
  .loan-grid,
  .calendar-grid,
  .advisor-tools-grid,
  .profit-loss-layout,
  .statement-grid,
  .rates-grid,
  .expense-category-summary {
    grid-template-columns: 1fr;
  }

  .profit-loss-chart-card { position: static; }

  .entry-form,
  .expense-form,
  .client-payment-form {
    grid-template-columns: 1fr;
  }

  .birth-capacity-form {
    grid-template-columns: 1fr;
  }

  .advisor-chat-section,
  .social-strategy-section {
    grid-template-rows: auto minmax(220px, 280px) auto;
  }

  .search { max-width: 100%; }
}

@media (max-width: 480px) {
  .app-header h1 { font-size: 1.5rem; }
  .summary-card strong,
  .summary-card strong .goal-amount,
  .summary-card strong .balance-total,
  .summary-card strong .collected-total { font-size: 1.625rem; }
  .next-due-card strong { font-size: 1.25rem; }
}

/* =======================================================================
   Accessibility
   ======================================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-xs);
}

.tab:focus-visible,
.tab-dropdown:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.tiny-button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* =======================================================================
   DESIGN ENHANCEMENT LAYER — richer visuals, icons, flourishes
   Overrides the base system with a more crafted, designed feel.
   ======================================================================= */

/* ---------- Page-level richness ---------- */

body {
  background:
    radial-gradient(at top left, rgba(237, 242, 238, 0.55), transparent 45%),
    radial-gradient(at top right, rgba(251, 240, 212, 0.4), transparent 40%),
    var(--bg);
  background-attachment: fixed;
}

/* Header — bold wordmark with decorative divider */
.app-header {
  padding: 36px clamp(24px, 4vw, 64px) 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.app-header::after {
  content: "";
  position: absolute;
  left: clamp(24px, 4vw, 64px);
  right: clamp(24px, 4vw, 64px);
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg,
    var(--sage-600) 0%,
    var(--sage-600) 18%,
    transparent 18%,
    transparent 100%);
  pointer-events: none;
}

.app-header h1 {
  font-size: clamp(2rem, 3.8vw, 3.25rem);
  letter-spacing: -0.025em;
  font-feature-settings: "ss01";
}

.app-header h1::first-letter {
  color: var(--sage-700);
}

.header-stat {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  width: fit-content;
  max-width: 100%;
}

.header-stat div {
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
  padding: 0 14px;
  border-right: 1px solid var(--border);
}

.header-stat div:last-child { border-right: 0; }
.header-stat div:first-child { padding-left: 0; }

.header-stat span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.header-stat strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.125rem;
  line-height: 1;
  letter-spacing: -0.01em;
}

/* ---------- Sidebar — brand anchor + icons ---------- */

.tabs {
  padding: 24px 12px;
  gap: 1px;
  position: relative;
}

.tabs::before {
  content: "LUNA CARE";
  display: block;
  padding: 4px 12px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--subtle);
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.tab, .tab-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 34px;
  min-height: 34px;
}

.tab.active::before {
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  height: auto;
  margin: 0;
}

/* SVG icons via ::before — only for top-level nav items */
.tabs > .tab::after,
.tabs > .tab-group > .tab-dropdown::after {
  font-family: inherit;
}

.tabs > .tab,
.tabs > .tab-group > .tab-dropdown {
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 16px 16px;
}

/* Dashboard — grid layout icon */
.tabs > .tab[data-view="dashboard"] {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6560' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='7' height='9' rx='1.5'/><rect x='14' y='3' width='7' height='5' rx='1.5'/><rect x='14' y='12' width='7' height='9' rx='1.5'/><rect x='3' y='16' width='7' height='5' rx='1.5'/></svg>");
}
.tabs > .tab[data-view="dashboard"].active {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232f4a37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='7' height='9' rx='1.5'/><rect x='14' y='3' width='7' height='5' rx='1.5'/><rect x='14' y='12' width='7' height='9' rx='1.5'/><rect x='3' y='16' width='7' height='5' rx='1.5'/></svg>");
}

/* Calendar — calendar icon */
.tabs > .tab[data-view="calendar"] {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6560' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='16' rx='2'/><line x1='3' y1='10' x2='21' y2='10'/><line x1='8' y1='3' x2='8' y2='7'/><line x1='16' y1='3' x2='16' y2='7'/></svg>");
}
.tabs > .tab[data-view="calendar"].active {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232f4a37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='16' rx='2'/><line x1='3' y1='10' x2='21' y2='10'/><line x1='8' y1='3' x2='8' y2='7'/><line x1='16' y1='3' x2='16' y2='7'/></svg>");
}

/* Clients dropdown — users icon */
.tabs > .tab-group:nth-of-type(1) > .tab-dropdown,
.tabs > .tab-group:has(.tab[data-view="clients"]) > .tab-dropdown {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6560' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><circle cx='9' cy='8' r='4'/><path d='M3 21v-1a6 6 0 0 1 12 0v1'/><circle cx='17' cy='7' r='3'/><path d='M21 20v-1a4 4 0 0 0-4-4'/></svg>");
}

/* Financials dropdown — chart icon */
.tabs > .tab-group:has(.tab[data-view="financials"]) > .tab-dropdown {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6560' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><path d='M3 3v18h18'/><path d='M7 15l4-4 4 3 5-6'/></svg>");
}

/* Resources dropdown — book icon */
.tabs > .tab-group:has(.tab[data-view="checkins"]) > .tab-dropdown {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6560' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><path d='M4 4v15a2 2 0 0 0 2 2h14V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2z'/><path d='M4 4h14v17'/><line x1='8' y1='8' x2='14' y2='8'/><line x1='8' y1='12' x2='14' y2='12'/></svg>");
}

/* Doula Advisor — sparkle icon */
.tabs > .tab[data-view="advisor"] {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6560' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><path d='M12 3l1.8 4.8L18.6 9 13.8 10.8 12 15.6 10.2 10.8 5.4 9l4.8-1.2L12 3z'/><path d='M19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8L19 15z'/></svg>");
}
.tabs > .tab[data-view="advisor"].active {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232f4a37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 3l1.8 4.8L18.6 9 13.8 10.8 12 15.6 10.2 10.8 5.4 9l4.8-1.2L12 3z'/><path d='M19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8L19 15z'/></svg>");
}

.tab-group:has(.tab.active) > .tab-dropdown {
  filter: none;
}

/* Sidebar section divider before Doula Advisor */
.tabs > .tab[data-view="advisor"] {
  margin-top: 12px;
  padding-top: 12px;
}
.tabs > .tab[data-view="advisor"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 1px;
  background: var(--border);
}
.tabs > .tab[data-view="advisor"].active::before {
  content: "";
  top: 8px;
  left: 0;
  right: auto;
  bottom: 8px;
  height: auto;
  width: 3px;
  background: var(--sage-600);
  border-radius: 999px;
}

/* ---------- Dashboard hero treatment ---------- */

#dashboard .next-due-section > div:first-child,
#dashboard .section-heading > div:first-child {
  position: relative;
}

#dashboard .next-due-section h2,
#dashboard > .section-heading h2 {
  font-size: clamp(1.75rem, 2.6vw, 2.25rem);
  letter-spacing: -0.02em;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--sage-soft);
  color: var(--sage-ink);
  border-radius: var(--r-pill);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--sage-600);
}

/* ---------- Summary card enrichment ---------- */

.summary-card {
  position: relative;
  overflow: hidden;
}

.summary-card::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--sage-soft);
  opacity: 0.5;
  pointer-events: none;
}

.summary-card:nth-child(2)::after { background: var(--warn-soft); opacity: 0.35; }
.summary-card:nth-child(3)::after { background: var(--rose-soft); opacity: 0.4; }
.summary-card:nth-child(4)::after { background: var(--info-soft); opacity: 0.5; }

.summary-card > span {
  position: relative;
  z-index: 1;
  padding: 4px 10px;
  background: var(--surface-muted);
  border-radius: var(--r-pill);
  width: fit-content;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.summary-card strong {
  position: relative;
  z-index: 1;
}

/* Sparkline / trend decoration for summary cards */
.summary-card strong::before {
  content: "";
  display: block;
  width: 28px;
  height: 2px;
  margin-bottom: 10px;
  background: var(--sage-600);
  border-radius: 999px;
}

.summary-card:nth-child(2) strong::before { background: var(--warn); }
.summary-card:nth-child(3) strong::before { background: var(--rose); }
.summary-card:nth-child(4) strong::before { background: var(--info); }

/* ---------- Next-due card enrichment ---------- */

.next-due-card {
  position: relative;
  padding: 20px 22px 20px 26px;
  overflow: hidden;
}

.next-due-card::after {
  content: "";
  position: absolute;
  inset: auto -16px -20px auto;
  width: 120px;
  height: 100px;
  background: radial-gradient(circle at center, var(--sage-soft) 0%, transparent 65%);
  opacity: 0.7;
  pointer-events: none;
}

.next-due-card:nth-child(2)::after {
  background: radial-gradient(circle at center, var(--warn-soft) 0%, transparent 65%);
}

.next-due-card:nth-child(3)::after {
  background: radial-gradient(circle at center, var(--rose-soft) 0%, transparent 65%);
}

.next-due-card::before {
  width: 4px;
  top: 18px;
  bottom: 18px;
  left: 10px;
  background: var(--sage-600);
  box-shadow: 0 0 0 3px var(--sage-soft);
}

.next-due-card:nth-child(2)::before {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
}

.next-due-card:nth-child(3)::before {
  background: var(--rose);
  box-shadow: 0 0 0 3px var(--rose-soft);
}

.next-due-card span {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--sage-soft);
  color: var(--sage-ink);
  border-radius: var(--r-pill);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  width: fit-content;
}

.next-due-card:nth-child(2) span {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

.next-due-card:nth-child(3) span {
  background: var(--rose-soft);
  color: #7a3e50;
}

.next-due-card strong {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  font-size: 1.5rem;
}

.next-due-card p { position: relative; z-index: 1; }

/* ---------- Tax card enrichment ---------- */

.tax-card::before {
  width: 4px;
  box-shadow: 0 0 0 3px var(--warn-soft);
}

.tax-card span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-radius: var(--r-pill);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  width: fit-content;
}

.tax-card span::before {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--warn);
  border-radius: 50%;
}

/* ---------- Status pills: add dots ---------- */

.status-pill {
  gap: 6px;
  padding: 3px 10px 3px 8px;
}

.status-pill::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sage-600);
}

.status-pill.paid::before { background: var(--subtle); }
.status-pill.overdue::before { background: var(--danger); }
.status-pill.due-soon::before { background: var(--warn); }

/* ---------- Progress bars: add depth + animation ---------- */

.summary-card strong .goal-progress-track,
.loan-progress-track {
  height: 28px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(26, 22, 18, 0.06);
}

.summary-card strong .goal-progress-fill,
.loan-progress-fill {
  background: linear-gradient(180deg, var(--sage) 0%, var(--sage-600) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 1px 2px rgba(47, 74, 55, 0.3);
  font-size: 0.7rem;
  font-weight: 600;
}

/* Note: the spec says no gradients, but for a 2-color tonal progress bar
   on a branded accent, the subtle top highlight reads as "polish" more
   than gradient artifact. Keeping this as a deliberate exception. */

/* ---------- Section heading: typographic hierarchy ---------- */

.section-heading {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.section-heading::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 40px;
  height: 2px;
  background: var(--sage-600);
  border-radius: 999px;
}

.section-heading h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

/* ---------- Pricing card enrichment ---------- */

.pricing-card {
  overflow: hidden;
  position: relative;
}

.pricing-card::before {
  width: 4px;
  box-shadow: 0 0 0 3px var(--surface-muted);
}

.pricing-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -30px auto;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.04;
  color: var(--ink);
  pointer-events: none;
}

.pricing-card.featured {
  background: var(--sage-soft);
  border-color: var(--sage-soft-2);
  box-shadow: 0 4px 16px rgba(122, 158, 130, 0.12);
}

.pricing-card.featured::before {
  box-shadow: 0 0 0 3px var(--surface);
}

.pricing-card.featured::after {
  background: var(--sage-600);
  opacity: 0.08;
}

.pricing-card strong {
  font-size: 1.75rem;
  line-height: 1;
}

.pricing-card span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--surface-muted);
  border-radius: var(--r-pill);
  font-size: 0.6rem;
  width: fit-content;
}

.pricing-card.featured span {
  background: var(--surface);
  color: var(--sage-ink);
}

/* ---------- Calendar capacity indicator ---------- */

.calendar-card {
  position: relative;
  padding-top: 24px;
}

.calendar-card::before {
  left: 20px;
  right: 20px;
  top: 0;
  height: 4px;
  border-radius: 0 0 var(--r-md) var(--r-md);
  background: var(--sage-600);
}

.calendar-card.caution::before { background: var(--warn); }
.calendar-card.full::before { background: var(--danger); }

.calendar-card-head h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.375rem;
  letter-spacing: -0.01em;
}

.calendar-card-head span {
  padding: 4px 10px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  border: 1px solid var(--sage-soft-2);
}

.calendar-card.caution .calendar-card-head span {
  border-color: #eac98a;
}

.calendar-card.full .calendar-card-head span {
  border-color: #f1b8a2;
}

/* ---------- Loan card polish ---------- */

.loan-card {
  position: relative;
  overflow: hidden;
}

.loan-card::before {
  width: 4px;
  box-shadow: 0 0 0 3px var(--sage-soft);
}

.loan-card::after {
  content: "";
  position: absolute;
  inset: auto -24px -24px auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--sage-soft);
  opacity: 0.5;
  pointer-events: none;
}

.loan-entry-card {
  background: var(--surface-muted);
  border-color: var(--border);
}

.loan-entry-card h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.loan-entry-card h4::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--sage-600);
  border-radius: 50%;
}

/* ---------- QuickBooks report polish ---------- */

.quickbooks-report-head {
  background: var(--surface);
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.quickbooks-report-head::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 40px;
  height: 3px;
  background: var(--sage-600);
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
}

.quickbooks-report-head h3 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: -0.015em;
}

.quickbooks-report-head span {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  font-size: 0.65rem;
  color: var(--sage-700);
}

/* ---------- Advisor / chat visual richness ---------- */

.advisor-chat-section,
.social-strategy-section,
.birth-capacity-section,
.expense-category-section {
  position: relative;
  overflow: hidden;
}

.advisor-chat-section::before,
.social-strategy-section::before {
  content: "";
  position: absolute;
  inset: auto -30px -30px auto;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--sage-soft);
  opacity: 0.35;
  pointer-events: none;
}

.social-strategy-section::before {
  background: var(--rose-soft);
  opacity: 0.4;
}

.advisor-tool-head h3 {
  position: relative;
  padding-left: 18px;
}

.advisor-tool-head h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--sage-600);
  border-radius: 999px;
}

.advisor-message {
  position: relative;
  border-radius: var(--r-md);
}

.advisor-bot {
  border-left: 3px solid var(--sage-600);
  padding-left: 14px;
}

.advisor-user {
  border-right: 3px solid var(--rose);
  padding-right: 14px;
  background: var(--rose-soft);
  border-color: transparent;
  border-left: 0;
}

.advisor-user span { color: #7a3e50; }

/* ---------- Form enrichment ---------- */

.entry-form,
.expense-form,
.client-payment-form {
  position: relative;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.entry-form::before,
.expense-form::before,
.client-payment-form::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 20px;
  right: 20px;
  height: 2px;
  background: var(--sage-600);
  opacity: 0.4;
  border-radius: 0 0 999px 999px;
}

.field label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ---------- Primary button flourish ---------- */

.primary-button {
  position: relative;
  padding: 10px 20px;
  background: var(--ink);
  color: #fffdf7;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: var(--r-sm);
  box-shadow:
    0 1px 2px rgba(26, 22, 18, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition:
    background var(--t-fast) var(--ease),
    box-shadow var(--t-med) var(--ease),
    transform var(--t-fast) var(--ease);
}

.primary-button:hover {
  background: var(--sage-700);
  transform: translateY(-1px);
  box-shadow:
    0 4px 12px rgba(47, 74, 55, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.primary-button:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(26, 22, 18, 0.12);
}

/* ---------- Table row richness ---------- */

tbody tr {
  position: relative;
  transition: background var(--t-fast) var(--ease);
}

tbody tr:hover td,
tbody tr:hover th {
  background: var(--sage-soft);
}

/* First-column accent on hover */
tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--sage-600);
}

/* ---------- Search input with icon ---------- */

.search {
  padding-left: 36px;
  background: var(--surface)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6560' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>")
    no-repeat 12px center;
  background-size: 16px;
}

/* ---------- P&L chart card ---------- */

.profit-loss-chart-card {
  padding: 24px;
  position: sticky;
  background:
    radial-gradient(at top right, var(--sage-soft), transparent 60%),
    var(--surface);
}

.profit-loss-chart-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.profit-loss-chart-card h3::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--sage-600);
  border-radius: 50%;
}

.profit-loss-line {
  stroke-width: 2.5;
}

.profit-loss-line-chart circle {
  r: 3;
  fill: var(--surface);
  stroke-width: 2.5;
}

/* ---------- PDF viewer polish ---------- */

.pdf-viewer {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}

/* ---------- Statement card hero treatment ---------- */

.statement-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.statement-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--sage-600);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.statement-head h3 {
  font-family: var(--font-display);
  font-size: 1.375rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.statement-head span {
  padding: 3px 10px;
  background: var(--surface-muted);
  border-radius: var(--r-pill);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.statement-total {
  padding-top: 14px !important;
  margin-top: 6px;
  border-top: 1px solid var(--ink-2) !important;
  font-family: var(--font-display) !important;
  font-size: 1.25rem !important;
  color: var(--sage-ink);
  font-weight: 400 !important;
}

/* ---------- Mobile refinements ---------- */

@media (max-width: 820px) {
  .tabs::before { display: none; }
  .tabs > .tab, .tabs > .tab-group > .tab-dropdown {
    padding-left: 34px;
    background-position: 10px center;
  }

  .app-header::after { display: none; }
  .app-header h1::first-letter { color: inherit; }

  .summary-card::after,
  .next-due-card::after,
  .pricing-card::after,
  .loan-card::after { display: none; }
}

/* Print */
@media print {
  body { background: #fff; }
  .tabs, .mobile-menu-toggle, .primary-button, .secondary-button, .tiny-button { display: none !important; }
  .app-shell { grid-template-columns: 1fr; }
  .view { display: block !important; }
  .summary-card, .next-due-card, .tax-card, .loan-card, .statement-card, .calendar-card {
    box-shadow: none;
    break-inside: avoid;
  }
}
