:root {
  color-scheme: light;
  --background: #f4f0e7;
  --foreground: #292929;
  --card: #f4f0e7;
  --card-foreground: #292929;
  --popover: #f4f0e7;
  --popover-foreground: #292929;
  --primary: #cfc4ac;
  --primary-foreground: #292929;
  --secondary: #e7e3da;
  --secondary-foreground: #292929;
  --muted: #cfc8b8;
  --muted-foreground: #5e5a52;
  --accent: #cfc4ac;
  --accent-foreground: #292929;
  --destructive: #dc2626;
  --border: #d8d2c7;
  --input: #d8d2c7;
  --ring: #3f6b57;
  --brand-accent: #cfc4ac;
  --brand-accent-ink: #292929;
  --brand-accent-text: #3f6b57;
  --sidebar: #e3ddcf;
  --sidebar-foreground: #292929;
  --sidebar-accent: #cfc4ac;
  --sidebar-border: #d8d2c7;
  --radius: 8px;
  --shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  --sans: "Inter", system-ui, sans-serif;
  --mono: var(--sans);
  --slot-online-bg: #3f6b57;
  --slot-online-border: #3f6b57;
  --slot-online-text: #f4f0e7;
  --slot-hybrid-bg: #cfc4ac;
  --slot-hybrid-border: #cfc4ac;
  --slot-hybrid-text: #292929;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

:root[data-theme="dark"] {
  --brand-accent-text: #cfc4ac;
  color-scheme: dark;
  --background: #202020;
  --foreground: #f4f0e7;
  --card: #292929;
  --card-foreground: #f4f0e7;
  --popover: #292929;
  --popover-foreground: #f4f0e7;
  --primary: #cfc4ac;
  --primary-foreground: #292929;
  --secondary: #222222;
  --secondary-foreground: #d1cfc0;
  --muted: #2a2a2a;
  --muted-foreground: #bcb7ad;
  --accent: #363636;
  --accent-foreground: #d1cfc0;
  --destructive: #ef4444;
  --border: #2c2c2c;
  --input: #2c2c2c;
  --ring: #d1cfc0;
  --sidebar: #202020;
  --sidebar-foreground: #f4f0e7;
  --sidebar-accent: #363636;
  --sidebar-border: #2c2c2c;
  --slot-online-bg: #3f6b57;
  --slot-online-border: #3f6b57;
  --slot-online-text: #f4f0e7;
  --slot-hybrid-bg: #cfc4ac;
  --slot-hybrid-border: #cfc4ac;
  --slot-hybrid-text: #292929;
  --shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body { min-height: 100vh; margin: 0; color: var(--foreground); background: var(--background); font-family: var(--sans); font-size: 14px; line-height: 1.5; letter-spacing: 0; font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
button, input, select, textarea, dialog { color: inherit; }
button { letter-spacing: inherit; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 30; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px; border-right: 1px solid var(--sidebar-border); background: var(--sidebar); }
.sidebar-brand { min-height: 48px; display: flex; flex-direction: column; align-items: center; padding: 4px 8px 18px; }
.profile-block > span:nth-child(2), .local-note span { min-width: 0; display: flex; flex-direction: column; }
.psiboard-logo { display: block; width: 170px; max-width: 100%; height: auto; aspect-ratio: 844.83 / 168.18; }
.profile-block small, .local-note small { color: var(--muted-foreground); font-size: 11px; }
.primary-nav { flex: 1; overflow-y: auto; scrollbar-width: none; }
.primary-nav::-webkit-scrollbar { display: none; }
.nav-label { margin: 14px 10px 7px; color: var(--muted-foreground); font-size: 10px; font-weight: 600; text-transform: uppercase; }
.nav-label-secondary { margin-top: 26px; }
.nav-item { width: 100%; min-height: 42px; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 9px; margin: 2px 0; padding: 9px 10px; border: 1px solid transparent; border-radius: var(--radius); color: var(--muted-foreground); background: transparent; text-align: left; font-weight: 600; transition: color 160ms ease, background-color 160ms ease, transform 140ms var(--ease-out); }
.nav-item:active { transform: scale(0.98); }
.nav-item.is-active { color: var(--sidebar-foreground); border-color: var(--sidebar-border); background: var(--sidebar-accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.nav-badge { min-width: 22px; padding: 2px 6px; border-radius: 999px; color: var(--brand-accent-ink); background: var(--brand-accent); text-align: center; font-size: 10px; }
.sidebar-footer { display: grid; gap: 12px; padding-top: 14px; border-top: 1px solid var(--sidebar-border); }
.local-note { display: flex; align-items: center; gap: 10px; padding: 11px; border: 1px dashed var(--sidebar-border); border-radius: var(--radius); color: var(--muted-foreground); }
.local-note strong { color: var(--sidebar-foreground); font-size: 11px; }
#sign-out-button[hidden] { display: none; }
.profile-block { min-width: 0; display: grid; grid-template-columns: 34px minmax(0, 1fr) 32px; align-items: center; gap: 9px; padding: 5px 4px; }
.profile-block strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.profile-block > .icon-button { color: inherit; text-decoration: none; }
.avatar { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--primary-foreground); background: var(--primary); font-size: 11px; font-weight: 600; }
.sidebar-backdrop { display: none; }

.app-main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 8px 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 88%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.topbar-start, .topbar-actions, .breadcrumb { display: flex; align-items: center; }
.topbar-actions { gap: 6px; }
.breadcrumb { gap: 7px; color: var(--muted-foreground); font-size: 12px; }
.breadcrumb svg { width: 14px; height: 14px; }
.breadcrumb strong { color: var(--foreground); font-weight: 600; }
.mobile-menu { display: none !important; margin-right: 6px; }
.topbar-brand { display: none; }
.icon-button { position: relative; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; padding: 0; border: 1px solid transparent; border-radius: var(--radius); color: var(--muted-foreground); background: transparent; transition: color 160ms ease, background-color 160ms ease, transform 140ms var(--ease-out); }
.icon-button:active, .button:active { transform: scale(0.96); }
.notification-dot { position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; border: 1px solid var(--background); border-radius: 50%; background: var(--brand-accent); }

.content-area { width: min(1500px, 100%); margin: 0 auto; padding: 28px 32px 56px; }
.app-view { animation: view-in 180ms var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-header h1 { margin: 0; font-size: 28px; font-weight: 600; line-height: 1.15; letter-spacing: 0; }
.page-header p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted-foreground); }
.compact-page-header { margin-bottom: 20px; }
.eyebrow { margin: 0 0 5px; color: var(--muted-foreground); font-size: 10px; font-weight: 600; text-transform: uppercase; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-header h2, .setting-card h2 { margin: 0; font-size: 14px; line-height: 1.35; }
.panel-header p, .setting-card p { margin: 4px 0 0; color: var(--muted-foreground); font-size: 12px; }

.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 13px; border: 1px solid transparent; border-radius: var(--radius); background: transparent; font-size: 12px; font-weight: 600; transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 140ms var(--ease-out); }
.button svg { width: 15px; height: 15px; }
.button-primary { color: var(--primary-foreground); background: var(--primary); }
.button-outline { border-color: var(--border); background: var(--card); }
.button-ghost { color: var(--muted-foreground); }
.align-start { align-self: flex-start; }
.button:focus-visible, .icon-button:focus-visible, .nav-item:focus-visible, .view-tab:focus-visible, input:focus-visible, select:focus-visible, .day-button:focus-visible, .slot-button:focus-visible { outline: 3px solid color-mix(in srgb, var(--ring) 35%, transparent); outline-offset: 2px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card { min-width: 0; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; align-items: start; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.metric-icon { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius); color: var(--muted-foreground); background: var(--secondary); }
.metric-card > div:last-child { min-width: 0; display: flex; flex-direction: column; }
.metric-card span { color: var(--muted-foreground); font-size: 11px; }
.metric-card strong { margin-top: 4px; font-family: var(--mono); font-size: 25px; line-height: 1.15; letter-spacing: 0; }
.metric-card small { margin-top: 4px; color: var(--muted-foreground); font-size: 10px; }
.accent-metric .metric-icon { color: var(--brand-accent-ink); background: var(--brand-accent); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr); gap: 18px; }
.today-panel, .compact-panel { padding: 18px; }
.dashboard-side { display: grid; gap: 18px; }
.appointment-list { margin-top: 16px; }
.empty-appointment { min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; }
.empty-appointment .empty-icon { width: 46px; height: 46px; flex: 0 0 auto; margin-bottom: 12px; border-radius: var(--radius); }
.empty-appointment strong { font-size: 14px; }
.empty-appointment p { max-width: 360px; margin: 5px 0 16px; color: var(--muted-foreground); font-size: 12px; }
.appointment-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--border); }
.appointment-row:last-child { border-bottom: 0; }
.appointment-time { font-family: var(--mono); font-size: 12px; }
.appointment-details { min-width: 0; }
.appointment-details strong, .appointment-details span { display: block; }
.appointment-details span { margin-top: 2px; color: var(--muted-foreground); font-size: 11px; }
.availability-overview { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; margin-top: 17px; }
.availability-day { min-width: 0; text-align: center; }
.availability-day span, .availability-day strong { display: block; }
.availability-day span { color: var(--muted-foreground); font-size: 9px; text-transform: uppercase; }
.availability-day strong { margin-top: 6px; padding: 8px 2px; border-radius: var(--radius); background: var(--secondary); font-family: var(--mono); font-size: 12px; }
.automation-summary { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: start; margin-top: 17px; }
.automation-icon, .setting-icon, .empty-icon { display: inline-flex; align-items: center; justify-content: center; color: var(--brand-accent-ink); background: var(--brand-accent); }
.automation-icon { width: 40px; height: 40px; border-radius: var(--radius); }
.automation-summary strong { font-size: 12px; }
.automation-summary p { margin: 4px 0 0; color: var(--muted-foreground); font-size: 11px; }
.status-chip { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; color: var(--muted-foreground); background: var(--secondary); font-size: 9px; font-weight: 600; text-transform: uppercase; }
.status-chip.large { padding: 7px 10px; }

.agenda-toolbar { min-height: 58px; display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-bottom: 10px; padding: 8px 12px; box-shadow: none; }
.view-tabs { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--secondary); }
.view-tab { min-height: 34px; display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border: 0; border-radius: 6px; color: var(--muted-foreground); background: transparent; font-size: 11px; font-weight: 600; }
.view-tab svg { width: 14px; height: 14px; }
.view-tab.is-active { color: var(--card-foreground); background: var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.09); }
.agenda-toolbar h2 { min-width: 0; margin: 0; text-align: center; font-size: 13px; }
.week-navigation { display: flex; align-items: center; gap: 5px; }
.calendar-legend { display: flex; justify-content: flex-end; gap: 14px; color: var(--muted-foreground); font-size: 10px; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 8px; height: 8px; display: inline-block; border-radius: 2px; }
.legend-swatch.hybrid { background: var(--slot-hybrid-bg); border: 1px solid var(--slot-hybrid-border); }
.legend-swatch.online { background: var(--slot-online-bg); border: 1px solid var(--slot-online-border); }
.legend-swatch.booked { background: var(--brand-accent); }
.calendar-frame { overflow: auto; box-shadow: none; }
.week-calendar { position: relative; min-width: 940px; display: grid; grid-template-columns: 64px repeat(7, minmax(120px, 1fr)); grid-template-rows: 48px repeat(var(--calendar-rows, 41), 24px); background: var(--card); }
.calendar-corner, .calendar-day-head { position: sticky; top: 0; z-index: 8; border-bottom: 1px solid var(--border); background: var(--card); }
.calendar-corner { left: 0; z-index: 9; grid-column: 1; grid-row: 1; border-right: 1px solid var(--border); }
.calendar-day-head { display: flex; flex-direction: column; align-items: center; justify-content: center; border-right: 1px solid var(--border); }
.calendar-day-head span { color: var(--muted-foreground); font-size: 9px; text-transform: uppercase; }
.calendar-day-head strong { font-size: 12px; }
.calendar-day-head.is-today { color: var(--foreground); background: color-mix(in srgb, var(--brand-accent) 18%, var(--card)); box-shadow: inset 0 3px 0 var(--brand-accent); }
.calendar-day-head.is-today strong { color: var(--foreground); }
.calendar-time { position: sticky; left: 0; z-index: 5; display: flex; align-items: flex-start; justify-content: flex-end; padding: 3px 8px 0 0; border-right: 1px solid var(--border); color: var(--muted-foreground); background: var(--card); font-family: var(--mono); font-size: 9px; }
.calendar-cell { border-right: 1px solid var(--border); border-bottom: 1px solid color-mix(in srgb, var(--border) 62%, transparent); }
.calendar-cell.hour-line { border-bottom-color: var(--border); }
.calendar-cell.is-today { border-left: 1px solid color-mix(in srgb, var(--brand-accent) 32%, var(--border)); border-right-color: color-mix(in srgb, var(--brand-accent) 32%, var(--border)); background: color-mix(in srgb, var(--brand-accent) 8%, var(--card)); }
.calendar-block { z-index: 3; min-width: 0; display: flex; flex-direction: column; gap: 4px; margin: 1px 3px; padding: 5px 6px; overflow: hidden; border: 1px solid var(--border); border-radius: 5px; background: var(--card); font-size: 10px; line-height: 1.2; }
.calendar-block strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-block span { color: var(--muted-foreground); }
.calendar-block.is-hybrid { color: var(--slot-hybrid-text); border-color: var(--slot-hybrid-border); background: var(--slot-hybrid-bg); }
.calendar-block.is-hybrid span { color: var(--slot-hybrid-text); }
.calendar-block.is-online { color: var(--slot-online-text); border-color: var(--slot-online-border); background: var(--slot-online-bg); }
.calendar-block.is-online span { color: var(--slot-online-text); }
.calendar-block.is-booked { color: #292929; border-color: var(--brand-accent); background: var(--brand-accent); }
.calendar-block.is-booked span { color: #292929; }

.availability-editor { display: grid; grid-template-columns: 220px minmax(0, 1fr); overflow: hidden; box-shadow: none; }
.editor-sidebar { padding: 18px 14px; border-right: 1px solid var(--border); background: var(--sidebar); }
.editor-sidebar-head { padding: 0 8px 13px; }
.editor-sidebar-head h2 { margin: 0; font-size: 18px; }
.editor-sidebar-head p:last-child { margin: 4px 0 0; color: var(--muted-foreground); font-size: 11px; }
.day-list { display: grid; gap: 3px; }
.day-button { width: 100%; min-height: 42px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid transparent; border-radius: var(--radius); color: var(--muted-foreground); background: transparent; text-align: left; font-size: 12px; font-weight: 600; }
.day-button small { min-width: 24px; padding: 2px 6px; border-radius: 999px; background: var(--secondary); text-align: center; font-family: var(--mono); font-size: 9px; }
.day-button.is-active { color: var(--foreground); border-color: var(--sidebar-border); background: var(--sidebar-accent); }
.day-button.is-active small { color: var(--brand-accent-ink); background: var(--brand-accent); }
.schedule-editor { min-width: 0; }
.editor-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 14px 22px; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.editor-head h2 { margin: 0; font-size: 20px; }
.editor-head > div > p:last-child { margin: 3px 0 0; color: var(--muted-foreground); font-size: 11px; }
.slot-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted-foreground); font-size: 11px; }
.slot-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.slot-swatch { width: 10px; height: 10px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 2px; background: var(--card); }
.slot-swatch.online { border-color: var(--slot-online-border); background: var(--slot-online-bg); }
.slot-swatch.hybrid { border-color: var(--slot-hybrid-border); background: var(--slot-hybrid-bg); }
.slot-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; padding: 18px 20px; background: var(--background); }
.slot-button { min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--foreground); background: var(--card); text-align: left; transition: transform 140ms var(--ease-out), border-color 160ms ease, background-color 160ms ease; }
.slot-button:active { transform: scale(0.97); }
.slot-button strong { font-family: var(--mono); font-size: 10px; }
.slot-button span { color: var(--muted-foreground); font-size: 9px; }
.slot-button[data-mode="online"] { color: var(--slot-online-text); border-color: var(--slot-online-border); background: var(--slot-online-bg); }
.slot-button[data-mode="online"] span { color: var(--slot-online-text); }
.slot-button[data-mode="hybrid"] { color: var(--slot-hybrid-text); border-color: var(--slot-hybrid-border); background: var(--slot-hybrid-bg); }
.slot-button[data-mode="hybrid"] span { color: var(--slot-hybrid-text); }
.editor-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--border); }
.editor-footer > div { display: flex; gap: 6px; }
.save-state { color: var(--muted-foreground); font-size: 10px; }

