.finance-stats { display:grid; grid-template-columns:repeat(5,1fr); gap:14px; margin-bottom:18px;}
.finance-stats article { padding:19px 20px; border:1px solid var(--line); border-radius:16px; background:white; box-shadow:var(--shadow-sm);}
.finance-stats span,.finance-stats small { display:block; color:var(--muted);}.finance-stats span { font-size:14px; font-weight:700;}.finance-stats strong { display:block; margin:10px 0 3px; color:var(--brand-navy); font-size:25px;}.finance-stats small { font-size:14px;}
.finance-layout { display:grid; grid-template-columns:minmax(0,1fr) 300px; gap:18px;}.finance-search { margin:12px 0; padding:11px 14px; border:1px solid var(--line); border-radius:10px; background:#fafcfe;}.finance-search input { width:100%; border:0; outline:0; color:var(--ink); background:transparent;}
.finance-filters { display:flex; gap:10px; margin-bottom:14px;}.finance-filters label { flex:1; color:#4b607d; font-size:14px; font-weight:700;}.finance-filters select { display:block; width:100%; margin-top:5px; padding:9px; border:1px solid var(--line); border-radius:8px; background:white; color:var(--ink);}
.finance-plan { display:grid; grid-template-columns:minmax(190px,1.4fr) minmax(130px,.8fr) minmax(180px,1fr) auto; gap:15px; align-items:center; padding:15px 5px; border-top:1px solid var(--line);}.finance-plan:first-child { border-top:0;}.finance-plan h3 { margin:0 0 4px; color:#2c4262; font-size:14px;}.finance-plan p { margin:0; color:var(--muted); font-size:14px;}.balance-bar { height:5px; margin-top:7px; overflow:hidden; border-radius:5px; background:#e7edf3;}.balance-bar span { display:block; height:100%; border-radius:5px; background:linear-gradient(90deg,var(--primary),var(--brand-navy));}.financial-badge,.plan-status { display:inline-flex; width:max-content; padding:5px 8px; border-radius:20px; font-size:11px; font-weight:900; text-transform:uppercase;}.financial-badge.pendiente { color:#9b5d17; background:#fff2dc;}.financial-badge.parcial { color:#1b6f9a; background:#e5f5fc;}.financial-badge.pagado { color:#18785f; background:#e3f7f0;}.plan-status { margin-top:6px; color:#576880; background:#edf2f7;}.finance-plan>div:last-child { display:flex; flex-direction:column; align-items:flex-end; gap:8px;}.finance-actions { display:flex; gap:6px;}.finance-actions button { border:0; border-radius:8px; padding:8px 10px; color:var(--brand-navy); background:#edf5fb; font-size:14px; font-weight:800; white-space:nowrap;}.finance-actions button.pay { color:white; background:linear-gradient(120deg,var(--brand-navy),#3479bb);}
.cash-panel { padding:22px; border:1px solid var(--line); border-radius:17px; background:white; box-shadow:var(--shadow-sm);}.cash-panel h2 { margin:5px 0 0; font-size:18px;}.cash-panel-heading { display:flex; flex-direction:column; gap:12px; margin-bottom:6px;}.cash-panel-controls { display:flex; gap:7px;}.cash-panel-controls select,.cash-panel-controls input#cash-date { flex:1; min-width:0; padding:8px; border:1px solid var(--line); border-radius:8px; background:white; color:var(--ink); font-size:14px; font-family:inherit;}.cash-panel-controls input#cash-date::-webkit-inner-spin-button,.cash-panel-controls input#cash-date::-webkit-outer-spin-button { -webkit-appearance:none; margin:0;}.cash-panel-controls input#cash-date { -moz-appearance:textfield;}.cash-range-label { margin:0 0 16px; color:var(--muted); font-size:14px;}.cash-method { display:flex; justify-content:space-between; align-items:center; padding:12px 0; border-top:1px solid var(--line);}.cash-method:first-child { border-top:0;}.cash-method span { color:var(--muted); font-size:14px; text-transform:capitalize;}.cash-method strong { color:#2d4567; font-size:14px;}.cash-total { display:flex; justify-content:space-between; margin-top:17px; padding:15px; border-radius:11px; color:white; background:linear-gradient(120deg,var(--brand-navy),var(--primary));}.cash-total span { font-size:14px;}.cash-total strong { font-size:16px;}
.cash-day-heading { display:flex; justify-content:space-between; align-items:center; margin:22px 0 10px;}.cash-day-heading h3 { margin:0; color:#2e4767; font-size:14px;}.cash-day-heading button { padding:6px 9px; font-size:14px;}
#cash-day-payments { display:grid; gap:8px; max-height:340px; overflow-y:auto;}
.cash-day-row { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px; border:1px solid var(--line); border-radius:10px;}.cash-day-row>div:first-child strong,.cash-day-row>div:first-child small { display:block;}.cash-day-row>div:first-child strong { font-size:14px; color:#2c4262;}.cash-day-row>div:first-child small { margin-top:2px; color:var(--muted); font-size:14px;}.cash-day-row>div:nth-child(2) { text-align:right;}.cash-day-row>div:nth-child(2) span { display:block; color:var(--muted); font-size:14px; text-transform:capitalize;}.cash-day-row>div:nth-child(2) strong { color:#2d4567; font-size:14px;}.cash-day-actions { display:flex; gap:5px;}
.wide-dialog { width:min(850px,calc(100% - 30px));}.items-heading { display:flex; justify-content:space-between; align-items:center; margin:20px 0 10px;}.items-heading strong,.items-heading small { display:block;}.items-heading strong { color:#344d6c; font-size:14px;}.items-heading small { margin-top:3px; color:var(--muted); font-size:14px;}.plan-item { display:grid; grid-template-columns:minmax(180px,1fr) 80px 125px 34px; gap:8px; margin-bottom:8px;}.plan-item input { width:100%; padding:9px; border:1px solid #dce5ee; border-radius:9px; background:#fbfcfe;}.remove-plan-item { border:0; border-radius:8px; color:#aa3540; background:#fff0f1; font-weight:900;}.standalone-label { display:block; margin-top:15px; color:#4b607d; font-size:14px; font-weight:700;}.standalone-label textarea { width:100%; margin-top:7px; padding:10px; border:1px solid #dce5ee; border-radius:10px;}.plan-calculation { display:flex; justify-content:flex-end; align-items:center; gap:16px; margin-top:15px; padding:13px 15px; border-radius:10px; color:#49617d; background:#f0f7fb;}.plan-calculation strong { color:var(--brand-navy); font-size:20px;}.payment-plan-summary { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:18px 0 4px; padding:15px; border-radius:11px; background:#eef7fb;}.payment-plan-summary span,.payment-plan-summary strong { display:block;}.payment-plan-summary span { color:var(--muted); font-size:14px; text-transform:uppercase;}.payment-plan-summary strong { margin-top:4px; color:#294b72; font-size:14px;}
.detail-shell { padding:25px;}.detail-hero { display:flex; justify-content:space-between; gap:20px; margin:20px 0; padding:18px; border-radius:13px; color:white; background:linear-gradient(120deg,var(--brand-navy),var(--primary));}.detail-hero h3 { margin:0 0 5px;}.detail-hero p { margin:0; color:#d6f1fb; font-size:14px;}.detail-amounts { display:flex; gap:24px; text-align:right;}.detail-amounts span,.detail-amounts strong { display:block;}.detail-amounts span { color:#ccecf8; font-size:11px; text-transform:uppercase;}.detail-amounts strong { margin-top:4px; font-size:16px;}.detail-toolbar { display:flex; justify-content:space-between; gap:10px; align-items:center; margin-bottom:16px;}.detail-toolbar select { padding:8px; border:1px solid var(--line); border-radius:8px;}.detail-toolbar div { display:flex; gap:7px;}.payments-heading { margin:23px 0 8px; color:#2e4767; font-size:15px;}.voided-payment { opacity:.55; text-decoration:line-through;}.receipt-button,.void-button { border:0; border-radius:7px; padding:6px 8px; font-size:11px; font-weight:800;}.receipt-button { color:#305080; background:#eaf4fa;}.void-button { color:#9d3039; background:#fff0f1;}
html[data-theme="dark"] .finance-stats article,html[data-theme="dark"] .cash-panel { border-color:#263a57; background:#101f35;}.finance-stats strong { color:var(--brand-navy);} html[data-theme="dark"] .finance-stats strong,html[data-theme="dark"] .finance-plan h3,html[data-theme="dark"] .cash-method strong,html[data-theme="dark"] .items-heading strong,html[data-theme="dark"] .payments-heading { color:#dce8f6;} html[data-theme="dark"] .finance-search,html[data-theme="dark"] .plan-item input,html[data-theme="dark"] .standalone-label textarea { color:#e0eaf6; border-color:#344963; background:#0d1b30;} html[data-theme="dark"] .cash-method,html[data-theme="dark"] .finance-plan{ border-color:#293d57;} html[data-theme="dark"] .balance-bar { background:#263a52;} html[data-theme="dark"] .plan-status { color:#aebed0; background:#273a51;} html[data-theme="dark"] .payment-plan-summary,html[data-theme="dark"] .plan-calculation { background:#162d46;} html[data-theme="dark"] .payment-plan-summary strong,html[data-theme="dark"] .plan-calculation strong { color:#8bdcf3;} html[data-theme="dark"] .standalone-label { color:#b8c7d9;} html[data-theme="dark"] .detail-toolbar select { color:#dce8f4; background:#13243a;} html[data-theme="dark"] .receipt-button { color:#8bdcf3; background:#1b3a55;} html[data-theme="dark"] .void-button,html[data-theme="dark"] .remove-plan-item { color:#ffaaa5; background:#43282e;}
html[data-theme="dark"] .finance-filters label { color:#b8c7d9;} html[data-theme="dark"] .finance-filters select,html[data-theme="dark"] .cash-panel-controls select,html[data-theme="dark"] .cash-panel-controls input#cash-date { color:#e0eaf6; border-color:#344963; background:#0d1b30; color-scheme:dark;}
html[data-theme="dark"] .cash-range-label { color:#a9b8ca;}
html[data-theme="dark"] .cash-day-heading h3 { color:#dce8f6;} html[data-theme="dark"] .cash-day-row { border-color:#293d57;} html[data-theme="dark"] .cash-day-row>div:first-child strong,html[data-theme="dark"] .cash-day-row>div:nth-child(2) strong { color:#dce8f6;} html[data-theme="dark"] .cash-day-row>div:first-child small,html[data-theme="dark"] .cash-day-row>div:nth-child(2) span { color:#a9b8ca;}
@media(max-width:1000px){.finance-stats{}}
@media(max-width:1350px){.finance-layout{}.cash-panel{}.cash-panel #cash-methods{display:grid;grid-template-columns:repeat(4,1fr);}.cash-method{}}
@media(max-width:1024px){.finance-plan{grid-template-columns:1fr auto;}.finance-plan>div:nth-child(2),.finance-plan>div:nth-child(3){}}
@media(max-width:760px){.finance-stats{}.finance-plan{}.finance-plan>div:nth-child(2),.finance-plan>div:nth-child(3){}.plan-item{}.detail-hero{}.detail-amounts{margin-top:15px;}.cash-panel #cash-methods{}.finance-filters{}.finance-filters label{}.cash-panel-heading{}.cash-panel-controls{}.cash-panel-controls select,.cash-panel-controls input#cash-date{flex:1;}.cash-day-row{}.cash-day-row>div:nth-child(2){}}

/* Finance text is read frequently; avoid tiny dashboard labels. */
.finance-stats span { font-size:14px;}.finance-stats small { font-size:14px;}
.finance-plan h3 { font-size:15px;}.finance-plan p { font-size:14px;}
.financial-badge,.plan-status { font-size:14px;}
.finance-actions button { font-size:14px;}
.cash-method span,.cash-method strong { font-size:14px;}.cash-total span { font-size:14px;}.cash-total strong { font-size:17px;}
.items-heading strong { font-size:14px;}.items-heading small { font-size:14px;}
.plan-item input,.standalone-label textarea { font-size:14px;}
.payment-plan-summary span { font-size:14px;}.payment-plan-summary strong { font-size:15px;}
.detail-hero p { font-size:14px;}.detail-amounts span { font-size:14px;}.detail-amounts strong { font-size:17px;}
.receipt-button,.void-button { font-size:14px;}
.finance-filters label { font-size:14px;}.finance-filters select { font-size:14px;}
.cash-day-row>div:first-child strong { font-size:14px;}.cash-day-row>div:first-child small { font-size:14px;}.cash-day-row>div:nth-child(2) span { font-size:14px;}.cash-day-row>div:nth-child(2) strong { font-size:14px;}.cash-day-heading h3 { font-size:15px;}.cash-day-actions button { font-size:14px;}
html[data-theme="dark"] .finance-stats span,html[data-theme="dark"] .finance-stats small,html[data-theme="dark"] .finance-plan p,html[data-theme="dark"] .cash-method span { color:#a9b8ca;}

@media(max-width:760px){
  .finance-layout{}
  .cash-panel{margin-bottom:13px;padding:16px;}
  .cash-panel #cash-methods{}
  .cash-method{padding:10px 0;}
  .finance-stats{}
  .finance-plan{}
  .finance-actions{}
  .finance-actions button{width:100%;}
  .financial-badge,.plan-status{}
  .plan-item input{}
  .payment-plan-summary{}
  .detail-amounts{display:grid;grid-template-columns:1fr;gap:10px;}}

/* Concrete payment concepts */
.payment-plan-summary { grid-template-columns:repeat(3,minmax(0,1fr));}
.payment-summary-wide { grid-column:1 / -1;}
.payment-concept-line { color:var(--text-secondary,var(--muted)); font-weight:700;}html[data-theme="dark"] .payment-concept-line { color:#b8c7d8;}
@media(max-width:760px){ .payment-plan-summary { grid-template-columns:1fr;} .payment-summary-wide { grid-column:auto;}}


/* Pago por procedimiento v41 */
.plan-item { grid-template-columns:minmax(170px,1fr) 145px 72px 120px 34px;}
.payment-procedure-list { display:grid; gap:8px; margin-top:8px;}
.payment-procedure-option { display:grid; grid-template-columns:22px minmax(0,1fr) auto; gap:10px; align-items:center; padding:10px 12px; border:1px solid var(--line); border-radius:11px; color:var(--text-primary,var(--ink)); background:var(--surface-soft); cursor:pointer;}
.payment-procedure-option:hover { border-color:var(--focus-ring,var(--primary)); background:var(--surface);}
.payment-procedure-option input { width:auto; margin:0; accent-color:var(--primary);}
.payment-procedure-copy { display:grid; gap:2px; min-width:0;}
.payment-procedure-copy strong { overflow-wrap:anywhere;}
.payment-procedure-copy small { color:var(--text-secondary,var(--muted)); font-size:14px;}
.payment-procedure-balance { color:var(--primary); font-size:14px; font-weight:850; white-space:nowrap;}
.payment-procedure-option.is-paid { opacity:.66; cursor:default;}
.payment-procedure-option.is-paid .payment-procedure-balance { color:var(--text-secondary,var(--muted));}
.payment-general-option { display:flex !important; align-items:flex-start; flex-wrap:wrap; gap:8px; padding:10px 12px; border:1px dashed var(--line); border-radius:11px; color:var(--text-primary,var(--ink)) !important; background:transparent;}
.payment-general-option input { width:auto !important; margin:3px 0 0 !important; accent-color:var(--primary);}
.payment-general-option .field-hint { flex-basis:100%; margin-left:25px;}
html[data-theme="dark"] .payment-procedure-option { border-color:var(--border-strong); background:var(--surface-soft);}
html[data-theme="dark"] .payment-procedure-option:hover { background:var(--surface);}
html[data-theme="dark"] .payment-procedure-balance { color:var(--link);}
html[data-theme="dark"] .payment-general-option { border-color:var(--border-strong);}
@media (max-width:760px) {
  .plan-item { grid-template-columns:1fr 1fr;}
  .plan-item [data-field="description"] { grid-column:1 / -1;}
  .plan-item [data-field="procedureDate"] { grid-column:1 / -1;}
  .plan-item [data-field="quantity"], .plan-item [data-field="unitPrice"] { min-width:0;}
  .plan-item .remove-plan-item { grid-column:1 / -1; min-height:38px;}
  .payment-procedure-option { grid-template-columns:22px minmax(0,1fr);}
  .payment-procedure-balance { grid-column:2;}
  .payment-general-option .field-hint { margin-left:0;}}
.delete-procedure { min-height:44px; margin-top:8px; white-space:normal;}
.leave-summary { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-bottom:18px; }.leave-summary article { padding:20px; border:1px solid var(--line); border-radius:16px; background:white; box-shadow:var(--shadow-sm); }.leave-summary span { display:block; color:var(--muted); font-size:14px; font-weight:700; }.leave-summary strong { display:block; margin-top:10px; color:var(--brand-navy); font-size:28px; }
.leave-search { margin:12px 0; padding:12px 15px; border:1px solid var(--line); border-radius:10px; background:#fafcfe; }.leave-search input { width:100%; border:0; outline:0; color:var(--ink); background:transparent; }
.leave-row { display:grid; grid-template-columns:minmax(190px,1.3fr) minmax(150px,1fr) minmax(150px,.9fr) 105px auto; gap:14px; align-items:center; padding:15px 6px; border-top:1px solid var(--line); }.leave-row:first-child { border-top:0; }.leave-row h3 { margin:0 0 4px; color:#2d4565; font-size:14px; }.leave-row p,.leave-row small { display:block; margin:0; color:var(--muted); font-size:14px; }.leave-row strong { display:block; color:#344d6d; font-size:14px; }.leave-status { display:inline-flex; width:max-content; padding:6px 9px; border-radius:20px; color:#16765d; background:#e4f7f0; font-size:14px; font-weight:900; text-transform:uppercase; }.leave-status.anulada { color:#a92d37; background:#ffeded; }.leave-actions { display:flex; gap:6px; }.leave-actions button { border:0; border-radius:8px; padding:8px 10px; color:var(--brand-navy); background:#eaf4fa; font-size:14px; font-weight:800; }.leave-actions .void-leave { color:#a02e38; background:#fff0f1; }
.leave-form-note { margin:17px 0 4px; padding:11px 13px; border:1px solid #cce8f3; border-radius:9px; color:#42677f; background:#eef9fd; font-size:14px; }.leave-days-preview { display:flex; justify-content:flex-end; align-items:center; gap:14px; margin-top:14px; padding:12px 14px; border-radius:10px; color:#536b84; background:#eff7fb; }.leave-days-preview span { font-size:14px; }.leave-days-preview strong { color:var(--brand-navy); font-size:17px; }
html[data-theme="dark"] .leave-summary article { border-color:#263a57; background:#101f35; } html[data-theme="dark"] .leave-summary strong,html[data-theme="dark"] .leave-row h3,html[data-theme="dark"] .leave-row strong { color:#dce8f6; } html[data-theme="dark"] .leave-search { border-color:#344963; background:#0d1b30; } html[data-theme="dark"] .leave-row { border-color:#293d57; } html[data-theme="dark"] .leave-row p,html[data-theme="dark"] .leave-row small { color:#a9b8ca; } html[data-theme="dark"] .leave-status { color:#7de1c2; background:#163c3a; } html[data-theme="dark"] .leave-status.anulada { color:#ffaaa5; background:#4a282c; } html[data-theme="dark"] .leave-actions button { color:#8bdcf3; background:#1b3a55; } html[data-theme="dark"] .leave-actions .void-leave { color:#ffaaa5; background:#43282e; } html[data-theme="dark"] .leave-form-note { color:#a7d9ec; border-color:#29516b; background:#112c43; } html[data-theme="dark"] .leave-days-preview { color:#b0c0d1; background:#162d46; } html[data-theme="dark"] .leave-days-preview strong { color:#8bdcf3; }
@media(max-width:900px){.leave-row{grid-template-columns:1fr 1fr}.leave-row>div:last-child{justify-self:end}}
@media(max-width:760px){.leave-summary{grid-template-columns:1fr}.leave-row{grid-template-columns:1fr auto}.leave-row>div:nth-child(2),.leave-row>div:nth-child(3){grid-column:1}.leave-actions{grid-column:2;grid-row:1/3;display:grid}}
.record-leave { display:grid; grid-template-columns:minmax(190px,1fr) minmax(170px,1fr) 100px auto; gap:14px; align-items:center; padding:16px 5px; border-top:1px solid var(--line); }.record-leave:first-child { border-top:0; }.record-leave h3 { margin:0 0 5px; color:#2d4565; font-size:14px; }.record-leave p,.record-leave small { display:block; margin:0; color:var(--muted); font-size:14px; }.record-leave strong { display:block; color:#344d6d; font-size:14px; }.record-leave-actions { display:flex; gap:6px; }.record-leave-actions button { border:0; border-radius:8px; padding:8px 10px; color:var(--brand-navy); background:#eaf4fa; font-size:14px; font-weight:800; }.record-leave-actions .void-leave { color:#a02e38; background:#fff0f1; }
html[data-theme="dark"] .record-leave { border-color:#293d57; } html[data-theme="dark"] .record-leave h3,html[data-theme="dark"] .record-leave strong { color:#dce8f6; } html[data-theme="dark"] .record-leave p,html[data-theme="dark"] .record-leave small { color:#a9b8ca; } html[data-theme="dark"] .record-leave-actions button { color:#8bdcf3; background:#1b3a55; } html[data-theme="dark"] .record-leave-actions .void-leave { color:#ffaaa5; background:#43282e; }
@media(max-width:760px){.record-leave{grid-template-columns:1fr auto}.record-leave>div:nth-child(2){grid-column:1}.record-leave-actions{grid-column:2;grid-row:1/3;display:grid}}
@media(max-width:760px){
  .leave-summary{grid-template-columns:1fr}
  .leave-row,.record-leave{grid-template-columns:1fr!important}
  .leave-actions,.record-leave-actions{grid-template-columns:1fr 1fr;width:100%}
  .leave-actions button,.record-leave-actions button{width:100%;min-height:40px}
  .leave-status{font-size:14px}
  .leave-form-note{font-size:14px;line-height:1.45}
  .leave-days-preview{justify-content:space-between}
}
/* Clínica Dental JH — Visual system v1
   Direction: precisión clínica cálida.
   The app is operational software: hierarchy, speed and legibility win over decoration.
*/
@media screen {
  :root {
    --surface: #ffffff;
    --surface-strong: #ffffff;
    --surface-soft: #f2f7fa;
    --field: #fbfdfe;
    --text-primary: #173550;
    --text-secondary: #526b82;
    --text-tertiary: #637b91;
    --border-strong: #c5d5df;
    --line: #d8e4eb;
    --focus-ring: #087ea9;
    --link: #0a668b;
    --navy: #102e50;
    --teal: #187f7a;
    --ink: var(--text-primary);
    --muted: var(--text-secondary);
    --white: var(--surface);
    --primary: #087ea9;
    --primary-dark: #076584;
    --brand-navy: #102e50;
    --brand-navy-dark: #0b223b;
    --brand-sky: #e3f4fa;
    --danger: #b33f48;
    --warning: #a76b26;
    --success: #177d61;
    --radius-md: 13px;
    --radius-lg: 18px;
    --shadow-sm: 0 5px 18px rgba(20, 56, 83, .055);
    --shadow-md: 0 14px 34px rgba(20, 56, 83, .105);
    --shadow-lg: 0 26px 70px rgba(11, 34, 59, .2);
    color-scheme: light;}

  html[data-theme='dark'] {
    --surface: #10243a;
    --surface-strong: #142c45;
    --surface-soft: #0b1b2c;
    --field: #0c1e31;
    --text-primary: #edf6fd;
    --text-secondary: #bbcede;
    --text-tertiary: #9db3c8;
    --border-strong: #3b5670;
    --line: #2d4762;
    --focus-ring: #73d8ef;
    --link: #8ddcf2;
    --navy: #071726;
    --teal: #55d0bd;
    --ink: var(--text-primary);
    --muted: var(--text-secondary);
    --white: var(--surface);
    --primary: #63c9e8;
    --primary-dark: #8cdef2;
    --brand-navy: #d0e8f7;
    --brand-navy-dark: #a9d7ee;
    --brand-sky: #173b56;
    --danger: #ff9ca3;
    --warning: #f1c378;
    --success: #78e0be;
    --shadow-sm: 0 5px 18px rgba(0, 0, 0, .18);
    --shadow-md: 0 16px 36px rgba(0, 0, 0, .24);
    --shadow-lg: 0 30px 80px rgba(0, 0, 0, .42);
    color-scheme: dark;}

  html,
  body {
    min-height: 100%;
    background: var(--surface-soft) !important;}

  body {
    margin: 0;
    color: var(--text-primary) !important;
    background-image: linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 82%, var(--primary) 18%), var(--surface-soft)) !important;
    font-family: 'DM Sans', Inter, 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: .002em;}

  body::before { display: none !important;}

  h1,
  h2,
  h3,
  h4,
  .user-chip strong,
  .finance-stats strong,
  .leave-summary strong {
    font-family: 'Manrope', Inter, 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    letter-spacing: -.025em;}

  h1,
  h2,
  h3,
  h4,
  p { margin-top: 0;}

  h1 { font-size: clamp(1.8rem, 2.3vw, 2.35rem); line-height: 1.1;}
  h2 { font-size: clamp(1.25rem, 1.7vw, 1.55rem); line-height: 1.2;}
  h3 { line-height: 1.25;}

  button,
  input,
  select,
  textarea { font: inherit;}

  button,
  [role='button'] { touch-action: manipulation;}

  button:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible,
  summary:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--focus-ring) 72%, transparent);
    outline-offset: 2px;}

  button:disabled { cursor: not-allowed; opacity: .58;}

  .sidebar {
    z-index: 80;
    width: 260px;
    padding: 25px 16px 20px;
    color: var(--text-primary);
    background: var(--surface) !important;
    border-right: 1px solid var(--border-strong);
    box-shadow: 8px 0 30px rgba(17, 53, 80, .045);}

  .brand {
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 0 8px 22px;
    border-bottom: 1px solid var(--line);}

  .brand-crop {
    width: 188px;
    height: 103px;
    overflow: hidden;
    border-radius: 15px;
    background: #fff;}

  .brand-crop img {
    position: static;
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    left: auto;
    top: auto;
    object-fit: cover;
    object-position: center;}

  .brand > small {
    color: var(--text-tertiary) !important;
    font-size:11px;
    font-weight: 800;
    letter-spacing: .17em;
    text-transform: uppercase;}

  nav { gap: 5px; margin-top: 18px;}

  .nav-label {
    margin: 16px 12px 8px;
    color: var(--text-tertiary) !important;
    font-size:11px;
    font-weight: 800;
    letter-spacing: .14em;}

  .nav-item {
    min-height: 45px;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: var(--text-secondary) !important;
    background: transparent;
    font-size: 14px;
    font-weight: 750;
    transition: color .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;}

  .nav-item:hover {
    color: var(--link) !important;
    background: var(--surface-soft) !important;
    border-color: color-mix(in srgb, var(--primary) 17%, var(--border-strong));
    transform: none !important;}

  .nav-item.active {
    color: #fff !important;
    background: var(--navy) !important;
    border-color: var(--navy);
    box-shadow: 0 8px 18px rgba(16, 46, 80, .2);}

  .nav-icon {
    width: 29px;
    height: 29px;
    border-radius: 9px;
    color: var(--link) !important;
    background: var(--brand-sky) !important;}

  .nav-item.active .nav-icon {
    color: #fff !important;
    background: rgba(255, 255, 255, .15) !important;}

  main {
    width: calc(100% - 260px);
    max-width: none !important;
    margin-left: 260px;
    padding: 28px clamp(20px, 3vw, 50px) 64px;}

  header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 22px;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);}

  header > div:not(.header-meta) { min-width: 0;}

  .eyebrow,
  .section-kicker,
  .welcome-kicker {
    color: var(--primary) !important;
    font-size:11px;
    font-weight: 850;
    letter-spacing: .13em;}

  .eyebrow { margin-bottom: 6px;}
  header h1 { margin-bottom: 0; color: var(--text-primary) !important;}
  .date { color: var(--text-secondary) !important; font-size:14px; white-space: nowrap;}

  .header-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    min-width: 0;
    padding: 6px;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 94%, transparent) !important;
    box-shadow: var(--shadow-sm);}

  .user-chip,
  .theme-toggle,
  .logout-button,
  .install-button {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-secondary) !important;
    background: transparent !important;
    transition: color .18s ease, background .18s ease, border-color .18s ease;}

  .user-chip { display: flex; gap: 9px; align-items: center; padding: 4px 9px 4px 5px;}
  .user-chip > span { width: 31px; height: 31px; border-radius: 9px; color: #fff; background: var(--primary); font-size: 11px;}
  .user-chip strong { color: var(--text-primary) !important; font-size:14px;}
  .user-chip small { color: var(--text-tertiary) !important; font-size: 11px;}
  .theme-toggle,
  .install-button,
  .logout-button { padding: 7px 10px; font-size:14px; font-weight: 750;}
  .theme-toggle:hover,
  .install-button:hover,
  .logout-button:hover { color: var(--link) !important; background: var(--brand-sky) !important; border-color: color-mix(in srgb, var(--primary) 28%, var(--border-strong));}
  .theme-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 3px; vertical-align: -4px;}
  .theme-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8;}

  .view.active { animation: view-in .22s ease-out both;}
  @keyframes view-in { from { opacity: .72; transform: translateY(4px);} to { opacity: 1; transform: none;}}

  .section-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    margin-bottom: 16px;
    padding: 18px 21px;
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius-lg);
    background: var(--surface) !important;
    box-shadow: var(--shadow-sm);}

  .section-actions h2 { margin-bottom: 4px; color: var(--text-primary) !important;}
  .section-actions p { margin-bottom: 0; color: var(--text-secondary) !important; font-size:14px;}
  .welcome-kicker { margin-bottom: 10px; color: #91ddef !important;}
  .welcome-actions { gap: 8px;}
  .welcome-actions button { min-height: 42px; padding: 9px 15px; border-radius: 10px; font-size:14px; font-weight: 800; transition: background .18s ease, color .18s ease, border-color .18s ease;}
  .welcome-primary { color: var(--navy); background: #fff; box-shadow: 0 7px 16px rgba(0,0,0,.12);}
  .welcome-primary:hover { background: #dff5fb; transform: none;}
  .welcome-secondary { color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.3) !important;}
  .welcome-secondary:hover { background: rgba(255,255,255,.18);}
  .welcome-mark { width: 118px; height: 118px; margin-right: 3%; border: 1px solid rgba(255,255,255,.32); background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 10px rgba(255,255,255,.035);}
  .birthday-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 13px 17px;
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    background: var(--surface) !important;
    box-shadow: var(--shadow-sm);}
  .birthday-card strong { color: var(--text-primary) !important; font-size:14px;}
  .birthday-card > div > span { color: var(--text-secondary) !important; font-size:14px;}
  .birthday-card { justify-content: flex-start; border-color: color-mix(in srgb, #d39a42 46%, var(--border-strong)) !important; background: color-mix(in srgb, var(--surface) 88%, #f2c66d 12%) !important;}
  .birthday-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--warning) !important; background: color-mix(in srgb, #f2c66d 22%, var(--surface)); font-size: 19px;}

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;}

  .stats article,
  .panel,
  .search,
  .doctor-card,
  .finance-stats article,
  .finance-mini-strip,
  .cash-panel,
  .leave-summary article,
  .role-grid article {
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius-lg);
    color: var(--text-primary) !important;
    background: var(--surface) !important;
    box-shadow: var(--shadow-sm);}

  .stats article { min-height: 139px; padding: 18px 19px; border-top: 3px solid var(--primary) !important; transition: box-shadow .18s ease, border-color .18s ease;}
  .stats article:nth-child(2) { border-top-color: #3974b6 !important;}
  .stats article:nth-child(3) { border-top-color: var(--teal) !important;}
  .stats article:hover { box-shadow: var(--shadow-md); transform: none;}
  .stat-icon { width: 34px; height: 34px; border-radius: 9px;}
  .stats strong { margin: 13px 0 1px; color: var(--text-primary) !important; font-size: 30px;}
  .stats article > span:last-child { color: var(--text-secondary) !important; font-size:14px;}

  .finance-mini-strip { gap: 12px; margin-bottom: 16px; padding: 14px 18px;}
  .finance-mini-item { gap: 10px;}
  .finance-mini-item strong { color: var(--text-primary) !important; font-size: 21px;}
  .finance-mini-item small { color: var(--text-secondary) !important; font-size:14px;}
  .finance-mini-divider { height: 35px; margin: 0 11px; background: var(--line);}

  .dashboard-grid { grid-template-columns: minmax(0, 1fr) 270px; gap: 14px;}
  .panel { padding: 20px;}
  .panel-heading { margin-bottom: 13px;}
  .panel-heading h2 { margin: 3px 0 3px; color: var(--text-primary) !important; font-size: 19px;}
  .panel-heading p { margin-bottom: 0; color: var(--text-secondary) !important; font-size:14px;}

  .primary,
  .secondary,
  .record-button,
  .finance-actions button,
  .leave-actions button,
  .record-leave-actions button,
  .receipt-button,
  .void-button,
  .google-button {
    min-height: 40px;
    border-radius: 9px;
    font-size:14px;
    font-weight: 800;
    transition: color .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;}

  .primary { padding: 8px 14px; color: #fff !important; background: var(--primary) !important; box-shadow: 0 6px 14px rgba(8,126,169,.16);}
  .primary:hover { background: var(--primary-dark) !important; box-shadow: 0 8px 18px rgba(8,126,169,.22);}
  .secondary { padding: 8px 13px; color: var(--text-primary) !important; border: 1px solid var(--border-strong); background: var(--surface-soft) !important;}
  .secondary:hover { color: var(--link) !important; border-color: var(--focus-ring); background: var(--brand-sky) !important;}
  .record-button,
  .finance-actions button,
  .leave-actions button,
  .record-leave-actions button,
  .receipt-button { padding: 7px 10px; color: var(--link) !important; background: var(--brand-sky) !important;}
  .record-button:hover,
  .finance-actions button:hover,
  .leave-actions button:hover,
  .record-leave-actions button:hover,
  .receipt-button:hover { background: color-mix(in srgb, var(--brand-sky) 70%, var(--primary) 30%) !important;}
  .record-button.danger,
  .void-button { color: var(--danger) !important; background: color-mix(in srgb, var(--surface) 85%, #ed8a91 15%) !important;}

  .search { padding: 13px 15px;}
  .search:focus-within,
  .finance-search:focus-within,
  .leave-search:focus-within { border-color: var(--focus-ring) !important; box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus-ring) 12%, transparent);}
  .search input,
  .finance-search input,
  .leave-search input { color: var(--text-primary) !important;}
  input::placeholder,
  textarea::placeholder { color: var(--text-tertiary); opacity: 1;}
  .empty { padding: 32px 18px; color: var(--text-secondary) !important;}

  .list-row,
  .appointment-row,
  .finance-plan,
  .leave-row,
  .record-leave,
  .user-row {
    border-color: var(--line) !important;
    color: var(--text-primary) !important;
    background: var(--surface) !important;}

  .list-row { grid-template-columns: minmax(190px, 1.45fr) minmax(115px, .8fr) minmax(125px, .85fr) 120px auto; min-height: 68px; padding: 12px 6px;}
  .list-row:hover,
  .appointment-row:hover,
  .finance-plan:hover,
  .leave-row:hover,
  .record-leave:hover { background: var(--surface-soft) !important; box-shadow: none; transform: none;}
  .list-row strong,
  .finance-plan h3,
  .leave-row h3,
  .record-leave h3 { color: var(--text-primary) !important; font-size:14px;}
  .list-row small,
  .finance-plan p,
  .leave-row p,
  .leave-row small,
  .record-leave p,
  .record-leave small { color: var(--text-secondary) !important; font-size:14px;}
  .avatar span { color: var(--link) !important; background: var(--brand-sky) !important; box-shadow: none;}
  .patient-row-actions { gap: 5px;}

  .appointment-row { grid-template-columns: var(--clinic-time-track) minmax(220px, 1fr) 130px auto; min-height: 69px; margin-bottom: 8px; padding: 11px 13px; border-left: 4px solid var(--doctor-color, var(--primary)) !important; border-radius: 12px; box-shadow: 0 3px 11px rgba(17,53,80,.045);}
  .appt-time-block strong { color: var(--text-primary) !important; font-variant-numeric: tabular-nums;}
  .appt-time-date { color: var(--text-tertiary) !important; font-size:11px;}
  .appt-main { gap: 10px;}
  .appt-main strong { color: var(--text-primary) !important; font-size:14px;}
  .appt-main small { color: var(--text-secondary) !important; font-size:14px;}
  .doctor-agenda-label { display: inline-flex; gap: 6px; color: var(--text-secondary) !important; font-size: 11px;}
  .doctor-agenda-label i { width: 8px; height: 8px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--doctor-color, var(--teal)) 16%, transparent);}
  .today-badge { color: var(--success) !important; background: #e3f5ee !important;}
  .appointment-status-select { min-height: 34px; border-color: transparent !important; font-size: 11px;}
  .appointment-menu summary { width: 37px; height: 37px; color: var(--text-secondary); border-color: var(--line); background: var(--surface) !important; box-shadow: none;}
  .appointment-menu summary:hover,
  .appointment-menu[open] summary { color: var(--link); border-color: var(--focus-ring); background: var(--brand-sky) !important;}
  .appointment-menu-popover { background: var(--surface) !important; border-color: var(--border-strong); box-shadow: var(--shadow-lg);}
  .appointment-menu-popover button { min-height: 38px; color: var(--text-primary) !important;}
  .appointment-menu-popover button:hover { color: var(--link) !important; background: var(--surface-soft) !important;}

  .doctor-grid { gap: 13px; grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));}
  .doctor-card { padding: 19px; border-top: 4px solid var(--doctor-color, var(--primary)) !important;}
  .doctor-card:hover { box-shadow: var(--shadow-md); transform: none;}
  .doctor-card h3 { color: var(--text-primary) !important;}
  .doctor-card p,
  .doctor-contact,
  .calendar-status { color: var(--text-secondary) !important;}
  .doctor-contact { border-color: var(--line);}
  .google-button { border-color: var(--border-strong); color: var(--link); background: var(--surface) !important;}

  .agenda-heading { padding: 19px 21px;}
  .appointment-filters { display: grid; grid-template-columns: minmax(0, 1fr) 194px auto; align-items: end; gap: 11px; padding: 12px 14px;}
  .appointment-filters label { display: grid; gap: 5px; min-width: 0; color: var(--text-secondary); font-size: 11px; font-weight: 800;}
  .appointment-filters label > span { color: var(--text-secondary);}
  .appointment-filters input[type='search'],
  .appointment-filters input[type='date'] { width: 100%; min-width: 0; height: 40px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 9px; color: var(--text-primary); background: var(--field);}
  .appointment-filters small { color: var(--text-tertiary); font-size:11px; font-weight: 600;}
  .agenda-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 13px 0; padding: 8px; border: 1px solid var(--border-strong); border-radius: 13px; background: var(--surface) !important; box-shadow: var(--shadow-sm);}
  .agenda-view-switch { gap: 3px; padding: 3px; border-radius: 10px; background: var(--surface-soft);}
  .agenda-view-switch button { min-height: 37px; padding: 7px 13px; border: 0; border-radius: 8px; color: var(--text-secondary); background: transparent; font-size:14px; font-weight: 800;}
  .agenda-view-switch button:hover { color: var(--link); background: var(--brand-sky);}
  .agenda-view-switch button.active { color: #fff; background: var(--navy); box-shadow: 0 4px 10px rgba(16,46,80,.15);}
  .agenda-navigation { gap: 5px;}
  .agenda-navigation .icon-button,
  .agenda-mini-navigation .icon-button { min-width: 39px; min-height: 39px; padding: 0; border: 1px solid var(--border-strong); border-radius: 9px;}
  .agenda-navigation strong { min-width: 188px; padding: 7px 10px; border: 0; color: var(--text-primary) !important; background: var(--surface-soft); font-size:14px;}
  .agenda-navigation .today-button { color: var(--link) !important; border-color: color-mix(in srgb, var(--primary) 36%, var(--border-strong)); background: var(--surface);}
  .agenda-summary-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 13px;}
  .agenda-summary-strip article { min-width: 0; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: 13px; background: var(--surface) !important; box-shadow: var(--shadow-sm);}
  .agenda-summary-strip article > span,
  .agenda-summary-strip article > small { display: block; color: var(--text-secondary); font-size: 11px;}
  .agenda-summary-strip article > span { font-weight: 800;}
  .agenda-summary-strip article > strong { display: block; margin: 5px 0 1px; color: var(--text-primary); font-family: 'Manrope', sans-serif; font-size: 23px; font-variant-numeric: tabular-nums;}
  .agenda-workspace { display: grid; grid-template-columns: minmax(190px, 220px) minmax(0, 1fr); gap: 14px; align-items: start;}
  .agenda-sidebar { position: sticky; top: 18px; min-width: 0; padding: 16px; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface) !important; box-shadow: var(--shadow-sm);}
  .agenda-sidebar-heading { margin-bottom: 13px;}
  .agenda-sidebar-heading strong { color: var(--text-primary) !important; font-family: 'Manrope', sans-serif; font-size: 16px;}
  .agenda-mini-navigation { gap: 4px;}
  .agenda-mini-navigation .icon-button { min-width: 32px; min-height: 32px; border: 0; color: var(--text-secondary); background: var(--surface-soft);}
  .agenda-mini-weekdays span { color: var(--text-tertiary); font-size:11px;}
  .agenda-mini-day { min-height: 31px; border-radius: 8px; color: var(--text-secondary);}
  .agenda-mini-day:hover,
  .agenda-mini-day:focus-visible { color: var(--link); background: var(--brand-sky); outline: none;}
  .agenda-mini-day.selected { color: #fff; background: var(--primary); box-shadow: 0 4px 10px rgba(8,126,169,.22);}
  .agenda-mini-day.selected .agenda-mini-number,
  .agenda-mini-day.selected.today .agenda-mini-number { color: #fff;}
  .agenda-mini-number { width: 25px; height: 25px;}
  .agenda-mini-count { color: var(--primary); font-size: 11px;}
  .agenda-mini-day.selected .agenda-mini-count { color: #fff;}
  .agenda-doctor-legend { margin-top: 18px; padding-top: 15px; border-color: var(--line);}
  .agenda-doctor-item { gap: 8px; padding: 8px 0; border-color: var(--line);}
  .agenda-doctor-swatch { width: 10px; height: 10px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--doctor-color, var(--teal)) 16%, transparent);}
  .agenda-doctor-item strong { color: var(--text-primary) !important; font-size:14px;}
  .agenda-doctor-item small { color: var(--text-secondary) !important; font-size:11px;}
  .agenda-selected-card { margin-top: 18px; padding-top: 15px; border-color: var(--line);}
  .agenda-selected-card > strong { color: var(--text-primary) !important; font-size:14px;}
  .agenda-day-preview { border-color: var(--line);}
  .agenda-day-preview time { color: var(--primary); font-size: 11px;}
  .agenda-day-preview strong { color: var(--text-primary) !important; font-size: 11px;}
  .agenda-day-preview small { color: var(--text-secondary) !important; font-size:11px;}
  .agenda-content { min-width: 0;}
  .calendar-panel { min-width: 0; padding: 14px; overflow: hidden;}
  .calendar-grid { min-width: 0; width: 100%;}
  .calendar-weekdays,
  .calendar-columns { grid-template-columns: repeat(7, minmax(0, 1fr));}
  .calendar-day-heading { min-width: 0; padding: 10px 7px; color: var(--text-secondary); background: var(--surface-soft);}
  .calendar-day-heading strong { color: var(--text-primary); font-size: 19px;}
  .calendar-day-heading small { color: var(--text-secondary); font-size:11px;}
  .calendar-day-heading.today strong,
  .calendar-day-heading.selected strong { color: var(--primary);}
  .calendar-day { min-width: 0; min-height: 310px; padding: 7px; border-color: var(--line); background: color-mix(in srgb, var(--surface) 93%, var(--primary) 7%) !important;}
  .calendar-day:nth-child(even) { background: var(--surface) !important;}
  .calendar-events-list { max-height: 650px; padding-right: 2px;}
  .calendar-event { min-width: 0; margin-bottom: 7px; border: 1px solid var(--line); border-left: 4px solid var(--event-color, var(--teal)) !important; border-radius: 9px; background: var(--surface-strong) !important; box-shadow: 0 3px 9px rgba(17,53,80,.06);}
  .calendar-event-main { min-width: 0; gap: 3px; padding: 8px; color: var(--text-primary) !important;}
  .calendar-event-time { color: var(--event-color, var(--teal)); font-size: 11px; font-weight: 900; font-variant-numeric: tabular-nums;}
  .calendar-event-patient { display: block; overflow: hidden; color: var(--text-primary) !important; font-size:14px; font-weight: 850; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap;}
  .calendar-event-reason { display: block; overflow: hidden; color: var(--text-secondary) !important; font-size:11px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap;}
  .calendar-event-edit { min-width: 32px; min-height: 32px; color: var(--text-secondary);}
  .calendar-event-edit:hover { color: var(--link); background: var(--brand-sky);}
  .calendar-empty { padding: 13px 4px; color: var(--text-tertiary) !important; font-size: 11px;}
  .calendar-more { min-height: 40px; border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); color: var(--link); background: var(--brand-sky); font-size:11px;}
  .calendar-month-layout { grid-template-columns: minmax(0, 1.8fr) minmax(275px, .7fr); gap: 14px;}
  .calendar-month-grid { min-width: 0; border-color: var(--border-strong); border-radius: 15px;}
  .calendar-month-heading { padding: 11px 6px; color: var(--text-secondary); background: var(--surface-soft); font-size:11px;}
  .calendar-month-day { min-width: 0; min-height: 143px; padding: 7px; border-color: var(--line); background: var(--surface) !important;}
  .calendar-month-day.outside-month { opacity: .46; background: var(--surface-soft) !important;}
  .calendar-month-day.today { box-shadow: inset 0 3px 0 var(--primary);}
  .calendar-month-day.selected { background: color-mix(in srgb, var(--surface) 88%, var(--primary) 12%) !important; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 54%, transparent);}
  .calendar-month-date { margin-bottom: 6px; color: var(--text-secondary);}
  .calendar-month-date strong { width: 28px; height: 28px; color: var(--text-primary); font-size:14px;}
  .calendar-month-day.today .calendar-month-date strong,
  .calendar-month-day.selected .calendar-month-date strong { color: #fff; background: var(--primary);}
  .calendar-month-day .calendar-event { margin-bottom: 5px;}
  .calendar-month-day .calendar-event-main { padding: 6px;}
  .calendar-month-day .calendar-event-time { font-size:11px;}
  .calendar-month-day .calendar-event-patient { font-size:11px;}
  .calendar-month-day .calendar-event-reason { font-size:11px;}
  .calendar-month-day .calendar-event-edit { min-width: 25px; min-height: 25px; padding: 0; font-size: 11px;}
  .calendar-month-day.selected .calendar-month-count,
  .calendar-month-day.today .calendar-month-count { color: var(--text-secondary); }
  .calendar-selected-day { min-width: 0; padding: 17px; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface) !important; box-shadow: var(--shadow-sm);}
  .calendar-selected-heading { padding-bottom: 12px; border-color: var(--line);}
  .calendar-selected-heading h3 { margin: 0; color: var(--text-primary) !important; font-size: 17px; line-height: 1.25;}
  .calendar-selected-meta { color: var(--text-secondary); font-size: 11px;}
  .calendar-selected-day-list { gap: 8px; max-height: min(68vh, 650px); padding-top: 12px; overflow-y: auto;}
  .calendar-selected-appointment { grid-template-columns: var(--clinic-time-track) minmax(0, 1fr) 9px 28px; gap: 8px; padding: 9px 8px; border-color: var(--line); border-left: 4px solid var(--doctor-color, var(--teal)); border-radius: 10px; background: var(--surface-strong) !important; box-shadow: none;}
  .calendar-selected-time > strong { color: var(--primary); font-size:14px;}
  .calendar-selected-status { font-size: 11px;}
  .calendar-selected-patient { color: var(--text-primary) !important; font-size:14px;}
  .calendar-selected-reason { color: var(--text-secondary) !important; font-size:11px;}
  .calendar-selected-doctor-dot { width: 8px; height: 8px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--doctor-color, var(--teal)) 16%, transparent);}
  .calendar-selected-edit { width: 40px; min-height: 40px; color: var(--text-secondary); background: var(--surface-soft);}

  .doctor-status,
  .status,
  .financial-badge,
  .plan-status,
  .leave-status,
  .document-status,
  .user-status { border: 1px solid transparent; font-size: 11px; font-weight: 850;}
  .status,
  .doctor-status { color: var(--success) !important; background: #e3f5ee !important;}
  .status.cancelada,
  .leave-status.anulada,
  .document-status.anulada { color: var(--danger) !important; background: #fae8ea !important;}
  html[data-theme="dark"] .status.cancelada,
  html[data-theme="dark"] .leave-status.anulada,
  html[data-theme="dark"] .document-status.anulada { color:#ffaaa5 !important; background:#4a282c !important;}

  .record-header { min-height: 115px; margin-bottom: 16px; padding: 22px 25px; border-radius: 19px; color: #fff; background: var(--navy) !important; box-shadow: 0 17px 33px rgba(16,46,80,.18);}
  .record-header h2 { color: #fff !important;}
  .record-header p { color: #c7e4f2 !important; font-size:14px;}
  .record-header .avatar-large { background: rgba(255,255,255,.14);}
  .record-number-badge { display: inline-flex; margin-top: 7px; padding: 4px 8px; border: 1px solid rgba(255,255,255,.18); border-radius: 7px; color: #d7eef7; background: rgba(255,255,255,.08); font-size: 11px;}
  .record-tabs { gap: 3px; margin-bottom: 18px; border-color: var(--line);}
  .record-tab { padding: 10px 13px; border-radius: 9px 9px 0 0; color: var(--text-secondary); font-size:14px;}
  .record-tab:hover { color: var(--link); background: var(--brand-sky);}
  .record-tab.active { color: var(--link); border-bottom-color: var(--primary); background: var(--surface);}
  .record-tab-panel > .section-actions { box-shadow: none;}
  .timeline-card h3,
  .clinical-document-card h3,
  .record-treatment-plan-head h3 { color: var(--text-primary) !important;}
  .timeline-card p,
  .clinical-document-head p,
  .clinical-document-body p { color: var(--text-secondary) !important;}
  .clinical-alert,
  .clinical-alert-clear,
  .timeline-card,
  .clinical-document-card,
  .record-treatment-plan-card,
  .intake-check-grid fieldset,
  .intake-detail-grid fieldset,
  .odontogram-general-notes { border-color: var(--border-strong) !important; background: var(--surface) !important;}
  .timeline-marker { border-color: var(--surface);}
  .timeline-card,
  .clinical-document-card,
  .record-treatment-plan-card { border-radius: 14px; box-shadow: none;}
  .intake-form h3 { color: var(--link); font-size: 15px;}
  .intake-form h3:not(:first-child) { border-color: var(--line);}
  .clinical-chart-controls { margin: 12px 0;}
  .clinical-chart-controls button,
  .mode-button,
  .scope-button,
  .tooth-state { min-height: 40px; border-radius: 9px;}
  .clinical-chart-controls button { border-color: var(--border-strong); color: var(--text-secondary); background: var(--surface);}
  .clinical-chart-controls button.active,
  .mode-button.active,
  .scope-button.active { color: #fff; border-color: var(--primary); background: var(--primary);}
  .odontogram-panel { padding: 20px; border-radius: var(--radius-lg);}
  .temporary-row .tooth-unit:nth-child(5) { margin-right: 26px;}
  .temporary-row .tooth-unit:nth-child(8) { margin-right: 0;}
  .odontogram-tools { gap: 18px 25px; padding-bottom: 17px; border-color: var(--line);}
  .tool-label { color: var(--text-secondary); font-size:11px;}
  .tooth-state,
  .scope-button { padding: 8px 11px; color: var(--text-primary); border: 1px solid var(--border-strong); background: var(--surface-soft); font-size:14px;}
  .tooth-state:hover,
  .scope-button:hover { transform: none; box-shadow: none;}
  .tooth-state.active { color: var(--link); border-color: var(--primary); background: var(--brand-sky);}
  .odontogram-general-notes { padding: 13px;}
  .odontogram-lock-box span { color: var(--text-secondary); font-size: 11px;}
  .odontogram-lock-box button { min-height: 38px;}
  .tooth-status-mark { text-shadow: 0 1px 2px rgba(255,255,255,.72);}
  .record-treatment-plan-items { border-color: var(--line);}
  .record-treatment-plan-items li { color: var(--text-secondary);}
  .record-treatment-plan-items strong,
  .record-treatment-plan-summary strong { color: var(--text-primary);}

  .finance-stats { gap: 11px; margin-bottom: 14px;}
  .finance-stats article { padding: 15px 16px;}
  .finance-stats span,
  .finance-stats small { color: var(--text-secondary) !important;}
  .finance-stats strong { color: var(--text-primary) !important; font-size: 23px;}
  .finance-layout { grid-template-columns: minmax(0, 1fr) 285px; gap: 14px;}
  .finance-search,
  .leave-search { padding: 11px 13px; border-color: var(--border-strong); background: var(--field) !important;}
  .finance-filters { gap: 8px;}
  .finance-filters label,
  .cash-panel label { color: var(--text-secondary) !important;}
  .finance-filters select,
  .cash-panel-controls select,
  .cash-panel-controls input#cash-date,
  .detail-toolbar select { min-height: 40px; border-color: var(--border-strong); color: var(--text-primary); background: var(--field) !important;}
  .finance-plan { gap: 13px; padding: 13px 6px;}
  .cash-method strong,
  .cash-day-row strong { color: var(--text-primary) !important;}
  .cash-method span,
  .cash-day-row small,
  .cash-day-row span,
  .cash-range-label { color: var(--text-secondary) !important;}
  .balance-bar { background: var(--line);}
  .balance-bar span { background: var(--teal);}
  .cash-panel { padding: 18px;}
  .cash-total { background: var(--navy);}
  .cash-day-row { border-color: var(--line); background: var(--surface-soft);}
  .detail-hero { background: var(--navy);}
  .payment-plan-summary,
  .plan-calculation { border: 1px solid var(--border-strong); color: var(--text-primary); background: var(--surface-soft);}
  .payment-plan-summary span,
  .payment-plan-summary strong,
  .plan-calculation span { color: var(--text-secondary);}
  .payment-plan-summary strong,
  .plan-calculation strong { color: var(--text-primary);}
  .payment-procedure-option { border-color: var(--border-strong); color: var(--text-primary); background: var(--surface-soft);}
  .payment-procedure-option:hover { border-color: var(--focus-ring); background: var(--brand-sky);}
  .payment-procedure-copy small { color: var(--text-secondary);}

  .leave-summary { gap: 11px; margin-bottom: 14px;}
  .leave-summary article { padding: 16px;}
  .leave-summary span { color: var(--text-secondary) !important;}
  .leave-summary strong { color: var(--text-primary) !important;}
  .leave-form-note,
  .leave-days-preview { border-color: var(--border-strong); color: var(--text-secondary); background: var(--surface-soft);}
  .leave-days-preview strong { color: var(--text-primary);}

  .role-grid { gap: 11px;}
  .role-grid article { padding: 16px;}
  .role-grid article strong { color: var(--text-primary);}
  .role-grid article span { color: var(--text-secondary);}

  dialog {
    width: min(640px, calc(100% - 36px));
    max-width: none;
    max-height: min(90vh, 900px);
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border-strong) !important;
    border-radius: 20px;
    color: var(--text-primary) !important;
    background: var(--surface) !important;
    box-shadow: var(--shadow-lg);}

  dialog.wide-dialog { width: min(900px, calc(100% - 36px));}
  dialog::backdrop { background: rgba(8, 25, 43, .58); backdrop-filter: blur(4px);}
  dialog form,
  .detail-shell,
  .install-help { max-height: min(90vh, 900px); overflow-y: auto; padding: 25px;}
  .modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding-bottom: 16px; border-color: var(--line);}
  .modal-heading h2 { margin-bottom: 0; color: var(--text-primary) !important; font-size: 20px;}
  .close { width: 38px; height: 38px; min-height: 38px; border: 1px solid var(--border-strong); border-radius: 9px; color: var(--text-secondary); background: var(--surface-soft) !important; font-size: 16px;}
  .close:hover { color: var(--link); border-color: var(--focus-ring); background: var(--brand-sky) !important;}
  .form-grid { gap: 14px;}
  .form-grid label,
  .color-picker legend,
  .standalone-label { color: var(--text-secondary) !important; font-size:14px; font-weight: 800;}
  .form-grid input,
  .form-grid select,
  .form-grid textarea,
  .standalone-label textarea,
  .plan-item input,
  #confirm-prompt-input { min-height: 43px; padding: 9px 11px; border: 1px solid var(--border-strong) !important; border-radius: 9px; color: var(--text-primary) !important; background: var(--field) !important;}
  .form-grid textarea,
  .standalone-label textarea { min-height: 96px; resize: vertical;}
  .form-grid input:focus,
  .form-grid select:focus,
  .form-grid textarea:focus,
  .standalone-label textarea:focus,
  .plan-item input:focus,
  #confirm-prompt-input:focus { border-color: var(--focus-ring) !important; background: var(--surface) !important; box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus-ring) 12%, transparent) !important; outline: none;}
  .field-hint { color: var(--text-tertiary) !important; font-size: 11px; font-weight: 600;}
  .age-field { min-width: 0;}
  .age-field .field-hint { display: block; margin-top: 6px; line-height: 1.35;}
  .form-error { min-height: 20px; margin: 13px 0 0; color: var(--danger) !important; font-size:14px; font-weight: 700;}
  .modal-actions { gap: 8px; padding-top: 17px; border-color: var(--line);}
  .color-picker { border-color: var(--line);}
  .color-options label { min-height: 39px; padding: 8px; border-color: var(--border-strong); color: var(--text-secondary); background: var(--surface-soft);}
  .color-options label:has(input:checked) { border-color: var(--primary); color: var(--link); background: var(--brand-sky);}
  .color-options span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-strong);}
  .items-heading { margin: 18px 0 9px;}
  .items-heading strong { color: var(--text-primary);}
  .items-heading small { color: var(--text-secondary);}
  .remove-plan-item { min-height: 40px; border: 1px solid color-mix(in srgb, var(--danger) 25%, var(--border-strong)); color: var(--danger); background: color-mix(in srgb, var(--surface) 86%, #e98a91 14%);}

  .login-screen {
    background: var(--surface-soft) !important;}
  .login-screen::before { content: ''; position: absolute; width: 420px; height: 420px; top: -180px; right: -100px; border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent); border-radius: 50%; pointer-events: none;}
  .login-card { position: relative; width: min(430px, 100%); padding: 34px; border: 1px solid var(--border-strong); border-top: 4px solid var(--primary); border-radius: 21px; background: var(--surface) !important; box-shadow: var(--shadow-lg);}
  .login-logo {
    width: 205px;
    height: 101px;
    margin: 0 auto 18px;
    overflow: hidden;
    border-radius: 15px;
    background: #fff;}
  .login-logo img {
    position: static;
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    object-fit: cover;
    object-position: center;}
  .login-card h1 { color: var(--text-primary) !important;}
  .login-card p,
  .login-card label,
  .login-help { color: var(--text-secondary) !important;}
  .login-card input { min-height: 46px; border-color: var(--border-strong); color: var(--text-primary); background: var(--field);}
  .login-card button { min-height: 46px;}

  #toast { right: 22px; bottom: 22px; min-width: 220px; max-width: min(360px, calc(100vw - 32px)); padding: 12px 15px; border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border-strong)); border-radius: 11px; color: #fff; background: var(--navy); box-shadow: var(--shadow-md); font-size:14px; font-weight: 700;}

  @media (max-width: 1280px) {
    main { padding-right: 24px; padding-left: 24px;}
    .dashboard-grid { grid-template-columns: minmax(0, 1fr) 235px;}
    .agenda-workspace { grid-template-columns: 190px minmax(0, 1fr);}
    .calendar-month-layout { grid-template-columns: minmax(0, 1fr) minmax(235px, .65fr);}
    .calendar-month-day { min-height: 132px; padding: 6px;}
    .calendar-month-day .calendar-event-patient { font-size:11px;}}

  @media (max-width: 1040px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr));}
    .stats article:last-child { grid-column: 1 / -1;}
    .finance-stats { grid-template-columns: repeat(3, minmax(0, 1fr));}
    .finance-layout { grid-template-columns: 1fr;}
    .cash-panel { order: -1;}
    .appointment-row { grid-template-columns: var(--clinic-time-track) minmax(0, 1fr) auto;}
    .appointment-row .appt-status { grid-column: 3; grid-row: 1;}
    .appointment-row .appt-actions { grid-column: 3; grid-row: 2;}}

  @media (max-width: 899px) {
    .mobile-menu-button { display: grid; place-items: center; position: relative; width: 43px; height: 43px; flex: 0 0 auto; border: 1px solid var(--border-strong); border-radius: 11px; background: var(--surface) !important; box-shadow: var(--shadow-sm);}
    .mobile-menu-button span { position: absolute; left: 50%; width: 18px; height: 2px; margin-left: -9px; border-radius: 2px; background: var(--link); transition: transform .2s ease, opacity .2s ease, top .2s ease;}
    .mobile-menu-button span:nth-child(1) { top: 15px;}
    .mobile-menu-button span:nth-child(2) { top: 20px;}
    .mobile-menu-button span:nth-child(3) { top: 25px;}
    body.mobile-menu-open .mobile-menu-button { background: var(--primary) !important; border-color: var(--primary);}
    body.mobile-menu-open .mobile-menu-button span { background: #fff;}
    body.mobile-menu-open .mobile-menu-button span:nth-child(1) { top: 20px; transform: rotate(45deg);}
    body.mobile-menu-open .mobile-menu-button span:nth-child(2) { opacity: 0;}
    body.mobile-menu-open .mobile-menu-button span:nth-child(3) { top: 20px; transform: rotate(-45deg);}
    .mobile-menu-backdrop { position: fixed; inset: 0; z-index: 75; display: block; background: rgba(8,25,43,.58); backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity .2s ease;}
    .mobile-menu-backdrop[hidden] { display: none;}
    body.mobile-menu-open .mobile-menu-backdrop { opacity: 1; pointer-events: auto;}
    .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-105%); width: min(306px, 86vw); padding: 19px 15px calc(19px + env(safe-area-inset-bottom)); border-right: 1px solid var(--border-strong); box-shadow: 18px 0 46px rgba(10,35,60,.25); transition: transform .22s ease;}
    body.mobile-menu-open .sidebar { transform: translateX(0);}
    .sidebar-close { display: grid; place-items: center; position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border: 1px solid var(--border-strong); border-radius: 10px; color: var(--text-secondary); background: var(--surface);}
    main { width: 100%; margin-left: 0; padding: 18px 18px calc(44px + env(safe-area-inset-bottom));}
    header { grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding-bottom: 14px;}
    header > div:not(.header-meta) { min-width: 0;}
    header h1 { overflow-wrap: anywhere; font-size: 23px;}
    .header-meta { gap: 4px; padding: 2px; border: 0; box-shadow: none; background: transparent !important;}
    .header-meta .date,
    .header-meta .user-chip,
    .header-meta .install-button { display: none;}
    .theme-toggle { min-width: 40px; padding: 8px;}
    .theme-text { display: none;}
    .logout-button { min-width: 40px; padding: 8px; font-size: 0;}
    .logout-button::after { content: '↪'; font-size: 18px;}
    .welcome-mark { display: none;}
    .section-actions { align-items: start; padding: 16px 17px;}
    .section-actions .primary,
    .section-actions .secondary { white-space: nowrap;}
    .dashboard-grid { grid-template-columns: 1fr;}
    .appointment-filters { grid-template-columns: 1fr; align-items: stretch;}
    .appointment-filters > button { width: 100%;}
    .agenda-toolbar { display: grid; gap: 8px;}
    .agenda-view-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));}
    .agenda-view-switch button { min-height: 43px; padding: 7px 4px;}
    .agenda-navigation { display: grid; grid-template-columns: 43px minmax(0, 1fr) 43px; grid-template-areas: 'prev range next' 'today today today'; gap: 7px;}
    .agenda-navigation [data-agenda-shift='-1'] { grid-area: prev;}
    .agenda-navigation [data-agenda-shift='1'] { grid-area: next;}
    .agenda-navigation strong { grid-area: range; min-width: 0; text-align: center; font-size:14px;}
    .agenda-navigation [data-agenda-today] { grid-area: today; justify-self: center; min-width: 92px;}
    .agenda-summary-strip { gap: 7px;}
    .agenda-summary-strip article { padding: 11px 9px;}
    .agenda-summary-strip article > span,
    .agenda-summary-strip article > small { overflow: hidden; font-size:11px; text-overflow: ellipsis; white-space: nowrap;}
    .agenda-summary-strip article > strong { font-size: 21px;}
    .agenda-workspace { display: flex; flex-direction: column; gap: 10px;}
    .agenda-sidebar { position: static; width: 100%; padding: 14px;}
    .agenda-selected-card { display: none;}
    .calendar-panel { overflow: visible; padding: 10px;}
    .calendar-weekdays { display: none;}
    .calendar-columns { display: grid; grid-template-columns: 1fr; gap: 9px;}
    .calendar-day { min-height: 0; padding: 12px; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface) !important;}
    .calendar-day:nth-child(even) { background: var(--surface) !important;}
    .calendar-day-mobile-heading { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; padding-bottom: 9px; border-bottom: 1px solid var(--line); color: var(--text-secondary);}
    .calendar-day-mobile-heading span { font-size:14px; font-weight: 800; text-transform: uppercase;}
    .calendar-day-mobile-heading strong { color: var(--text-primary); font-size: 25px; line-height: 1;}
    .calendar-day-mobile-heading small { margin-left: auto; color: var(--text-secondary); font-size: 11px;}
    .calendar-day-mobile-heading.today strong,
    .calendar-day-mobile-heading.selected strong { color: var(--primary);}
    .calendar-event { grid-template-columns: minmax(0, 1fr) auto; margin-bottom: 8px; border-left-width: 4px;}
    .calendar-event-main { padding: 11px;}
    .calendar-event-time { font-size:14px;}
    .calendar-event-patient { font-size: 14px; white-space: normal;}
    .calendar-event-reason { font-size:14px; white-space: normal;}
    .calendar-event-edit { min-width: 42px; min-height: 42px;}
    .calendar-events-list { max-height: none; overflow: visible;}
    .calendar-month-layout { display: grid; grid-template-columns: 1fr; gap: 11px;}
    .calendar-month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-radius: 14px;}
    .calendar-month-heading { min-height: 39px; padding: 11px 2px; font-size:11px;}
    .calendar-month-day,
    .calendar-month-day.outside-month { min-height: 68px; padding: 4px 2px; opacity: 1;}
    .calendar-month-date { position: relative; display: grid; place-items: center; min-height: 55px; margin: 0;}
    .calendar-month-date span { display: none;}
    .calendar-month-date strong { width: 31px; height: 31px; font-size:14px;}
    .calendar-month-day .calendar-event,
    .calendar-month-day .calendar-empty,
    .calendar-month-day .calendar-more,
    .calendar-month-day .calendar-month-count { display: none;}
    .calendar-month-day.has-events .calendar-month-date::after { content: ''; position: absolute; bottom: 1px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary);}
    .calendar-selected-day { padding: 14px;}
    .calendar-selected-day-list { max-height: none; overflow: visible;}
    .calendar-selected-appointment { grid-template-columns: var(--clinic-time-track) minmax(0, 1fr) 9px 32px; padding: 10px 9px;}
    .calendar-selected-patient { font-size:14px;}
    .calendar-selected-reason { font-size: 11px;}
    .list-row,
    .finance-plan,
    .leave-row,
    .record-leave,
    .user-row { display: grid; grid-template-columns: 1fr; gap: 9px; min-height: 0; margin-bottom: 8px; padding: 13px; border: 1px solid var(--border-strong) !important; border-radius: 14px;}
    .list-row > div,
    .finance-plan > div,
    .leave-row > div,
    .record-leave > div,
    .user-row > div { grid-column: auto !important; grid-row: auto !important;}
    .patient-row-actions,
    .finance-actions,
    .leave-actions,
    .record-leave-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 7px;}
    .patient-row-actions button,
    .finance-actions button,
    .leave-actions button,
    .record-leave-actions button { width: 100%; min-height: 42px;}
    .list-row > div:last-child { margin-top: 2px;}
    .appointment-row { display: grid; grid-template-columns: var(--clinic-time-track) minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 12px;}
    .appointment-row .appt-time-block { grid-column: 1; grid-row: 1;}
    .appointment-row .appt-main { grid-column: 2 / -1; grid-row: 1;}
    .appointment-row .appt-status { grid-column: 1 / 3; grid-row: 2;}
    .appointment-row .appt-actions { grid-column: 3; grid-row: 2;}
    .appointment-row .appt-status .appointment-status-select { width: 100%; min-height: 40px;}
    .appointment-row .appt-time-date { display: none;}
    .appointment-row .appt-main strong { font-size: 14px;}
    .appointment-row .appt-main small { font-size:14px;}
    .record-header { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; min-height: 0; padding: 17px;}
    .record-header h2 { font-size: 20px;}
    .record-header p { overflow-wrap: anywhere; font-size:14px;}
    .record-tabs { gap: 5px; overflow-x: auto; padding-bottom: 1px;}
    .record-tab { padding: 10px 11px; font-size:14px;}
    .intake-detail-grid { grid-template-columns: 1fr;}
    .odontogram-tools { padding: 14px;}
    .odontogram-lock-box { width: 100%; justify-content: space-between; margin-left: 0;}
    .odontogram-lock-box button { flex: 1;}
    .finance-stats { grid-template-columns: repeat(2, minmax(0, 1fr));}
    .finance-stats article { min-height: 0;}
    .finance-plan { grid-template-columns: 1fr !important;}
    .finance-plan > div:last-child { align-items: stretch;}
    .cash-panel #cash-methods { grid-template-columns: 1fr 1fr;}
    .detail-hero { display: block;}
    .detail-amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 16px; text-align: left;}
    dialog,
    dialog.wide-dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; margin: 0; border-radius: 19px 19px 0 0;}
    dialog[open] { position: fixed; inset: auto 0 0;}
    dialog form,
    .detail-shell,
    .install-help { max-height: calc(100dvh - 10px); padding: 19px 16px calc(19px + env(safe-area-inset-bottom));}
    dialog .modal-heading { position: sticky; top: -19px; z-index: 2; margin: -19px -16px 16px; padding: 15px 16px; background: var(--surface);}
    .form-grid { grid-template-columns: 1fr; gap: 12px;}
    .modal-actions { position: sticky; bottom: calc(-19px - env(safe-area-inset-bottom)); z-index: 2; margin: 16px -16px calc(-19px - env(safe-area-inset-bottom)); padding: 13px 16px calc(19px + env(safe-area-inset-bottom)); background: var(--surface);}
    .modal-actions button { flex: 1; min-height: 45px;}
    .login-card { padding: 27px 21px;}
    .login-screen.show { display: grid; padding: 16px;}
    #toast { right: 16px; bottom: 16px;}}

  @media (max-width: 600px) {
    main { padding-right: 14px; padding-left: 14px;}
    header { gap: 9px;}
    header h1 { font-size: 21px;}
    .stats,
    .finance-stats { grid-template-columns: 1fr;}
    .stats article:last-child { grid-column: auto;}
    .welcome-actions { display: grid; grid-template-columns: 1fr;}
    .welcome-actions button { width: 100%;}
    .section-actions { grid-template-columns: 1fr; gap: 11px;}
    .section-actions > button { justify-self: start;}
    .agenda-summary-strip { grid-template-columns: repeat(3, minmax(0, 1fr));}
    .agenda-summary-strip article { padding: 10px 7px;}
    .agenda-summary-strip article > strong { font-size: 19px;}
    .agenda-summary-strip article > span,
    .agenda-summary-strip article > small { font-size:14px;}
    .calendar-month-heading { font-size: 11px;}
    .calendar-month-day,
    .calendar-month-day.outside-month { min-height: 62px;}
    .calendar-month-date { min-height: 50px;}
    .calendar-month-date strong { width: 28px; height: 28px; font-size:14px;}
    .detail-amounts { grid-template-columns: 1fr;}
    .cash-panel #cash-methods { grid-template-columns: 1fr;}
    .patient-row-actions,
    .finance-actions,
    .leave-actions,
    .record-leave-actions { grid-template-columns: 1fr;}}

  .birthday-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;}

  .control-icon {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;}

  .odontogram-lock-box button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;}

  .logout-icon {
    display: none;
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;}

  @media (max-width: 899px) {
    .logout-button::after { content: none !important;}
    .logout-button .logout-label { display: none;}
    .logout-button .logout-icon { display: block;}}
  /* Tablet dashboard balance */
  @media (min-width: 900px) and (max-width: 1100px) {
    .dashboard-grid { grid-template-columns: 1fr;}}}
