body {
  --fm-bg: #ffffff;
  --fm-surface: #f6f6f5;
  --fm-surface-2: #eeeeec;
  --fm-ink: #111111;
  --fm-muted: #8a8a87;
  --fm-line: #ebebe9;
  --fm-accent: #0b3d31;
  --fm-accent-hover: #0f5244;
  --fm-accent-soft: #e4efe9;
  --pn-up: #1f9d55;
  --pn-chip: #efefed;
  --bs-body-font-family: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-body-bg: var(--fm-bg);
  --bs-body-color: var(--fm-ink);
  --bs-emphasis-color: var(--fm-ink);
  --bs-secondary-color: var(--fm-muted);
  --bs-tertiary-bg: var(--fm-surface-2);
  --bs-border-color: var(--fm-line);
  --bs-border-radius: .9rem;
  --bs-border-radius-sm: .7rem;
  --bs-border-radius-lg: 1.1rem;
  --bs-primary: var(--fm-accent);
  --bs-link-color: var(--fm-accent);
  background: var(--fm-bg);
  color: var(--fm-ink);
}
[data-bs-theme="dark"] body {
  --fm-bg: #0b0c0c;
  --fm-surface: #161818;
  --fm-surface-2: #202322;
  --fm-ink: #f3f3f1;
  --fm-muted: #8f918e;
  --fm-line: #242726;
  --fm-accent: #3fbf9f;
  --fm-accent-hover: #5fd3b6;
  --fm-accent-soft: #12302a;
  --pn-up: #46c47f;
  --pn-chip: #202322;
}

body .page-title { font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.1rem); font-weight: 500; letter-spacing: -.03em; }
body .page-subtitle { color: var(--fm-muted); }
body .back-link { color: var(--fm-ink); }
body .back-link .bi { display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--pn-chip); }

body .surface { background: var(--fm-surface); border: 0; border-radius: 1.25rem; }
body .surface-header, body .surface-toolbar { border-bottom-color: var(--fm-line); }
body .surface-title { font-weight: 600; font-size: 1.02rem; }
body .stat { background: var(--fm-surface); border: 0; border-radius: 1.25rem; padding: 1.1rem 1.2rem; }
body .stat-label { font-size: .85rem; font-weight: 400; color: var(--fm-muted); }
body .stat-value { font-size: clamp(1.7rem, 1.2rem + 1.4vw, 2.2rem); font-weight: 500; letter-spacing: -.035em; }
body .stat-value small, body .cents { font-size: .55em; letter-spacing: 0; font-weight: 500; }
body .stat-detail { color: var(--fm-muted); }
body .stat-icon, body .hero-icon, body .feature-icon { border-radius: 50%; background: var(--fm-bg); color: var(--fm-ink); }
body .callout, body .state-card, body .choice-card, body .line-item, body .plan-summary { border-radius: 1rem; }
body .state-card { border: 0; background: var(--fm-surface); }
body .receipt-card { border-radius: 1.25rem; background: var(--fm-surface); }
body .line-item { background: var(--fm-bg); border-color: var(--fm-line); }
body .qty-stepper { border-radius: 999px; background: var(--fm-bg); }