.table-panel { overflow: hidden; box-shadow: none; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); }
.search-field { min-width: 260px; max-width: 420px; flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--input); border-radius: var(--radius); background: var(--background); }
.search-field svg { width: 15px; height: 15px; color: var(--muted-foreground); }
.search-field input { width: 100%; min-height: 36px; padding: 0; border: 0; outline: 0; background: transparent; }
input, select, textarea { min-width: 0; min-height: 38px; padding: 8px 10px; border: 1px solid var(--input); border-radius: var(--radius); background: var(--background); }
textarea { width: 100%; resize: vertical; line-height: 1.5; }
.patient-table-wrap { overflow-x: auto; }
.patient-table { width: 100%; border-collapse: collapse; }
.patient-table th, .patient-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); text-align: left; }
.patient-table th { color: var(--muted-foreground); font-size: 10px; font-weight: 600; text-transform: uppercase; }
.patient-table td { font-size: 12px; }
.patient-name-cell { display: flex; align-items: center; gap: 10px; }
.patient-avatar { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; border-radius: 50%; background: var(--secondary); font-size: 10px; font-weight: 600; }
.patient-name-cell strong, .patient-name-cell small, .contact-cell span { display: block; }
.patient-name-cell small, .contact-cell span { color: var(--muted-foreground); font-size: 10px; }
.status-pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; color: var(--muted-foreground); background: var(--secondary); font-size: 9px; font-weight: 600; }
.status-pill.active { color: var(--foreground); background: var(--accent); }
.status-pill.waiting { color: var(--brand-accent-ink); background: var(--brand-accent); }
.empty-state { min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 36px; text-align: center; }
.empty-state .empty-icon { width: 46px; height: 46px; margin-bottom: 14px; border-radius: var(--radius); }
.empty-state h2 { margin: 0; font-size: 16px; }
.empty-state p { max-width: 420px; margin: 6px 0 18px; color: var(--muted-foreground); font-size: 12px; }