/*
 * Clinica Dental JH - CRM visual system
 * Operational first: clear hierarchy, calm surfaces, fast scanning.
 * Screen-only layer. Print documents keep their existing ink-saving rules.
 */
@media screen {
  :root {
    --crm-canvas: #eef4f7;
    --crm-surface: #ffffff;
    --crm-surface-raised: #ffffff;
    --crm-surface-soft: #f6fafc;
    --crm-field: #fbfdfe;
    --crm-ink: #122e4a;
    --crm-copy: #4f6981;
    --crm-copy-soft: #6d8397;
    --crm-line: #d8e5ec;
    --crm-line-strong: #c2d5e0;
    --crm-navy: #102e50;
    --crm-navy-deep: #0a2038;
    --crm-primary: #087ea9;
    --crm-primary-strong: #076a8e;
    --crm-teal: #187f7a;
    --crm-success: #17755f;
    --crm-warning: #9a641f;
    --crm-danger: #b33f48;
    --crm-focus: #087ea9;
    --crm-brand-tint: #e3f4fa;
    --crm-success-tint: #e6f6f1;
    --crm-warning-tint: #fff4df;
    --crm-shadow-xs: 0 1px 2px rgba(18, 46, 74, .04);
    --crm-shadow-sm: 0 5px 18px rgba(18, 55, 82, .065);
    --crm-shadow-md: 0 16px 34px rgba(18, 55, 82, .11);
    --crm-radius-md: 13px;
    --crm-radius-lg: 18px;
    --crm-sidebar: 244px;

    --surface: var(--crm-surface);
    --surface-strong: var(--crm-surface-raised);
    --surface-soft: var(--crm-surface-soft);
    --field: var(--crm-field);
    --text-primary: var(--crm-ink);
    --text-secondary: var(--crm-copy);
    --text-tertiary: var(--crm-copy-soft);
    --border-strong: var(--crm-line-strong);
    --line: var(--crm-line);
    --focus-ring: var(--crm-focus);
    --link: var(--crm-primary-strong);
    --navy: var(--crm-navy);
    --teal: var(--crm-teal);
    --ink: var(--crm-ink);
    --muted: var(--crm-copy);
    --white: var(--crm-surface);
    --primary: var(--crm-primary);
    --primary-dark: var(--crm-primary-strong);
    --brand-navy: var(--crm-navy);
    --brand-navy-dark: var(--crm-navy-deep);
    --brand-sky: var(--crm-brand-tint);
    --danger: var(--crm-danger);
    --warning: var(--crm-warning);
    --success: var(--crm-success);
    color-scheme: light;}

  html[data-theme="dark"] {
    --crm-canvas: #091725;
    --crm-surface: #10243a;
    --crm-surface-raised: #142c45;
    --crm-surface-soft: #142c45;
    --crm-field: #0c1d31;
    --crm-ink: #edf6fd;
    --crm-copy: #c1d0de;
    --crm-copy-soft: #a5b9cb;
    --crm-line: #2d4862;
    --crm-line-strong: #3c5a75;
    --crm-navy: #071726;
    --crm-navy-deep: #06121f;
    --crm-primary: #63c9e8;
    --crm-primary-strong: #8cdef2;
    --crm-teal: #55d0bd;
    --crm-success: #78e0be;
    --crm-warning: #f1c378;
    --crm-danger: #ff9ca3;
    --crm-focus: #73d8ef;
    --crm-brand-tint: #173b56;
    --crm-success-tint: #153b3a;
    --crm-warning-tint: #493820;
    --crm-shadow-xs: 0 1px 2px rgba(0, 0, 0, .24);
    --crm-shadow-sm: 0 7px 22px rgba(0, 0, 0, .19);
    --crm-shadow-md: 0 18px 42px rgba(0, 0, 0, .28);

    --surface: var(--crm-surface);
    --surface-strong: var(--crm-surface-raised);
    --surface-soft: var(--crm-surface-soft);
    --field: var(--crm-field);
    --text-primary: var(--crm-ink);
    --text-secondary: var(--crm-copy);
    --text-tertiary: var(--crm-copy-soft);
    --border-strong: var(--crm-line-strong);
    --line: var(--crm-line);
    --focus-ring: var(--crm-focus);
    --link: var(--crm-primary-strong);
    --navy: var(--crm-navy);
    --teal: var(--crm-teal);
    --ink: var(--crm-ink);
    --muted: var(--crm-copy);
    --white: var(--crm-surface);
    --primary: var(--crm-primary);
    --primary-dark: var(--crm-primary-strong);
    --brand-navy: #d5ecf8;
    --brand-navy-dark: #b7dfef;
    --brand-sky: var(--crm-brand-tint);
    --danger: var(--crm-danger);
    --warning: var(--crm-warning);
    --success: var(--crm-success);
    color-scheme: dark;}

  html,
  body {
    min-height: 100%;
    min-width: 320px;
    background: var(--crm-canvas) !important;}

  body {
    overflow-x: hidden;
    color: var(--crm-ink) !important;
    background-image: none !important;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: .002em;
    text-rendering: optimizeLegibility;}

  body::before {
    display: none !important;}

  *,
  *::before,
  *::after {
    scrollbar-color: var(--crm-line-strong) transparent;}

  ::selection {
    color: #ffffff;
    background: var(--crm-primary);}

  h1,
  h2,
  h3,
  h4 {
    color: var(--crm-ink);
    letter-spacing: -.018em;}

  p {
    color: var(--crm-copy);}

  button,
  input,
  select,
  textarea {
    font-family: inherit;}

  button {
    -webkit-tap-highlight-color: transparent;}

  button:focus-visible,
  a:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible,
  summary:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--crm-focus) 68%, transparent) !important;
    outline-offset: 2px;}

  .app-shell {
    min-height: 100vh;
    background: var(--crm-canvas);}

  /* Navigation */
  .sidebar {
    z-index: 80;
    width: var(--crm-sidebar);
    padding: 22px 14px 18px;
    border: 0;
    border-right: 1px solid rgba(255,255,255,.08);
    color: #d5e8f2;
    background: var(--crm-navy-deep);
    box-shadow: 12px 0 32px rgba(5, 24, 41, .12);}

  .brand {
    display: block;
    padding: 0 8px 20px;
    border-bottom: 1px solid rgba(210, 234, 246, .13);}

  .brand-crop {
    display: grid;
    width: 190px;
    height: 128px;
    margin: 0 auto;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 13px;
    background: #ffffff;}

  .brand-crop img {
    position: static;
    display: block;
    width: 126px !important;
    height: 126px !important;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    object-fit: contain;
    object-position: center;}

  .brand > small {
    display: block;
    margin-top: 12px;
    color: #9bb6c8 !important;
    font-size:11px;
    font-weight: 800;
    letter-spacing: .16em;
    text-align: center;
    text-transform: uppercase;}

  .nav-label {
    margin: 22px 10px 9px;
    color: #7594aa !important;
    font-size:11px;
    font-weight: 800;
    letter-spacing: .15em;
    line-height: 1.2;
    text-transform: uppercase;}

  .nav-label-sub {
    margin-top: 24px;}

  nav {
    gap: 4px;}

  .nav-item {
    min-height: 43px;
    padding: 10px 11px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #b8cedd !important;
    background: transparent !important;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    text-align: left;
    transition: color .18s ease, background-color .18s ease, border-color .18s ease;}

  .nav-item:hover {
    color: #ffffff !important;
    background: rgba(121, 208, 236, .12) !important;
    border-color: rgba(121, 208, 236, .14);
    transform: none;}

  .nav-item.active {
    color: #ffffff !important;
    background: linear-gradient(90deg, #0d83ab, #126b96) !important;
    border-color: rgba(148, 229, 248, .32);
    box-shadow: 0 8px 18px rgba(3, 112, 153, .22);}

  .nav-icon {
    width: 29px;
    height: 29px;
    border: 1px solid rgba(183, 223, 239, .14);
    border-radius: 9px;
    color: #8cb5ca;
    background: rgba(255,255,255,.055);}

  .nav-item:hover .nav-icon,
  .nav-item.active .nav-icon {
    color: #ffffff !important;
    background: rgba(255,255,255,.15);
    border-color: rgba(255,255,255,.18);}

  .nav-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;}

  /* Main frame and utility header */
  main {
    width: calc(100% - var(--crm-sidebar));
    max-width: none;
    min-height: 100vh;
    margin-left: var(--crm-sidebar);
    padding: 28px clamp(24px, 3.1vw, 58px) 64px;}

  header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    min-height: 62px;
    margin-bottom: 25px;
    padding: 0 0 17px;
    border-bottom: 1px solid var(--crm-line);}

  header > div:not(.header-meta) {
    min-width: 0;}

  header h1 {
    margin: 0;
    color: var(--crm-ink) !important;
    font-family: "Segoe UI", Inter, system-ui, sans-serif;
    font-size: clamp(24px, 2vw, 30px);
    font-weight: 760;
    line-height: 1.12;}

  .eyebrow {
    margin: 0 0 6px;
    color: var(--crm-primary) !important;
    font-size:11px;
    font-weight: 850;
    letter-spacing: .14em;
    line-height: 1.2;
    text-transform: uppercase;}

  .header-meta {
    display: flex;
    align-items: center;
    gap: 8px;}

  .date {
    padding-right: 10px;
    color: var(--crm-copy) !important;
    font-size:14px;
    font-weight: 650;}

  .user-chip {
    min-height: 41px;
    padding: 5px 11px 5px 5px;
    border: 1px solid var(--crm-line);
    border-radius: 12px;
    color: var(--crm-ink);
    background: var(--crm-surface);
    box-shadow: var(--crm-shadow-xs);}

  .user-chip > span {
    width: 30px;
    height: 30px;
    color: #ffffff;
    background: var(--crm-teal);
    font-size: 11px;}

  .user-chip strong,
  .user-chip small {
    color: var(--crm-ink) !important;}

  .user-chip strong {
    font-size:14px;
    font-weight: 800;}

  .user-chip small {
    color: var(--crm-copy) !important;
    font-size: 11px;}

  .theme-toggle,
  .logout-button,
  .install-button {
    min-height: 41px;
    border: 1px solid var(--crm-line-strong);
    border-radius: 10px;
    color: var(--crm-copy) !important;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-xs);
    font-size:14px;
    font-weight: 750;}

  .theme-toggle:hover,
  .logout-button:hover,
  .install-button:hover {
    color: var(--crm-primary-strong) !important;
    border-color: var(--crm-primary);
    background: var(--crm-brand-tint) !important;}

  .theme-icon {
    color: currentColor;}

  .theme-icon svg,
  .logout-icon {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;}

  /* Shared page rhythm */
  .view.active {
    animation: crm-view-in .18s ease-out both;}

  @keyframes crm-view-in {
    from { opacity: .01; transform: translateY(3px);}
    to { opacity: 1; transform: translateY(0);}}

  .section-actions {
    min-height: 70px;
    margin-bottom: 18px;
    padding: 0 0 17px;
    border: 0;
    border-bottom: 1px solid var(--crm-line);
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;}

  .section-actions h2 {
    margin: 0 0 5px;
    color: var(--crm-ink) !important;
    font-size: 23px;
    font-weight: 760;
    line-height: 1.2;}

  .section-actions p,
  .panel-heading p {
    margin: 0;
    color: var(--crm-copy) !important;
    font-size:14px;
    line-height: 1.45;}

  .section-kicker,
  .welcome-kicker {
    color: var(--crm-primary) !important;
    font-size:11px;
    font-weight: 850;
    letter-spacing: .13em;
    line-height: 1.2;
    text-transform: uppercase;}

  .panel,
  .search,
  .stats article,
  .finance-stats article,
  .finance-mini-strip,
  .leave-summary article,
  .role-grid article,
  .agenda-toolbar,
  .agenda-sidebar,
  .calendar-panel,
  .calendar-selected-day,
  .record-tabs,
  .setup-notice,
  .birthday-card {
    border-color: var(--crm-line) !important;
    border-radius: var(--crm-radius-lg);
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-sm);}

  .panel {
    padding: 20px;}

  .panel-heading {
    align-items: flex-start;
    margin-bottom: 15px;}

  .panel-heading h2,
  .panel-heading h3 {
    margin: 4px 0 4px;
    color: var(--crm-ink) !important;
    font-size: 18px;
    font-weight: 760;
    line-height: 1.25;}

  .text-button,
  .record-button,
  .back-button {
    min-height: 40px;
    border-radius: 9px;
    color: var(--crm-primary-strong) !important;
    background: transparent !important;
    font-weight: 800;}

  .text-button:hover,
  .record-button:hover,
  .back-button:hover {
    color: var(--crm-primary) !important;
    background: var(--crm-brand-tint) !important;}

  .primary,
  .secondary,
  .welcome-primary,
  .welcome-secondary,
  .google-button,
  .receipt-button,
  .void-button {
    min-height: 41px;
    border-radius: 9px;
    font-size:14px;
    font-weight: 800;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, opacity .18s ease;}

  .primary,
  .welcome-primary {
    border: 1px solid var(--crm-primary);
    color: #ffffff !important;
    background: var(--crm-primary) !important;
    box-shadow: 0 5px 12px rgba(8, 126, 169, .16);}

  .primary:hover,
  .welcome-primary:hover {
    border-color: var(--crm-primary-strong);
    background: var(--crm-primary-strong) !important;
    box-shadow: 0 7px 16px rgba(8, 126, 169, .21);}

  .secondary,
  .welcome-secondary {
    border: 1px solid var(--crm-line-strong);
    color: var(--crm-ink) !important;
    background: var(--crm-surface) !important;}

  .secondary:hover,
  .welcome-secondary:hover {
    color: var(--crm-primary-strong) !important;
    border-color: var(--crm-primary);
    background: var(--crm-brand-tint) !important;}

  button:disabled,
  [aria-disabled="true"] {
    cursor: not-allowed;
    opacity: .55;}

  .welcome-kicker {
    color: #86daed !important;}

  .welcome-actions {
    gap: 8px;}

  .welcome-secondary {
    color: #d7eff7 !important;
    border-color: rgba(201, 236, 247, .28);
    background: rgba(255,255,255,.08) !important;}

  .welcome-secondary:hover {
    color: #ffffff !important;
    border-color: rgba(201, 236, 247, .6);
    background: rgba(255,255,255,.15) !important;}

  .welcome-mark {
    min-width: 150px;
    min-height: 120px;
    border: 1px solid rgba(191, 234, 245, .18);
    border-radius: 16px;
    background: rgba(255,255,255,.055);}

  .welcome-mark span {
    color: #ffffff;
    font-size: 34px;
    letter-spacing: .08em;}

  .welcome-mark small {
    color: #9fd3e4;
    font-size:11px;
    letter-spacing: .16em;
    text-transform: uppercase;}

  .stats {
    gap: 12px;
    margin-bottom: 16px;}

  .stats article {
    min-height: 126px;
    padding: 16px 18px;
    border-top: 3px solid var(--crm-primary) !important;
    transition: border-color .18s ease, box-shadow .18s ease;}

  .stats article:nth-child(2) {
    border-top-color: #3f72b4 !important;}

  .stats article:nth-child(3) {
    border-top-color: var(--crm-teal) !important;}

  .stats article:hover {
    box-shadow: var(--crm-shadow-md);
    transform: none;}

  .stat-icon {
    width: 31px;
    height: 31px;
    border-radius: 9px;
    font-size: 11px !important;}

  .stats strong {
    margin: 12px 0 1px;
    color: var(--crm-ink) !important;
    font-size: 29px;
    font-weight: 780;
    font-variant-numeric: tabular-nums;}

  .stats article > span:last-child {
    color: var(--crm-copy) !important;
    font-size:14px;}

  .finance-mini-strip {
    gap: 13px;
    margin-bottom: 16px;
    padding: 13px 17px;}

  .finance-mini-item strong {
    color: var(--crm-ink) !important;
    font-size: 19px;
    font-variant-numeric: tabular-nums;}

  .finance-mini-item small {
    color: var(--crm-copy) !important;
    font-size: 11px;}

  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr) 286px;
    gap: 14px;}

  .quick-icon {
    width: 30px;
    height: 30px;
    color: var(--crm-primary);
    border-radius: 9px;
    background: var(--crm-brand-tint);}
  .birthday-card {
    gap: 14px;
    margin-bottom: 16px;
    padding: 13px 16px;
    color: var(--crm-copy);}
  .birthday-card strong {
    color: var(--crm-ink);
    font-size:14px;}
  .birthday-card span {
    color: var(--crm-copy);
    font-size:14px;}

  /* Search, forms and lists */
  .search {
    padding: 12px;
    margin-bottom: 14px;}

  .search input {
    min-height: 39px;
    color: var(--crm-ink) !important;
    background: transparent;}

  .search input::placeholder,
  input::placeholder,
  textarea::placeholder {
    color: var(--crm-copy-soft) !important;
    opacity: 1;}

  .patient-search-box {
    padding: 12px 14px;}

  .patient-search-row {
    gap: 8px;}

  .patient-search-row input {
    min-height: 42px;
    padding: 8px 11px;
    border: 1px solid var(--crm-line-strong);
    border-radius: 9px;
    color: var(--crm-ink);
    background: var(--crm-field);}

  .patient-letter-filter {
    gap: 4px;
    margin-top: 10px;}

  .patient-letter {
    min-width: 29px;
    min-height: 29px;
    padding: 4px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--crm-copy);
    background: transparent;
    font-size: 11px;
    font-weight: 800;}

  .patient-letter:hover,
  .patient-letter.active {
    color: #ffffff;
    background: var(--crm-primary);}

  .patient-search-summary {
    display: block;
    margin-top: 8px;
    color: var(--crm-copy-soft) !important;
    font-size: 11px;}

  .list-row {
    min-height: 66px;
    grid-template-columns: minmax(210px, 1.55fr) minmax(120px, .72fr) minmax(145px, .85fr) minmax(110px, .7fr) auto;
    gap: 14px;
    padding: 13px 5px;
    border-color: var(--crm-line) !important;
    color: var(--crm-ink);}

  .list-row:hover {
    background: var(--crm-surface-soft) !important;
    box-shadow: none;
    transform: none;}

  .list-row strong {
    color: var(--crm-ink) !important;
    font-size:14px;
    font-weight: 800;}

  .list-row small,
  .muted {
    color: var(--crm-copy) !important;
    font-size: 11px;}

  .avatar {
    gap: 10px;}

  .avatar > span {
    width: 34px;
    height: 34px;
    color: var(--crm-primary-strong) !important;
    background: var(--crm-brand-tint) !important;
    font-size: 11px;
    font-weight: 850;}

  .patient-row-actions {
    gap: 4px;}

  .record-button {
    min-height: 36px;
    padding: 7px 9px;
    font-size: 11px;}

  .record-button.danger {
    color: var(--crm-danger) !important;}

  .appointment-row {
    min-height: 75px;
    grid-template-columns: var(--clinic-time-track) minmax(220px, 1.6fr) 138px auto;
    gap: 14px;
    margin-bottom: 8px;
    padding: 12px 13px;
    border: 1px solid var(--crm-line) !important;
    border-left: 3px solid var(--doctor-color, var(--crm-teal)) !important;
    border-radius: 11px;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-xs);}

  .appointment-row:hover {
    border-color: var(--crm-line-strong) !important;
    background: var(--crm-surface-soft) !important;
    box-shadow: var(--crm-shadow-sm);
    transform: none;}

  .appt-time-block strong {
    color: var(--crm-ink);
    font-size: 15px;
    font-variant-numeric: tabular-nums;}

  .appt-time-date {
    color: var(--crm-copy-soft);
    font-size:11px;}

  .appt-main {
    min-width: 0;
    gap: 10px;}

  .appt-main strong,
  .appt-main small {
    overflow: hidden;
    color: var(--crm-ink) !important;
    text-overflow: ellipsis;
    white-space: nowrap;}

  .appt-main small {
    color: var(--crm-copy) !important;
    font-size:14px;}

  .doctor-agenda-label {
    max-width: 100%;
    overflow: hidden;
    color: var(--crm-copy-soft) !important;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;}

  .doctor-agenda-label i {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--doctor-color, var(--crm-teal)) 16%, transparent);}

  .appointment-status-select {
    width: 128px;
    min-height: 35px;
    padding: 7px 25px 7px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 850;}

  .appointment-menu summary {
    width: 34px;
    height: 34px;
    color: var(--crm-copy) !important;
    border-color: var(--crm-line-strong);
    background: var(--crm-surface) !important;}

  .appointment-menu summary:hover,
  .appointment-menu[open] summary {
    color: var(--crm-primary-strong) !important;
    border-color: var(--crm-primary);
    background: var(--crm-brand-tint) !important;}

  .appointment-menu-popover {
    width: 228px;
    padding: 7px;
    border-color: var(--crm-line);
    border-radius: 12px;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-md);}

  .appointment-menu-popover button {
    min-height: 37px;
    color: var(--crm-copy) !important;
    background: transparent !important;
    font-size:14px;}

  .appointment-menu-popover button:hover {
    color: var(--crm-primary-strong) !important;
    background: var(--crm-brand-tint) !important;}

  .appointment-menu-popover button.warning {
    color: var(--crm-warning) !important;}

  .appointment-menu-popover button.danger,
  .appointment-menu-popover button.delete {
    color: var(--crm-danger) !important;}

  /* Agenda command center */
  .agenda-heading {
    min-height: 70px;}

  .appointment-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px auto;
    align-items: end;
    gap: 10px;
    padding: 13px 14px;}

  .appointment-filters label {
    min-width: 0;}

  .appointment-filters label > span {
    display: block;
    margin: 0 0 6px 2px;
    color: var(--crm-copy);
    font-size: 11px;
    font-weight: 800;}

  .appointment-filters input[type="search"],
  .appointment-filters input[type="date"] {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--crm-line-strong);
    border-radius: 9px;
    color: var(--crm-ink);
    background: var(--crm-field);}

  .appointment-filters small {
    display: block;
    margin: 5px 2px 0;
    color: var(--crm-copy-soft);
    font-size:11px;}

  .appointment-filters > button {
    min-width: 110px;}

  .agenda-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 12px 0;
    padding: 8px;}

  .agenda-view-switch {
    display: flex;
    gap: 3px;
    padding: 3px;
    border-radius: 10px;
    background: var(--crm-surface-soft);}

  .agenda-view-switch button {
    min-height: 38px;
    padding: 7px 14px;
    border: 0;
    border-radius: 8px;
    color: var(--crm-copy);
    background: transparent;
    font-size:14px;
    font-weight: 850;}

  .agenda-view-switch button:hover {
    color: var(--crm-primary-strong);
    background: var(--crm-brand-tint);}

  .agenda-view-switch button.active {
    color: #ffffff;
    background: var(--crm-navy);
    box-shadow: 0 4px 10px rgba(16, 46, 80, .16);}

  .agenda-navigation {
    display: flex;
    align-items: center;
    gap: 6px;}

  .agenda-navigation .icon-button,
  .agenda-mini-navigation .icon-button {
    min-width: 39px;
    min-height: 39px;
    padding: 0;
    border: 1px solid var(--crm-line-strong);
    border-radius: 9px;
    color: var(--crm-copy);
    background: var(--crm-surface);}

  .agenda-navigation .icon-button:hover,
  .agenda-mini-navigation .icon-button:hover {
    color: var(--crm-primary-strong);
    border-color: var(--crm-primary);
    background: var(--crm-brand-tint);}

  .agenda-navigation strong {
    min-width: 205px;
    padding: 8px 12px;
    border-radius: 9px;
    color: var(--crm-ink) !important;
    background: var(--crm-surface-soft);
    font-size:14px;
    font-weight: 800;
    text-align: center;}

  .agenda-navigation .today-button {
    color: var(--crm-primary-strong) !important;
    border-color: color-mix(in srgb, var(--crm-primary) 42%, var(--crm-line-strong));
    background: var(--crm-surface) !important;}

  .agenda-summary-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;}

  .agenda-summary-strip article {
    min-width: 0;
    padding: 13px 15px;
    border: 1px solid var(--crm-line) !important;
    border-radius: var(--crm-radius-md);
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-xs);}

  .agenda-summary-strip article > span,
  .agenda-summary-strip article > small {
    display: block;
    color: var(--crm-copy) !important;
    font-size: 11px;}

  .agenda-summary-strip article > span {
    font-weight: 800;}

  .agenda-summary-strip article > strong {
    display: block;
    margin: 5px 0 1px;
    color: var(--crm-ink) !important;
    font-size: 23px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;}

  .agenda-workspace {
    display: grid;
    grid-template-columns: 205px minmax(0, 1fr);
    gap: 12px;
    align-items: start;}

  .agenda-sidebar {
    position: sticky;
    top: 18px;
    min-width: 0;
    padding: 15px;}

  .agenda-sidebar-heading {
    align-items: flex-start;
    margin-bottom: 12px;}

  .agenda-sidebar-heading strong {
    display: block;
    margin-top: 5px;
    color: var(--crm-ink) !important;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.2;}

  .agenda-mini-navigation {
    gap: 4px;}

  .agenda-mini-navigation .icon-button {
    min-width: 36px;
    min-height: 36px;
    border: 0;
    background: var(--crm-surface-soft);}

  .agenda-mini-weekdays {
    gap: 1px;}

  .agenda-mini-weekdays span {
    color: var(--crm-copy-soft) !important;
    font-size:11px;
    font-weight: 850;}

  .agenda-mini-grid {
    gap: 4px;}

  .agenda-mini-day {
    min-height: 34px;
    border-radius: 8px;
    color: var(--crm-copy) !important;}

  .agenda-mini-day:hover,
  .agenda-mini-day:focus-visible {
    color: var(--crm-primary-strong) !important;
    background: var(--crm-brand-tint) !important;
    outline: none;}

  .agenda-mini-day.outside-month {
    color: var(--crm-copy-soft) !important;
    opacity: .55;}

  .agenda-mini-day.today {
    box-shadow: inset 0 0 0 1px var(--crm-primary);}

  .agenda-mini-day.selected {
    color: #ffffff !important;
    background: var(--crm-primary) !important;
    box-shadow: 0 4px 10px rgba(8, 126, 169, .22);}

  .agenda-mini-number {
    width: 24px;
    height: 24px;
    font-size: 11px;}

  .agenda-mini-count {
    color: var(--crm-primary-strong) !important;
    font-size: 11px;
    font-weight: 850;}

  .agenda-mini-day.selected .agenda-mini-count {
    color: #ffffff !important;}

  .agenda-doctor-legend {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--crm-line);}

  .agenda-doctor-item {
    gap: 8px;
    padding: 8px 0;
    border-bottom-color: var(--crm-line);}

  .agenda-doctor-item strong {
    display: block;
    overflow: hidden;
    color: var(--crm-ink) !important;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;}

  .agenda-doctor-item small {
    color: var(--crm-copy) !important;
    font-size:11px;}

  .agenda-doctor-swatch {
    width: 9px;
    height: 9px;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--doctor-color, var(--crm-teal)) 17%, transparent);}

  .agenda-selected-card {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--crm-line);}

  .agenda-selected-card > strong {
    display: block;
    margin: 5px 0 3px;
    color: var(--crm-ink) !important;
    font-size:14px;}

  .agenda-selected-card > span {
    color: var(--crm-copy) !important;
    font-size: 11px;}

  .agenda-day-preview {
    padding: 8px 0;
    border-bottom-color: var(--crm-line);}

  .agenda-day-preview time {
    color: var(--crm-primary-strong) !important;
    font-size:11px;
    font-weight: 850;}

  .agenda-day-preview strong {
    display: block;
    overflow: hidden;
    color: var(--crm-ink) !important;
    font-size:11px;
    text-overflow: ellipsis;
    white-space: nowrap;}

  .agenda-day-preview small {
    display: block;
    overflow: hidden;
    color: var(--crm-copy) !important;
    font-size:11px;
    text-overflow: ellipsis;
    white-space: nowrap;}

  .agenda-content {
    min-width: 0;}

  .calendar-panel {
    min-width: 0;
    padding: 13px;
    overflow: hidden;}

  .calendar-grid {
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--crm-line-strong);
    border-radius: 13px;
    background: var(--crm-line);}

  .calendar-weekdays,
  .calendar-columns {
    grid-template-columns: repeat(7, minmax(0, 1fr));}

  .calendar-weekdays {
    background: var(--crm-surface-soft);}

  .calendar-weekdays > * {
    min-width: 0;
    border-right: 1px solid var(--crm-line);}

  .calendar-weekdays > *:last-child {
    border-right: 0;}

  .calendar-day-heading {
    min-width: 0;
    min-height: 59px;
    padding: 9px 7px;
    color: var(--crm-copy) !important;
    background: var(--crm-surface-soft);}

  .calendar-day-heading:hover,
  .calendar-day-heading:focus-visible {
    color: var(--crm-primary-strong) !important;
    background: var(--crm-brand-tint);
    outline: none;}

  .calendar-day-heading strong {
    color: var(--crm-ink) !important;
    font-size: 19px;
    font-weight: 800;}

  .calendar-day-heading small {
    color: var(--crm-copy) !important;
    font-size:11px;}

  .calendar-day-heading.today strong,
  .calendar-day-heading.selected strong {
    color: var(--crm-primary) !important;}

  .calendar-day-heading.today {
    box-shadow: inset 0 -3px 0 var(--crm-primary);}

  .calendar-columns {
    gap: 1px;
    background: var(--crm-line);}

  .calendar-day {
    min-width: 0;
    min-height: 380px;
    padding: 8px;
    background: var(--crm-surface) !important;}

  .calendar-day:nth-child(even) {
    background: var(--crm-surface) !important;}

  .calendar-day-mobile-heading {
    display: none;}

  .calendar-events-list {
    max-height: 550px;
    padding-right: 2px;
    overflow-y: auto;
    scrollbar-gutter: auto;}

  .calendar-event {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 29px;
    min-width: 0;
    margin-bottom: 6px;
    border: 1px solid var(--crm-line) !important;
    border-left: 4px solid var(--event-color, var(--crm-teal)) !important;
    border-radius: 9px;
    background: var(--crm-surface-raised) !important;
    box-shadow: var(--crm-shadow-xs);
    width: 100%;}

  .calendar-event-main {
    display: flex;
    width: 100%;
    min-width: 0;
    min-inline-size: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    padding: 8px 7px;
    overflow: hidden;
    color: var(--crm-ink) !important;
    background: transparent !important;
    text-align: left;}

  .calendar-event-time {
    color: var(--event-color, var(--crm-teal)) !important;
    font-size:11px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;}

  .calendar-event-patient,
  .calendar-event-reason {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;}

  .calendar-event-patient {
    color: var(--crm-ink) !important;
    font-size: 11px;
    font-weight: 850;
    line-height: 1.25;}

  .calendar-event-reason {
    color: var(--crm-copy) !important;
    font-size:11px;
    line-height: 1.25;}

  .calendar-event-edit {
    width: 29px;
    min-width: 29px;
    min-height: 29px;
    align-self: start;
    margin-top: 5px;
    color: var(--crm-copy) !important;
    background: transparent !important;}

  .calendar-event-edit:hover {
    color: var(--crm-primary-strong) !important;
    background: var(--crm-brand-tint) !important;}

  .calendar-empty {
    display: block;
    padding: 14px 4px;
    color: var(--crm-copy-soft) !important;
    font-size: 11px;
    text-align: center;}

  .calendar-more {
    min-height: 40px;
    border-color: color-mix(in srgb, var(--crm-primary) 48%, var(--crm-line)) !important;
    border-radius: 8px;
    color: var(--crm-primary-strong) !important;
    background: var(--crm-brand-tint) !important;
    font-size:11px;
    font-weight: 850;}

  /* Month calendar and selected-day drawer */
  .calendar-month-layout {
    grid-template-columns: minmax(0, 1fr) minmax(255px, 282px);
    gap: 12px;
    align-items: start;}

  .calendar-month-grid {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--crm-line-strong);
    border-radius: 13px;
    background: var(--crm-line);}

  .calendar-month-heading {
    min-width: 0;
    padding: 11px 6px;
    color: var(--crm-copy) !important;
    background: var(--crm-surface-soft);
    font-size:11px;
    font-weight: 850;}

  .calendar-month-day {
    min-width: 0;
    min-height: 142px;
    padding: 7px;
    border-color: var(--crm-line);
    background: var(--crm-surface) !important;}

  .calendar-month-day.outside-month {
    opacity: .48;
    background: var(--crm-surface-soft) !important;}

  .calendar-month-day.today {
    box-shadow: inset 0 3px 0 var(--crm-primary);}

  .calendar-month-day.selected {
    background: color-mix(in srgb, var(--crm-surface) 88%, var(--crm-primary) 12%) !important;
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--crm-primary) 55%, transparent);}

  .calendar-month-date {
    min-width: 0;
    margin-bottom: 6px;
    color: var(--crm-copy) !important;}

  .calendar-month-date span {
    color: var(--crm-copy-soft) !important;
    font-size:11px;}

  .calendar-month-date strong {
    width: 28px;
    height: 28px;
    color: var(--crm-ink) !important;
    font-size:14px;
    font-weight: 800;}

  .calendar-month-day.today .calendar-month-date strong,
  .calendar-month-day.selected .calendar-month-date strong {
    color: #ffffff !important;
    background: var(--crm-primary) !important;}
  html[data-theme="dark"] .calendar-month-day.today .calendar-month-date strong,
  html[data-theme="dark"] .calendar-month-day.selected .calendar-month-date strong {
    color: #062f38 !important;}

  .calendar-month-day .calendar-event {
    margin-bottom: 5px;}

  .calendar-month-day .calendar-event-main {
    padding: 6px;}

  .calendar-month-day .calendar-event-time {
    font-size:11px;}

  .calendar-month-day .calendar-event-patient {
    font-size:11px;}

  .calendar-month-day .calendar-event-reason {
    font-size:11px;}

  .calendar-month-day .calendar-event-edit {
    width: 25px;
    min-width: 25px;
    min-height: 25px;
    padding: 0;
    font-size: 11px;}

  .calendar-selected-day {
    min-width: 0;
    padding: 17px;}

  .calendar-selected-heading {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--crm-line);}

  .calendar-selected-heading h3 {
    margin: 5px 0 0;
    color: var(--crm-ink) !important;
    font-size: 17px;
    line-height: 1.25;}

  .calendar-selected-meta {
    color: var(--crm-copy) !important;
    font-size: 11px;}

  .calendar-selected-meta .text-button {
    min-height: 40px;
    font-size:11px;}

  .calendar-selected-day-list {
    gap: 8px;
    max-height: min(68vh, 650px);
    padding-top: 12px;
    overflow-y: auto;}

  .calendar-selected-appointment {
    grid-template-columns: var(--clinic-time-track) minmax(0, 1fr) 9px 29px;
    gap: 8px;
    padding: 9px 8px;
    border-color: var(--crm-line) !important;
    border-left: 4px solid var(--doctor-color, var(--crm-teal)) !important;
    border-radius: 10px;
    background: var(--crm-surface-raised) !important;
    box-shadow: var(--crm-shadow-xs);}

  .calendar-selected-time > strong {
    color: var(--crm-primary-strong) !important;
    font-size:14px;
    font-variant-numeric: tabular-nums;}

  .calendar-selected-status {
    font-size: 11px;}

  .calendar-selected-patient {
    overflow: hidden;
    color: var(--crm-ink) !important;
    font-size:14px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;}

  .calendar-selected-reason {
    overflow: hidden;
    color: var(--crm-copy) !important;
    font-size:11px;
    text-overflow: ellipsis;
    white-space: nowrap;}

  .calendar-selected-doctor-dot {
    width: 8px;
    height: 8px;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--doctor-color, var(--crm-teal)) 16%, transparent);}

  .calendar-selected-edit {
    width: 29px;
    min-height: 29px;
    color: var(--crm-copy) !important;
    background: var(--crm-surface-soft) !important;}

  .calendar-selected-edit:hover {
    color: var(--crm-primary-strong) !important;
    background: var(--crm-brand-tint) !important;}

  /* Doctors, finance, records and documents */
  .doctor-grid {
    grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
    gap: 13px;}

  .doctor-card {
    padding: 19px;
    border: 1px solid var(--crm-line) !important;
    border-top: 4px solid var(--doctor-color, var(--crm-primary)) !important;
    border-radius: var(--crm-radius-lg);
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-sm);}

  .doctor-card h3,
  .doctor-card p,
  .doctor-contact {
    color: var(--crm-ink);}

  .doctor-card p,
  .doctor-contact {
    color: var(--crm-copy) !important;}

  .doctor-avatar {
    width: 44px;
    height: 44px;
    background: var(--doctor-color, var(--crm-primary));
    font-size: 14px;}

  .doctor-edit {
    border-color: var(--crm-line-strong);
    border-radius: 8px;
    color: var(--crm-primary-strong);
    background: var(--crm-surface);}

  .doctor-edit:hover,
  .google-button:hover {
    color: var(--crm-primary-strong);
    border-color: var(--crm-primary);
    background: var(--crm-brand-tint);}

  .finance-stats {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 10px;
    margin-bottom: 14px;}

  .finance-stats article {
    min-height: 98px;
    padding: 14px 15px;}

  .finance-stats span,
  .finance-stats small {
    color: var(--crm-copy) !important;
    font-size: 11px;}

  .finance-stats strong {
    margin: 6px 0 2px;
    color: var(--crm-ink) !important;
    font-size: 22px;
    font-variant-numeric: tabular-nums;}

  .finance-layout {
    grid-template-columns: minmax(0, 1fr) minmax(290px, 318px);
    gap: 13px;}

  .finance-search,
  .leave-search {
    padding: 10px 12px;
    border: 1px solid var(--crm-line);
    border-radius: 10px;
    background: var(--crm-surface-soft);}

  .finance-search input,
  .leave-search input {
    min-height: 38px;
    color: var(--crm-ink) !important;
    background: transparent;}

  .finance-filters {
    gap: 8px;}

  .finance-filters label,
  .cash-panel label {
    color: var(--crm-copy) !important;
    font-size: 11px;
    font-weight: 800;}

  .finance-filters select,
  .cash-panel select,
  .cash-panel input,
  .detail-toolbar select {
    min-height: 40px;
    border-color: var(--crm-line-strong) !important;
    border-radius: 9px;
    color: var(--crm-ink) !important;
    background: var(--crm-field) !important;
    font-size:14px;}

  .finance-plan {
    gap: 13px;
    padding: 14px 5px;
    border-color: var(--crm-line) !important;}

  .finance-plan:hover {
    background: var(--crm-surface-soft) !important;
    box-shadow: none;
    transform: none;}

  .finance-plan h3,
  .finance-plan strong {
    color: var(--crm-ink) !important;}

  .finance-plan p,
  .finance-plan small {
    color: var(--crm-copy) !important;}

  .cash-panel {
    padding: 18px;
    border: 1px solid var(--crm-line) !important;
    border-radius: var(--crm-radius-lg);
    color: var(--crm-ink);
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-sm);}

  .cash-panel h2,
  .cash-panel h3 {
    color: var(--crm-ink) !important;}

  .cash-panel-heading,
  .cash-day-heading {
    border-color: var(--crm-line);}

  .cash-range-label,
  .cash-day-row small,
  .cash-method small {
    color: var(--crm-copy) !important;}

  .cash-total {
    border-radius: 11px;
    background: var(--crm-navy) !important;}

  .cash-day-row {
    border-color: var(--crm-line);
    background: var(--crm-surface-soft);}

  .record-header {
    min-height: 120px;
    margin-bottom: 14px;
    padding: 21px 24px;
    border: 1px solid rgba(151, 228, 243, .24);
    border-radius: 18px;
    color: #ffffff;
    background: var(--crm-navy) !important;
    box-shadow: 0 16px 32px rgba(16, 46, 80, .17);}

  .record-header h2 {
    color: #ffffff !important;
    font-size: 23px;}

  .record-header p {
    color: #c8deea !important;
    font-size:14px;}

  .record-header .avatar-large {
    background: rgba(255,255,255,.13);}

  .record-number-badge {
    color: #d5edf6;
    border-color: rgba(255,255,255,.2);
    background: rgba(255,255,255,.08);}

  .record-tabs {
    gap: 3px;
    margin-bottom: 17px;
    padding: 4px;
    border: 1px solid var(--crm-line) !important;
    overflow-x: auto;}

  .record-tab {
    min-height: 40px;
    padding: 9px 12px;
    border: 0;
    border-radius: 9px;
    color: var(--crm-copy) !important;
    font-size:14px;
    font-weight: 800;}

  .record-tab:hover {
    color: var(--crm-primary-strong) !important;
    background: var(--crm-brand-tint) !important;}

  .record-tab.active {
    color: #ffffff !important;
    background: var(--crm-navy) !important;
    border-bottom: 0;
    box-shadow: var(--crm-shadow-xs);}

  .record-tab-panel > .section-actions {
    border-bottom: 1px solid var(--crm-line);}
  .record-treatment-plan-head h3 {
    color: var(--crm-ink) !important;}

  .clinical-alert {
    border-color: var(--crm-line);
    border-left-width: 4px;
    border-radius: 10px;
    background: var(--crm-surface);}

  .intake-form h3 {
    margin-top: 3px;
    color: var(--crm-primary-strong) !important;
    font-size: 16px;}

  .intake-form h3:not(:first-child) {
    margin-top: 24px;
    padding-top: 20px;
    border-top-color: var(--crm-line);}

  .intake-check-grid fieldset,
  .habits-fieldset,
  .minor-responsible-fields {
    border-color: var(--crm-line-strong) !important;
    border-radius: 11px;
    background: var(--crm-surface-soft);}

  .intake-check-grid legend,
  .minor-responsible-fields legend {
    color: var(--crm-ink) !important;}

  .intake-check-grid label,
  .standalone-label,
  .form-grid label,
  .color-picker legend {
    color: var(--crm-copy) !important;
    font-size:14px;
    font-weight: 800;}

  .form-grid input,
  .form-grid select,
  .form-grid textarea,
  .standalone-label textarea,
  .plan-item input,
  #confirm-prompt-input {
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--crm-line-strong) !important;
    border-radius: 9px;
    color: var(--crm-ink) !important;
    background: var(--crm-field) !important;
    font-size: 14px;}

  .form-grid textarea,
  .standalone-label textarea {
    min-height: 92px;}

  .form-grid input:focus,
  .form-grid select:focus,
  .form-grid textarea:focus,
  .standalone-label textarea:focus,
  .plan-item input:focus,
  #confirm-prompt-input:focus,
  .patient-search-row input:focus,
  .appointment-filters input:focus {
    border-color: var(--crm-focus) !important;
    background: var(--crm-surface) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--crm-focus) 13%, transparent) !important;
    outline: none;}

  .field-hint,
  .form-status {
    color: var(--crm-copy-soft) !important;
    font-size: 11px;}

  .form-error {
    color: var(--crm-danger) !important;
    font-size:14px;
    font-weight: 750;}

  .modal-actions {
    gap: 8px;
    padding-top: 15px;
    border-color: var(--crm-line);}

  .odontogram-panel {
    padding: 18px;}

  .odontogram-tools {
    gap: 18px 26px;
    padding-bottom: 18px;
    border-bottom-color: var(--crm-line);}

  .tool-label {
    color: var(--crm-copy) !important;
    font-size:11px;}

  .tooth-state,
  .scope-button {
    min-height: 38px;
    padding: 8px 11px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size:14px;}

  .tooth-state.active,
  .scope-button.active {
    border-color: var(--crm-navy);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--crm-primary) 20%, transparent);}

  .odontogram-general-notes {
    margin-top: 15px;
    padding: 13px;
    border: 1px solid var(--crm-line);
    border-radius: 11px;
    background: var(--crm-surface-soft);}

  .clinical-history-block {
    margin-top: 20px;
    padding-top: 18px;
    border-top-color: var(--crm-line);}

  /* Dialogs */
  dialog {
    width: min(700px, calc(100% - 32px));
    padding: 0;
    border: 1px solid var(--crm-line-strong) !important;
    border-radius: 16px;
    color: var(--crm-ink) !important;
    background: var(--crm-surface) !important;
    box-shadow: 0 28px 78px rgba(8, 28, 48, .24);}

  dialog.wide-dialog {
    width: min(900px, calc(100% - 32px));}

  dialog::backdrop {
    background: rgba(6, 24, 40, .58);
    backdrop-filter: blur(4px);}

  dialog form,
  .detail-shell,
  .install-help {
    max-height: min(90vh, 900px);
    overflow-y: auto;
    padding: 23px;}

  .modal-heading {
    margin-bottom: 17px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--crm-line);}

  .modal-heading h2 {
    margin: 0;
    color: var(--crm-ink) !important;
    font-size: 20px;}

  .close {
    width: 38px;
    height: 38px;
    min-height: 38px;
    border: 1px solid var(--crm-line-strong);
    border-radius: 9px;
    color: var(--crm-copy) !important;
    background: var(--crm-surface-soft) !important;}

  .close:hover {
    color: var(--crm-primary-strong) !important;
    border-color: var(--crm-primary);
    background: var(--crm-brand-tint) !important;}

  .color-options label {
    border-color: var(--crm-line-strong);
    border-radius: 9px;
    color: var(--crm-copy);
    background: var(--crm-surface-soft);}

  .color-options label:has(input:checked) {
    color: var(--crm-primary-strong);
    border-color: var(--crm-primary);
    background: var(--crm-brand-tint);}

  .detail-hero {
    border-radius: 13px;
    background: var(--crm-navy) !important;}

  .detail-hero h3,
  .detail-hero p {
    color: #ffffff !important;}

  .detail-toolbar {
    gap: 12px;
    border-color: var(--crm-line);}

  .payments-heading {
    color: var(--crm-ink) !important;}

  /* Login */
  .login-screen {
    background: var(--crm-canvas) !important;}

  .login-screen::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: min(38vw, 520px);
    border-right: 1px solid color-mix(in srgb, var(--crm-primary) 16%, transparent);
    background: linear-gradient(160deg, var(--crm-navy) 0%, var(--crm-navy-deep) 70%, transparent 70%);
    opacity: .96;
    pointer-events: none;}

  .login-card {
    position: relative;
    z-index: 1;
    width: min(430px, 100%);
    padding: 32px;
    border: 1px solid var(--crm-line-strong);
    border-top: 4px solid var(--crm-primary);
    border-radius: 17px;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-md);}

  .login-logo {
    width: 205px;
    height: 101px;
    margin: 0 auto 19px;
    overflow: hidden;
    border: 1px solid #e0e8ed;
    border-radius: 13px;
    background: #ffffff;}

  .login-logo img {
    position: static;
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    object-fit: cover;
    object-position: center;}

  .login-card h1 {
    color: var(--crm-ink) !important;
    font-size: 27px;}

  .login-card p,
  .login-card label,
  .login-help {
    color: var(--crm-copy) !important;}

  .login-card input {
    min-height: 45px;
    border-color: var(--crm-line-strong);
    color: var(--crm-ink);
    background: var(--crm-field);}

  .login-card button {
    min-height: 45px;}

  #toast {
    right: 22px;
    bottom: 22px;
    min-width: 220px;
    max-width: min(360px, calc(100vw - 32px));
    padding: 12px 15px;
    border: 1px solid color-mix(in srgb, var(--crm-primary) 30%, var(--crm-line-strong));
    border-radius: 11px;
    color: #ffffff;
    background: var(--crm-navy);
    box-shadow: var(--crm-shadow-md);
    font-size:14px;
    font-weight: 750;}

  /* Desktop calendar events: reserve the card width for clinical context; edit stays available as an overlay. */
  @media (min-width: 900px) {
    .calendar-event {
      grid-template-columns: minmax(0, 1fr);
      position: relative;}

    .calendar-event-edit {
      position: absolute;
      top: 2px;
      right: 2px;
      z-index: 1;
      width: 24px;
      min-width: 24px;
      min-height: 24px;
      margin-top: 0;
      padding: 0;
      font-size:14px;}}

  /* Desktop density steps */
  @media (min-width: 1440px) {
    main {
      padding-right: clamp(40px, 4.2vw, 86px);
      padding-left: clamp(40px, 4.2vw, 86px);}

    .agenda-workspace {
      grid-template-columns: 214px minmax(0, 1fr);}

    .calendar-event-patient {
      font-size:14px;}

    .calendar-event-reason {
      font-size:11px;}}

  @media (min-width: 1900px) {
    .agenda-workspace {
      grid-template-columns: 224px minmax(0, 1fr);}

    .calendar-month-layout {
      grid-template-columns: minmax(0, 1fr) 292px;}

    .calendar-month-day {
      min-height: 154px;}}

  @media (max-width: 1279px) and (min-width: 900px) {
    main {
      padding-right: 24px;
      padding-left: 24px;}

    .dashboard-grid {
      grid-template-columns: minmax(0, 1fr) 235px;}

    main:has(#appointments.active) .agenda-workspace {
      grid-template-columns: minmax(0, 1fr);}

    .agenda-workspace > .calendar-panel {
      grid-column: 1;
      grid-row: 1;}

    .agenda-workspace > .agenda-sidebar {
      grid-column: 1;
      grid-row: 2;}

    .calendar-month-layout {
      grid-template-columns: 1fr;}

    .calendar-selected-day {
      margin-top: 0;}

    .calendar-month-day {
      min-height: 130px;
      padding: 6px;}

    .calendar-month-day .calendar-event-patient {
      font-size:11px;}

    .finance-layout {
      grid-template-columns: minmax(0, 1fr) 286px;}

    .list-row {
      grid-template-columns: minmax(180px, 1.3fr) minmax(105px, .7fr) minmax(120px, .8fr) 100px auto;}

    .appointment-row {
      grid-template-columns: var(--clinic-time-track) minmax(0, 1fr) 124px auto;
      gap: 10px;}}

  /* Mobile drawer and one-column workspaces */
  @media (max-width: 899px) {
    .mobile-menu-button {
      display: grid;
      place-items: center;
      position: relative;
      width: 43px;
      height: 43px;
      flex: 0 0 auto;
      border: 1px solid var(--crm-line-strong);
      border-radius: 11px;
      background: var(--crm-surface) !important;
      box-shadow: var(--crm-shadow-xs);}

    .mobile-menu-button span {
      position: absolute;
      left: 50%;
      width: 18px;
      height: 2px;
      margin-left: -9px;
      border-radius: 2px;
      background: var(--crm-primary-strong);
      transition: transform .18s ease, opacity .18s ease, top .18s ease;}

    .mobile-menu-button span:nth-child(1) { top: 15px;}
    .mobile-menu-button span:nth-child(2) { top: 20px;}
    .mobile-menu-button span:nth-child(3) { top: 25px;}

    body.mobile-menu-open .mobile-menu-button {
      border-color: var(--crm-primary);
      background: var(--crm-primary) !important;}

    body.mobile-menu-open .mobile-menu-button span {
      background: #ffffff;}

    body.mobile-menu-open .mobile-menu-button span:nth-child(1) {
      top: 20px;
      transform: rotate(45deg);}

    body.mobile-menu-open .mobile-menu-button span:nth-child(2) {
      opacity: 0;}

    body.mobile-menu-open .mobile-menu-button span:nth-child(3) {
      top: 20px;
      transform: rotate(-45deg);}

    .mobile-menu-backdrop {
      position: fixed;
      inset: 0;
      z-index: 75;
      display: block;
      background: rgba(6, 22, 38, .62);
      backdrop-filter: blur(4px);
      opacity: 0;
      pointer-events: none;
      transition: opacity .18s ease;}

    .mobile-menu-backdrop[hidden] {
      display: none;}

    body.mobile-menu-open .mobile-menu-backdrop {
      opacity: 1;
      pointer-events: auto;}

    .sidebar {
      position: fixed;
      inset: 0 auto 0 0;
      width: min(310px, 86vw);
      padding: 18px 15px calc(18px + env(safe-area-inset-bottom));
      border-right: 1px solid var(--crm-line-strong);
      background: var(--crm-navy-deep);
      box-shadow: 18px 0 46px rgba(2, 13, 24, .33);
      transform: translateX(-105%);
      transition: transform .2s ease;}

    body.mobile-menu-open .sidebar {
      transform: translateX(0);}

    .sidebar-close {
      display: grid;
      place-items: center;
      position: absolute;
      top: 13px;
      right: 13px;
      width: 42px;
      height: 42px;
      border: 1px solid rgba(190, 225, 238, .2);
      border-radius: 10px;
      color: #bdd5e2;
      background: rgba(255,255,255,.07);}

    .brand {
      padding-bottom: 17px;}

    main {
      width: 100%;
      margin-left: 0;
      padding: 18px 17px calc(42px + env(safe-area-inset-bottom));}

    header {
      position: sticky;
      top: 0;
      z-index: 50;
      grid-template-columns: auto minmax(0, 1fr) auto;
      gap: 10px;
      min-height: 0;
      margin: -18px -17px 15px;
      padding: 13px 17px 11px;
      border-bottom: 1px solid var(--crm-line);
      background: color-mix(in srgb, var(--crm-canvas) 92%, transparent) !important;
      backdrop-filter: blur(14px);}

    header h1 {
      overflow-wrap: anywhere;
      font-size: 22px;}

    .eyebrow {
      margin-bottom: 4px;
      font-size:11px;}

    .header-meta {
      gap: 5px;}

    .header-meta .date,
    .header-meta .user-chip,
    .header-meta .install-button {
      display: none;}

    .theme-toggle,
    .logout-button {
      min-width: 42px;
      min-height: 42px;
      padding: 8px;}

    .theme-text,
    .logout-label {
      display: none;}

    .section-actions {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: start;
      gap: 12px;
      min-height: 0;
      padding-bottom: 14px;}

    .section-actions h2 {
      font-size: 21px;}

    .section-actions > .primary,
    .section-actions > .secondary {
      white-space: nowrap;}

    .welcome-mark {
      display: none;}

    .dashboard-grid {
      grid-template-columns: 1fr;}

    .appointment-filters {
      grid-template-columns: 1fr;
      align-items: stretch;}

    .appointment-filters > button {
      width: 100%;}

    .agenda-toolbar {
      display: grid;
      gap: 8px;}

    .agenda-view-switch {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));}

    .agenda-view-switch button {
      min-height: 43px;
      padding: 7px 4px;}

    .agenda-navigation {
      display: grid;
      grid-template-columns: 43px minmax(0, 1fr) 43px;
      grid-template-areas: "prev range next" "today today today";
      gap: 7px;}

    .agenda-navigation [data-agenda-shift="-1"] { grid-area: prev;}
    .agenda-navigation [data-agenda-shift="1"] { grid-area: next;}
    .agenda-navigation [data-agenda-shift] { min-height: 43px;}

    .agenda-navigation strong {
      grid-area: range;
      min-width: 0;
      font-size: 11px;}

    .agenda-navigation [data-agenda-today] {
      grid-area: today;
      justify-self: center;
      min-width: 100px;}

    .agenda-summary-strip {
      gap: 7px;}

    .agenda-summary-strip article {
      padding: 11px 8px;}

    .agenda-summary-strip article > span,
    .agenda-summary-strip article > small {
      overflow: hidden;
      font-size:11px;
      text-overflow: ellipsis;
      white-space: nowrap;}

    .agenda-summary-strip article > strong {
      font-size: 21px;}

    .agenda-workspace {
      display: flex;
      flex-direction: column;
      gap: 10px;}

    .agenda-sidebar {
      position: static;
      width: 100%;
      padding: 14px;}

    .agenda-selected-card {
      display: none;}

    .calendar-panel {
      overflow: visible;
      padding: 10px;}

    .calendar-weekdays {
      display: none;}

    .calendar-columns {
      display: grid;
      grid-template-columns: 1fr;
      gap: 9px;
      background: transparent;}

    .calendar-day {
      min-height: 0;
      padding: 12px;
      border: 1px solid var(--crm-line-strong);
      border-radius: 13px;
      background: var(--crm-surface) !important;}

    .calendar-day-mobile-heading {
      display: flex;
      align-items: baseline;
      gap: 8px;
      margin-bottom: 10px;
      padding-bottom: 9px;
      border-bottom: 1px solid var(--crm-line);
      color: var(--crm-copy);}

    .calendar-day-mobile-heading span {
      font-size: 11px;
      font-weight: 850;
}

    .calendar-day-mobile-heading strong {
      color: var(--crm-ink);
      font-size: 25px;
      line-height: 1;}

    .calendar-day-mobile-heading small {
      margin-left: auto;
      color: var(--crm-copy);
      font-size: 11px;}

    .calendar-day-mobile-heading.today strong,
    .calendar-day-mobile-heading.selected strong {
      color: var(--crm-primary-strong);}

    .calendar-event {
      grid-template-columns: minmax(0, 1fr) 41px;
      margin-bottom: 8px;
      border-left-width: 4px !important;}

    .calendar-event-main {
      padding: 11px;}

    .calendar-event-time {
      font-size:14px;}

    .calendar-event-patient {
      font-size: 14px;
      white-space: normal;}

    .calendar-event-reason {
      font-size:14px;
      white-space: normal;}

    .calendar-event-edit {
      width: 41px;
      min-width: 41px;
      min-height: 41px;
      margin-top: 5px;}

    .calendar-events-list {
      max-height: none;
      overflow: visible;}

    .calendar-month-layout {
      display: grid;
      grid-template-columns: 1fr;
      gap: 11px;}

    .calendar-month-grid {
      display: grid;
      grid-template-columns: repeat(7, minmax(0, 1fr));
      border-radius: 13px;}

    .calendar-month-heading {
      min-height: 39px;
      padding: 10px 2px;
      font-size:11px;}

    .calendar-month-day,
    .calendar-month-day.outside-month {
      min-height: 72px;
      padding: 4px 2px;
      opacity: 1;}

    .calendar-month-date {
      position: relative;
      display: grid;
      place-items: center;
      min-height: 56px;
      margin: 0;}

    .calendar-month-date span {
      display: none;}

    .calendar-month-date strong {
      width: 31px;
      height: 31px;
      font-size:14px;}

    .calendar-month-day .calendar-event,
    .calendar-month-day .calendar-empty,
    .calendar-month-day .calendar-event-edit {
      display: none;}

    .calendar-month-day .calendar-month-count {
      display: block;
      position: absolute;
      bottom: 1px;
      color: var(--crm-primary-strong);
      font-size:11px;
      font-weight: 850;}

    .calendar-month-day.has-events .calendar-month-date::after {
      content: "";
      position: absolute;
      bottom: 0;
      width: 5px;
      height: 5px;
      border-radius: 50%;
      background: var(--crm-primary);}

    .calendar-selected-day {
      padding: 14px;}

    .calendar-selected-day-list {
      max-height: none;
      overflow: visible;}

    .calendar-selected-appointment {
      grid-template-columns: var(--clinic-time-track) minmax(0, 1fr) 9px 40px;
      padding: 10px 9px;}

    .calendar-selected-edit {
      width: 40px;
      min-width: 40px;
      min-height: 40px;}

    .calendar-selected-patient {
      font-size:14px;}

    .calendar-selected-reason {
      font-size: 11px;}

    .list-row,
    .finance-plan,
    .leave-row,
    .record-leave,
    .user-row {
      display: grid;
      grid-template-columns: 1fr;
      gap: 9px;
      min-height: 0;
      margin-bottom: 9px;
      padding: 13px;
      border: 1px solid var(--crm-line-strong) !important;
      border-radius: 13px;
      background: var(--crm-surface) !important;
      box-shadow: var(--crm-shadow-xs);}

    .list-row > div,
    .finance-plan > div,
    .leave-row > div,
    .record-leave > div,
    .user-row > div {
      grid-column: auto !important;
      grid-row: auto !important;}

    .patient-row-actions,
    .finance-actions,
    .leave-actions,
    .record-leave-actions {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      width: 100%;
      gap: 7px;}

    .patient-row-actions button,
    .finance-actions button,
    .leave-actions button,
    .record-leave-actions button {
      width: 100%;
      min-height: 42px;}

    .appointment-row {
      grid-template-columns: var(--clinic-time-track) minmax(0, 1fr) auto;
      gap: 9px;
      align-items: center;}

    .appointment-row .appt-time-block {
      grid-column: 1;
      grid-row: 1;}

    .appointment-row .appt-main {
      grid-column: 2 / -1;
      grid-row: 1;}

    .appointment-row .appt-status {
      grid-column: 1 / 3;
      grid-row: 2;}

    .appointment-row .appt-actions {
      grid-column: 3;
      grid-row: 2;}

    .appointment-row .appt-status .appointment-status-select {
      width: 100%;
      min-height: 40px;}

    .appointment-row .appt-main strong {
      font-size: 14px;}

    .appointment-row .appt-main small {
      font-size:14px;}

    .record-header {
      grid-template-columns: auto minmax(0, 1fr);
      gap: 12px;
      min-height: 0;
      padding: 17px;}

    .record-header h2 {
      font-size: 20px;}

    .record-header p {
      overflow-wrap: anywhere;
      font-size:14px;}

    .record-tabs {
      gap: 4px;
      padding: 4px;}

    .record-tab {
      min-height: 42px;
      padding: 10px 11px;
      font-size:14px;}

    .intake-detail-grid {
      grid-template-columns: 1fr;}

    .odontogram-tools {
      padding: 14px;}

    .odontogram-lock-box {
      width: 100%;
      justify-content: space-between;
      margin-left: 0;}

    .odontogram-lock-box button {
      flex: 1;}

    .finance-stats {
      grid-template-columns: repeat(2, minmax(0, 1fr));}

    .finance-layout {
      grid-template-columns: 1fr;}

    .cash-panel {
      order: -1;}

    .cash-panel #cash-methods {
      grid-template-columns: 1fr 1fr;}

    .detail-hero {
      display: block;}

    .detail-amounts {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      margin-top: 15px;
      text-align: left;}

    dialog,
    dialog.wide-dialog {
      width: 100vw;
      max-width: 100vw;
      max-height: 100dvh;
      margin: 0;
      border-radius: 17px 17px 0 0;}

    dialog[open] {
      position: fixed;
      inset: auto 0 0;}

    dialog form,
    .detail-shell,
    .install-help {
      max-height: calc(100dvh - 10px);
      padding: 18px 16px calc(18px + env(safe-area-inset-bottom));}

    dialog .modal-heading {
      position: sticky;
      top: -18px;
      z-index: 2;
      margin: -18px -16px 16px;
      padding: 14px 16px;
      background: var(--crm-surface);}

    .modal-actions {
      position: sticky;
      bottom: calc(-18px - env(safe-area-inset-bottom));
      z-index: 2;
      margin: 16px -16px calc(-18px - env(safe-area-inset-bottom));
      padding: 12px 16px calc(18px + env(safe-area-inset-bottom));
      background: var(--crm-surface);}

    .modal-actions button {
      min-height: 45px;}

    .login-screen.show {
      display: grid;
      padding: 16px;}

    .login-screen::before {
      width: 100%;
      height: 145px;
      border-right: 0;
      border-bottom: 1px solid rgba(164, 226, 242, .2);
      background: var(--crm-navy);}

    .login-card {
      margin-top: 54px;
      padding: 26px 21px;}

    #toast {
      right: 16px;
      bottom: 16px;}}

  @media (max-width: 600px) {
    main {
      padding-right: 13px;
      padding-left: 13px;}

    header {
      margin-right: -13px;
      margin-left: -13px;
      padding-right: 13px;
      padding-left: 13px;}

    header h1 {
      font-size: 20px;}

    .section-actions {
      grid-template-columns: 1fr;
      gap: 10px;}

    .section-actions > button {
      justify-self: start;}

    .welcome-actions {
      display: grid;
      grid-template-columns: 1fr;}

    .welcome-actions button {
      width: 100%;}

    .stats,
    .finance-stats {
      grid-template-columns: 1fr;}

    .stats article:last-child {
      grid-column: auto;}

    .stats article,
    .finance-stats article {
      min-height: 0;
      padding: 15px;}

    .agenda-summary-strip article {
      padding: 10px 7px;}

    .agenda-summary-strip article > span,
    .agenda-summary-strip article > small {
      font-size: 11px;}

    .agenda-summary-strip article > strong {
      font-size: 19px;}

    .patient-row-actions,
    .finance-actions,
    .leave-actions,
    .record-leave-actions {
      grid-template-columns: 1fr;}

    .detail-amounts {
      grid-template-columns: 1fr;}

    .cash-panel #cash-methods {
      grid-template-columns: 1fr;}

    .finance-stats strong {
      font-size: 24px;}

    .calendar-month-heading {
      padding-right: 1px;
      padding-left: 1px;
      font-size: 11px;}

    .calendar-month-day,
    .calendar-month-day.outside-month {
      min-height: 64px;}

    .calendar-month-date {
      min-height: 51px;}

    .calendar-month-date strong {
      width: 28px;
      height: 28px;
      font-size:14px;}

    .calendar-selected-heading h3 {
      font-size: 16px;}

    .calendar-selected-appointment {
      grid-template-columns: var(--clinic-time-track) minmax(0, 1fr) 8px 32px;}

    .appointment-row {
      grid-template-columns: var(--clinic-time-track) minmax(0, 1fr) auto;}}

  @media (max-width: 380px) {
    main {
      padding-right: 10px;
      padding-left: 10px;}

    header {
      margin-right: -10px;
      margin-left: -10px;
      padding-right: 10px;
      padding-left: 10px;}

    .theme-toggle,
    .logout-button {
      min-width: 42px;
      min-height: 42px;
      padding-right: 7px;
      padding-left: 7px;}

    .sidebar {
      width: min(292px, 88vw);}

    .calendar-month-heading {
      font-size: 11px;}

    .calendar-month-day,
    .calendar-month-day.outside-month {
      min-height: 60px;}}

  @media (max-width: 899px) and (orientation: landscape) {
    main {
      padding-top: 14px;}

    header {
      margin-top: -14px;}

    .stats {
      grid-template-columns: repeat(3, minmax(0, 1fr));}

    .dashboard-grid {
      grid-template-columns: minmax(0, 1fr) 260px;}

    .calendar-columns {
      grid-template-columns: repeat(2, minmax(0, 1fr));}

    .calendar-day:nth-child(n+3) {
      display: block;}}