body .btn { --bs-btn-border-radius: 999px; --bs-btn-font-weight: 600; --bs-btn-padding-x: 1.15rem; }
body .btn-sm { --bs-btn-padding-x: .85rem; }
body .btn-primary {
  --bs-btn-bg: var(--fm-accent); --bs-btn-border-color: var(--fm-accent); --bs-btn-color: #fff;
  --bs-btn-hover-bg: var(--fm-accent-hover); --bs-btn-hover-border-color: var(--fm-accent-hover); --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--fm-accent-hover); --bs-btn-active-border-color: var(--fm-accent-hover); --bs-btn-active-color: #fff;
  --bs-btn-disabled-bg: var(--fm-accent); --bs-btn-disabled-border-color: var(--fm-accent); --bs-btn-disabled-color: #fff;
}
[data-bs-theme="dark"] body .btn-primary { --bs-btn-color: #04140f; --bs-btn-hover-color: #04140f; --bs-btn-active-color: #04140f; --bs-btn-disabled-color: #04140f; }
body .btn-outline-primary, body .btn-outline-secondary {
  --bs-btn-color: var(--fm-ink); --bs-btn-bg: var(--pn-chip); --bs-btn-border-color: var(--pn-chip);
  --bs-btn-hover-bg: var(--fm-surface-2); --bs-btn-hover-border-color: var(--fm-surface-2); --bs-btn-hover-color: var(--fm-ink);
  --bs-btn-active-bg: var(--fm-surface-2); --bs-btn-active-border-color: var(--fm-surface-2); --bs-btn-active-color: var(--fm-ink);
  background: var(--bs-btn-bg);
}
body .btn-outline-danger { background: var(--pn-chip); border-color: var(--pn-chip); }
body .input-group > .btn { --bs-btn-border-radius: var(--bs-border-radius); }

body .form-control, body .form-select { background-color: var(--fm-bg); border-color: var(--fm-line); }
body .form-control:focus, body .form-select:focus { border-color: var(--fm-accent); }
body .input-group-text { background: var(--fm-surface-2); border-color: var(--fm-line); }
body .form-label { font-weight: 500; }

body .table { --bs-table-hover-bg: var(--fm-surface-2); }
body .table > thead th { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: .8rem; }
body .badge { border-radius: 999px; font-weight: 600; }
body .text-bg-muted-soft { box-shadow: none; }
body .dropdown-menu { border: 0; border-radius: 1.1rem; --bs-dropdown-box-shadow: 0 18px 50px -12px rgba(0, 0, 0, .22); }
body .dropdown-item { border-radius: .7rem; }
body .modal { --bs-modal-border-radius: 1.5rem; --bs-modal-border-color: transparent; }

body .nav-pills .nav-link, body .filter-pills .nav-link { border-radius: 999px; color: var(--fm-muted); font-weight: 500; }
body .filter-pills .btn-check:checked + .nav-link, body .nav-pills .nav-link.active { background: var(--pn-chip); color: var(--fm-ink); }
body .filter-pills .btn-check:checked + .nav-link .filter-count { background: var(--fm-bg); }

body .panel-sidebar { --bs-offcanvas-bg: var(--fm-bg); border-right: 1px solid var(--fm-line); }
body .sidebar-link { border-radius: 999px; color: var(--fm-muted); font-weight: 500; }
body .sidebar-link:hover { background: var(--fm-surface); color: var(--fm-ink); }
body .sidebar-link.active { background: var(--pn-chip); color: var(--fm-ink); font-weight: 600; }
body .sidebar-link.active .bi { color: var(--fm-ink); }
body .panel-topbar { background: color-mix(in srgb, var(--fm-bg) 88%, transparent); border-bottom: 0; }
body .avatar { background: var(--pn-chip); color: var(--fm-ink); }

body .text-success, body .text-up { color: var(--pn-up) !important; }
body .theme-switch .btn { --bs-btn-bg: transparent; --bs-btn-border-color: var(--fm-line); }
body .theme-switch .btn.active, body .theme-switch .btn.active:hover { background: var(--pn-chip); border-color: var(--pn-chip); color: var(--fm-ink); }

.tabbar { display: none; }
@media (max-width: 991.98px) {
  body .panel-topbar > [data-bs-target="#sidebar"] { display: none; }
  body .panel-main { padding-bottom: calc(7rem + env(safe-area-inset-bottom, 0px)); }
  .tabbar {
    position: fixed; left: 50%; bottom: calc(.75rem + env(safe-area-inset-bottom, 0px)); z-index: 1030; transform: translateX(-50%);
    display: flex; gap: .15rem; padding: .35rem; width: min(100% - 1.5rem, 26rem);
    background: color-mix(in srgb, var(--fm-bg) 82%, transparent); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border: 1px solid var(--fm-line); border-radius: 999px; box-shadow: 0 12px 40px -12px rgba(0, 0, 0, .25);
  }
  .tabbar-link { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .45rem .25rem; border: 0; border-radius: 999px; background: none; color: var(--fm-muted); font-size: .68rem; font-weight: 500; text-decoration: none; }
  .tabbar-link .bi { font-size: 1.2rem; }
  .tabbar-link.active { background: var(--pn-chip); color: var(--fm-ink); }
  .tabbar-link-main .bi { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; margin-top: -.1rem; border-radius: 50%; background: var(--fm-accent); color: #fff; font-size: 1.1rem; }
  [data-bs-theme="dark"] .tabbar-link-main .bi { color: #04140f; }
}
@media print { .tabbar { display: none !important; } }
body .receipt-amount { font-size: clamp(2.2rem, 1.6rem + 2vw, 2.8rem); font-weight: 500; letter-spacing: -.035em; line-height: 1.1; }

body .btn-group:has(> .btn-check) { gap: .25rem; padding: .25rem; background: var(--pn-chip); border-radius: 999px; }
body .btn-group > .btn-check + .btn { --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-hover-bg: var(--fm-surface-2); --bs-btn-hover-border-color: transparent; border-radius: 999px !important; margin: 0 !important; color: var(--fm-muted); }
body .btn-group > .btn-check:checked + .btn { background: var(--fm-accent); border-color: var(--fm-accent); color: #fff; box-shadow: 0 2px 8px -2px rgba(0, 0, 0, .25); }
[data-bs-theme="dark"] body .btn-group > .btn-check:checked + .btn { color: #04140f; }
body .btn-group > .btn-check:focus-visible + .btn { box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }

body .auth-card { background: var(--fm-surface); border: 0; border-radius: 1.5rem; }
body .public-header { background: var(--fm-bg); border-bottom-color: var(--fm-line); }
body .receipt-public { border-radius: 1.25rem; }

[data-resource-view-target="loading"]:not([hidden]),
[data-resource-table-target="loading"]:not([hidden]) {
  position: relative; min-height: 3.5rem; color: transparent !important; overflow: hidden;
  border-radius: 1rem; background: var(--fm-surface-2);
  animation: fm-appear .2s ease .25s both;
}
[data-resource-view-target="loading"]:not([hidden])::after,
[data-resource-table-target="loading"]:not([hidden])::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--fm-bg) 70%, transparent), transparent);
  transform: translateX(-100%); animation: fm-shimmer 1.2s ease-in-out infinite;
}
[data-resource-view-target="content"]:not([hidden]),
[data-resource-table-target="table"]:not([hidden]),
[data-resource-table-target="empty"]:not([hidden]) { animation: fm-content-in .22s ease-out both; }
[aria-busy="true"] [data-resource-table-target="table"],
[aria-busy="true"] [data-resource-view-target="content"] { opacity: .55; transition: opacity .15s ease .15s; }
[data-resource-table-target="table"], [data-resource-view-target="content"] { transition: opacity .15s ease; }

@keyframes fm-appear { from { opacity: 0; } to { opacity: 1; } }
@keyframes fm-shimmer { to { transform: translateX(100%); } }
@keyframes fm-content-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
.page-subtitle:empty::before, .page-title:empty::before { content: "\a0"; }
.page-header { align-items: flex-start; }
@media (min-width: 576px) { .page-header .page-actions { padding-top: .35rem; } }
body .receipt-notes { margin: .75rem 0; padding: .75rem .9rem; border-radius: .9rem; background: var(--fm-bg); }
body .receipt-notes [data-field="notes"] { white-space: pre-line; overflow-wrap: anywhere; }
body .bitacora { max-height: 24rem; overflow-y: auto; }
body .bitacora-item { padding: .85rem 1rem; border-bottom: 1px solid var(--fm-line); }
body .bitacora-item:last-child { border-bottom: 0; }
body .bitacora-note { margin: .25rem 0; white-space: pre-line; overflow-wrap: anywhere; }

.chart-app { --chart-muted: #cfcfca; --chart-grid: var(--fm-line); --chart-surface: var(--fm-surface); }
[data-bs-theme="dark"] .chart-app { --chart-muted: #353a38; }
.chart-readout { display: flex; flex-direction: column; gap: .1rem; margin-bottom: .75rem; min-height: 4.6rem; }
.chart-readout-label { font-size: .85rem; color: var(--fm-muted); }
.chart-readout-value { font-size: clamp(1.8rem, 1.3rem + 1.4vw, 2.3rem); font-weight: 500; letter-spacing: -.035em; line-height: 1.1; font-variant-numeric: normal; }
.chart-readout-value small { font-size: .5em; letter-spacing: 0; }
.chart-readout-sub { font-size: .85rem; color: var(--fm-muted); min-height: 1.2em; }
.chart-readout-sub.is-up { color: var(--pn-up, #1f9d55); }
.chart-readout-sub.is-down { color: var(--fm-danger); }
.chart-app .chart-tick.is-on { font-weight: 700; }
.chart-cap { font-size: 12px; font-weight: 600; fill: var(--fm-ink); font-variant-numeric: tabular-nums; }
.chart-scrub { cursor: pointer; touch-action: pan-y; -webkit-tap-highlight-color: transparent; }
.chart-app .chart-tooltip { display: none; }

body .line-payment { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding-top: .55rem; margin-top: .1rem; border-top: 1px dashed var(--fm-line); }
body .line-payment[hidden] { display: none; }
body .line-amount { width: 9.5rem; }
body .line-item-tracked { background: var(--fm-accent-soft); }
body .patient-clear { position: absolute; top: 0; right: 0; bottom: 0; display: grid; place-items: center; width: 2.75rem; padding: 0; border: 0; background: none; color: var(--bs-secondary-color); }
body .patient-suggestions { max-height: min(18rem, 45vh); overflow-y: auto; }
body .patient-suggestions .dropdown-item { display: block; white-space: normal; padding-block: .6rem; }
body .patient-clear:hover { color: var(--bs-body-color); }
body .position-relative:has(.patient-clear:not([hidden])) > .form-control { padding-right: 2.75rem; }
body .patient-purchases { display: grid; gap: .6rem; margin-top: 1rem; }
body .patient-purchases-title { margin: 0; font-size: .85rem; font-weight: 600; }
body .purchase-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; padding: .8rem .9rem; border-radius: 1rem; background: var(--fm-bg); border: 1px solid var(--fm-line); }
body .purchase-debt { color: var(--fm-warn); font-weight: 600; }
body .line-item { flex-wrap: wrap; }
body .line-item > .min-w-0 { flex: 1 1 12rem; }
body .line-items { grid-template-columns: minmax(0, 1fr); }
body .line-items > * { min-width: 0; }
body .line-item[data-tracked] [data-name], body .line-item-tracked [data-name] { white-space: normal; }
body .purchase-list { display: grid; }
body .purchase-item { display: grid; gap: .5rem; padding: .9rem 1rem; border-bottom: 1px solid var(--fm-line); }
body .purchase-item:last-child { border-bottom: 0; }
body .purchase-bar { height: 6px; border-radius: 999px; background: var(--fm-surface-2); overflow: hidden; }
body .purchase-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--chart-1); }