.settings-grid { display: grid; gap: 10px; }
.setting-card { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 16px; box-shadow: none; }
.setting-icon { width: 42px; height: 42px; border-radius: var(--radius); }
.switch { position: relative; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 40px; height: 22px; display: block; padding: 2px; border-radius: 999px; background: var(--muted); cursor: pointer; transition: background-color 160ms ease; }
.switch span::after { content: ""; width: 18px; height: 18px; display: block; border-radius: 50%; background: var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); transition: transform 180ms var(--ease-out); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.privacy-callout { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted-foreground); }
.privacy-callout strong { color: var(--foreground); font-size: 12px; }
.privacy-callout p { margin: 3px 0 0; font-size: 11px; }
.finance-metrics { max-width: 650px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.finance-empty { min-height: 320px; box-shadow: none; }
.settings-columns { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr); gap: 16px; }
.settings-form, .appearance-panel { padding: 18px; box-shadow: none; }
.settings-form { display: grid; gap: 14px; }
.settings-form label, .dialog label { display: grid; gap: 6px; font-size: 11px; font-weight: 600; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.settings-tabs { display: flex; gap: 4px; max-width: 100%; overflow-x: auto; border-bottom: 1px solid var(--border); padding: 0 0 12px; margin-bottom: 24px; }
.settings-tabs .view-tab { flex: 0 0 auto; }
.practice-form { max-width: 980px; }
.saving-fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
.practice-section { display: grid; gap: 20px; min-width: 0; }
.practice-section h2 { margin: 0; font-size: 17px; }
.practice-section label { display: grid; gap: 7px; min-width: 0; font-size: 12px; font-weight: 600; }
.practice-section input, .practice-section select, .practice-section textarea { width: 100%; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.narrow-field { width: min(100%, 360px); }
.crp-field { display: grid; gap: 7px; align-content: start; min-width: 0; margin: 0; padding: 0; border: 0; }
.crp-field legend { float: left; width: 100%; padding: 0; font-size: 12px; font-weight: 600; }
.crp-input { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 38px; padding: 0 10px; border: 1px solid var(--input); border-radius: var(--radius); background: var(--background); }
.crp-input > span { flex: 0 0 auto; color: var(--muted-foreground); font-size: 12px; }
.practice-section .crp-input input { min-width: 0; padding: 8px 0; border: 0; border-radius: 0; background: transparent; font-variant-numeric: tabular-nums; }
.practice-section .crp-input input[name="crpRegion"] { flex: 0 0 3ch; width: 3ch; text-align: center; }
.practice-section .crp-input input[name="crpRegistration"] { flex: 1; width: 0; }
.crp-input:focus-within { outline: 3px solid color-mix(in srgb, var(--ring) 35%, transparent); outline-offset: 2px; }
.crp-input input:focus-visible { outline: none; }
.choice-field { min-width: 0; padding: 0; margin: 0; border: 0; }
.choice-field legend { padding: 0; margin-bottom: 10px; font-size: 12px; font-weight: 600; }
.checkbox-options { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.checkbox-options label { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; }
.checkbox-options input { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--primary); }
.service-list { display: grid; gap: 16px; }
.service-entry { display: grid; gap: 16px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.service-entry-head { display: flex; align-items: center; justify-content: space-between; }
.service-entry-head strong { font-size: 13px; }
.service-entry .checkbox-options { margin-top: 2px; }
.settings-empty { min-height: 160px; }
.settings-empty > svg { width: 28px; height: 28px; color: var(--muted-foreground); }
.settings-empty h3 { font-size: 14px; font-weight: 500; }
.practice-save-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 30px; padding: 18px 0; border-top: 1px solid var(--border); }
.practice-save-bar > span { color: var(--muted-foreground); font-size: 12px; }
.practice-save-bar > div { display: flex; gap: 8px; }
.practice-section .theme-options label { display: block; }
@media (max-width: 640px) {
  .practice-section input, .practice-section select, .practice-section textarea { font-size: 16px; }
  .practice-save-bar { flex-direction: column; align-items: stretch; }
  .practice-save-bar > div { flex-wrap: wrap; }
  .practice-save-bar .button-primary { flex: 1; }
  .service-entry { padding: 14px; }
}
.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.theme-options input { position: absolute; opacity: 0; pointer-events: none; }
.theme-options span { min-height: 116px; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--background); cursor: pointer; }
.theme-options svg { margin-bottom: auto; }
.theme-options strong { font-size: 11px; }
.theme-options small { margin-top: 3px; color: var(--muted-foreground); font-size: 9px; }
.theme-options label:has(input:checked) span { border-color: var(--ring); box-shadow: inset 0 0 0 1px var(--ring); }

.dialog { width: min(620px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); color: var(--popover-foreground); background: var(--popover); box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22); }
.dialog::backdrop { background: rgba(20, 20, 20, 0.46); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.dialog[open] { animation: dialog-in 180ms var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.97) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.dialog form { display: grid; gap: 14px; padding: 20px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 2px; }
.dialog-header h2 { margin: 0; font-size: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 4px; }
.form-note { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted-foreground); font-size: 10px; }
.form-note svg { width: 15px; height: 15px; }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 260px; max-width: 380px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--popover-foreground); background: var(--popover); box-shadow: var(--shadow); animation: toast-in 180ms var(--ease-out); }
.toast svg { color: var(--brand-accent-text); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity 160ms ease, transform 160ms var(--ease-out); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (hover: hover) and (pointer: fine) {
  .nav-item:hover, .icon-button:hover, .button-ghost:hover { color: var(--foreground); background: var(--accent); }
  .button-primary:hover { filter: brightness(1.08); }
  .button-outline:hover { border-color: var(--ring); }
  .day-button:hover { color: var(--foreground); background: var(--sidebar-accent); }
  .slot-button:hover { transform: translateY(-1px); border-color: var(--ring); }
  .patient-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 58%, transparent); }
}

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agenda-toolbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .week-navigation { grid-column: 3; grid-row: 1; }
  .agenda-toolbar h2 { grid-column: 1 / 3; grid-row: 2; text-align: left; }
  .calendar-legend { grid-column: 3; grid-row: 2; }
  .slot-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .settings-columns { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 252px; box-shadow: 14px 0 40px rgba(0, 0, 0, 0.18); transition: transform 240ms var(--ease-out); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; display: block; border: 0; background: rgba(20, 20, 20, 0.35); opacity: 0; pointer-events: none; transition: opacity 180ms ease; }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .mobile-menu { display: inline-flex !important; }
  .topbar-brand { display: block; width: 140px; }
  .breadcrumb { display: none; }
  .topbar { padding-inline: 16px; }
  .content-area { padding: 22px 18px 48px; }
  .availability-editor { width: 100%; grid-template-columns: minmax(0, 1fr); }
  .schedule-editor { width: 100%; max-width: 100%; overflow: hidden; }
  .editor-sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .editor-sidebar-head { display: none; }
  .day-list { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: inline proximity; }
  .day-list::-webkit-scrollbar { display: none; }
  .day-button { min-width: 130px; scroll-snap-align: start; }
  .theme-options { grid-template-columns: 1fr; }
  .theme-options span { min-height: 82px; }
}