/*
 * Clínica Dental JH — capa de coherencia visual
 * Esta hoja se carga al final para reconciliar estilos históricos sin
 * modificar la lógica clínica ni los documentos de impresión.
 */
@media screen {
  :root {
    --polish-canvas: #eef5f8;
    --polish-surface: #ffffff;
    --polish-surface-soft: #f6fafc;
    --polish-field: #fbfdfe;
    --polish-ink: #102e50;
    --polish-copy: #4b6680;
    --polish-copy-soft: #586d84;
    --polish-line: #d5e3eb;
    --polish-line-strong: #bed3df;
    --polish-primary: #087ea9;
    --polish-primary-strong: #06698d;
    --polish-teal: #147e78;
    --polish-navy: #0b2947;
    --polish-navy-deep: #071e36;
    --polish-success: #17755f;
    --polish-warning: #9a641f;
    --polish-danger: #b33f48;
    --polish-brand-tint: #e6f4f9;
    --polish-shadow-xs: 0 1px 2px rgba(16, 46, 80, .045);
    --polish-shadow-sm: 0 7px 22px rgba(16, 46, 80, .075);
    --polish-shadow-md: 0 18px 44px rgba(16, 46, 80, .12);

    --crm-canvas: var(--polish-canvas);
    --crm-surface: var(--polish-surface);
    --crm-surface-raised: var(--polish-surface);
    --crm-surface-soft: var(--polish-surface-soft);
    --crm-field: var(--polish-field);
    --crm-ink: var(--polish-ink);
    --crm-copy: var(--polish-copy);
    --crm-copy-soft: var(--polish-copy-soft);
    --crm-line: var(--polish-line);
    --crm-line-strong: var(--polish-line-strong);
    --crm-primary: var(--polish-primary);
    --crm-primary-strong: var(--polish-primary-strong);
    --crm-teal: var(--polish-teal);
    --crm-navy: var(--polish-navy);
    --crm-navy-deep: var(--polish-navy-deep);
    --crm-success: var(--polish-success);
    --crm-warning: var(--polish-warning);
    --crm-danger: var(--polish-danger);
    --crm-brand-tint: var(--polish-brand-tint);
    --crm-shadow-xs: var(--polish-shadow-xs);
    --crm-shadow-sm: var(--polish-shadow-sm);
    --crm-shadow-md: var(--polish-shadow-md);}

  html {
    color-scheme: light;
    background: var(--polish-canvas);
    scrollbar-color: var(--polish-line-strong) transparent;}

  html[data-theme="dark"] {
    color-scheme: dark;
    --polish-canvas: #071624;
    --polish-surface: #0e253c;
    --polish-surface-soft: #112d46;
    --polish-field: #0a1e31;
    --polish-ink: #f2f8fc;
    --polish-copy: #c1d1de;
    --polish-copy-soft: #9eb6c8;
    --polish-line: #29475f;
    --polish-line-strong: #3b5d77;
    --polish-primary: #68cbe7;
    --polish-primary-strong: #91e0f2;
    --polish-teal: #58d2bc;
    --polish-navy: #0a1f34;
    --polish-navy-deep: #06121f;
    --polish-success: #7de0be;
    --polish-warning: #f2c57d;
    --polish-danger: #ff9da5;
    --polish-brand-tint: #143a55;
    --polish-shadow-xs: 0 1px 2px rgba(0, 0, 0, .26);
    --polish-shadow-sm: 0 8px 24px rgba(0, 0, 0, .23);
    --polish-shadow-md: 0 20px 48px rgba(0, 0, 0, .32);}

  * {
    scrollbar-width: thin;
    scrollbar-color: var(--polish-line-strong) transparent;}

  *::selection {
    color: #fff;
    background: var(--polish-primary);}

  body {
    min-width: 320px;
    color: var(--polish-ink) !important;
    background:
      radial-gradient(circle at 94% 0%, color-mix(in srgb, var(--polish-brand-tint) 65%, transparent), transparent 26rem),
      radial-gradient(circle at 2% 100%, color-mix(in srgb, var(--teal) 9%, transparent), transparent 30rem),
      var(--polish-canvas) !important;
    text-rendering: optimizeLegibility;}

  button,
  input,
  select,
  textarea {
    font: inherit;}

  button:not(:disabled),
  [role="button"]:not([aria-disabled="true"]) {
    cursor: pointer;
    touch-action: manipulation;}

  button:focus-visible,
  [role="button"]:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible,
  summary:focus-visible,
  a:focus-visible {
    outline: 3px solid var(--focus-ring) !important;
    outline-offset: 2px;}

  button,
  .nav-item,
  .primary,
  .secondary,
  .text-button,
  .icon-button,
  .record-tab,
  .agenda-view-switch button {
    transition:
      background-color .18s ease,
      border-color .18s ease,
      color .18s ease,
      box-shadow .18s ease,
      transform .18s ease;}

  input:disabled,
  select:disabled,
  textarea:disabled {
    cursor: not-allowed;
    opacity: .7;}

  form[data-submitting="true"] button:disabled {
    cursor: progress;}

  /* Application shell */
  .app-shell {
    background: transparent;}

  .sidebar {
    border-right: 1px solid color-mix(in srgb, var(--polish-line) 90%, transparent) !important;
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--polish-surface) 95%, var(--polish-brand-tint)), var(--polish-surface)) !important;
    box-shadow: 6px 0 24px rgba(16, 46, 80, .035);}

  html[data-theme="dark"] .sidebar {
    background:
      linear-gradient(180deg, #0d2840, #091c2e 88%) !important;
    border-right-color: #29475f !important;
    box-shadow: 8px 0 28px rgba(0, 0, 0, .14);}

  .brand {
    padding-bottom: 21px !important;
    border-bottom: 1px solid var(--polish-line) !important;}

  .brand small {
    color: var(--polish-copy) !important;
    font-size:11px !important;
    font-weight: 800 !important;
    letter-spacing: .15em;}

  .nav-label {
    margin-top: 22px !important;
    margin-bottom: 8px !important;
    color: var(--polish-copy-soft) !important;
    font-size:11px !important;
    font-weight: 850 !important;
    letter-spacing: .13em !important;}

  .nav-label-sub {
    margin-top: 24px !important;}

  .nav-item {
    min-height: 44px;
    margin: 2px 0;
    padding: 0 12px !important;
    border: 1px solid transparent !important;
    border-radius: 11px !important;
    color: var(--polish-copy) !important;
    font-size: 14px !important;
    font-weight: 730 !important;}

  .nav-item .nav-icon {
    color: var(--polish-primary) !important;
    background: color-mix(in srgb, var(--polish-brand-tint) 78%, transparent) !important;}

  .nav-item:hover,
  .nav-item:focus-visible {
    color: var(--polish-ink) !important;
    border-color: color-mix(in srgb, var(--polish-primary) 22%, var(--polish-line)) !important;
    background: color-mix(in srgb, var(--polish-brand-tint) 68%, var(--polish-surface)) !important;
    outline: none !important;}

  .nav-item:hover .nav-icon,
  .nav-item:focus-visible .nav-icon {
    color: var(--polish-primary-strong) !important;
    background: color-mix(in srgb, var(--polish-primary) 15%, var(--polish-surface)) !important;}

  .nav-item.active,
  .nav-item.active:hover {
    color: #fff !important;
    border-color: transparent !important;
    background: linear-gradient(135deg, var(--polish-primary), #2872b7) !important;
    box-shadow: 0 8px 18px color-mix(in srgb, var(--polish-primary) 24%, transparent);}

  .nav-item.active::before {
    width: 3px !important;
    border-radius: 0 4px 4px 0;
    background: #e5fbff !important;}

  .nav-item.active .nav-icon,
  .nav-item.active:hover .nav-icon {
    color: #fff !important;
    background: rgba(255, 255, 255, .17) !important;}

  html[data-theme="dark"] .nav-item {
    color: #c3d5e2 !important;}

  html[data-theme="dark"] .nav-item .nav-icon {
    color: #81d8ef !important;
    background: #133956 !important;}

  html[data-theme="dark"] .nav-item:hover,
  html[data-theme="dark"] .nav-item:focus-visible {
    color: #f3fbff !important;
    border-color: #345a76 !important;
    background: #14324c !important;}

  html[data-theme="dark"] .nav-item.active,
  html[data-theme="dark"] .nav-item.active:hover {
    color: #062035 !important;
    background: linear-gradient(135deg, #69cbe7, #54b8d7) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .2);}

  html[data-theme="dark"] .nav-item.active .nav-icon,
  html[data-theme="dark"] .nav-item.active:hover .nav-icon {
    color: #06314a !important;
    background: rgba(255, 255, 255, .35) !important;}

  main {
    max-width: none;}

  header {
    min-height: 80px;
    margin-bottom: 22px !important;
    padding: 14px 18px !important;
    border: 1px solid var(--polish-line) !important;
    border-radius: 17px !important;
    background: color-mix(in srgb, var(--polish-surface) 94%, var(--polish-brand-tint)) !important;
    box-shadow: var(--polish-shadow-xs);}

  header .eyebrow {
    margin-bottom: 2px !important;
    color: var(--polish-primary) !important;
    font-size: 11px !important;
    font-weight: 850 !important;
    letter-spacing: .13em !important;}

  html:not([data-theme="dark"]) header .eyebrow {
    color: #0b5f7f !important;}

  header h1 {
    color: var(--polish-ink) !important;
    font-size: clamp(21px, 1.7vw, 28px) !important;
    line-height: 1.13 !important;
    letter-spacing: -.035em;}

  .header-meta {
    gap: 9px !important;}

  .header-meta .date {
    color: var(--polish-copy) !important;
    font-size:14px !important;
    font-weight: 650;}

  .theme-toggle,
  .user-chip,
  .logout-button,
  .install-button {
    min-height: 39px;
    border-color: var(--polish-line-strong) !important;
    color: var(--polish-copy) !important;
    background: var(--polish-surface) !important;
    box-shadow: none !important;}

  .theme-toggle:hover,
  .user-chip:hover,
  .logout-button:hover,
  .install-button:hover {
    color: var(--polish-primary-strong) !important;
    border-color: var(--polish-primary) !important;
    background: var(--polish-brand-tint) !important;}

  .user-chip strong,
  .user-chip small {
    color: inherit !important;}

  .user-chip > span {
    color: var(--polish-primary-strong) !important;
    background: var(--polish-brand-tint) !important;}

  html[data-theme="dark"] header {
    background: color-mix(in srgb, var(--polish-surface) 95%, #163b57) !important;}

  html[data-theme="dark"] .theme-toggle,
  html[data-theme="dark"] .user-chip,
  html[data-theme="dark"] .logout-button,
  html[data-theme="dark"] .install-button {
    background: #0b2034 !important;}

  /* Shared hierarchy and surfaces */
  .section-actions {
    min-height: 88px;
    margin-bottom: 16px !important;
    padding: 17px 18px !important;
    border: 1px solid var(--polish-line) !important;
    border-radius: 16px !important;
    background:
      linear-gradient(100deg, color-mix(in srgb, var(--polish-brand-tint) 46%, var(--polish-surface)), var(--polish-surface) 48%) !important;
    box-shadow: var(--polish-shadow-xs);}

  .section-actions h2 {
    color: var(--polish-ink) !important;
    font-size: clamp(20px, 1.6vw, 25px) !important;
    line-height: 1.15 !important;
    letter-spacing: -.025em;}

  .section-actions p,
  .panel-heading p,
  .record-header p,
  .doctor-card p {
    color: var(--polish-copy) !important;}

  .section-kicker,
  .label,
  .eyebrow {
    color: var(--polish-primary) !important;
    font-size:11px !important;
    font-weight: 850 !important;
    letter-spacing: .13em !important;}

  .panel,
  .doctor-card,
  .agenda-sidebar,
  .calendar-selected-day,
  .record-header,
  .record-tabs,
  .clinical-record,
  .patient-record,
  .cash-panel,
  .finance-panel,
  .stats-card,
  .empty,
  .setup-notice {
    border-color: var(--polish-line) !important;
    background: var(--polish-surface) !important;
    box-shadow: var(--polish-shadow-sm);}

  .panel,
  .doctor-card,
  .agenda-sidebar,
  .calendar-selected-day,
  .record-header,
  .record-tabs,
  .clinical-record,
  .patient-record,
  .cash-panel,
  .finance-panel,
  .stats-card {
    border-radius: 16px !important;}

  .panel-heading h2,
  .record-header h2,
  .patient-name,
  .doctor-card h3,
  .finance-panel h3 {
    color: var(--polish-ink) !important;
    letter-spacing: -.02em;}

  .panel-heading {
    padding-bottom: 13px !important;
    border-bottom-color: var(--polish-line) !important;}

  .text-button {
    min-height: 40px;
    color: var(--polish-primary-strong) !important;
    font-weight: 780 !important;}

  .text-button:hover {
    color: var(--polish-primary-strong) !important;
    background: var(--polish-brand-tint) !important;}

  .primary,
  .welcome-primary {
    min-height: 42px;
    border-color: var(--polish-primary) !important;
    color: #fff !important;
    background: var(--polish-primary) !important;
    box-shadow: 0 7px 14px color-mix(in srgb, var(--polish-primary) 19%, transparent);
    font-weight: 780 !important;}

  .primary:hover,
  .welcome-primary:hover {
    border-color: var(--polish-primary-strong) !important;
    background: var(--polish-primary-strong) !important;
    box-shadow: 0 10px 20px color-mix(in srgb, var(--polish-primary) 25%, transparent);
    transform: translateY(-1px);}

  html[data-theme="dark"] .primary,
  html[data-theme="dark"] .welcome-primary {
    color: #062036 !important;}

  .secondary,
  .welcome-secondary,
  .icon-button,
  .record-button,
  .close-button {
    min-height: 40px;
    border-color: var(--polish-line-strong) !important;
    color: var(--polish-ink) !important;
    background: var(--polish-surface) !important;
    font-weight: 720 !important;}

  .secondary:hover,
  .welcome-secondary:hover,
  .icon-button:hover,
  .record-button:hover,
  .close-button:hover {
    border-color: var(--polish-primary) !important;
    color: var(--polish-primary-strong) !important;
    background: var(--polish-brand-tint) !important;}

  button:disabled,
  [aria-disabled="true"] {
    cursor: not-allowed;
    opacity: .52;}

  /* Inputs, filters and compact controls */
  input,
  select,
  textarea {
    border-color: var(--polish-line-strong) !important;
    color: var(--polish-ink) !important;
    background: var(--polish-field) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);}

  input::placeholder,
  textarea::placeholder {
    color: var(--polish-copy-soft) !important;
    opacity: 1;}

  input:hover,
  select:hover,
  textarea:hover {
    border-color: color-mix(in srgb, var(--polish-primary) 52%, var(--polish-line-strong)) !important;}

  input:focus,
  select:focus,
  textarea:focus {
    border-color: var(--polish-primary) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--polish-primary) 16%, transparent) !important;}

  .search,
  .appointment-filters,
  .patient-search-box,
  .filter-bar,
  .agenda-toolbar {
    border-color: var(--polish-line) !important;
    background: var(--polish-surface) !important;
    box-shadow: var(--polish-shadow-xs);}

  .search label > span,
  .appointment-filters label > span,
  .filter-label,
  label > span {
    color: var(--polish-copy) !important;
    font-weight: 760 !important;}

  .agenda-view-switch {
    padding: 4px !important;
    border: 1px solid var(--polish-line) !important;
    border-radius: 12px !important;
    background: var(--polish-surface-soft) !important;}

  .agenda-view-switch button {
    min-height: 38px;
    padding: 0 17px !important;
    border-radius: 8px !important;
    color: var(--polish-copy) !important;
    font-weight: 780 !important;}

  .agenda-view-switch button:hover {
    color: var(--polish-primary-strong) !important;
    background: color-mix(in srgb, var(--polish-brand-tint) 72%, transparent) !important;}

  .agenda-view-switch button.active {
    color: #fff !important;
    background: var(--polish-primary) !important;
    box-shadow: 0 3px 8px color-mix(in srgb, var(--polish-primary) 25%, transparent);}

  html[data-theme="dark"] .agenda-view-switch button.active {
    color: #062036 !important;}

  .agenda-summary-strip {
    gap: 12px !important;
    margin-bottom: 14px !important;}

  .agenda-summary-strip article {
    min-height: 86px;
    padding: 14px 16px !important;
    border-color: var(--polish-line) !important;
    border-radius: 14px !important;
    background: var(--polish-surface) !important;
    box-shadow: var(--polish-shadow-xs);}

  .agenda-summary-strip article > span,
  .agenda-summary-strip article > small {
    color: var(--polish-copy) !important;}

  .agenda-summary-strip article > strong {
    color: var(--polish-ink) !important;
    font-size: 25px !important;}

  /* Agenda: the calendar is the primary work surface in week/month. */
  .agenda-workspace {
    gap: 16px !important;}

  .agenda-sidebar {
    padding: 16px !important;}

  .agenda-sidebar-heading strong,
  .agenda-selected-card > strong {
    color: var(--polish-ink) !important;}

  .agenda-doctor-legend,
  .agenda-selected-card {
    border-top-color: var(--polish-line) !important;}

  .agenda-doctor-item,
  .agenda-day-preview {
    border-bottom-color: var(--polish-line) !important;}

  .agenda-doctor-item strong,
  .agenda-day-preview strong {
    color: var(--polish-ink) !important;}

  .agenda-doctor-item small,
  .agenda-day-preview small,
  .agenda-selected-card > span {
    color: var(--polish-copy) !important;}

  .calendar-panel {
    padding: 16px !important;
    border-radius: 16px !important;}

  .calendar-grid,
  .calendar-month-grid {
    border-color: var(--polish-line-strong) !important;
    border-radius: 14px !important;
    background: var(--polish-line) !important;}

  .calendar-weekdays,
  .calendar-month-heading,
  .calendar-day-heading {
    background: var(--polish-surface-soft) !important;}

  .calendar-day-heading {
    min-height: 66px !important;
    padding: 11px 10px !important;}

  .calendar-day-heading strong {
    color: var(--polish-ink) !important;
    font-size: 20px !important;}

  .calendar-day {
    min-height: 440px !important;
    padding: 9px !important;
    background: var(--polish-surface) !important;}

  .calendar-event {
    border-color: var(--polish-line) !important;
    border-left-width: 4px !important;
    border-radius: 10px !important;
    background: var(--polish-surface) !important;
    box-shadow: var(--polish-shadow-xs);}

  .calendar-event:hover {
    border-color: color-mix(in srgb, var(--event-color, var(--polish-primary)) 48%, var(--polish-line)) !important;
    box-shadow: var(--polish-shadow-sm);}

  .calendar-event-main {
    padding: 9px 8px !important;}

  .calendar-event-time {
    color: var(--event-color, var(--polish-teal)) !important;
    font-size: 11px !important;}

  .calendar-event-patient {
    color: var(--polish-ink) !important;
    font-size:14px !important;}

  .calendar-event-reason {
    color: var(--polish-copy) !important;
    font-size: 11px !important;}

  .calendar-event-edit {
    color: var(--polish-copy-soft) !important;
    border-radius: 7px !important;}

  .calendar-event-edit:hover {
    color: var(--polish-primary-strong) !important;
    background: var(--polish-brand-tint) !important;}

  .calendar-empty {
    color: var(--polish-copy-soft) !important;
    font-size:14px !important;}

  .calendar-month-layout {
    gap: 16px !important;}

  .calendar-month-heading {
    padding: 12px 8px !important;
    color: var(--polish-copy) !important;
    font-size: 11px !important;}

  .calendar-month-day {
    min-height: 154px !important;
    padding: 8px !important;
    border-color: var(--polish-line) !important;
    background: var(--polish-surface) !important;}

  .calendar-month-day.outside-month {
    background: var(--polish-surface-soft) !important;}

  .calendar-month-day.selected {
    background: color-mix(in srgb, var(--polish-surface) 89%, var(--polish-primary) 11%) !important;}

  .calendar-month-date {
    margin-bottom: 7px !important;}

  .calendar-month-date strong {
    color: var(--polish-ink) !important;}

  .calendar-month-day .calendar-event-main {
    padding: 7px !important;}

  .calendar-selected-day {
    padding: 17px !important;}

  .calendar-selected-heading,
  .calendar-selected-appointment {
    border-color: var(--polish-line) !important;}

  .calendar-selected-heading h3,
  .calendar-selected-appointment strong {
    color: var(--polish-ink) !important;}

  .calendar-selected-appointment span,
  .calendar-selected-meta {
    color: var(--polish-copy) !important;}

  /* Lists, records and finance */
  .list-row,
  .appointment-row,
  .timeline-item,
  .payment-row,
  .plan-row,
  .clinical-history-entry,
  .patient-result,
  .appointment-card {
    border-color: var(--polish-line) !important;}

  .list-row:hover,
  .appointment-row:hover,
  .patient-result:hover,
  .appointment-card:hover {
    background: color-mix(in srgb, var(--polish-brand-tint) 36%, var(--polish-surface)) !important;}

  .list-row strong,
  .appointment-row strong,
  .patient-result strong,
  .payment-row strong,
  .plan-row strong,
  .treatment-plan-title {
    color: var(--polish-ink) !important;}

  .list-row small,
  .appointment-row small,
  .patient-result small,
  .payment-row small,
  .plan-row small,
  .muted {
    color: var(--polish-copy) !important;}

  .record-tabs {
    gap: 5px !important;
    padding: 6px !important;
    background: var(--polish-surface-soft) !important;}

  .record-tab {
    min-height: 39px;
    color: var(--polish-copy) !important;
    font-weight: 740 !important;}

  .record-tab:hover {
    color: var(--polish-primary-strong) !important;
    background: var(--polish-surface) !important;}

  .record-tab.active {
    color: var(--polish-primary-strong) !important;
    background: var(--polish-surface) !important;
    box-shadow: var(--polish-shadow-xs);}

  .record-number-badge,
  .status-badge,
  .doctor-status,
  .tag,
  .chip {
    border-color: color-mix(in srgb, var(--polish-primary) 24%, var(--polish-line)) !important;}

  .finance-stats article,
  .finance-mini-strip{
    border-color: var(--polish-line) !important;
    background: var(--polish-surface) !important;
    box-shadow: var(--polish-shadow-sm);}

  .finance-stats article:hover{
    border-color: color-mix(in srgb, var(--polish-primary) 36%, var(--polish-line)) !important;
    box-shadow: var(--polish-shadow-md);
    transform: translateY(-2px);}

  .finance-stats strong,
  .finance-mini-item strong {
    color: var(--polish-ink) !important;}

  .finance-stats span,
  .finance-stats small,
  .finance-mini-item small {
    color: var(--polish-copy) !important;}

  /* Clinical tools and status controls */
  .odontogram-card,
  .tooth-panel,
  .clinical-panel,
  .intake-section,
  .prescription-card,
  .consent-card,
  .treatment-plan-card {
    border-color: var(--polish-line) !important;
    background: var(--polish-surface) !important;}

  .odontogram-toolbar,
  .odontogram-legend,
  .treatment-plan-summary,
  .clinical-toolbar {
    border-color: var(--polish-line) !important;
    background: var(--polish-surface-soft) !important;}

  .tooth-tool,
  .clinical-tool,
  .odontogram-toggle,
  .dentition-toggle button {
    border-color: var(--polish-line-strong) !important;
    color: var(--polish-copy) !important;
    background: var(--polish-surface) !important;}

  .tooth-tool:hover,
  .clinical-tool:hover,
  .odontogram-toggle:hover,
  .dentition-toggle button:hover {
    color: var(--polish-primary-strong) !important;
    background: var(--polish-brand-tint) !important;}

  .tooth-tool.active,
  .clinical-tool.active,
  .odontogram-toggle.active,
  .dentition-toggle button.active {
    border-color: var(--polish-primary) !important;
    color: #fff !important;
    background: var(--polish-primary) !important;}

  html[data-theme="dark"] .tooth-tool.active,
  html[data-theme="dark"] .clinical-tool.active,
  html[data-theme="dark"] .odontogram-toggle.active,
  html[data-theme="dark"] .dentition-toggle button.active {
    color: #062036 !important;}

  /* Dialogs and feedback */
  dialog {
    max-width: min(720px, calc(100vw - 28px));
    border-color: var(--polish-line) !important;
    border-radius: 18px !important;
    color: var(--polish-ink) !important;
    background: var(--polish-surface) !important;
    box-shadow: var(--polish-shadow-md);}

  dialog::backdrop {
    background: rgba(5, 21, 36, .56);
    backdrop-filter: blur(3px);}

  dialog h2,
  dialog h3,
  .modal-header h2 {
    color: var(--polish-ink) !important;}

  dialog p,
  dialog small,
  .modal-header p {
    color: var(--polish-copy) !important;}

  .form-error {
    color: var(--polish-danger) !important;}

  .empty,
  .calendar-selected-empty {
    color: var(--polish-copy) !important;
    background: var(--polish-surface-soft) !important;}

  .empty::before {
    color: var(--polish-primary) !important;
    background: var(--polish-brand-tint) !important;}

  #toast {
    border-color: color-mix(in srgb, var(--polish-primary) 35%, var(--polish-line)) !important;
    color: #f8fcff !important;
    background: var(--polish-navy) !important;
    box-shadow: var(--polish-shadow-md);}

  /* Wide screens reserve reading width, but give the calendar its needed room. */
  @media (min-width: 900px) {
    #appointments[data-agenda-layout="week"] .agenda-workspace,
    #appointments[data-agenda-layout="month"] .agenda-workspace {
      grid-template-columns: minmax(0, 1fr) !important;}

    #appointments[data-agenda-layout="week"] .agenda-sidebar,
    #appointments[data-agenda-layout="month"] .agenda-sidebar {
      display: none !important;}

    #appointments[data-agenda-layout="week"] .calendar-panel,
    #appointments[data-agenda-layout="month"] .calendar-panel {
      grid-column: 1;
      grid-row: 1;
      width: 100%;}

    #appointments[data-agenda-layout="week"] .calendar-day {
      min-height: 500px !important;}

    #appointments[data-agenda-layout="month"] .calendar-month-layout {
      grid-template-columns: minmax(0, 1fr) 224px !important;}

    #appointments[data-agenda-layout="month"] .calendar-selected-day {
      position: sticky;
      top: 18px;}}

  @media (min-width: 1280px) {
    main {
      padding-right: clamp(30px, 3.3vw, 68px) !important;
      padding-left: clamp(30px, 3.3vw, 68px) !important;}

    #appointments[data-agenda-layout="month"] .calendar-month-layout {
      grid-template-columns: minmax(0, 1fr) 214px !important;}

    #appointments[data-agenda-layout="month"] .calendar-month-day {
      min-height: 170px !important;}}

  @media (min-width: 1720px) {
    main {
      padding-right: clamp(42px, 4.4vw, 104px) !important;
      padding-left: clamp(42px, 4.4vw, 104px) !important;}

    #appointments[data-agenda-layout="month"] .calendar-month-layout {
      grid-template-columns: minmax(0, 1fr) 244px !important;}

    #appointments[data-agenda-layout="month"] .calendar-month-day {
      min-height: 184px !important;}}

  @media (max-width: 1279px) and (min-width: 900px) {
    header .date,
    .user-chip small {
      display: none;}

    .section-actions {
      min-height: 82px;}

    #appointments[data-agenda-layout="month"] .calendar-month-layout {
      grid-template-columns: minmax(0, 1fr) !important;}

    #appointments[data-agenda-layout="month"] .calendar-selected-day {
      position: static;}}

  @media (max-width: 899px) {
    body {
      background: var(--polish-canvas) !important;}

    header {
      min-height: 62px;
      margin-bottom: 14px !important;
      padding: 10px 12px !important;
      border-radius: 13px !important;}

    header h1 {
      font-size: 20px !important;}

    header .eyebrow,
    .header-meta .date,
    .user-chip > div,
    .logout-label {
      display: none !important;}

    .header-meta {
      gap: 6px !important;}

    .theme-toggle,
    .user-chip,
    .logout-button {
      min-width: 39px;
      min-height: 39px;
      padding: 0 9px !important;}

    .section-actions {
      min-height: auto;
      gap: 12px;
      margin-bottom: 12px !important;
      padding: 15px !important;
      border-radius: 14px !important;}

    .section-actions h2 {
      font-size: 20px !important;}

    .section-actions p {
      margin-top: 4px !important;
      font-size:14px !important;
      line-height: 1.4;}

    .section-actions .primary {
      width: 100%;}

    .agenda-toolbar,
    .search,
    .appointment-filters,
    .patient-search-box {
      border-radius: 14px !important;}

    .agenda-view-switch {
      width: 100%;}

    .agenda-view-switch button {
      flex: 1 1 0;
      padding: 0 8px !important;}

    .agenda-navigation {
      width: 100%;
      justify-content: space-between;}

    .agenda-summary-strip {
      grid-template-columns: 1fr !important;
      gap: 8px !important;}

    .agenda-summary-strip article {
      min-height: 72px;}

    .agenda-sidebar,
    .calendar-panel,
    .calendar-selected-day,
    .panel,
    .record-tabs {
      border-radius: 14px !important;}

    .calendar-panel {
      padding: 10px !important;}

    .calendar-day {
      min-height: 0 !important;
      padding: 9px !important;}

    .calendar-event-main {
      padding: 9px !important;}

    .calendar-event-patient {
      font-size:14px !important;}

    .calendar-event-reason {
      font-size:14px !important;}

    .calendar-month-day {
      min-height: 0 !important;}

    dialog {
      width: min(100% - 20px, 680px);
      max-width: none;
      border-radius: 16px !important;}}

  @media (max-width: 430px) {
    .section-actions {
      align-items: stretch;}

    .primary,
    .secondary,
    .welcome-primary,
    .welcome-secondary {
      min-height: 44px;}

    .record-tabs {
      gap: 4px !important;}

    .record-tab {
      min-height: 40px;
      font-size:14px !important;}}

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