@media (max-width: 640px) {
  .breadcrumb span, .breadcrumb svg { display: none; }
  .page-header { align-items: stretch; flex-direction: column; margin-bottom: 18px; }
  .page-header h1 { font-size: 24px; }
  .page-header .button-primary { align-self: flex-start; }
  .metric-grid { grid-template-columns: 1fr; gap: 8px; }
  .metric-card { grid-template-columns: 34px minmax(0, 1fr); padding: 13px; }
  .metric-icon { width: 34px; height: 34px; }
  .metric-card strong { font-size: 21px; }
  .dashboard-side { grid-template-columns: 1fr; }
  .today-panel, .compact-panel { padding: 14px; }
  .availability-overview { gap: 4px; }
  .agenda-toolbar { grid-template-columns: 1fr auto; }
  .view-tabs { grid-column: 1 / -1; }
  .agenda-toolbar h2 { grid-column: 1 / -1; grid-row: 2; }
  .week-navigation { grid-column: 1; grid-row: 3; }
  .calendar-legend { grid-column: 1 / -1; grid-row: 4; justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
  .slot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px; }
  .editor-head { padding: 16px 14px; }
  .editor-footer { align-items: stretch; flex-direction: column; padding: 12px 14px; }
  .editor-footer > div { display: grid; grid-template-columns: 1fr 1fr; }
  .editor-footer .button-primary { grid-column: 1 / -1; }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { min-width: 0; max-width: none; }
  .patient-table th:nth-child(2), .patient-table td:nth-child(2), .patient-table th:nth-child(3), .patient-table td:nth-child(3) { display: none; }
  .settings-grid { gap: 8px; }
  .setting-card { grid-template-columns: 38px minmax(0, 1fr) auto; padding: 13px; }
  .setting-icon { width: 38px; height: 38px; }
  .finance-metrics { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .dialog form { padding: 16px; }
  .toast-region { right: 12px; bottom: 12px; left: 12px; }
  .toast { width: 100%; min-width: 0; max-width: none; }
}

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