@media screen {
  /* In Mes, the day drawer keeps the calendar compact while each appointment
     still has a full readable patient and procedure line. */
  #appointments[data-agenda-layout="month"] .calendar-selected-appointment {
    position: relative;
    grid-template-columns: minmax(0, 1fr) 40px;
    grid-template-areas:
      "time edit"
      "main main";
    gap: 4px 7px;
    padding: 8px 7px;}

  #appointments[data-agenda-layout="month"] .calendar-selected-time {
    grid-area: time;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;}

  #appointments[data-agenda-layout="month"] .calendar-selected-time > strong {
    font-size: 11px;}

  #appointments[data-agenda-layout="month"] .calendar-selected-status {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;}

  #appointments[data-agenda-layout="month"] .calendar-selected-main {
    grid-area: main;
    min-width: 0;}

  #appointments[data-agenda-layout="month"] .calendar-selected-patient {
    font-size:14px;}

  #appointments[data-agenda-layout="month"] .calendar-selected-reason {
    font-size:11px;}

  #appointments[data-agenda-layout="month"] .calendar-selected-doctor-dot {
    position: absolute;
    top: 14px;
    right: 54px;}

  #appointments[data-agenda-layout="month"] .calendar-selected-edit {
    grid-area: edit;
    width: 40px;
    min-height: 40px;}}


@media screen and (max-width: 899px) {
  /* Week and Month already have their own date navigation. Hiding the duplicate
     sidebar lets the actual schedule begin much earlier on a phone. */
  #appointments[data-agenda-layout="week"] .agenda-sidebar,
  #appointments[data-agenda-layout="month"] .agenda-sidebar {
    display: none !important;}}


@media screen and (min-width: 360px) and (max-width: 899px) {
  #appointments .agenda-summary-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 7px !important;}

  #appointments .agenda-summary-strip article {
    min-height: 83px;
    padding: 11px 10px !important;}

  #appointments .agenda-summary-strip article > span,
  #appointments .agenda-summary-strip article > small {
    font-size:11px !important;
    line-height: 1.2;}

  #appointments .agenda-summary-strip article > strong {
    margin-top: 5px;
    font-size: 23px !important;}}


@media screen {
  /* Ajuste de interaccion para Agenda, menus y selector de tema. */
  .theme-toggle {
    position: relative;
    isolation: isolate;
    min-height: 44px !important;
    gap: 8px !important;
    padding: 5px 11px 5px 6px !important;
    overflow: hidden;
    border-radius: 13px !important;
    color: var(--polish-copy) !important;
    background: var(--polish-surface) !important;
    box-shadow: var(--polish-shadow-xs) !important;}

  .theme-toggle::before {
    position: absolute;
    z-index: -1;
    top: 50%;
    left: 18px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    content: "";
    background: radial-gradient(circle, color-mix(in srgb, var(--polish-primary) 23%, transparent), transparent 68%);
    opacity: 0;
    transform: translate(-50%, -50%) scale(.55);
    transition: opacity .2s ease, transform .18s cubic-bezier(.2, .8, .2, 1);}

  .theme-toggle:hover,
  .theme-toggle:focus-visible {
    color: var(--polish-primary-strong) !important;
    border-color: var(--polish-primary) !important;
    background: color-mix(in srgb, var(--polish-brand-tint) 56%, var(--polish-surface)) !important;
    box-shadow: 0 8px 18px color-mix(in srgb, var(--polish-primary) 13%, transparent) !important;}

  .theme-toggle:hover::before,
  .theme-toggle:focus-visible::before {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);}

  .theme-toggle:active { transform: scale(.97);}

  .theme-icon {
    position: relative;
    display: grid !important;
    width: 30px !important;
    height: 30px !important;
    flex: 0 0 30px;
    place-items: center;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--polish-primary) 28%, transparent);
    border-radius: 10px !important;
    color: #fff !important;
    background: linear-gradient(145deg, var(--polish-primary-strong), var(--polish-primary)) !important;
    box-shadow: 0 5px 12px color-mix(in srgb, var(--polish-primary) 28%, transparent);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1), box-shadow .28s ease, background .28s ease;}

  .theme-icon::after {
    position: absolute;
    top: 4px;
    right: 6px;
    width: 9px;
    height: 4px;
    border-radius: 999px;
    content: "";
    background: rgba(255, 255, 255, .48);
    filter: blur(1px);
    transform: rotate(-28deg);}

  .theme-icon svg {
    position: relative;
    z-index: 1;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;}

  .theme-toggle:hover .theme-icon,
  .theme-toggle:focus-visible .theme-icon {
    transform: rotate(14deg) scale(1.08);
    box-shadow: 0 8px 17px color-mix(in srgb, var(--polish-primary) 37%, transparent);}

  .theme-icon[data-mode="day"] {
    color: #183b5c !important;
    background: linear-gradient(145deg, #f7d77b, #f4ad42) !important;
    animation: theme-sun-arrive .34s cubic-bezier(.2, .8, .2, 1);}

  html[data-theme="dark"] .theme-toggle {
    color: var(--polish-copy) !important;
    background: color-mix(in srgb, var(--polish-surface) 84%, #071a2b) !important;}

  html[data-theme="dark"] .theme-toggle:hover,
  html[data-theme="dark"] .theme-toggle:focus-visible {
    color: var(--polish-primary-strong) !important;
    background: color-mix(in srgb, var(--polish-brand-tint) 65%, var(--polish-surface)) !important;}

  html[data-theme="dark"] .theme-icon[data-mode="night"] {
    color: #d9f4ff !important;
    background: linear-gradient(145deg, #256a9a, #173d70) !important;}

  .theme-icon[data-mode="night"] { animation: theme-moon-arrive .34s cubic-bezier(.2, .8, .2, 1);}

  @keyframes theme-sun-arrive {
    from { opacity: .15; transform: rotate(-34deg) scale(.72);}
    to { opacity: 1; transform: rotate(0) scale(1);}}

  @keyframes theme-moon-arrive {
    from { opacity: .15; transform: rotate(28deg) scale(.72);}
    to { opacity: 1; transform: rotate(0) scale(1);}}

  .payment-general-option {
    display: grid !important;
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: start !important;
    gap: 10px !important;
    padding: 12px 13px !important;
    border-style: solid !important;
    border-color: var(--polish-line) !important;
    border-radius: 12px !important;
    color: var(--polish-ink) !important;
    background: var(--polish-surface-soft) !important;
    transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;}

  .payment-general-option > input {
    grid-column: 1;
    grid-row: 1;
    width: 19px !important;
    height: 19px;
    margin: 2px 0 0 !important;
    accent-color: var(--polish-primary);}

  .payment-general-copy {
    display: grid;
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    gap: 3px;}

  .payment-general-copy strong {
    color: var(--polish-ink) !important;
    font-size: 14px;
    line-height: 1.25;}

  .payment-general-copy .field-hint {
    margin: 0 !important;
    color: var(--polish-copy) !important;
    font-size:14px !important;
    line-height: 1.38;}

  .payment-general-option:hover,
  .payment-general-option:focus-within {
    border-color: var(--polish-primary) !important;
    background: color-mix(in srgb, var(--polish-brand-tint) 48%, var(--polish-surface)) !important;}

  .payment-general-option:has(input:checked) {
    border-color: var(--polish-primary) !important;
    background: color-mix(in srgb, var(--polish-brand-tint) 75%, var(--polish-surface)) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--polish-primary) 28%, transparent);}

  html[data-theme="dark"] .payment-general-option {
    border-color: var(--polish-line-strong) !important;
    background: color-mix(in srgb, var(--polish-surface-soft) 85%, #06192b) !important;}

  .appointment-menu summary {
    display: grid !important;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    place-items: center;
    list-style: none;
    border: 1px solid var(--polish-line) !important;
    border-radius: 11px !important;
    color: var(--polish-copy) !important;
    background: var(--polish-surface-soft) !important;
    box-shadow: none !important;
    transition: color .18s ease, border-color .18s ease, background-color .18s ease, transform .18s ease;}

  .appointment-menu summary::-webkit-details-marker { display: none;}

  .appointment-menu summary::after {
    display: block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    content: "" !important;
    background: currentColor;
    box-shadow: 0 -6px currentColor, 0 6px currentColor;}

  .appointment-menu summary:hover,
  .appointment-menu[open] summary,
  .appointment-menu summary:focus-visible {
    color: var(--polish-primary-strong) !important;
    border-color: var(--polish-primary) !important;
    background: color-mix(in srgb, var(--polish-brand-tint) 70%, var(--polish-surface)) !important;}

  .appointment-menu[open] summary { transform: rotate(90deg);}

  .appointment-menu-popover {
    overflow: hidden;
    min-width: 228px !important;
    padding: 6px !important;
    border: 1px solid var(--polish-line-strong) !important;
    border-radius: 14px !important;
    color: var(--polish-ink) !important;
    background: var(--polish-surface) !important;
    box-shadow: var(--polish-shadow-md) !important;}

  .appointment-menu-popover button {
    min-height: 40px;
    padding: 9px 10px !important;
    border-radius: 9px;
    color: var(--polish-copy) !important;
    font-weight: 720 !important;}

  .appointment-menu-popover button > span {
    color: var(--polish-primary-strong) !important;
    background: var(--polish-brand-tint) !important;}

  .appointment-menu-popover button:hover,
  .appointment-menu-popover button:focus-visible {
    color: var(--polish-primary-strong) !important;
    background: var(--polish-surface-soft) !important;}

  .appointment-menu-popover .menu-separator {
    margin: 5px 2px !important;
    background: var(--polish-line) !important;}

  .appointment-menu-popover button.warning { color: var(--polish-warning) !important;}

  .appointment-menu-popover button.danger,
  .appointment-menu-popover button.delete { color: var(--polish-danger) !important;}

  html[data-theme="dark"] .appointment-menu summary {
    color: var(--polish-copy) !important;
    border-color: var(--polish-line-strong) !important;
    background: var(--polish-surface-soft) !important;}

  html[data-theme="dark"] .appointment-menu-popover {
    border-color: var(--polish-line-strong) !important;
    background: #0a1e31 !important;}

  html[data-theme="dark"] .appointment-menu-popover button:hover,
  html[data-theme="dark"] .appointment-menu-popover button:focus-visible {
    background: var(--polish-brand-tint) !important;}

  .record-tabs {
    border: 1px solid var(--polish-line) !important;
    border-radius: 14px !important;
    background: var(--polish-surface-soft) !important;}

  .record-tab {
    border: 1px solid transparent !important;
    border-radius: 9px !important;}

  .record-tab:hover,
  .record-tab:focus-visible {
    color: var(--polish-primary-strong) !important;
    border-color: var(--polish-line) !important;
    background: var(--polish-surface) !important;}

  .record-tab.active {
    border-color: color-mix(in srgb, var(--polish-primary) 33%, var(--polish-line)) !important;
    box-shadow: var(--polish-shadow-xs) !important;}

  html[data-theme="dark"] select { color-scheme: dark;}

  html[data-theme="dark"] select option,
  html[data-theme="dark"] select optgroup {
    color: var(--polish-ink);
    background: #0e253c;}

  .calendar-event-main[data-agenda-open-record],
  .calendar-selected-main[data-agenda-open-record],
  .agenda-day-preview[data-agenda-open-record] {
    position: relative;}

  .calendar-event-main[data-agenda-open-record]:hover,
  .calendar-event-main[data-agenda-open-record]:focus-visible,
  .agenda-day-preview[data-agenda-open-record]:hover,
  .agenda-day-preview[data-agenda-open-record]:focus-visible {
    background: color-mix(in srgb, var(--polish-brand-tint) 60%, var(--polish-surface)) !important;}

  .calendar-event-main[data-agenda-open-record]:hover .calendar-event-patient,
  .calendar-event-main[data-agenda-open-record]:focus-visible .calendar-event-patient,
  .agenda-day-preview[data-agenda-open-record]:hover strong,
  .agenda-day-preview[data-agenda-open-record]:focus-visible strong {
    color: var(--polish-primary-strong) !important;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;}

  .calendar-selected-main[data-agenda-open-record]::after {
    display: inline-block;
    width: max-content;
    margin-top: 5px;
    padding: 3px 6px;
    border-radius: 999px;
    content: "Abrir expediente";
    color: var(--polish-primary-strong);
    background: var(--polish-brand-tint);
    font-size:11px;
    font-weight: 800;
    line-height: 1.2;}

  [data-agenda-open-record][aria-busy="true"] {
    cursor: progress !important;
    opacity: .68;}

  @media (max-width: 760px) {
    .appointment-menu summary {
      width: 100%;
      min-width: 0;
      justify-content: center;
      grid-template-columns: auto auto;
      gap: 8px;}

    .appointment-menu summary::after {
      width: auto;
      height: auto;
      border-radius: 0;
      content: "Opciones" !important;
      background: transparent;
      box-shadow: none;
      font-size:14px;
      font-weight: 800;}

    .appointment-menu[open] summary { transform: none;}

    .payment-general-option { padding: 11px 12px !important;}

    .calendar-selected-main[data-agenda-open-record]::after { margin-top: 4px;}}}


/* Correcciones finales de auditoría local */
@media screen {
  .menu-icon {
    display: inline-block;
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;}
  .appointment-menu summary .menu-icon { width: 18px; height: 18px;}
  .appointment-menu summary::after,
  .appointment-menu-popover button::before,
  .appointment-menu-popover button::after { content: none !important; display: none !important;}
  .appointment-menu-popover button { display: flex; align-items: center; gap: 9px;}
  .appointment-menu-popover button > span {
    display: contents;
    color: inherit !important;
    background: transparent !important;}
  .calendar-selected-main[data-agenda-open-record]::after { content: none !important; display: none !important;}
  .record-tab-panel[hidden] { display: none !important;}
  .upcoming-more { margin: 9px 0 0; color: var(--polish-primary-strong); font-size:14px; font-weight: 800;}
  .age-input-row { display: flex; align-items: center; gap: 8px; min-width: 0;}
  .age-input-row input { min-width: 0; flex: 1 1 auto;}
  .age-auto-button { min-height: 40px; padding: 0 10px; border: 1px solid var(--polish-line-strong); border-radius: 9px; color: var(--polish-primary-strong); background: var(--polish-brand-tint); font-size: 11px; font-weight: 800; white-space: nowrap; cursor: pointer;}
  .age-auto-button:hover, .age-auto-button:focus-visible { border-color: var(--polish-primary); background: var(--polish-surface);}
  .dashboard-grid, .finance-layout, .agenda-workspace, .calendar-month-layout, .calendar-event, .calendar-selected-appointment, .appointment-row, .list-row { min-width: 0;}
  .dashboard-grid { grid-template-columns: minmax(0, 1fr) minmax(220px, 280px) !important;}
  .finance-stats { grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));}
  .finance-plan > div { min-width: 0;}
  .finance-plan h3, .finance-plan p{ overflow-wrap: anywhere;}
  .finance-actions { flex-wrap: wrap; justify-content: flex-end;}
  .payment-general-option { gap: 8px !important; padding: 10px 12px !important;}
  .payment-general-copy { gap: 2px !important;}
  .payment-general-copy .field-hint { margin: 0 !important;}
  @media (min-width: 900px) and (max-width: 1439px) {
    #appointments[data-agenda-layout='week'] .agenda-sidebar,
    #appointments[data-agenda-layout='month'] .agenda-sidebar { display: none !important;}
    #appointments[data-agenda-layout='month'] .calendar-month-layout { grid-template-columns: minmax(0, 1fr) minmax(190px, 220px) !important;}
    #appointments[data-agenda-layout='month'] .calendar-month-day { min-height: 145px !important;}
    #appointments[data-agenda-layout='week'] .calendar-day { min-height: 330px !important;}}
  @media (min-width: 900px) and (max-width: 1199px) {
    #appointments[data-agenda-layout='week'] .calendar-event-main { padding: 7px 6px !important;}
    #appointments[data-agenda-layout='week'] .calendar-event-patient { font-size:11px !important;}
    #appointments[data-agenda-layout='week'] .calendar-event-reason { font-size:11px !important;}}
  @media (max-width: 1150px) {
    .finance-layout { display: block !important;}
    .cash-panel { margin-top: 16px;}
    .finance-plan { grid-template-columns: minmax(0, 1fr) auto !important;}
    .finance-plan > div:nth-child(2), .finance-plan > div:nth-child(3) { grid-column: 1;}}
  @media (max-width: 899px) {
    .dashboard-grid { grid-template-columns: 1fr !important;}
    .calendar-grid { border: 0 !important; background: transparent !important;}
    .calendar-weekdays { display: none !important;}
    .calendar-columns { display: grid !important; grid-template-columns: 1fr !important; gap: 10px;}
    .calendar-day { min-height: 0 !important; padding: 10px !important; border: 1px solid var(--polish-line) !important; border-radius: 13px !important;}
    .calendar-day-mobile-heading { display: grid !important;}
    .calendar-events-list { max-height: none !important; overflow: visible !important;}
    .calendar-event { grid-template-columns: minmax(0, 1fr) auto;}
    .calendar-event-main { min-width: 0;}
    .calendar-event-patient, .calendar-event-reason { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
    .calendar-event-edit { min-width: 36px; min-height: 36px;}}
  @media (max-width: 600px) {
    .finance-plan { grid-template-columns: 1fr !important;}
    .finance-plan > div:nth-child(2), .finance-plan > div:nth-child(3) { grid-column: auto;}
    .finance-plan > div:last-child { align-items: stretch;}
    .finance-actions { justify-content: stretch;}
    .finance-actions button { flex: 1 1 auto;}
    .age-input-row { align-items: stretch; flex-wrap: wrap;}
    .age-auto-button { flex: 1 1 100%;}}}
/* Estado dental: obturación en mal estado */
.tooth-state.obturacion-mal-estado { color:#fff; background:#8b5e3c; border-color:#8b5e3c;}
.surface.obturacion_mal_estado { fill:#8b5e3c;}
.tooth-diagram.whole-obturacion_mal_estado { color:#8b5e3c; outline:4px solid currentColor; outline-offset:2px;}
html[data-theme="dark"] .tooth-state.obturacion-mal-estado { color:#27180f; background:#c08a5a; border-color:#c08a5a;}
html[data-theme="dark"] .surface.obturacion_mal_estado { fill:#c08a5a;}
html[data-theme="dark"] .tooth-diagram.whole-obturacion_mal_estado { color:#c08a5a;}

/* Whole-tooth prostheses: fill the crown, not only its outline. */
.tooth-diagram.whole-corona { color:#dda913; background:#dda913;}
.tooth-diagram.whole-puente { color:#07819a; background:#07819a;}
.tooth-diagram.whole-corona .surface,
.tooth-diagram.whole-puente .surface { fill:currentColor !important;}
html[data-theme="dark"] .tooth-diagram.whole-corona { color:#e9bb32; background:#e9bb32;}
html[data-theme="dark"] .tooth-diagram.whole-puente { color:#39c0d2; background:#39c0d2;}
.scope-button:disabled { opacity:.5; cursor:not-allowed;}

/* Odontograma: selección inequívoca en temas claro y oscuro. */
.tooth-state, .scope-button { position:relative; isolation:isolate;}
.tooth-state.active {
  z-index:1; padding-right:36px; border-color:#fff !important;
  outline:3px solid var(--polish-navy); outline-offset:2px;
  box-shadow:0 7px 16px rgba(7,30,54,.2), inset 0 0 0 1px rgba(255,255,255,.72) !important;
  transform:translateY(-2px);}
.tooth-state.active::after {
  content:"✓"; position:absolute; top:50%; right:9px; display:grid;
  width:20px; height:20px; place-items:center; border-radius:50%;
  color:var(--polish-navy-deep); background:#fff; font-size:14px;
  font-weight:950; line-height:1; transform:translateY(-50%);
  box-shadow:0 1px 4px rgba(7,30,54,.24);}
.tooth-state:focus-visible, .scope-button:focus-visible {
  outline:3px solid var(--polish-primary); outline-offset:3px;}
.scope-options {
  display:inline-flex; padding:4px; gap:4px !important;
  border:1px solid var(--polish-line-strong); border-radius:14px;
  background:var(--polish-surface-soft);}
.scope-button {
  min-height:42px; border:1px solid transparent !important;
  border-radius:10px !important; padding:9px 14px !important;
  color:var(--polish-copy) !important; background:transparent !important;
  box-shadow:none !important;}
.scope-button.active {
  color:#fff !important; border-color:var(--polish-navy) !important;
  background:var(--polish-navy) !important;
  box-shadow:0 5px 12px rgba(7,30,54,.2) !important; transform:none;}
.scope-button.active::before { content:"✓"; margin-right:7px; font-weight:950;}
.scope-button:disabled { color:var(--polish-copy-soft) !important; opacity:.58;}
.odontogram-selection-summary {
  display:inline-flex; align-items:center; gap:10px; min-height:48px;
  margin:12px 0 2px; padding:8px 14px 8px 9px;
  border:1px solid var(--polish-line-strong); border-radius:12px;
  color:var(--polish-ink); background:var(--polish-brand-tint);}
.odontogram-selection-summary .selection-check {
  display:grid; width:30px; height:30px; flex:0 0 auto; place-items:center;
  border-radius:9px; color:#fff; background:var(--polish-primary-strong);
  font-weight:950;}
.odontogram-selection-summary > span:last-child { display:grid; gap:1px;}
.odontogram-selection-summary small {
  color:var(--polish-copy); font-size:11px; font-weight:750;
  letter-spacing:.04em; text-transform:uppercase;}
.odontogram-selection-summary strong { font-size:14px;}
html[data-theme="dark"] .tooth-state.active {
  border-color:#071e36 !important; outline-color:#8de4ff;
  box-shadow:0 0 0 1px rgba(141,228,255,.28), 0 7px 18px rgba(0,0,0,.38), inset 0 0 0 1px rgba(255,255,255,.28) !important;}
html[data-theme="dark"] .tooth-state.active::after { color:#06192b; background:#dff8ff;}
html[data-theme="dark"] .scope-options { border-color:#36516a; background:#0b2947;}
html[data-theme="dark"] .scope-button { color:#b9ccda !important;}
html[data-theme="dark"] .scope-button.active {
  color:#06192b !important; border-color:#8de4ff !important;
  background:#8de4ff !important;
  box-shadow:0 0 0 1px rgba(141,228,255,.26), 0 6px 14px rgba(0,0,0,.36) !important;}
html[data-theme="dark"] .odontogram-selection-summary {
  border-color:#36516a; color:#f2f8fc; background:#0e2d49;}
html[data-theme="dark"] .odontogram-selection-summary .selection-check {
  color:#06192b; background:#8de4ff;}
html[data-theme="dark"] .odontogram-selection-summary small { color:#a9bfce;}
@media (max-width:600px) {
  .odontogram-selection-summary { display:flex; width:100%;}}

/* Preserve each clinical condition color while selected. */
.tooth-state[data-tooth-state="sano"] { --condition-bg:#edf3f2; --condition-fg:#425a57;}
.tooth-state.caries { --condition-bg:#e0453b; --condition-fg:#fff;}
.tooth-state.obturacion-resina { --condition-bg:#2f7fc4; --condition-fg:#fff;}
.tooth-state.obturacion-amalgama { --condition-bg:#64748b; --condition-fg:#fff;}
.tooth-state.obturacion-mal-estado { --condition-bg:#8b5e3c; --condition-fg:#fff;}
.tooth-state.sellante { --condition-bg:#219873; --condition-fg:#fff;}
.tooth-state.corona { --condition-bg:#dda913; --condition-fg:#4b3a00;}
.tooth-state.puente { --condition-bg:#07819a; --condition-fg:#fff;}
.tooth-state.desgaste { --condition-bg:#b7791f; --condition-fg:#fff;}
.tooth-state.endodoncia { --condition-bg:#7c4fb0; --condition-fg:#fff;}
.tooth-state.ausente { --condition-bg:#6b7573; --condition-fg:#fff;}
.tooth-state.implante { --condition-bg:#4b5459; --condition-fg:#fff;}
.tooth-state.extraccion { --condition-bg:#e8752a; --condition-fg:#fff;}
.tooth-state.active {
  color:var(--condition-fg) !important;
  background:var(--condition-bg) !important;}
html[data-theme="dark"] .tooth-state[data-tooth-state="sano"] { --condition-bg:#18344c; --condition-fg:#dceaf2;}
html[data-theme="dark"] .tooth-state.caries { --condition-bg:#e94d42; --condition-fg:#fff;}
html[data-theme="dark"] .tooth-state.obturacion-resina { --condition-bg:#69b7ed; --condition-fg:#061d2a;}
html[data-theme="dark"] .tooth-state.obturacion-amalgama { --condition-bg:#7f91aa; --condition-fg:#fff;}
html[data-theme="dark"] .tooth-state.obturacion-mal-estado { --condition-bg:#c08a5a; --condition-fg:#27180f;}
html[data-theme="dark"] .tooth-state.sellante { --condition-bg:#1d9675; --condition-fg:#fff;}
html[data-theme="dark"] .tooth-state.corona { --condition-bg:#e9bb32; --condition-fg:#342900;}
html[data-theme="dark"] .tooth-state.puente { --condition-bg:#39c0d2; --condition-fg:#061d2a;}
html[data-theme="dark"] .tooth-state.desgaste { --condition-bg:#d39a37; --condition-fg:#fff;}
html[data-theme="dark"] .tooth-state.endodoncia { --condition-bg:#8050bb; --condition-fg:#fff;}
html[data-theme="dark"] .tooth-state.ausente { --condition-bg:#687472; --condition-fg:#fff;}
html[data-theme="dark"] .tooth-state.implante { --condition-bg:#4d5963; --condition-fg:#fff;}
html[data-theme="dark"] .tooth-state.extraccion { --condition-bg:#df7425; --condition-fg:#fff;}

/* Inicio operativo: contenido clínico primero, sin acciones duplicadas. */
.dashboard-overview {
  display:flex; align-items:center; justify-content:space-between; gap:24px;
  margin:0 0 16px; padding:22px 24px; border:1px solid var(--polish-line);
  border-radius:18px; color:var(--polish-ink); background:var(--polish-surface);
  box-shadow:var(--polish-shadow-sm);}
.dashboard-overview > div:first-child { min-width:0; max-width:760px;}
.dashboard-overview h2 {
  margin:5px 0 6px; color:var(--polish-ink) !important;
  font-size:clamp(22px,2.3vw,29px); line-height:1.18; letter-spacing:-.025em;}
.dashboard-overview p { margin:0; color:var(--polish-copy) !important; font-size:14px; line-height:1.5;}
.dashboard-overview-actions { display:flex; flex:0 0 auto; gap:8px; align-items:center;}
.dashboard-overview-actions .primary, .dashboard-overview-actions .secondary { min-height:44px; white-space:nowrap;}
.dashboard-birthday { margin:0 0 16px;}
.dashboard-metrics {
  display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px;
  margin:0 0 16px;}
.dashboard-metric {
  display:flex; min-width:0; min-height:116px; gap:13px; align-items:center;
  padding:16px; border:1px solid var(--polish-line); border-radius:16px;
  color:var(--polish-ink); text-align:left; background:var(--polish-surface);
  box-shadow:var(--polish-shadow-xs); cursor:pointer;
  transition:border-color .18s ease, box-shadow .18s ease, background .18s ease;}
.dashboard-metric:hover, .dashboard-metric:focus-visible {
  border-color:var(--polish-primary); outline:0;
  background:var(--polish-brand-tint); box-shadow:var(--polish-shadow-sm);}
.dashboard-metric:focus-visible { box-shadow:0 0 0 3px color-mix(in srgb,var(--polish-primary) 30%,transparent),var(--polish-shadow-sm);}
.dashboard-metric-icon {
  display:grid; width:40px; height:40px; flex:0 0 40px; place-items:center;
  border-radius:12px; color:var(--polish-primary-strong); background:var(--polish-brand-tint);}
.dashboard-metric-icon.today { color:#2869a5; background:#e6eef9;}
.dashboard-metric-icon.upcoming { color:var(--polish-teal); background:#e3f5f1;}
.dashboard-metric-icon svg, .dashboard-metric-arrow {
  fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round;}
.dashboard-metric-icon svg { width:21px; height:21px;}
.dashboard-metric-copy { display:grid; min-width:0; gap:2px;}
.dashboard-metric-copy small { color:var(--polish-copy); font-size:14px; font-weight:720;}
.dashboard-metric-copy strong { color:var(--polish-ink); font-size:27px; font-variant-numeric:tabular-nums; line-height:1.08;}
.dashboard-metric-copy span { color:var(--polish-primary-strong); font-size:14px; font-weight:780;}
.dashboard-metric-arrow { width:18px; height:18px; flex:0 0 auto; margin-left:auto; color:var(--polish-copy-soft);}
.dashboard-grid { grid-template-columns:minmax(0,1fr) !important;}
.dashboard-agenda-panel { padding:20px;}
.dashboard-view-all { display:inline-flex !important; align-items:center; gap:4px; min-height:40px; padding:0 8px;}
.upcoming-more {
  display:inline-flex; min-height:42px; align-items:center; justify-content:center;
  margin:12px 0 0; padding:0 12px; border:1px solid var(--polish-line-strong);
  border-radius:10px; color:var(--polish-primary-strong); background:var(--polish-brand-tint);
  font-size:14px; font-weight:800; cursor:pointer;}
.upcoming-more:hover, .upcoming-more:focus-visible { border-color:var(--polish-primary); background:var(--polish-surface); outline:0;}
html[data-theme="dark"] .dashboard-overview,
html[data-theme="dark"] .dashboard-metric { border-color:var(--polish-line); color:var(--polish-ink); background:var(--polish-surface);}
html[data-theme="dark"] .dashboard-overview p,
html[data-theme="dark"] .dashboard-metric-copy small { color:var(--polish-copy) !important;}
html[data-theme="dark"] .dashboard-metric:hover,
html[data-theme="dark"] .dashboard-metric:focus-visible { border-color:#8de4ff; background:var(--polish-surface-soft);}
html[data-theme="dark"] .dashboard-metric-icon { color:#8de4ff; background:#123955;}
html[data-theme="dark"] .dashboard-metric-icon.today { color:#a9caf7; background:#183656;}
html[data-theme="dark"] .dashboard-metric-icon.upcoming { color:#78e0cb; background:#123f42;}
html[data-theme="dark"] .upcoming-more { border-color:#3b5d77; color:#8de4ff; background:#123955;}
@media (max-width:760px) {
  .dashboard-overview { display:grid; gap:16px; padding:18px; border-radius:15px;}
  .dashboard-overview h2 { font-size:23px;}
  .dashboard-overview-actions { display:grid; grid-template-columns:1fr 1fr; width:100%;}
  .dashboard-overview-actions .primary, .dashboard-overview-actions .secondary { width:100%;}
  .dashboard-metrics { grid-template-columns:1fr; gap:9px;}
  .dashboard-metric { min-height:92px; padding:14px;}
  .dashboard-metric-copy strong { font-size:25px;}
  .dashboard-agenda-panel { padding:16px;}
  .dashboard-agenda-panel .panel-heading { gap:10px;}
  .dashboard-view-all { min-height:42px; padding:0 4px;}}
@media (max-width:420px) {
  .dashboard-overview-actions { grid-template-columns:1fr;}}

/* Fixed bridge: outlined retainers joined by a clean clinical bar. */
.tooth-diagram.whole-puente {
  color:#07819a;
  background:var(--polish-surface,#fff);
  outline:3px solid currentColor;
  outline-offset:2px;
  overflow:visible;}
.tooth-diagram.whole-puente .surface { fill:var(--polish-surface,#fff) !important;}
.tooth-unit.bridge-link-right { position:relative; z-index:1;}
.tooth-unit.bridge-link-right .tooth-diagram.whole-puente::after {
  content:"";
  position:absolute;
  z-index:-1;
  top:50%;
  left:calc(100% + 1px);
  width:10px;
  height:5px;
  transform:translateY(-50%);
  border-radius:999px;
  background:currentColor;
  pointer-events:none;}
html[data-theme="dark"] .tooth-diagram.whole-puente { color:#57d3e4; background:var(--polish-surface,#17263a);}
html[data-theme="dark"] .tooth-diagram.whole-puente .surface { fill:var(--polish-surface,#17263a) !important;}
@media (max-width:760px) { .tooth-unit.bridge-link-right .tooth-diagram.whole-puente::after { width:7px;}}

.tooth-unit.bridge-link-right .tooth-diagram.whole-puente::after {
  z-index:3;
  border:0;}

/* Clinical history: focused filters and readable evolution details. */
.clinical-history-filter { display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin:0 0 14px; padding:10px 12px; border:1px solid var(--polish-line); border-radius:13px; background:var(--polish-surface-soft);}
.clinical-history-filter > span { margin-right:2px; color:var(--polish-copy); font-size:14px; font-weight:800;}
.clinical-history-filter button { min-height:40px; padding:0 12px; border:1px solid var(--polish-line-strong); border-radius:9px; color:var(--polish-copy); background:var(--polish-surface); font-size:14px; font-weight:800; cursor:pointer; transition:border-color .16s ease,background .16s ease,color .16s ease,box-shadow .16s ease;}
.clinical-history-filter button:hover,.clinical-history-filter button:focus-visible { border-color:var(--polish-primary); color:var(--polish-primary-strong); outline:0;}
.clinical-history-filter button.active { border-color:var(--polish-primary); color:#fff; background:var(--polish-primary); box-shadow:0 3px 8px color-mix(in srgb,var(--polish-primary) 24%,transparent);}
.clinical-history-filter strong { margin-left:auto; color:var(--polish-copy); font-size:14px; font-weight:800;}
.clinical-evolution-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; margin:14px 0 0;}
.clinical-evolution-grid div,.odontogram-evolution-summary { padding:10px 11px; border:1px solid var(--polish-line); border-radius:10px; background:var(--polish-surface-soft);}
.clinical-evolution-grid dt { margin:0 0 4px; color:var(--polish-copy-soft); font-size:11px; font-weight:850; letter-spacing:.055em; text-transform:uppercase;}
.clinical-evolution-grid dd { margin:0; color:var(--polish-ink); font-size:14px; line-height:1.45;}
.odontogram-evolution-summary { margin-top:14px; color:var(--polish-ink); font-size:14px; line-height:1.5;}
.odontogram-evolution-summary strong { color:var(--polish-primary-strong);}
.odontogram-evolution-summary p { margin:8px 0 0; color:var(--polish-copy);}
html[data-theme="dark"] .clinical-history-filter { border-color:var(--polish-line); background:var(--polish-surface-soft);}
html[data-theme="dark"] .clinical-history-filter button { border-color:var(--polish-line-strong); color:var(--polish-copy); background:var(--polish-surface);}
html[data-theme="dark"] .clinical-history-filter button.active { border-color:#6edaf4; color:#05293a; background:#6edaf4;}
html[data-theme="dark"] .clinical-evolution-grid div,html[data-theme="dark"] .odontogram-evolution-summary { border-color:var(--polish-line); background:var(--polish-surface-soft);}
@media (max-width:760px) { .clinical-history-filter { align-items:stretch;} .clinical-history-filter > span,.clinical-history-filter strong { width:100%; margin:0;} .clinical-history-filter button { flex:1 1 auto;} .clinical-evolution-grid { grid-template-columns:1fr;}}

.agenda-summary-next { position:relative; display:grid; width:100%; min-width:0; padding:0; border:0; color:inherit; text-align:left; background:transparent; cursor:pointer;}
.agenda-summary-next em { margin-top:3px; color:var(--polish-primary-strong); font-size:11px; font-style:normal; font-weight:850; opacity:0; transition:opacity .16s ease;}
.agenda-summary-next:hover em,.agenda-summary-next:focus-visible em { opacity:1;}
.agenda-summary-next:focus-visible { outline:2px solid var(--polish-primary); outline-offset:5px; border-radius:8px;}

.record-upcoming-item { display:grid; gap:7px; margin-bottom:10px;}
.record-upcoming-item .appointment-row { margin:0;}
.record-upcoming-agenda { justify-self:end; min-height:40px; padding:0 12px; border:1px solid var(--polish-line-strong); border-radius:9px; color:var(--polish-primary-strong); background:var(--polish-brand-tint); font:inherit; font-size:14px; font-weight:800; cursor:pointer;}
.record-upcoming-agenda:hover,.record-upcoming-agenda:focus-visible { border-color:var(--polish-primary); color:#fff; background:var(--polish-primary); outline:0;}
html[data-theme="dark"] .record-upcoming-agenda { border-color:var(--polish-line-strong); color:#8de4ff; background:#123955;}
@media (max-width:760px) { .record-upcoming-agenda { width:100%; min-height:44px;}}

.record-upcoming-actions { display:flex; align-items:center; justify-content:flex-end; gap:10px;}
.record-upcoming-actions .primary { min-height:42px; white-space:nowrap;}
@media (max-width:620px) { .record-upcoming-actions { width:100%; justify-content:space-between;} .record-upcoming-actions .primary { flex:1;}}

html[data-theme="dark"] #patient-form :is(input, textarea),
html[data-theme="dark"] #intake-form :is(input:not([type="checkbox"]):not([type="radio"]), textarea, select) {
  background: var(--polish-surface-soft) !important;
  color: #e7f0fa !important;
  border-color: #526d86 !important;
  color-scheme: dark;}
#patient-form .form-error[role="alert"],
#intake-form .form-error[role="alert"] {
  scroll-margin-block: 90px;
  line-height: 1.6;}
html[data-theme="dark"] :is(#patient-form, #intake-form) .form-error {
  color: #ffb4b4;}
/* Expediente / DUI: always legible against the light record header. */
.record-header .record-number-badge {
  margin-top:9px;
  padding:7px 11px;
  border:1px solid #164d83 !important;
  border-radius:8px;
  color:#fff !important;
  background:#164d83 !important;
  box-shadow:0 2px 5px rgba(16,61,104,.18);
  font-size:14px;
  font-weight:850;
  letter-spacing:.025em;}
html[data-theme="dark"] .record-header .record-number-badge {
  border-color:#63d7f0 !important;
  color:#071e2d !important;
  background:#63d7f0 !important;
  box-shadow:none;}

/* Accessible action contrast in the locally reviewed patient and payment flows. */
html[data-theme="dark"] :is(#patients, #payments, #patient-form, #intake-form, #treatment-plan-tab) .primary {
  background: #68cbe7 !important;
  color: #071e2d !important;
  border-color: #68cbe7 !important;}

.procedure-delete-confirm #confirm-ok.danger, #plan-detail-content .delete-procedure { min-height:44px; background:var(--surface) !important; color:var(--danger) !important; border:1px solid var(--danger) !important; box-shadow:none;}
.procedure-delete-confirm #confirm-ok.danger:hover, #plan-detail-content .delete-procedure:hover { background:color-mix(in srgb,var(--surface) 90%,var(--danger)) !important;}

/* Keep all navigation entries reachable independently of the page. */
#sidebar { height:100vh; height:100dvh; min-height:0; overflow:hidden;}
#sidebar > .brand, #sidebar > .nav-label { flex-shrink:0;}
#sidebar > nav {
  flex:1 1 auto; min-height:0; display:grid; align-content:start;
  overflow-y:scroll; overflow-x:hidden; overscroll-behavior-y:contain;
  scrollbar-gutter:stable; scrollbar-width:auto;
  scrollbar-color:var(--text-secondary) var(--surface);
  padding:3px 5px 12px 3px;}
#sidebar > nav::-webkit-scrollbar { width:10px;}
#sidebar > nav::-webkit-scrollbar-track { background:var(--surface); border-radius:8px;}
#sidebar > nav::-webkit-scrollbar-thumb { background:var(--text-secondary); border:2px solid var(--surface); border-radius:8px;}
@media (max-height:500px) {
  #sidebar > .brand { padding-bottom:8px;}
  #sidebar .brand-crop { height:64px;}
  #sidebar .brand-crop img { width:60px !important; height:60px !important; object-fit:contain;}
  #sidebar > .nav-label { margin-top:8px; margin-bottom:4px;}
  #sidebar > nav { margin-top:4px;}}

/* Agenda: one command area, consistent controls, readable appointment times. */
@media screen {
  #appointments .agenda-command-deck { border-radius:16px; overflow:visible; box-shadow:var(--polish-shadow-xs);}
  #appointments .appointment-filters {
    display:grid; grid-template-columns:minmax(220px,1.6fr) minmax(155px,.85fr) minmax(150px,1fr) minmax(135px,.8fr) auto;
    gap:12px; align-items:end; margin:0; padding:16px;
    background:transparent; border:0; box-shadow:none;}
  #appointments .appointment-filters label { min-width:0; display:flex; flex-direction:column; gap:6px;}
  #appointments .appointment-filters label > span { font-size:14px; line-height:1.4; text-transform:none; letter-spacing:0; font-weight:700;}
  #appointments .appointment-filters input, #appointments .appointment-filters select, #appointment-filter-clear {
    width:100%; min-width:0; height:44px; min-height:44px; margin:0; border-radius:9px;
    border:1px solid var(--polish-line-strong); background:var(--polish-field); color:var(--polish-ink); font-size:14px;}
  #appointments .appointment-filters small { display:none;}
  #appointments .agenda-toolbar { padding:12px 16px; gap:12px; margin:0; border:0; border-top:1px solid var(--polish-line); border-radius:0; box-shadow:none; background:transparent;}
  #appointments .agenda-view-switch { padding:3px; border-radius:10px; box-shadow:none;}
  #appointments .agenda-view-switch button { min-height:40px; font-size:14px;}
  #appointments .agenda-navigation { gap:6px;}
  #appointments .agenda-navigation button { min-height:42px; min-width:42px;}
  #appointments #agenda-range-label { background:transparent; padding:0 8px; font-size:14px;}
  #appointments .agenda-summary-strip {
    display:grid; grid-template-columns:1fr 1fr 1.35fr; gap:0; margin:0; padding:12px 16px;
    border-top:1px solid var(--polish-line); background:var(--polish-surface-soft); border-radius:0 0 16px 16px;}
  #appointments .agenda-summary-strip > article, #appointments .agenda-summary-next {
    position:relative; display:grid; grid-template-columns:1fr auto; align-content:center; align-items:center; gap:3px 12px;
    min-width:0; min-height:54px; padding:0 18px; margin:0; border:0; border-radius:0; box-shadow:none;
    background:transparent; color:var(--polish-ink);}
  #appointments .agenda-summary-strip > :first-child { padding-left:0;}
  #appointments .agenda-summary-strip > :not(:first-child) { border-left:1px solid var(--polish-line-strong);}
  #appointments .agenda-summary-strip > * > span { font-size:14px; font-weight:700; text-transform:none; letter-spacing:0;}
  #appointments .agenda-summary-strip > * > strong { grid-column:2; grid-row:1 / 3; font-size:20px; line-height:1.25; white-space:nowrap; color:var(--polish-ink);}
  #appointments .agenda-summary-strip > * > small { grid-column:1; font-size:14px; color:var(--polish-copy);}
  #appointments .agenda-summary-next em { display:none;}
  #appointments .agenda-summary-next:disabled { cursor:default; opacity:.65;}
  #appointments .agenda-summary-next:not(:disabled):hover { background:var(--polish-brand-tint); border-radius:8px;}
  #appointments .agenda-workspace { margin-top:16px;}
  #appointments .appt-time-block { min-width:var(--clinic-time-track);}
  #appointments .appt-time-block strong { white-space:nowrap; font-size:14px; font-variant-numeric:tabular-nums;}
  #appointments .appointment-row { grid-template-columns:var(--clinic-time-track) minmax(0,1fr) 132px auto; gap:12px; padding:14px 12px; box-shadow:none;}
  #appointments .appointment-status-select { min-height:40px; border:1px solid var(--polish-line); border-radius:8px;}
  #appointments .appointment-quick-actions > button, #appointments .appointment-menu summary { min-height:40px;}
  #appointments .appt-main > div:last-child { min-width:0;}
  #appointments .appt-main strong { font-size:14px;}
  #appointments .calendar-month-date > span { display:none;}
  #appointments .calendar-month-date { justify-content:space-between;}
  #appointments .calendar-event-time { white-space:nowrap; font-variant-numeric:tabular-nums; color:var(--polish-primary-strong) !important;}
  #appointments .calendar-event { box-shadow:none; border-left:3px solid var(--event-color) !important;}
  #appointments .calendar-event-main { min-width:0;}
  #appointments .calendar-event-patient, #appointments .calendar-event-reason { overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
  #appointments .calendar-selected-day { box-shadow:none; border-radius:12px;}
  @media (max-width:1199px) {
    #appointments .appointment-filters { grid-template-columns:minmax(180px,1.4fr) 1fr 1fr;}
    #appointments .appointment-filters > :nth-child(4) { grid-column:2;}
    #appointment-filter-clear { grid-column:3;}
    #appointments .agenda-toolbar { flex-wrap:wrap;}
    #appointments .appointment-row { grid-template-columns:var(--clinic-time-track) minmax(0,1fr) 120px auto; gap:8px;}}
  @media (max-width:899px) {
    #appointments .agenda-summary-strip { grid-template-columns:1fr 1fr;}
    #appointments .agenda-summary-next { grid-column:1 / -1; border-left:0 !important; border-top:1px solid var(--polish-line); padding:10px 0 0; margin-top:10px;}
    #appointments .agenda-navigation { flex-wrap:wrap;}
    #appointments .appointment-row { grid-template-columns:var(--clinic-time-track) minmax(0,1fr) !important;}
    #appointments .appointment-status-select { grid-column:1; width:100%; font-size:14px;}
    #appointments .appointment-quick-actions { grid-column:2; justify-content:flex-end;}}
  @media (max-width:599px) {
    #appointments .appointment-filters { grid-template-columns:1fr 1fr; gap:10px; padding:12px;}
    #appointments .agenda-search-field { grid-column:1 / -1;}
    #appointments .appointment-filters > :nth-child(4) { grid-column:1;}
    #appointment-filter-clear { grid-column:2;}
    #appointments .agenda-toolbar { display:grid; grid-template-columns:1fr auto; padding:12px;}
    #appointments .agenda-view-switch { width:100%;}
    #appointments .agenda-navigation { grid-column:1 / -1; grid-row:2; justify-content:center;}
    #appointments #agenda-range-label { flex:1 1 100%; text-align:center; margin-top:4px;}
    #appointments .agenda-create-button { min-height:44px; padding:0 10px; white-space:nowrap;}
    #appointments .agenda-summary-strip { padding:10px 12px;}
    #appointments .agenda-summary-strip > article { padding-right:10px; padding-left:10px;}
    #appointments .agenda-summary-strip > article:first-child { padding-left:0;}
    #appointments .agenda-summary-strip > * > strong { font-size:18px;}
    #appointments .calendar-month-count { font-size:11px;}}}

@media screen {
  #appointments .appointment-filters { border-radius:16px 16px 0 0; background:transparent !important;}
  #appointments .agenda-summary-strip > article { background:transparent !important; border:0 !important; border-radius:0 !important; box-shadow:none !important; min-height:54px !important;}
  #appointments .agenda-summary-strip > article + article { border-left:1px solid var(--polish-line-strong) !important;}
  #appointments .agenda-summary-strip article > strong { margin:0 !important; font-size:20px !important;}
  #appointments .agenda-summary-strip article > span, #appointments .agenda-summary-strip article > small { font-size:14px !important;}
  @media (max-width:899px) {
    #appointments .agenda-summary-strip { grid-template-columns:1fr 1fr !important; gap:0 !important;}
    #appointments .agenda-summary-strip > article { padding:0 12px !important;}
    #appointments .agenda-summary-strip > article:first-child { padding-left:0 !important;}}}

@media screen and (max-width:899px) {
  #appointments .appointment-row .appt-time-block { grid-column:1; grid-row:1; align-self:start;}
  #appointments .appointment-row .appt-main { grid-column:2; grid-row:1; min-width:0;}
  #appointments .appointment-row .appt-status { grid-column:1 / -1; grid-row:2; min-width:0; padding-right:100px;}
  #appointments .appointment-row .appt-actions { grid-column:2; grid-row:2; justify-self:end;}
  #appointments .appointment-row .appt-main .avatar { flex-shrink:0;}
  #appointments .appointment-row .appt-main strong { white-space:normal; overflow-wrap:anywhere;}
  #appointments .appointment-row .appt-main small { white-space:normal;}}
@media screen and (max-width:599px) {
  #appointments .appointment-row .appt-main .avatar { display:none;}
  #appointments .calendar-event-edit { min-width:44px; min-height:44px;}
  #appointments .agenda-navigation { display:flex !important; flex-wrap:wrap; justify-content:center; width:100%;}
  #appointments .agenda-navigation > * { grid-area:auto !important; order:0 !important;}
  #appointments .agenda-navigation #agenda-range-label { order:1 !important; flex:1 1 100%; margin:6px 0 0;}
  #appointments .agenda-navigation .today-button { width:auto; min-width:64px;}}

/* Tablet agenda: the legacy mobile flex breakpoint must still fill the work area. */
@media screen and (min-width:761px) and (max-width:899px) {
  #appointments .agenda-workspace { align-items:stretch;}
  #appointments .agenda-content,
  #appointments .calendar-panel { width:100%;}
  #appointments .calendar-day-mobile-heading {
    display:flex !important;
    width:100%;
    min-height:44px;
    align-items:baseline;
    gap:8px;
    margin:0 0 10px;
    padding:0 0 9px;
    border:0;
    border-bottom:1px solid var(--polish-line);
    color:var(--polish-copy);
    background:transparent;
    font:inherit;
    text-align:left;
    cursor:pointer;
    appearance:none;}
  #appointments .calendar-day-mobile-heading small { margin-left:auto;}}

/* Audit: concise hierarchy and context-specific controls. */
@media screen {
  #app-shell :is(#patients, #doctors, #payments, #medical-leaves, #users) > .section-actions > div > h2 { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;}
  #app-shell :is(#patients, #doctors, #payments, #medical-leaves, #users) > .section-actions { padding: 12px 16px; box-shadow: none;}
  #record .record-header { padding: 16px 20px; margin-bottom: 12px;}
  #record .record-tabs { margin-bottom: 12px; box-shadow: none;}
  #record .record-tab-panel > .section-actions { padding: 12px 16px; margin-bottom: 12px; box-shadow: none;}

  .pending-update-notice { position: fixed; bottom: 16px; right: 16px; max-width: min(380px, calc(100vw - 32px)); padding: 14px 18px; border: 1px solid var(--polish-line-strong); border-radius: 12px; background: var(--polish-surface); color: var(--polish-ink); box-shadow: var(--polish-shadow-sm); z-index: 100; font-size: 14px; line-height: 1.5; display: grid; gap: 10px;}
  .pending-update-notice .pending-update-actions { display: flex; gap: 8px; justify-content: flex-end;}
  #app-shell .appt-time-block > strong { white-space: nowrap; font-variant-numeric: tabular-nums;}
  #audit .audit-panel { margin-top: 0;}}

@media screen {
  .patient-more { position: relative;}
  .patient-more summary { cursor: pointer; padding: 10px 12px; border: 1px solid var(--polish-line-strong); border-radius: 8px; color: var(--polish-ink); font-size:14px;}
  .patient-more[open] > button { position: absolute; right: 0; top: calc(100% + 6px); min-width: 155px; z-index: 5; background: var(--polish-surface); box-shadow: var(--polish-shadow-sm);}}

/* Keep mini-calendar targets usable on compact desktop layouts. */
@media (min-width: 1100px) and (max-width: 1400px) {
  #appointments .agenda-sidebar { padding-inline: 10px !important;}}

/* Hidden color radios stay focusable without enlarging the doctor dialog. */
.color-options label { position: relative;}
.color-options input[type="radio"] {
  width: 1px !important; height: 1px !important; min-height: 0 !important;
  padding: 0 !important; margin: 0; border: 0; overflow: hidden; clip-path: inset(50%);}
.color-options label:has(input:focus-visible) { outline: 2px solid var(--polish-ink); outline-offset: 2px;}

/* Desktop operability: preserve compact controls with reliable targets. */
@media screen and (min-width:761px) {
  .appointment-status-select,
  .theme-toggle,
  .logout-button,
  .install-button,
  #agenda-selected-day-open,
  #patients .patient-letter,
  #appointments .agenda-navigation .icon-button,
  #appointments .agenda-mini-navigation .icon-button,
  #appointments .agenda-mini-day { min-height:40px;}}

/* Mobile operability: preserve the compact clinical layout with reliable tap targets. */
@media screen and (max-width:760px) {
  #app-shell .view :is(
    button,
    summary,
    input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]),
    select,
    textarea
  ) { min-height:44px;}

  #app-shell .view :is(input, select, textarea) { font-size:16px;}

  .mobile-menu-button,
  .logout-button,
  .sidebar-close,
  .appointment-record-action,
  #appointments .agenda-navigation .icon-button,
  #appointments .agenda-mini-navigation .icon-button,
  #appointments .appointment-menu summary { min-width:44px; min-height:44px;}

  #appointments .agenda-mini-day,
  #patients .patient-letter { min-width:44px; min-height:44px;}

  .appointment-menu { width:44px;}
  .appointment-menu-popover {
    position:absolute;
    top:calc(100% + 8px);
    right:0;
    width:min(228px,calc(100vw - 32px));
    margin:0;
    box-shadow:var(--polish-shadow-sm);}
  .appointment-menu-popover button { min-height:44px;}}

/* Contrast parity for primary actions and compact status labels. */
@media screen {
  html[data-theme="dark"] :is(#app-shell, dialog) button.primary {
    color:#fff !important;}
  html[data-theme="dark"] :is(#patients, #payments, #patient-form, #intake-form, #treatment-plan-tab) button.primary {
    color:#071e2d !important;}
  .doctor-status,
  .user-status.active {
    color:var(--polish-success) !important;
    background:#e3f5ee !important;}
  html[data-theme="dark"] .doctor-status,
  html[data-theme="dark"] .user-status.active {
    color:#7de0be !important;
    background:#163c3a !important;}
  html[data-theme="dark"] .today-badge {
    color:#7de0be !important;
    background:#163c3a !important;}
  html[data-theme="dark"] .agenda-mini-day.selected {
    color:#062f38 !important;
    background:#68cbe7 !important;}
  html[data-theme="dark"] .agenda-mini-day.selected :is(.agenda-mini-number, .agenda-mini-count) {
    color:#062f38 !important;}}

/* En el apilado móvil el divisor del resumen financiero es una línea, no un bloque. */
@media screen and (max-width:640px) {
  .finance-mini-divider { width:100%; height:1px; margin:0;}}
