:root{
  --bg:#f2f6fb;
  --surface:#ffffff;
  --surface-2:#f8fafc;
  --text:#122033;
  --muted:#66758a;
  --line:#dce4ee;
  --primary:#1769e0;
  --primary-dark:#0f52b7;
  --primary-soft:#eaf2ff;
  --accent:#0f9f83;
  --accent-soft:#e8f8f4;
  --danger:#b42318;
  --danger-soft:#fff0ef;
  --warn:#b54708;
  --ok:#067647;
  --radius-sm:11px;
  --radius:17px;
  --radius-lg:22px;
  --shadow:0 12px 34px rgba(26,48,78,.08);
  --shadow-hover:0 16px 38px rgba(26,48,78,.13);
}
*{box-sizing:border-box}
html{font-family:system-ui,-apple-system,"Segoe UI",Tahoma,Arial,sans-serif;background:var(--bg);color:var(--text);-webkit-text-size-adjust:100%}
body{margin:0;direction:rtl;min-height:100vh;background:linear-gradient(180deg,#f8fbff 0,#f2f6fb 280px,#f2f6fb 100%)}
a{color:inherit;text-decoration:none}
button,input,textarea,select{font:inherit}
button{touch-action:manipulation}
.shell{max-width:1180px;margin:auto;padding:14px 12px 34px}
.min-w-0{min-width:0}

.topbar{position:sticky;top:0;z-index:20;background:rgba(248,251,255,.94);backdrop-filter:blur(14px);border-bottom:1px solid rgba(220,228,238,.9)}
.topbar-inner{max-width:1180px;margin:auto;padding:10px 12px;display:flex;gap:10px;align-items:center;justify-content:space-between}
.brand{font-weight:900;letter-spacing:-.2px;color:#10253f}
.nav{display:flex;gap:7px;overflow-x:auto;white-space:nowrap;padding:2px 0;scrollbar-width:none}
.nav::-webkit-scrollbar{display:none}
.nav a{padding:9px 12px;border-radius:12px;background:rgba(255,255,255,.92);border:1px solid var(--line);font-size:13px;font-weight:700;transition:.18s ease}
.nav a:hover{border-color:#b8c8dc;background:#fff}
.nav a.nav-add-patient{background:var(--primary);color:#fff;border-color:var(--primary);box-shadow:0 7px 18px rgba(23,105,224,.18)}

.card,.search-card,.patient-tile,.stat-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow)}
.card{padding:15px;margin-bottom:13px}
.grid{display:grid;gap:12px}
.grid-2,.grid-3{grid-template-columns:1fr}
.metric{font-size:29px;line-height:1;font-weight:900;letter-spacing:-.8px;color:#10253f}
.muted{color:var(--muted)}
h1,h2,h3{margin:0;color:#10253f;line-height:1.25}
h1{font-size:clamp(24px,6vw,34px);letter-spacing:-.7px}
h2{font-size:20px}
h3{font-size:17px}
p{line-height:1.7}
.kicker{font-size:11px;font-weight:900;color:var(--primary);letter-spacing:.2px;margin-bottom:5px}
.small{font-size:12px}

.form-grid{display:grid;gap:11px}
.field label{display:block;font-size:13px;font-weight:800;margin-bottom:6px;color:#33445a}
.input,.field input,.field textarea,.field select{width:100%;border:1px solid #cbd6e2;border-radius:13px;padding:12px 13px;background:#fff;color:var(--text);outline:none;transition:.16s ease}
.field textarea{min-height:125px;resize:vertical}
.input:focus,.field input:focus,.field textarea:focus,.field select:focus{border-color:#6da5f4;box-shadow:0 0 0 4px rgba(23,105,224,.10)}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;border:1px solid transparent;border-radius:12px;padding:10px 14px;min-height:42px;font-weight:800;cursor:pointer;background:#edf2f7;color:#24364c;transition:transform .16s ease,box-shadow .16s ease,background .16s ease,border-color .16s ease}
.btn:hover{transform:translateY(-1px)}
.btn-primary{background:linear-gradient(135deg,var(--primary),#2c7cf0);color:#fff;box-shadow:0 8px 20px rgba(23,105,224,.18)}
.btn-primary:hover{background:linear-gradient(135deg,var(--primary-dark),var(--primary))}
.btn-soft{background:#fff;border-color:var(--line);color:#29415e}
.btn-soft:hover{background:var(--surface-2);border-color:#b9c9db}
.btn-danger{background:var(--danger-soft);color:var(--danger);border-color:#ffd5d1}
.btn-ok{background:#e7f8ef;color:var(--ok)}
.btn-compact{padding:8px 11px;min-height:36px;font-size:12px;background:#f5f8fc;border-color:var(--line)}
.btn-icon{font-size:16px}
.actions{display:flex;gap:8px;flex-wrap:wrap}

.badge{display:inline-flex;align-items:center;justify-content:center;padding:5px 9px;border-radius:999px;font-size:11px;font-weight:900;white-space:nowrap}
.paid{background:#e3f8ec;color:#067647}
.unpaid{background:#fff0ef;color:#b42318}

.flash{padding:12px 14px;border-radius:13px;margin-bottom:11px;border:1px solid transparent;font-weight:700}
.flash.success{background:#ecfdf3;color:#067647;border-color:#b7ebca}
.flash.error{background:#fef3f2;color:#b42318;border-color:#ffd0cc}
.flash.info{background:#eff8ff;color:#175cd3;border-color:#cfe4ff}

.table-wrap{overflow:auto;border:1px solid var(--line);border-radius:14px;background:#fff}
.table{width:100%;border-collapse:collapse;min-width:650px}
.table th,.table td{padding:11px;border-bottom:1px solid var(--line);text-align:right;vertical-align:top}
.table th{background:#f7f9fc;font-size:12px;color:#50627a}

.quick-buttons{display:flex;gap:7px;flex-wrap:wrap}
.quick-buttons button{border:1px solid #b9d1ff;background:#eef5ff;color:#174d9d;border-radius:10px;padding:8px 10px;cursor:pointer;font-weight:700}
.event-dot{width:8px;height:8px;border-radius:50%;background:#12b76a;display:inline-block;box-shadow:0 0 0 4px rgba(18,183,106,.12)}
.thumbs{display:flex;gap:8px;overflow:auto}
.thumbs img{width:88px;height:88px;object-fit:cover;border-radius:12px;border:1px solid var(--line)}
.login-wrap{min-height:100vh;display:grid;place-items:center;padding:18px}
.login-card{width:min(420px,100%)}
.danger-zone{border-color:#f5bdb7;background:#fffafa}
.ltr{direction:ltr;text-align:left}
.toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;justify-content:space-between}
.pagination{display:flex;gap:7px;align-items:center;justify-content:center;flex-wrap:wrap;margin-top:16px}
.pagination a,.page-current{padding:8px 12px;border:1px solid var(--line);border-radius:10px;background:#fff;font-size:13px;font-weight:800}
.pagination a.disabled{opacity:.45;pointer-events:none}
.section-title{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}

.dashboard-hero,.patients-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin:5px 0 14px;padding:4px 2px}
.dashboard-hero p,.patients-head p{margin:5px 0 0;max-width:660px}
.stats-toggle{white-space:nowrap}
.stats-panel{margin-bottom:13px}
.stats-panel[hidden]{display:none!important}
.stats-grid{animation:statsIn .18s ease-out}
@keyframes statsIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
.stat-card{display:flex;align-items:center;gap:12px;padding:15px;box-shadow:none}
.stat-icon{width:42px;height:42px;border-radius:13px;display:grid;place-items:center;background:var(--primary-soft);color:var(--primary);font-weight:900;font-size:18px;flex:0 0 auto}
.stat-label{font-size:12px;color:var(--muted);font-weight:800;margin-bottom:5px}
.subscription{display:flex;align-items:center;justify-content:space-between;gap:12px;background:linear-gradient(135deg,#eff7ff,#f1fbf8);border-color:#cfe2ee}
.subscription h2{margin-bottom:5px}
.subscription-mark{width:48px;height:48px;border-radius:15px;background:var(--accent-soft);color:var(--accent);display:grid;place-items:center;font-size:24px;font-weight:900;flex:0 0 auto}
.dashboard-actions .actions{display:grid;grid-template-columns:1fr;gap:9px}
.dashboard-actions .btn{min-height:49px}
.live-card{overflow:hidden}
.live-pill{display:inline-flex;align-items:center;gap:8px;padding:6px 9px;border:1px solid #cfeade;border-radius:999px;background:#f3fcf8;color:#087a59;font-size:11px;font-weight:900}

.visit-list{display:grid;gap:8px}
.visit-row-card{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:11px;border:1px solid #e2e8f0;border-radius:13px;background:#fbfdff;transition:.16s ease}
.visit-row-card:hover{border-color:#b9cbe0;background:#fff;transform:translateY(-1px)}
.visit-main{display:flex;align-items:center;gap:10px;min-width:0}
.avatar,.patient-avatar{display:grid;place-items:center;flex:0 0 auto;font-weight:900;background:linear-gradient(135deg,#dceaff,#edf5ff);color:#195fbd;border:1px solid #c8ddfb}
.avatar{width:38px;height:38px;border-radius:12px}
.visit-patient{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:3px}

.patients-head{margin-bottom:11px}
.add-patient-main{white-space:nowrap}
.search-card{padding:11px;margin-bottom:13px;box-shadow:0 8px 25px rgba(26,48,78,.055)}
.searchbar{display:flex;gap:8px;width:100%}
.search-input-wrap{position:relative;min-width:0;flex:1}
.search-input-wrap .input{padding-right:40px;height:45px}
.search-icon{position:absolute;right:14px;top:50%;transform:translateY(-50%);color:#7a8da5;font-size:18px;z-index:1}
.searchbar .btn{min-width:82px}

.patient-grid{display:grid;grid-template-columns:1fr;gap:11px}
.patient-tile{display:block;padding:14px;box-shadow:0 8px 25px rgba(26,48,78,.055);overflow:hidden;transition:transform .18s ease,box-shadow .18s ease,border-color .18s ease}
.patient-tile:hover{transform:translateY(-2px);box-shadow:var(--shadow-hover);border-color:#bdcde0}
.patient-tile-top{display:flex;align-items:center;gap:11px;min-width:0}
.patient-avatar{width:46px;height:46px;border-radius:14px;font-size:20px}
.patient-title{flex:1}
.patient-title h3{margin:0 0 4px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}
.file-code{display:inline-flex;padding:3px 7px;border-radius:7px;background:#f0f4f8;color:#607087;font:700 11px ui-monospace,SFMono-Regular,Menlo,monospace;direction:ltr}
.open-arrow{font-size:25px;color:#8b9bb0;line-height:1;flex:0 0 auto}
.patient-meta{display:grid;grid-template-columns:85px minmax(0,1fr);gap:8px;margin-top:13px;padding-top:12px;border-top:1px solid #edf1f5}
.meta-item{min-width:0;padding:8px 9px;border-radius:10px;background:#f8fafc}
.meta-wide{min-width:0}
.meta-label{display:block;font-size:10px;color:#7b899b;font-weight:800;margin-bottom:4px}
.meta-item strong{display:block;font-size:13px;color:#2d3f55;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.patient-tile-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:11px;color:#5c6f86;font-size:11px;font-weight:800}
.tile-action{color:var(--primary)}
.empty-state{padding:24px 16px;text-align:center;color:var(--muted);border:1px dashed #c8d4e2;border-radius:14px;background:#fafcff}
.patient-empty{grid-column:1/-1;display:grid;gap:6px;justify-items:center}
.patient-empty span{font-size:12px}
.empty-icon{width:44px;height:44px;border-radius:14px;background:var(--primary-soft);color:var(--primary);display:grid;place-items:center;font-size:20px;margin-bottom:3px}

.patient-new-card{max-width:760px;margin-inline:auto}
.patient-save-btn{width:100%;min-height:49px}
.patient-toolbar-actions{margin-inline-start:auto}

@media(min-width:600px){
  .patient-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .dashboard-actions .actions{grid-template-columns:1fr 1fr}
}
@media(min-width:720px){
  .shell{padding:20px 18px 40px}
  .grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}
  .grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}
  .form-grid.two{grid-template-columns:repeat(2,minmax(0,1fr))}
  .card{padding:18px}
  .search-card{padding:13px}
}
@media(min-width:1020px){
  .patient-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
}
@media(max-width:719px){
  .topbar-inner{align-items:flex-start;flex-direction:column}
  .nav{width:100%}
  .nav-add-patient{position:sticky;right:0}
  .dashboard-hero,.patients-head{align-items:stretch;flex-direction:column}
  .stats-toggle,.add-patient-main{width:100%}
  .section-title{align-items:flex-start}
  .searchbar{align-items:stretch}
  .searchbar .btn{min-width:76px;padding-inline:12px}
  .patient-meta{grid-template-columns:74px minmax(0,1fr)}
  .recent-visits .section-title{align-items:center}
}
@media(max-width:390px){
  .shell{padding-inline:9px}
  .patient-tile{padding:12px}
  .patient-avatar{width:42px;height:42px}
  .patient-tile-footer{font-size:10px}
  .searchbar{gap:6px}
  .searchbar .btn{min-width:68px;padding-inline:9px}
}
@media print{
  .no-print,.topbar,.stats-toggle{display:none!important}
  .shell{max-width:none;padding:0}
  .card{box-shadow:none;border:0}
  body{background:#fff}
}

/* ===== MedFlow modern medical UI v1.2 ===== */
:root{
  --bg:#f4fafb;
  --surface:#ffffff;
  --surface-2:#f7fbfc;
  --surface-med:#eef9f8;
  --text:#16303a;
  --muted:#6b8088;
  --line:#d9e8eb;
  --primary:#0f7f78;
  --primary-dark:#0a645f;
  --primary-soft:#e5f6f4;
  --accent:#1688b8;
  --accent-soft:#e8f5fb;
  --danger:#b42318;
  --danger-soft:#fff1ef;
  --ok:#067647;
  --shadow:0 10px 28px rgba(23,61,72,.07);
  --shadow-hover:0 16px 38px rgba(23,61,72,.11);
}
body{background:linear-gradient(180deg,#f9fdfd 0,#f4fafb 240px,#f4fafb 100%)}
.ui-icon{width:19px;height:19px;display:inline-block;vertical-align:middle;flex:0 0 auto}
.section-icon{width:34px;height:34px;color:var(--primary);opacity:.9}

.topbar{background:rgba(250,254,254,.94);border-bottom:1px solid rgba(208,228,231,.88);box-shadow:0 6px 24px rgba(27,67,78,.045)}
.topbar-inner{padding:9px 12px}
.brand-wrap{display:flex;align-items:center;gap:10px;min-width:0}
.brand-mark{width:42px;height:42px;border-radius:14px;display:grid;place-items:center;background:linear-gradient(145deg,#0f7f78,#279bb0);color:#fff;box-shadow:0 8px 20px rgba(15,127,120,.18)}
.brand-mark .ui-icon{width:23px;height:23px}
.brand-copy{min-width:0}
.brand{font-size:15px;color:#153640}
.brand-user{font-size:11px;color:var(--muted);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:180px}
.nav{gap:6px}
.nav a{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:8px 11px;border-color:#d9e8eb;background:rgba(255,255,255,.86);color:#36535d}
.nav a .ui-icon{width:17px;height:17px;color:#56808a}
.nav a:hover{background:#fff;border-color:#bdd9dc;color:#183d47}
.nav a.nav-add-patient{background:linear-gradient(135deg,#0f7f78,#168ca0);border-color:transparent;color:#fff;box-shadow:0 8px 18px rgba(15,127,120,.18)}
.nav a.nav-add-patient .ui-icon{color:#fff}

.btn{border-radius:13px;min-height:44px}
.btn .ui-icon{width:18px;height:18px}
.btn-primary{background:linear-gradient(135deg,#0f7f78,#168ca0);box-shadow:0 8px 20px rgba(15,127,120,.17)}
.btn-primary:hover{background:linear-gradient(135deg,#0b6d67,#0f7f78)}
.btn-soft{border-color:#d7e7e9;color:#31535d;background:#fff}

.medical-hero{position:relative;overflow:hidden;display:grid;gap:18px;padding:20px;margin:4px 0 14px;border:1px solid #cfe6e7;border-radius:24px;background:linear-gradient(145deg,#f0fbfa 0%,#f7fcff 56%,#edf8fb 100%);box-shadow:0 14px 34px rgba(35,89,98,.075)}
.medical-hero:after{content:"";position:absolute;left:-42px;top:-52px;width:150px;height:150px;border-radius:50%;background:rgba(41,164,165,.07);pointer-events:none}
.medical-hero-copy{position:relative;z-index:1}
.hero-kicker{display:flex;align-items:center;gap:7px;color:#0f7f78;font-size:12px;font-weight:900;margin-bottom:7px}
.hero-kicker .ui-icon{width:18px;height:18px}
.medical-hero h1{font-size:clamp(25px,6vw,36px);color:#123944;letter-spacing:-.8px}
.medical-hero p{margin:7px 0 0;color:#5e7a82;font-size:13px}
.subscription-chip{display:inline-flex;align-items:center;gap:7px;margin-top:12px;padding:7px 10px;border:1px solid #cfe8e5;border-radius:999px;background:rgba(255,255,255,.78);font-size:11px;color:#53727a}
.subscription-chip .ui-icon{width:15px;height:15px;color:#0f7f78}
.subscription-chip b{color:#17444d}
.hero-actions{position:relative;z-index:1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.hero-icon-button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;min-height:74px;padding:9px 7px;border:1px solid #d4e7e9;border-radius:17px;background:rgba(255,255,255,.92);color:#31545e;font-size:11px;font-weight:900;cursor:pointer;box-shadow:0 5px 18px rgba(31,82,91,.045);transition:.18s ease}
.hero-icon-button:hover{transform:translateY(-1px);border-color:#a9d3d4;box-shadow:0 9px 22px rgba(31,82,91,.08)}
.hero-icon-button .ui-icon{width:23px;height:23px;color:#0f7f78}
.hero-icon-primary{background:linear-gradient(145deg,#0f7f78,#168ca0);border-color:transparent;color:#fff}
.hero-icon-primary .ui-icon{color:#fff}

.stats-panel-modern{margin:0 0 14px;padding:13px;border:1px solid #cfe3e6;border-radius:20px;background:#fff;box-shadow:var(--shadow);animation:statsIn .18s ease}
.stats-panel-modern[hidden]{display:none!important}
.stats-loading{display:flex;align-items:center;justify-content:center;gap:9px;min-height:70px;color:var(--muted);font-size:12px}
.spinner{width:18px;height:18px;border:2px solid #d8e8e9;border-top-color:#0f7f78;border-radius:50%;animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.today-stats-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.today-stat{padding:12px;border:1px solid #dfebed;border-radius:15px;background:#f9fcfc}
.today-stat span{display:block;font-size:10px;color:#6d838a;font-weight:800;margin-bottom:5px}
.today-stat b{font-size:24px;line-height:1;color:#173d46}
.today-stat.fees{grid-column:1/-1;background:#eef9f7;border-color:#cfeae4}
.today-stat.fees b{font-size:19px;color:#0b6e62}
.stats-date{display:flex;align-items:center;justify-content:space-between;margin-bottom:9px;font-size:11px;color:#70868d}

.workspace-card{padding:15px;margin-bottom:14px;border:1px solid var(--line);border-radius:20px;background:#fff;box-shadow:var(--shadow)}
.workspace-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:12px}
.workspace-heading p{margin:4px 0 0;font-size:12px}
.patient-search-modern{display:flex;gap:8px;align-items:stretch}
.search-input-modern{position:relative;display:flex;align-items:center;flex:1;min-width:0;border:1px solid #c9dfe2;border-radius:14px;background:#fafdfe;transition:.16s ease}
.search-input-modern:focus-within{border-color:#65b8b3;box-shadow:0 0 0 4px rgba(15,127,120,.09);background:#fff}
.search-input-modern .ui-icon{position:absolute;right:13px;width:19px;height:19px;color:#6b8a92}
.search-input-modern input{width:100%;height:48px;border:0;outline:0;background:transparent;padding:11px 42px 11px 12px;color:#173640;font-weight:700}
.search-input-modern input::placeholder{font-weight:500;color:#9aabb0}
.inline-hint{margin-top:9px;padding:9px 11px;border-radius:11px;font-size:11px;font-weight:700}
.error-hint{background:#fff3f1;color:#a9362c;border:1px solid #ffd8d2}
.search-results-head{display:flex;justify-content:space-between;align-items:center;margin:15px 1px 9px;color:#637a82;font-size:11px;font-weight:800}
.search-results-head b{display:grid;place-items:center;min-width:25px;height:25px;padding:0 7px;border-radius:999px;background:#e7f6f4;color:#0f766e}
.search-empty-guide{display:flex;gap:11px;align-items:center;margin-top:12px;padding:14px;border:1px dashed #c9dfe2;border-radius:15px;background:#f9fcfd;color:#5e7981}
.search-empty-guide>.ui-icon{width:27px;height:27px;color:#67a5aa}
.search-empty-guide b,.search-empty-guide span{display:block}
.search-empty-guide b{font-size:13px;color:#31535c;margin-bottom:3px}
.search-empty-guide span{font-size:11px;line-height:1.7}
.count-pill{display:inline-flex;align-items:center;gap:6px;padding:7px 9px;border-radius:999px;background:#eaf7f6;color:#0c716a;font-size:12px}
.count-pill .ui-icon{width:16px;height:16px}

.patient-grid-modern{display:grid;grid-template-columns:1fr;gap:10px}
.patient-card-modern{position:relative;overflow:hidden;border:1px solid #dbe9eb;border-radius:18px;background:#fff;box-shadow:0 5px 20px rgba(25,66,76,.045);transition:.18s ease}
.patient-card-modern:hover{border-color:#bad7da;box-shadow:0 10px 28px rgba(25,66,76,.085);transform:translateY(-1px)}
.patient-card-open{display:block;padding:13px 13px 10px}
.patient-card-head{display:flex;align-items:center;gap:10px;min-width:0}
.patient-avatar-modern{width:47px;height:47px;border-radius:15px;display:grid;place-items:center;flex:0 0 auto;background:linear-gradient(145deg,#dff5f2,#e8f6fb);border:1px solid #c9e5e3;color:#0c766e;font-size:20px;font-weight:900}
.patient-card-name{flex:1;min-width:0}
.patient-card-name h3{font-size:16px;margin:0 0 4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#173b44}
.patient-card-chevron{display:grid;place-items:center;width:29px;height:29px;border-radius:10px;background:#f4f9fa;color:#83a0a7}
.patient-card-chevron .ui-icon{width:16px;height:16px}
.patient-card-info{display:grid;grid-template-columns:72px minmax(0,1fr);gap:7px;margin-top:11px;padding-top:10px;border-top:1px solid #edf3f4}
.patient-card-info>div{min-width:0;padding:7px 8px;border-radius:10px;background:#f8fbfc}
.patient-card-info span{display:block;font-size:9px;color:#84969c;font-weight:800;margin-bottom:3px}
.patient-card-info strong{display:block;font-size:12px;color:#38565e;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.patient-card-status{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:0 13px 9px}
.patient-card-status .muted{margin-inline-start:auto}
.patient-card-actions{display:grid;grid-template-columns:1fr 1fr;border-top:1px solid #eaf1f2;background:#fbfdfd}
.icon-action{appearance:none;border:0;background:transparent;display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:43px;padding:8px 10px;color:#526e76;font-size:11px;font-weight:900;cursor:pointer}
.icon-action+.icon-action{border-inline-start:1px solid #e5eeee}
.icon-action .ui-icon{width:17px;height:17px;color:#5f8b91}
.icon-action.primary{color:#0c766e}
.icon-action.primary .ui-icon{color:#0f7f78}
.icon-action:hover{background:#f1f9f8;color:#0d6d67}
.icon-action.compact{min-height:38px;border:1px solid #dce9eb;border-radius:11px;background:#fff;padding:7px 9px}
.icon-action.compact+.icon-action{border-inline-start:1px solid #dce9eb}
.icon-action.danger{color:#a72e25;border-color:#f1d3cf;background:#fff8f7}
.icon-action.danger .ui-icon{color:#b42318}
.patient-inline-stats{padding:11px 13px;border-top:1px solid #e5eeee;background:linear-gradient(180deg,#f6fbfb,#fbfdfd)}
.patient-inline-stats[hidden]{display:none!important}
.patient-stat-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
.patient-stat-item{padding:8px;border:1px solid #deeaec;border-radius:11px;background:#fff}
.patient-stat-item span{display:block;font-size:9px;color:#7d9096;margin-bottom:3px;font-weight:800}
.patient-stat-item b{font-size:14px;color:#254b53}
.patient-stat-footer{margin-top:7px;font-size:10px;color:#74888f}

.patients-head-modern,.archive-hero{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin:5px 0 13px;padding:3px 2px}
.patients-head-modern p,.archive-hero p{margin:5px 0 0;font-size:12px}
.archive-breadcrumbs{display:flex;align-items:center;gap:6px;overflow-x:auto;margin-bottom:11px;padding:8px 10px;border:1px solid #dce9eb;border-radius:13px;background:#fff;font-size:11px;color:#71858c;white-space:nowrap;scrollbar-width:none}
.archive-breadcrumbs a{color:#0f766e;font-weight:800}
.archive-grid{display:grid;grid-template-columns:1fr;gap:10px}
.archive-card{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:12px;padding:14px;border:1px solid #d9e8ea;border-radius:18px;background:#fff;box-shadow:0 7px 22px rgba(26,68,77,.05);transition:.18s ease}
.archive-card:hover{transform:translateY(-1px);border-color:#b8d8da;box-shadow:0 12px 28px rgba(26,68,77,.085)}
.archive-icon,.archive-day-number{width:47px;height:47px;border-radius:14px;display:grid;place-items:center;background:#e8f7f5;color:#0f766e;font-weight:900}
.archive-icon .ui-icon{width:22px;height:22px}
.archive-day-number{font-size:20px;background:linear-gradient(145deg,#e4f6f3,#eaf6fb)}
.archive-label{display:block;color:#81949a;font-size:10px;font-weight:800;margin-bottom:3px}
.archive-card h2{font-size:18px;color:#234950}
.archive-card p{margin:4px 0 0;color:#71868d;font-size:11px}
.archive-arrow{color:#92a7ad}
.archive-arrow .ui-icon{width:18px;height:18px}

.patient-profile-hero{position:relative;padding:17px;margin:4px 0 14px;border:1px solid #cfe4e6;border-radius:22px;background:linear-gradient(145deg,#f0fbfa,#f7fcff);box-shadow:0 12px 30px rgba(29,75,84,.065)}
.profile-main{display:flex;align-items:center;gap:12px;min-width:0}
.profile-avatar{width:59px;height:59px;border-radius:18px;display:grid;place-items:center;flex:0 0 auto;background:linear-gradient(145deg,#d9f2ef,#e1f3fa);border:1px solid #c5e2df;color:#0c746c;font-size:25px;font-weight:900}
.profile-copy{min-width:0}
.profile-code{display:inline-flex;align-items:center;gap:5px;margin-bottom:4px;color:#68838a;font:800 10px ui-monospace,SFMono-Regular,Menlo,monospace;direction:ltr}
.profile-code .ui-icon{width:14px;height:14px}
.profile-copy h1{font-size:clamp(23px,6vw,32px);white-space:normal;overflow-wrap:anywhere}
.profile-meta{display:flex;gap:7px;flex-wrap:wrap;margin-top:8px}
.profile-meta span{display:inline-flex;align-items:center;gap:4px;padding:5px 7px;border-radius:9px;background:rgba(255,255,255,.78);color:#627d84;font-size:10px}
.profile-meta .ui-icon{width:13px;height:13px;color:#5d9798}
.profile-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));margin-top:13px;border:1px solid #d8e8ea;border-radius:14px;overflow:hidden;background:#fff}
.profile-actions .icon-action{min-height:46px}
.profile-inline-stats{margin-top:10px;border:1px solid #d9e8ea;border-radius:14px}
.patient-edit-details summary,.archive-patient-zone summary{display:flex;align-items:center;gap:7px;cursor:pointer;font-weight:900;color:#365960;list-style:none}
.patient-edit-details summary::-webkit-details-marker,.archive-patient-zone summary::-webkit-details-marker{display:none}
.patient-edit-details summary .ui-icon,.archive-patient-zone summary .ui-icon{color:#0f7f78}
.edit-patient-form{margin-top:13px}

.visit-top-fields{grid-template-columns:1fr}
.money-input{position:relative;display:flex;align-items:center}
.money-input>.ui-icon{position:absolute;right:12px;width:17px;height:17px;color:#679198;z-index:1}
.money-input input{padding-right:39px!important;direction:ltr;text-align:right}
.field small{display:block;margin-top:5px;color:#7b8d93;font-size:10px;line-height:1.5}
.clinical-fields{display:grid;grid-template-columns:1fr;gap:11px;margin-top:12px}
.clinical-box{padding:12px;border:1px solid #dce9ea;border-radius:16px;background:#fbfdfd}
.clinical-title{display:flex;align-items:center;gap:7px;margin-bottom:8px;color:#2d535b;font-size:13px;font-weight:900}
.clinical-title .ui-icon{width:19px;height:19px;color:#0f7f78}
.clinical-box textarea{width:100%;min-height:135px;border:1px solid #cbdfe1;border-radius:13px;padding:12px;background:#fff;color:#173840;outline:none;resize:vertical;line-height:1.7}
.clinical-box textarea:focus{border-color:#67b8b3;box-shadow:0 0 0 4px rgba(15,127,120,.08)}
.quick-buttons{margin-bottom:8px}
.quick-buttons button{border-color:#c5dfdf;background:#eef9f8;color:#176a66;border-radius:999px;font-size:11px;padding:7px 10px}
.attachment-field label{display:flex;align-items:center;gap:6px}
.attachment-field label .ui-icon{width:17px;height:17px;color:#1688a1}
.save-visit-button{width:100%;min-height:49px}

.visits-section{margin-top:17px}
.visits-section-title{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin:0 2px 11px}
.visits-section-title p{margin:4px 0 0;font-size:11px}
.visit-timeline{position:relative;display:grid;gap:11px}
.visit-card-modern{position:relative;padding:14px;border:1px solid #d9e7e9;border-radius:19px;background:#fff;box-shadow:0 7px 24px rgba(25,68,77,.05)}
.visit-card-header{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;padding-bottom:11px;border-bottom:1px solid #edf3f4}
.visit-date{display:flex;align-items:center;gap:6px;color:#294e56;font-size:12px}
.visit-date .ui-icon{width:16px;height:16px;color:#0f7f78}
.visit-date span{color:#7c9096;font-size:10px}
.visit-doctor{display:flex;align-items:center;gap:5px;margin-top:5px;color:#71868d;font-size:10px}
.visit-doctor .ui-icon{width:14px;height:14px}
.visit-badges{display:flex;align-items:flex-end;gap:5px;flex-direction:column}
.fee-badge{display:inline-flex;align-items:center;gap:4px;padding:5px 8px;border-radius:999px;background:#edf8f6;color:#0b6d63;font-size:10px;font-weight:900;direction:ltr}
.fee-badge .ui-icon{width:13px;height:13px}
.visit-content-grid{display:grid;grid-template-columns:1fr;gap:9px;margin-top:11px}
.visit-clinical-block{padding:11px;border:1px solid #e0ebec;border-radius:14px;background:#f9fcfc}
.visit-clinical-block.treatment{background:#f7fbfd}
.visit-block-title{display:flex;align-items:center;gap:6px;margin-bottom:7px;color:#31545c;font-size:11px}
.visit-block-title .ui-icon{width:16px;height:16px;color:#0f7f78}
.visit-text{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.8;font-size:13px;color:#263f46}
.visit-note{display:flex;gap:8px;margin-top:9px;padding:9px 10px;border-radius:12px;background:#fffaf1;border:1px solid #f4e7c8;color:#685b3c}
.visit-note>.ui-icon{width:17px;height:17px;flex:0 0 auto;margin-top:2px}
.visit-note b{font-size:10px}
.visit-note p{margin:2px 0 0;font-size:11px;white-space:pre-wrap}
.visit-thumbs{margin-top:10px;padding-top:9px;border-top:1px solid #edf2f3}
.visit-thumbs img{width:82px;height:82px;border-radius:13px}
.visit-actions{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;margin-top:11px;padding-top:10px;border-top:1px solid #edf2f3}
.record-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.record-actions form{margin:0}

@media(min-width:600px){
  .medical-hero{grid-template-columns:minmax(0,1fr) auto;align-items:center;padding:23px}
  .hero-actions{width:300px}
  .patient-grid-modern{grid-template-columns:repeat(2,minmax(0,1fr))}
  .archive-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .visit-top-fields{grid-template-columns:repeat(3,minmax(0,1fr))}
  .clinical-fields{grid-template-columns:repeat(2,minmax(0,1fr))}
  .visit-content-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(min-width:980px){
  .patient-grid-modern{grid-template-columns:repeat(3,minmax(0,1fr))}
  .archive-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
}
@media(max-width:719px){
  .topbar-inner{gap:8px}
  .brand-wrap{width:100%}
  .nav{margin-inline:-2px;width:calc(100% + 4px);padding-bottom:2px}
  .nav a{flex:0 0 auto;padding:8px 10px}
  .nav a span{font-size:11px}
  .shell{padding:11px 10px 30px}
  .medical-hero{padding:16px}
  .patient-search-modern{display:grid;grid-template-columns:minmax(0,1fr) auto}
  .patient-search-modern .btn{padding-inline:14px}
  .patients-head-modern,.archive-hero{flex-direction:column;align-items:stretch}
  .patients-head-modern .actions,.archive-hero .btn{width:100%}
  .patients-head-modern .actions{display:grid;grid-template-columns:1fr 1fr}
  .profile-main{align-items:flex-start}
  .profile-avatar{width:52px;height:52px;border-radius:16px}
  .visit-card-header{align-items:flex-start}
  .visit-actions{align-items:stretch}
  .record-actions{width:100%}
  .record-actions .icon-action,.record-actions form{flex:1}
  .record-actions form .icon-action{width:100%}
}
@media(max-width:390px){
  .hero-icon-button{min-height:68px;padding-inline:4px}
  .hero-icon-button span{font-size:10px}
  .patient-card-info{grid-template-columns:66px minmax(0,1fr)}
  .profile-actions .icon-action span{font-size:10px}
  .archive-card{padding:12px;gap:9px}
  .archive-icon,.archive-day-number{width:42px;height:42px}
}
.patient-card-info>div:nth-child(n+3){grid-column:1/-1}

/* ===== MedFlow UI stabilization v1.3 ===== */
:root{
  --med-ink:#15363d;
  --med-primary:#0b8079;
  --med-primary-2:#178fa2;
  --med-border:#d7e8e9;
  --med-soft:#edf9f7;
}
.shell{max-width:1120px}
.topbar{background:rgba(249,253,253,.96);box-shadow:0 4px 18px rgba(26,71,78,.045)}
.topbar-inner{max-width:1120px}
.nav a{border-radius:13px;box-shadow:0 2px 8px rgba(23,61,72,.025)}
.medical-hero{background:linear-gradient(145deg,#edf9f7 0%,#f8fcfd 58%,#edf7fb 100%);border-color:#cce4e4}
.medical-hero:before{content:"";position:absolute;right:-60px;bottom:-85px;width:190px;height:190px;border-radius:50%;background:rgba(23,143,162,.055);pointer-events:none}
.workspace-card{box-shadow:0 8px 25px rgba(22,65,72,.055)}
.patient-card-modern{box-shadow:0 4px 18px rgba(22,65,72,.045)}
.patient-card-open:focus-visible,.icon-action:focus-visible,.hero-icon-button:focus-visible,.live-sync-pill:focus-visible,.btn:focus-visible{outline:3px solid rgba(15,127,120,.18);outline-offset:2px}
.badge.new-patient{background:#e8f4ff;color:#1769a7;border:1px solid #cce5f7}
.workspace-side{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.live-sync-pill{appearance:none;display:inline-flex;align-items:center;gap:7px;min-height:34px;padding:7px 10px;border:1px solid #cfe5df;border-radius:999px;background:#f5fbf9;color:#416b68;font-size:10px;font-weight:900;cursor:pointer;transition:.18s ease}
.live-sync-pill:hover{background:#edf9f6;border-color:#acd7cd}
.live-sync-pill .event-dot{width:7px;height:7px;background:#12a66d;box-shadow:0 0 0 4px rgba(18,166,109,.10)}
.live-sync-pill.is-syncing .event-dot{animation:syncPulse .85s ease-in-out infinite;background:#1688b8}
.live-sync-pill.is-updated{background:#eaf8f1;color:#087a59;border-color:#bfe5d3}
.live-sync-pill.is-updated .event-dot{background:#0c9b67;animation:syncPop .42s ease}
.live-sync-pill.is-error{background:#fff4f2;color:#a23a30;border-color:#f1d0cb}
.live-sync-pill.is-error .event-dot{background:#c04435;box-shadow:0 0 0 4px rgba(192,68,53,.09)}
@keyframes syncPulse{0%,100%{transform:scale(.85);opacity:.6}50%{transform:scale(1.25);opacity:1}}
@keyframes syncPop{0%{transform:scale(.6)}70%{transform:scale(1.45)}100%{transform:scale(1)}}
.live-card-enter{animation:liveCardIn .22s ease-out both}
@keyframes liveCardIn{from{opacity:.45;transform:translateY(3px)}to{opacity:1;transform:none}}

.settings-hero{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin:5px 0 14px;padding:4px 2px}
.settings-hero p{margin:5px 0 0}
.settings-form{display:grid;gap:0}
.feature-toggle-grid{display:grid;grid-template-columns:1fr;gap:10px}
.feature-toggle-card{position:relative;display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;padding:14px;border:1px solid #d8e8e8;border-radius:17px;background:#fbfdfd;cursor:pointer;transition:.18s ease}
.feature-toggle-card:hover{border-color:#bddbd8;background:#fff}
.feature-switch-input{position:absolute;opacity:0;pointer-events:none}
.feature-icon{width:44px;height:44px;border-radius:14px;display:grid;place-items:center;background:#e9f7f5;color:#0c7a72}
.feature-icon .ui-icon{width:21px;height:21px}
.feature-copy{min-width:0}
.feature-copy b{display:block;color:#25484f;font-size:13px;margin-bottom:4px}
.feature-copy small{display:block;color:#75888e;font-size:10px;line-height:1.6}
.switch-ui{position:relative;width:48px;height:27px;border-radius:999px;background:#cad7da;box-shadow:inset 0 0 0 1px rgba(55,79,85,.08);transition:.2s ease;flex:0 0 auto}
.switch-ui:after{content:"";position:absolute;top:4px;right:4px;width:19px;height:19px;border-radius:50%;background:#fff;box-shadow:0 2px 6px rgba(26,55,63,.18);transition:.2s ease}
.feature-switch-input:checked~.switch-ui{background:linear-gradient(135deg,#0f7f78,#20a096)}
.feature-switch-input:checked~.switch-ui:after{transform:translateX(-21px)}
.feature-switch-input:focus-visible~.switch-ui{outline:3px solid rgba(15,127,120,.16);outline-offset:2px}
.settings-save-bar{position:sticky;bottom:10px;z-index:8;display:flex;justify-content:flex-start;padding:10px;border:1px solid rgba(208,228,229,.95);border-radius:17px;background:rgba(250,254,254,.94);backdrop-filter:blur(12px);box-shadow:0 10px 30px rgba(22,65,72,.08)}
.settings-save-bar .btn{min-width:180px}

@media(min-width:650px){
  .feature-toggle-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:719px){
  body{background:linear-gradient(180deg,#fbfefe 0,#f4fafb 200px,#f4fafb 100%)}
  .topbar{position:sticky;top:0}
  .topbar-inner{padding:8px 10px;gap:7px}
  .brand-mark{width:38px;height:38px;border-radius:12px}
  .brand-mark .ui-icon{width:21px;height:21px}
  .brand{font-size:14px}
  .brand-user{font-size:10px}
  .nav{gap:6px;padding-bottom:1px;scroll-snap-type:x proximity}
  .nav a{scroll-snap-align:start;min-height:38px;padding:7px 9px;font-size:10px}
  .nav a .ui-icon{width:16px;height:16px}
  .shell{padding-top:10px}
  .medical-hero{border-radius:20px;gap:14px}
  .hero-actions{gap:7px}
  .hero-icon-button{border-radius:15px;min-height:66px}
  .workspace-heading{align-items:flex-start}
  .workspace-side{align-items:flex-end;flex-direction:column;gap:6px}
  .live-sync-pill{min-height:31px;padding:6px 9px}
  .patient-card-modern{border-radius:17px}
  .patient-card-open{padding:12px 12px 9px}
  .profile-actions{grid-template-columns:repeat(3,minmax(0,1fr))}
  .feature-toggle-card{padding:12px;gap:10px}
  .feature-icon{width:40px;height:40px}
  .settings-save-bar{bottom:8px}
  .settings-save-bar .btn{width:100%;min-width:0}
}
@media(max-width:390px){
  .workspace-heading{gap:8px}
  .workspace-side{min-width:95px}
  .live-sync-pill{font-size:9px}
  .feature-toggle-card{grid-template-columns:auto minmax(0,1fr)}
  .feature-toggle-card .switch-ui{grid-column:1/-1;justify-self:end}
}

/* ===== MedFlow v1.4 focused mobile UI ===== */
.topbar-inner{min-height:54px;padding:7px 10px!important;flex-direction:row!important;align-items:center!important;gap:8px!important}
.brand-wrap{min-width:0;gap:7px}.brand-mark{width:34px;height:34px;border-radius:11px}.brand-mark .ui-icon{width:18px;height:18px}.brand{font-size:13px!important}.brand-user{font-size:9px!important;max-width:110px!important;margin-top:0!important}
.nav{width:auto!important;max-width:70%;margin:0!important;gap:5px!important;padding:0!important;align-items:center}
.nav a.nav-icon-only{width:38px;min-width:38px;height:38px;min-height:38px;padding:0!important;display:inline-grid!important;place-items:center;border-radius:12px}
.nav a.nav-icon-only .ui-icon{width:18px;height:18px}.nav a.nav-logout{min-height:38px;padding:7px 10px!important;gap:5px}.nav a.nav-logout span{font-size:10px!important}
.medical-hero.medical-hero-compact{padding:10px 12px!important;min-height:0;border-radius:18px;display:flex!important;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.medical-hero-compact .medical-hero-copy{display:flex;align-items:center;gap:8px;min-width:0;flex-wrap:wrap}.medical-hero-compact .hero-kicker{margin:0;font-size:11px}.medical-hero-compact .subscription-chip{margin:0;padding:6px 8px;font-size:9px;min-height:30px}.medical-hero-compact .hero-actions-compact{display:flex;grid-template-columns:none;width:auto!important;gap:6px}.medical-hero-compact .hero-icon-button{min-width:42px;padding:7px 9px;min-height:38px}.medical-hero-compact .hero-icon-button span{font-size:9px}
.archive-year-card{display:block!important;padding:0!important;overflow:hidden}.archive-card-main{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:12px;padding:13px;text-decoration:none;color:inherit}.archive-year-stats-button{width:calc(100% - 24px);margin:0 12px 12px;border:1px solid #d9e8ea;background:#f6fbfb;color:#35646b;border-radius:12px;min-height:38px;display:flex;align-items:center;justify-content:center;gap:6px;font-weight:800}.archive-year-stats-button .ui-icon{width:16px;height:16px}.archive-year-stats-panel{border-top:1px solid #e5efef;padding:10px 12px;background:#fbfefe}.year-stat-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}.year-stat-item{padding:9px;border:1px solid #e0ecec;border-radius:11px;background:#fff}.year-stat-item span{display:block;font-size:9px;color:var(--muted)}.year-stat-item b{display:block;margin-top:3px;font-size:15px;color:#214c55}
.visit-block-title-actions{display:flex!important;align-items:center!important;justify-content:space-between!important;gap:8px}.visit-block-title-actions>span{display:inline-flex;align-items:center;gap:6px}.print-section-button{width:34px;height:34px;display:grid;place-items:center;border:1px solid #d3e5e6;border-radius:10px;background:#f7fcfc;color:#0f817c;box-shadow:0 3px 10px rgba(27,82,87,.05)}.print-section-button .ui-icon{width:16px;height:16px}.print-section-button:hover{background:#eaf8f7;border-color:#b8dbdc}
.quick-library-grid,.template-grid,.clinic-admin-grid{display:grid;gap:10px;margin:12px 0}.quick-library-card,.template-card,.clinic-admin-card{border:1px solid #d8e7e8;border-radius:17px;background:#fff;box-shadow:0 7px 22px rgba(25,68,77,.045)}.quick-library-card{padding:12px;display:flex;align-items:flex-start;justify-content:space-between;gap:10px}.quick-library-card h3,.template-card h3{margin:7px 0 4px;font-size:14px}.quick-library-card p{margin:0;white-space:pre-wrap;color:#607981;font-size:11px;line-height:1.7}.field-span-two{grid-column:1/-1}.template-card{overflow:hidden}.template-preview{height:150px;background:#eef5f5;display:grid;place-items:center;overflow:hidden}.template-preview img{width:100%;height:100%;object-fit:contain;background:#fff}.template-card-body{padding:10px;display:flex;justify-content:space-between;align-items:center;gap:8px}.template-card-body>div{min-width:0}.template-card-body h3{margin:0 0 5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.compact-settings-hero{padding:14px!important;margin-bottom:10px!important}.compact-settings-hero h1{font-size:22px!important}.clinic-feature-row{display:flex;gap:7px;flex-wrap:wrap;margin:11px 0}.mini-toggle{display:flex;align-items:center;gap:6px;padding:8px 10px;border:1px solid #dce9ea;border-radius:11px;background:#f8fcfc;font-size:10px;font-weight:800}.clinic-admin-card{overflow:hidden}.clinic-admin-card summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:13px}.clinic-admin-card summary::-webkit-details-marker{display:none}.clinic-admin-card summary>div{display:grid;grid-template-columns:auto 1fr;align-items:center;gap:2px 7px}.clinic-admin-card summary small{grid-column:2;color:var(--muted);font-size:9px}.status-dot{width:9px;height:9px;border-radius:50%;grid-row:1/3}.status-dot.on{background:#27a36a;box-shadow:0 0 0 4px rgba(39,163,106,.09)}.status-dot.off{background:#c85b5b;box-shadow:0 0 0 4px rgba(200,91,91,.09)}.clinic-admin-form{border-top:1px solid #e7eeee;padding:12px}.clinic-toggles{margin:10px 0}.clinic-toggles .feature-toggle-card{margin:0}
@media(min-width:720px){.quick-library-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.template-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.clinic-admin-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.year-stat-grid{grid-template-columns:repeat(5,minmax(0,1fr))}}
@media(max-width:560px){.topbar-inner{padding:6px 8px!important}.brand-mark{width:32px;height:32px}.brand-user{display:none}.nav{max-width:76%!important}.nav a.nav-icon-only{width:36px;min-width:36px;height:36px;min-height:36px}.medical-hero.medical-hero-compact{align-items:stretch}.medical-hero-compact .medical-hero-copy{display:grid;gap:5px}.medical-hero-compact .subscription-chip{max-width:170px}.medical-hero-compact .hero-icon-button span{display:none}.medical-hero-compact .hero-icon-button{width:38px;min-width:38px;padding:0;display:grid;place-items:center}.medical-hero-compact .hero-icon-button .ui-icon{width:17px;height:17px}.archive-card-main{padding:11px;gap:9px}.template-preview{height:120px}}
.workspace-heading-actions{display:flex;align-items:center;gap:7px}.section-icon-button{width:38px;height:38px;display:grid;place-items:center;border-radius:12px;border:1px solid #cfe4e4;background:#eef9f8;color:#0f817c}.section-icon-button .ui-icon{width:18px;height:18px}

/* ===== MedFlow v1.5 toolbar-only top banner ===== */
.topbar-inner{min-height:50px!important;padding:6px 8px!important;justify-content:center!important}
.topbar .nav.nav-distributed{width:100%!important;max-width:100%!important;margin:0!important;padding:0!important;display:flex!important;align-items:center!important;justify-content:space-evenly!important;gap:6px!important;overflow:visible!important}
.topbar .nav.nav-distributed a.nav-icon-only{flex:0 0 40px;width:40px!important;min-width:40px!important;height:40px!important;min-height:40px!important;padding:0!important;display:grid!important;place-items:center!important;border-radius:13px;background:rgba(255,255,255,.88);border:1px solid #d8e8e9;box-shadow:0 2px 10px rgba(24,73,79,.035)}
.topbar .nav.nav-distributed a.nav-icon-only .ui-icon{width:18px;height:18px;color:#3d7479}
.topbar .nav.nav-distributed a.nav-icon-only:hover{background:#fff;border-color:#bcdcdc;color:#0f7f78}
.topbar .nav.nav-distributed a.nav-logout{flex:0 0 auto;min-height:40px!important;padding:7px 11px!important;border-radius:13px;background:#fff;border-color:#d8e8e9;color:#7b4a46}
.topbar .nav.nav-distributed a.nav-logout .ui-icon{color:#a75b52}
.medical-hero.medical-hero-compact{padding:8px 10px!important;margin-bottom:8px!important;gap:8px!important;border-radius:16px!important}
.medical-hero-compact .hero-kicker{font-size:10px!important}
.medical-hero-compact .subscription-chip{min-height:27px!important;padding:5px 7px!important;font-size:8.5px!important}
.user-admin-details{border:1px solid #dce9ea;border-radius:14px;background:#fbfefe;margin-top:9px;overflow:hidden}
.user-admin-details>summary{cursor:pointer;padding:12px 13px;font-weight:850;color:#31545b;list-style:none}
.user-admin-details>summary::-webkit-details-marker{display:none}
.user-admin-form{padding:12px;border-top:1px solid #e4eeee}
@media(max-width:560px){
  .topbar-inner{min-height:48px!important;padding:5px 6px!important}
  .topbar .nav.nav-distributed{gap:4px!important}
  .topbar .nav.nav-distributed a.nav-icon-only{flex-basis:38px;width:38px!important;min-width:38px!important;height:38px!important;min-height:38px!important}
  .topbar .nav.nav-distributed a.nav-logout{min-height:38px!important;padding:6px 9px!important}
  .medical-hero.medical-hero-compact{padding:7px 9px!important}
}
.permissions-subheading{margin-top:16px;padding-top:14px;border-top:1px solid #e5eeee}
.permission-check-card{display:flex;align-items:center;gap:9px;padding:11px 12px;border:1px solid #dce9ea;border-radius:13px;background:#fbfefe;font-size:12px;font-weight:800;color:#36585f;cursor:pointer}
.permission-check-card input{width:18px;height:18px;accent-color:#0f7f78;flex:0 0 auto}
.permission-check-card:has(input:checked){background:#edf9f7;border-color:#bfe0db;color:#155f5a}

/* ===== MedFlow v1.6 visibility, new-patient attention and clearer icon palette ===== */
.topbar .nav.nav-distributed a.nav-icon-only{border-width:1px!important;box-shadow:0 4px 12px rgba(24,73,79,.055)!important}
.topbar .nav.nav-distributed a.nav-home{background:#eaf8f6!important;border-color:#bfe3de!important}.topbar .nav.nav-distributed a.nav-home .ui-icon{color:#087d72!important}
.topbar .nav.nav-distributed a.nav-archive{background:#eef6fd!important;border-color:#cadeef!important}.topbar .nav.nav-distributed a.nav-archive .ui-icon{color:#3476a8!important}
.topbar .nav.nav-distributed a.nav-quick{background:#f4f0fd!important;border-color:#ddd1f5!important}.topbar .nav.nav-distributed a.nav-quick .ui-icon{color:#7156ad!important}
.topbar .nav.nav-distributed a.nav-clinics{background:#edf9f2!important;border-color:#c8e8d4!important}.topbar .nav.nav-distributed a.nav-clinics .ui-icon{color:#2a8554!important}
.topbar .nav.nav-distributed a.nav-admin{background:#fff5e9!important;border-color:#efd9ba!important}.topbar .nav.nav-distributed a.nav-admin .ui-icon{color:#a66d25!important}
.topbar .nav.nav-distributed a.nav-icon-only:active{transform:translateY(1px);box-shadow:0 1px 5px rgba(24,73,79,.06)!important}

.add-patient-visible{display:inline-flex!important;align-items:center;justify-content:center;gap:7px;white-space:nowrap;min-height:40px;padding-inline:13px!important;box-shadow:0 6px 16px rgba(15,127,120,.13)}
.add-patient-visible .ui-icon{width:17px;height:17px}

.patient-card-modern.patient-new-unseen{background:linear-gradient(145deg,#fffdf3,#fff9db);border-color:#ecd98a;box-shadow:0 7px 24px rgba(181,143,29,.11)}
.patient-card-modern.patient-new-unseen::before{content:"";position:absolute;inset-block:0;inset-inline-start:0;width:4px;background:#e4b52f}
.patient-card-modern.patient-new-unseen .patient-avatar-modern{background:#fff1b8;color:#8c6411}
.badge.unseen-patient{background:#fff0ae;color:#77520a;border:1px solid #ead37a}

.patient-card-modern.patient-hidden-card{background:linear-gradient(145deg,#f1f3f3,#e9eded);border-color:#c9d1d2;box-shadow:none;filter:saturate(.62)}
.patient-card-modern.patient-hidden-card::after{content:"";position:absolute;inset:0;pointer-events:none;background:repeating-linear-gradient(135deg,rgba(89,107,111,.035) 0 8px,transparent 8px 16px)}
.patient-hidden-card .patient-card-open,.patient-hidden-card .patient-card-actions,.patient-hidden-card .patient-inline-stats{position:relative;z-index:1}
.badge.hidden-patient,.patient-hidden-banner{display:inline-flex;align-items:center;gap:5px;background:#e2e7e8;color:#596b70;border:1px solid #c5ced0;border-radius:999px;font-size:9px;font-weight:900;padding:4px 7px}
.patient-hidden-banner{margin-top:6px}.patient-hidden-banner .ui-icon{width:13px;height:13px}
.patient-profile-hidden{background:linear-gradient(145deg,#f2f4f4,#e8eeee)!important;border-color:#c9d3d5!important}

.patient-visibility-control{display:flex;align-items:center;justify-content:space-between;gap:14px;border-inline-start:4px solid #48a997}
.patient-visibility-control.is-hidden{border-inline-start-color:#7b8b8f;background:#f3f5f5}
.patient-visibility-control h2{font-size:15px;margin:2px 0 3px}.patient-visibility-control p{margin:0;max-width:640px}.patient-visibility-control form{flex:0 0 auto}
.visibility-hide-button{border-color:#d8bebe!important;background:#fff8f7!important;color:#8d4640!important}

.patient-card-actions .icon-action{background:#fbfefe}.patient-card-actions .icon-action.primary{background:#eef9f7;color:#087b72}.patient-card-actions .icon-action.primary .ui-icon{color:#087b72}.patient-card-actions .icon-action:not(.primary){background:#f2f7fb;color:#426d89}.patient-card-actions .icon-action:not(.primary) .ui-icon{color:#4e7f9d}

.patient-edit-details summary,.delete-patient-zone summary{display:flex;align-items:center;gap:7px;cursor:pointer;font-weight:900;color:#365960;list-style:none}
.patient-edit-details summary::-webkit-details-marker,.delete-patient-zone summary::-webkit-details-marker{display:none}
.delete-patient-zone summary{color:#a23a32}.delete-patient-zone summary .ui-icon{color:#b33f36}

@media(max-width:560px){
  .workspace-heading-actions{width:auto}.add-patient-visible{min-height:38px;padding:7px 10px!important;font-size:10px}
  .patient-visibility-control{align-items:stretch;flex-direction:column}.patient-visibility-control form,.patient-visibility-control form .btn{width:100%}
  .topbar .nav.nav-distributed a.nav-icon-only{box-shadow:0 2px 8px rgba(24,73,79,.05)!important}
}


/* ===== MedFlow v1.6.1 compact subscription countdown ===== */
.subscription-countdown-bar{display:flex;align-items:center;justify-content:center;margin:7px 0 9px;padding:0 8px}
.subscription-countdown-pill{display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:34px;padding:7px 13px;border:1px solid #c9e3e3;border-radius:999px;background:linear-gradient(145deg,#f8fefe,#edf8f8);color:#126d6d;box-shadow:0 4px 14px rgba(27,82,87,.055);font-size:11px;line-height:1;white-space:nowrap}
.subscription-countdown-pill .ui-icon{width:17px;height:17px;color:#0a8c88;flex:0 0 auto}
.subscription-countdown-pill b{font-size:12px;font-weight:950;letter-spacing:0;color:#125f61}
.dashboard-stats-button{background:#eef6fd!important;border-color:#cadeef!important;color:#3476a8!important;box-shadow:0 4px 12px rgba(52,118,168,.07)!important}
.dashboard-stats-button .ui-icon{color:#3476a8!important}
@media(max-width:560px){
  .subscription-countdown-bar{margin:6px 0 8px;padding:0 6px}
  .subscription-countdown-pill{min-height:31px;padding:6px 11px;font-size:10px}
  .subscription-countdown-pill b{font-size:11px}
  .workspace-heading-actions{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:wrap}
  .dashboard-stats-button{width:38px;height:38px;min-width:38px}
}

/* ===== MedFlow v1.6.2 precise subscription countdown ===== */
.subscription-countdown-pill.is-active{padding:5px 9px;gap:8px;max-width:100%;overflow:hidden}
.subscription-countdown-units{display:flex;align-items:stretch;justify-content:center;gap:3px;direction:rtl;min-width:0}
.subscription-unit{display:grid;grid-template-columns:auto auto;align-items:baseline;justify-content:center;gap:3px;min-width:43px;padding:4px 7px;border:1px solid rgba(157,205,205,.58);border-radius:10px;background:rgba(255,255,255,.72);line-height:1}
.subscription-unit b{font-size:12px!important;font-weight:950!important;color:#0d6666!important;font-variant-numeric:tabular-nums;min-width:1ch;text-align:center}
.subscription-unit small{font-size:8.5px;font-weight:850;color:#668185;white-space:nowrap}
.subscription-countdown-pill.is-state{padding-inline:14px}
.subscription-countdown-pill.is-expired{background:#fff5f4;border-color:#e8cdca;color:#914f49}
.subscription-countdown-pill.is-expired .ui-icon,.subscription-countdown-pill.is-expired b{color:#914f49}
@media(max-width:560px){
  .subscription-countdown-pill.is-active{width:min(100%,360px);padding:5px 7px;gap:5px}
  .subscription-countdown-pill.is-active>.ui-icon{width:15px;height:15px}
  .subscription-countdown-units{flex:1;gap:2px}
  .subscription-unit{flex:1;min-width:0;padding:4px 4px;border-radius:9px;gap:2px}
  .subscription-unit b{font-size:11px!important}
  .subscription-unit small{font-size:7.5px}
}
@media(max-width:380px){
  .subscription-countdown-pill.is-active{padding-inline:5px}
  .subscription-unit{padding-inline:3px}
  .subscription-unit b{font-size:10px!important}
  .subscription-unit small{font-size:7px}
}

/* ===== MedFlow v1.6.3 compact patient search actions ===== */
.patient-search-workspace.patient-search-compact{padding:11px 12px 12px}
.patient-search-toolbar{direction:ltr;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:center;gap:8px;margin-bottom:8px;padding:0}
.search-toolbar-button{direction:rtl;display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:35px;padding:6px 10px;border:1px solid transparent;border-radius:11px;text-decoration:none;font-size:10.5px;font-weight:900;line-height:1;white-space:nowrap;cursor:pointer;transition:transform .16s ease,border-color .16s ease,box-shadow .16s ease,background .16s ease}
.search-toolbar-button .ui-icon{width:16px;height:16px;flex:0 0 auto}
.search-toolbar-button:hover{transform:translateY(-1px)}
.search-toolbar-stats{grid-column:1;background:#edf6fd;border-color:#cfe2f0;color:#2f6f9d;box-shadow:0 3px 10px rgba(47,111,157,.055)}
.search-toolbar-stats .ui-icon{color:#3479aa}
.search-toolbar-add{grid-column:2;background:#eaf8f5;border-color:#c9e9e2;color:#08776e;box-shadow:0 3px 10px rgba(8,119,110,.055)}
.search-toolbar-add .ui-icon{color:#078178}
.search-toolbar-spacer{grid-column:2}
.patient-search-modern.patient-search-modern-compact{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:7px;align-items:stretch;margin:0}
.patient-search-modern-compact .search-input-modern{min-height:0;border-radius:12px}
.patient-search-modern-compact .search-input-modern input{height:41px;padding:8px 11px;font-size:12px}
.patient-search-modern-compact .search-input-plain input{padding-inline:11px}
.search-submit-compact{min-width:64px;min-height:41px;padding:7px 13px!important;border-radius:12px;font-size:11px}
.patient-search-compact .inline-hint{margin-top:7px}
.patient-search-compact .search-results-head{margin-top:11px}
@media(max-width:560px){
  .patient-search-workspace.patient-search-compact{padding:9px 10px 10px;border-radius:17px}
  .patient-search-toolbar{gap:6px;margin-bottom:7px}
  .search-toolbar-button{min-height:33px;padding:5px 8px;border-radius:10px;font-size:10px}
  .search-toolbar-button .ui-icon{width:15px;height:15px}
  .patient-search-modern.patient-search-modern-compact{gap:6px}
  .patient-search-modern-compact .search-input-modern input{height:39px;font-size:11.5px}
  .search-submit-compact{min-width:59px;min-height:39px;padding:6px 11px!important;font-size:10.5px}
}

/* ===== MedFlow v1.6.4 system validity moved to quick buttons/forms ===== */
.system-validity-card{padding:12px 14px;border-color:#cfe5e4;background:linear-gradient(145deg,#fbfefe,#f2fbfa)}
.system-validity-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:8px}
.system-validity-heading h2{margin:1px 0 0;font-size:14px;color:#174f54}
.system-validity-heading .section-icon{width:25px;height:25px;color:#0b8a84}
.system-validity-card .subscription-countdown-contained{margin:0;padding:0;justify-content:flex-start}
.system-validity-card .subscription-countdown-pill{box-shadow:none;background:#fff;border-color:#cde5e4}
@media(max-width:560px){
  .system-validity-card{padding:10px 11px}
  .system-validity-heading{margin-bottom:7px}
  .system-validity-heading h2{font-size:13px}
  .system-validity-card .subscription-countdown-contained{justify-content:center}
}

/* ===== XCLINIC v1.7 launch: compact cards, managed pages, light/dark themes ===== */
.login-brand{display:flex;justify-content:center;margin:-2px 0 12px}.login-brand img{width:88px;height:88px;object-fit:contain;border-radius:24px}.login-card h1{text-align:center}.login-card>p{text-align:center;margin-top:7px}.remember-login{display:flex;align-items:center;gap:8px;margin-top:12px;padding:9px 10px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2);font-size:12px;font-weight:800;color:var(--muted);cursor:pointer}.remember-login input{width:17px;height:17px;accent-color:var(--primary)}.login-help-links{display:flex;justify-content:center;align-items:center;gap:7px;margin-top:14px;font-size:11px;font-weight:800;color:var(--muted)}.login-help-links a{color:var(--primary)}.login-help-links a:hover{text-decoration:underline}.login-submit{min-height:46px}

.admin-home-grid{margin-top:8px}.admin-home-card{display:block;min-height:118px;transition:.17s ease}.admin-home-card:hover{transform:translateY(-2px);box-shadow:var(--shadow-hover);border-color:color-mix(in srgb,var(--primary) 35%,var(--line))}.admin-home-card h2{font-size:16px}.admin-home-card p{margin:7px 0 0;font-size:11px}.settings-form{display:grid;gap:0}.settings-save-bar{position:sticky;bottom:10px;z-index:8;display:flex;justify-content:flex-start;padding:8px;border:1px solid var(--line);border-radius:15px;background:color-mix(in srgb,var(--surface) 93%,transparent);backdrop-filter:blur(12px);box-shadow:var(--shadow)}

.managed-page-editor-form{overflow:hidden}.editor-color-preview{width:34px;height:34px;border-radius:11px;border:1px solid var(--line);box-shadow:inset 0 0 0 3px var(--surface)}.color-input{min-height:44px;padding:5px!important}.rich-field{grid-column:1/-1;margin-top:12px}.rich-editor-toolbar{display:flex;align-items:center;gap:5px;flex-wrap:wrap;padding:7px;border:1px solid var(--line);border-bottom:0;border-radius:13px 13px 0 0;background:var(--surface-2)}.rich-editor-toolbar button,.editor-color-control{min-height:31px;padding:5px 8px;border:1px solid var(--line);border-radius:9px;background:var(--surface);color:var(--text);font-size:10px;font-weight:850;cursor:pointer}.rich-editor-toolbar button:hover{border-color:color-mix(in srgb,var(--primary) 45%,var(--line));background:var(--primary-soft)}.editor-color-control{display:inline-flex;align-items:center;gap:6px}.editor-color-control input{width:27px;height:21px;border:0;padding:0;background:transparent}.rich-editor{min-height:175px;padding:13px;border:1px solid var(--line);border-radius:0 0 13px 13px;background:var(--surface);color:var(--text);outline:none;line-height:1.85;overflow-wrap:anywhere}.rich-editor:focus{border-color:color-mix(in srgb,var(--primary) 65%,var(--line));box-shadow:0 0 0 3px color-mix(in srgb,var(--primary) 12%,transparent)}.rich-editor h2,.rich-editor h3{margin:10px 0 6px}.rich-editor p{margin:6px 0}.rich-editor blockquote{margin:8px 0;padding:8px 12px;border-inline-start:3px solid var(--primary);background:var(--surface-2);border-radius:8px}

.managed-page-wrap,.error-page-shell{min-height:calc(100vh - 28px);display:grid;place-items:center;padding:18px}.managed-page-card,.error-page-card{width:min(760px,100%);border:1px solid var(--line);border-top:4px solid var(--managed-accent,var(--error-accent,var(--primary)));border-radius:22px;background:var(--surface);box-shadow:var(--shadow);padding:clamp(18px,4vw,28px)}.managed-page-mark,.error-page-icon{width:48px;height:48px;border-radius:15px;display:grid;place-items:center;margin-bottom:12px;background:color-mix(in srgb,var(--managed-accent,var(--error-accent,var(--primary))) 12%,var(--surface));color:var(--managed-accent,var(--error-accent,var(--primary)))}.managed-page-mark .ui-icon,.error-page-icon .ui-icon{width:25px;height:25px}.managed-page-card h1,.error-page-card h1{font-size:clamp(22px,5vw,30px);margin-bottom:12px}.managed-rich-content{line-height:1.9;color:var(--text);overflow-wrap:anywhere}.managed-rich-content p{margin:8px 0}.managed-rich-content h2,.managed-rich-content h3{margin:15px 0 7px}.managed-rich-content blockquote{padding:9px 12px;margin:10px 0;border-inline-start:3px solid currentColor;background:var(--surface-2);border-radius:9px}.managed-back-link{display:inline-flex;margin-top:18px;font-weight:850;color:var(--primary)}.error-page-code{font:900 11px ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--muted);letter-spacing:1.5px;margin-bottom:4px}.error-page-detail{margin-top:14px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2);color:var(--muted);font-size:12px}.error-page-action{margin-top:17px}.cleanup-single-card{display:grid;gap:12px;max-width:480px;margin-top:12px;padding:14px;border:1px solid var(--line);border-radius:15px;background:var(--surface-2)}

/* Patient cards: same information, less vertical space. */
.patient-grid-modern{gap:8px}.patient-card-modern{border-radius:15px}.patient-card-open{padding:9px 10px 7px}.patient-card-head{gap:8px}.patient-avatar-modern{width:39px;height:39px;border-radius:12px;font-size:17px}.patient-card-name h3{font-size:14px;margin-bottom:2px}.patient-card-chevron{width:26px;height:26px;border-radius:8px}.patient-card-info{grid-template-columns:62px minmax(0,1fr);gap:5px;margin-top:7px;padding-top:7px}.patient-card-info>div{padding:5px 7px;border-radius:8px}.patient-card-info span{font-size:8px;margin-bottom:2px}.patient-card-info strong{font-size:11px}.patient-card-status{gap:5px;padding:0 10px 6px}.patient-card-footer,.patient-card-status{font-size:9px}.patient-card-actions .icon-action{min-height:37px;padding:6px 8px;font-size:10px}.patient-inline-stats{padding:8px 10px}.patient-stat-item{padding:6px}.patient-stat-item b{font-size:12px}.patient-stat-item span{font-size:8px}.badge{padding:4px 7px;font-size:9.5px}.file-code{padding:2px 6px;font-size:10px}

/* Light/dark engine. Forced light uses the default palette. Auto follows the device. */
html[data-theme-effective="dark"]{
  color-scheme:dark;
  --bg:#0b1215;--surface:#111b1f;--surface-2:#162327;--surface-med:#132a2a;--text:#e7f0f2;--muted:#91a6ad;--line:#27383d;--primary:#55c7bd;--primary-dark:#35a99f;--primary-soft:#173533;--accent:#65bfe4;--accent-soft:#16303c;--danger:#ff8c83;--danger-soft:#351c1c;--warn:#f4b46a;--ok:#69d6a3;--shadow:0 12px 34px rgba(0,0,0,.24);--shadow-hover:0 18px 42px rgba(0,0,0,.34)
}
@media(prefers-color-scheme:dark){
  html[data-theme-mode="auto"]{color-scheme:dark;--bg:#0b1215;--surface:#111b1f;--surface-2:#162327;--surface-med:#132a2a;--text:#e7f0f2;--muted:#91a6ad;--line:#27383d;--primary:#55c7bd;--primary-dark:#35a99f;--primary-soft:#173533;--accent:#65bfe4;--accent-soft:#16303c;--danger:#ff8c83;--danger-soft:#351c1c;--warn:#f4b46a;--ok:#69d6a3;--shadow:0 12px 34px rgba(0,0,0,.24);--shadow-hover:0 18px 42px rgba(0,0,0,.34)}
}

html[data-theme-effective="dark"] body{background:linear-gradient(180deg,#0e171a 0,#0b1215 260px,#0b1215 100%)}
html[data-theme-effective="dark"] h1,html[data-theme-effective="dark"] h2,html[data-theme-effective="dark"] h3,html[data-theme-effective="dark"] .metric{color:var(--text)}
html[data-theme-effective="dark"] .topbar{background:rgba(12,20,23,.94);border-bottom-color:#24363a;box-shadow:0 6px 24px rgba(0,0,0,.18)}
html[data-theme-effective="dark"] :is(.card,.search-card,.patient-tile,.stat-card,.workspace-card,.stats-panel-modern,.patient-card-modern,.quick-library-card,.template-card,.clinic-admin-card,.managed-page-card,.error-page-card){background:var(--surface);border-color:var(--line);color:var(--text)}
html[data-theme-effective="dark"] :is(.input,.field input,.field textarea,.field select,.search-input-modern,.rich-editor){background:#0e191c;border-color:#31454b;color:var(--text)}
html[data-theme-effective="dark"] :is(.input,.field input,.field textarea,.field select)::placeholder,html[data-theme-effective="dark"] .search-input-modern input::placeholder{color:#728a91}
html[data-theme-effective="dark"] .search-input-modern input{color:var(--text)}
html[data-theme-effective="dark"] :is(.btn-soft,.btn-compact,.icon-action.compact,.rich-editor-toolbar button,.editor-color-control){background:#172428;border-color:#31454b;color:#d5e4e7}
html[data-theme-effective="dark"] :is(.btn-soft,.btn-compact,.icon-action.compact):hover{background:#1c2d31;border-color:#436067}
html[data-theme-effective="dark"] :is(.table-wrap,.pagination a,.page-current){background:var(--surface);border-color:var(--line)}
html[data-theme-effective="dark"] .table th{background:#172428;color:#b1c2c7}html[data-theme-effective="dark"] .table td{border-color:#27383d}
html[data-theme-effective="dark"] :is(.patient-card-info>div,.patient-card-chevron,.patient-stat-item,.today-stat,.search-empty-guide,.empty-state,.cleanup-single-card,.remember-login,.mini-toggle,.permission-check-card,.user-admin-details,.rich-editor-toolbar,.error-page-detail){background:var(--surface-2);border-color:var(--line)}
html[data-theme-effective="dark"] :is(.patient-card-name h3,.patient-card-info strong,.patient-stat-item b,.today-stat b,.search-empty-guide b,.workspace-heading h1,.workspace-heading h2){color:var(--text)}
html[data-theme-effective="dark"] .patient-card-info{border-top-color:#26383d}html[data-theme-effective="dark"] .patient-card-actions{background:#0f1a1d;border-top-color:#27383d}html[data-theme-effective="dark"] .icon-action+.icon-action{border-inline-start-color:#27383d}html[data-theme-effective="dark"] .icon-action:hover{background:#17302e}
html[data-theme-effective="dark"] .patient-card-modern.patient-new-unseen{background:linear-gradient(145deg,#2b2918,#242313);border-color:#655d2d;box-shadow:0 7px 24px rgba(0,0,0,.18)}html[data-theme-effective="dark"] .patient-card-modern.patient-new-unseen .patient-avatar-modern{background:#463e18;color:#f1cf64;border-color:#655d2d}html[data-theme-effective="dark"] .badge.unseen-patient{background:#463e18;color:#f2d675;border-color:#695d2b}
html[data-theme-effective="dark"] .patient-card-modern.patient-hidden-card,html[data-theme-effective="dark"] .patient-profile-hidden{background:linear-gradient(145deg,#1a2022,#171d1f)!important;border-color:#384448!important;filter:saturate(.72)}html[data-theme-effective="dark"] .badge.hidden-patient,html[data-theme-effective="dark"] .patient-hidden-banner{background:#263135;color:#b6c2c5;border-color:#3c4b50}
html[data-theme-effective="dark"] :is(.medical-hero,.subscription,.system-validity-card){background:linear-gradient(145deg,#122426,#111f24);border-color:#2b4448}html[data-theme-effective="dark"] .medical-hero h1{color:var(--text)}html[data-theme-effective="dark"] .medical-hero p{color:var(--muted)}
html[data-theme-effective="dark"] :is(.subscription-chip,.subscription-countdown-pill,.subscription-unit){background:#17282b;border-color:#305054;color:#b7ced2}html[data-theme-effective="dark"] .subscription-unit b{color:#7bddcf!important}html[data-theme-effective="dark"] .subscription-unit small{color:#8ea9ad}
html[data-theme-effective="dark"] .template-preview{background:#172326}html[data-theme-effective="dark"] .template-preview img{background:#fff}
html[data-theme-effective="dark"] :is(.flash.info){background:#14283a;color:#8dc6ff;border-color:#27445f}html[data-theme-effective="dark"] :is(.flash.success){background:#153126;color:#81ddb0;border-color:#28513f}html[data-theme-effective="dark"] :is(.flash.error){background:#351d1d;color:#ffaaa3;border-color:#5d3330}
html[data-theme-effective="dark"] .danger-zone{background:#28191a;border-color:#5b3333}html[data-theme-effective="dark"] .btn-danger{background:#351d1d;border-color:#5d3330;color:#ffaaa3}html[data-theme-effective="dark"] .btn-ok{background:#163326;color:#77d6a8}
html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-icon-only{box-shadow:0 4px 12px rgba(0,0,0,.16)!important}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-home{background:#15302e!important;border-color:#28534e!important}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-home .ui-icon{color:#66d1c5!important}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-archive{background:#162a38!important;border-color:#294758!important}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-archive .ui-icon{color:#7ec2ef!important}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-quick{background:#251f35!important;border-color:#44375d!important}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-quick .ui-icon{color:#b39ae6!important}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-clinics{background:#182e24!important;border-color:#2c503d!important}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-clinics .ui-icon{color:#84d3a5!important}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-admin{background:#33291c!important;border-color:#554329!important}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-admin .ui-icon{color:#e5b66e!important}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-logout{background:#2b1f1f;border-color:#4d3533;color:#efb0aa}html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-logout .ui-icon{color:#ef958b}
html[data-theme-effective="dark"] :is(.search-toolbar-stats,.dashboard-stats-button){background:#162a38!important;border-color:#294758!important;color:#8dc9ef!important}html[data-theme-effective="dark"] :is(.search-toolbar-stats,.dashboard-stats-button) .ui-icon{color:#7ec2ef!important}html[data-theme-effective="dark"] .search-toolbar-add{background:#15302e;border-color:#28534e;color:#76d6ca}html[data-theme-effective="dark"] .search-toolbar-add .ui-icon{color:#66d1c5}
html[data-theme-effective="dark"] .feature-toggle-card{background:#142025;border-color:#2b3d42}html[data-theme-effective="dark"] .feature-copy b{color:var(--text)}html[data-theme-effective="dark"] .feature-copy small{color:var(--muted)}html[data-theme-effective="dark"] .switch-ui{background:#34474c;border-color:#40565c}html[data-theme-effective="dark"] .feature-switch-input:checked~.switch-ui{background:#2e9d93;border-color:#45bdb2}
html[data-theme-effective="dark"] .permission-check-card:has(input:checked){background:#17302e;border-color:#2f5954;color:#9ce3da}
html[data-theme-effective="dark"] .rich-editor-toolbar{background:#142025}html[data-theme-effective="dark"] .editor-color-preview{box-shadow:inset 0 0 0 3px var(--surface)}

@media(prefers-color-scheme:dark){
  html[data-theme-mode="auto"] body{background:linear-gradient(180deg,#0e171a 0,#0b1215 260px,#0b1215 100%)}
  html[data-theme-mode="auto"] h1,html[data-theme-mode="auto"] h2,html[data-theme-mode="auto"] h3,html[data-theme-mode="auto"] .metric{color:var(--text)}
  html[data-theme-mode="auto"] .topbar{background:rgba(12,20,23,.94);border-bottom-color:#24363a;box-shadow:0 6px 24px rgba(0,0,0,.18)}
  html[data-theme-mode="auto"] :is(.card,.search-card,.patient-tile,.stat-card,.workspace-card,.stats-panel-modern,.patient-card-modern,.quick-library-card,.template-card,.clinic-admin-card,.managed-page-card,.error-page-card){background:var(--surface);border-color:var(--line);color:var(--text)}
  html[data-theme-mode="auto"] :is(.input,.field input,.field textarea,.field select,.search-input-modern,.rich-editor){background:#0e191c;border-color:#31454b;color:var(--text)}
  html[data-theme-mode="auto"] .search-input-modern input{color:var(--text)}
  html[data-theme-mode="auto"] :is(.btn-soft,.btn-compact,.icon-action.compact,.rich-editor-toolbar button,.editor-color-control){background:#172428;border-color:#31454b;color:#d5e4e7}
  html[data-theme-mode="auto"] :is(.patient-card-info>div,.patient-card-chevron,.patient-stat-item,.today-stat,.search-empty-guide,.empty-state,.cleanup-single-card,.remember-login,.mini-toggle,.permission-check-card,.user-admin-details,.rich-editor-toolbar,.error-page-detail){background:var(--surface-2);border-color:var(--line)}
  html[data-theme-mode="auto"] :is(.patient-card-name h3,.patient-card-info strong,.patient-stat-item b,.today-stat b,.search-empty-guide b){color:var(--text)}
  html[data-theme-mode="auto"] .patient-card-actions{background:#0f1a1d;border-top-color:#27383d}html[data-theme-mode="auto"] .icon-action+.icon-action{border-inline-start-color:#27383d}
  html[data-theme-mode="auto"] .patient-card-modern.patient-new-unseen{background:linear-gradient(145deg,#2b2918,#242313);border-color:#655d2d}html[data-theme-mode="auto"] .badge.unseen-patient{background:#463e18;color:#f2d675;border-color:#695d2b}
  html[data-theme-mode="auto"] .patient-card-modern.patient-hidden-card,html[data-theme-mode="auto"] .patient-profile-hidden{background:linear-gradient(145deg,#1a2022,#171d1f)!important;border-color:#384448!important}
  html[data-theme-mode="auto"] :is(.medical-hero,.subscription,.system-validity-card){background:linear-gradient(145deg,#122426,#111f24);border-color:#2b4448}html[data-theme-mode="auto"] .medical-hero h1{color:var(--text)}html[data-theme-mode="auto"] .medical-hero p{color:var(--muted)}
  html[data-theme-mode="auto"] :is(.subscription-chip,.subscription-countdown-pill,.subscription-unit){background:#17282b;border-color:#305054;color:#b7ced2}html[data-theme-mode="auto"] .subscription-unit b{color:#7bddcf!important}
  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-home{background:#15302e!important;border-color:#28534e!important}html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-home .ui-icon{color:#66d1c5!important}html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-archive{background:#162a38!important;border-color:#294758!important}html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-archive .ui-icon{color:#7ec2ef!important}html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-quick{background:#251f35!important;border-color:#44375d!important}html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-quick .ui-icon{color:#b39ae6!important}html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-clinics{background:#182e24!important;border-color:#2c503d!important}html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-clinics .ui-icon{color:#84d3a5!important}html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-admin{background:#33291c!important;border-color:#554329!important}html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-admin .ui-icon{color:#e5b66e!important}html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-logout{background:#2b1f1f;border-color:#4d3533;color:#efb0aa}
  html[data-theme-mode="auto"] .rich-editor-toolbar{background:#142025}
}

@media(max-width:560px){
  .managed-page-wrap,.error-page-shell{padding:11px}.managed-page-card,.error-page-card{padding:16px;border-radius:18px}.login-wrap{padding:12px}.login-card{padding:16px}.login-brand img{width:76px;height:76px}.admin-home-card{min-height:98px;padding:13px}.patient-card-open{padding:8px 9px 6px}.patient-avatar-modern{width:37px;height:37px}.patient-card-info{margin-top:6px;padding-top:6px}.patient-card-actions .icon-action{min-height:35px}.rich-editor{min-height:150px}.settings-save-bar{bottom:6px;padding:6px}
}


/* ===== XCLINIC v1.7.1 account password settings ===== */
.account-password-card{border-color:#d6e8e7;background:linear-gradient(145deg,#fff,#f7fcfb)}
.account-password-card .workspace-heading{margin-bottom:12px}
.account-password-card .section-icon{color:#287f7a}
.account-password-card .btn{margin-top:12px}
html[data-theme-effective="dark"] .account-password-card{background:linear-gradient(145deg,#132226,#101c20);border-color:#294247}
@media(prefers-color-scheme:dark){html[data-theme-mode="auto"] .account-password-card{background:linear-gradient(145deg,#132226,#101c20);border-color:#294247}}
@media(max-width:560px){.account-password-card{padding:12px}.account-password-card .workspace-heading{margin-bottom:9px}.account-password-card .btn{width:100%}}

/* ===== XCLINIC v1.7.2: clearer framed action icons + editable text library ===== */
:root{
  --action-icon-bg:#f2f8fb;
  --action-icon-border:#c9dce6;
  --action-icon-color:#2c7180;
  --action-icon-shadow:0 2px 7px rgba(32,84,99,.10);
}
.ui-icon{stroke-width:2.08}
:is(.btn,.icon-action,.search-toolbar-button,.archive-year-stats-button,.nav-logout)>.ui-icon{
  box-sizing:content-box;
  width:16px;height:16px;
  padding:3px;
  border:1px solid var(--action-icon-border);
  border-radius:8px;
  background:var(--action-icon-bg);
  color:var(--action-icon-color);
  box-shadow:var(--action-icon-shadow);
}
.btn-primary>.ui-icon{
  color:#fff;background:rgba(255,255,255,.12);border-color:rgba(255,255,255,.30);box-shadow:0 2px 7px rgba(0,0,0,.10)
}
.btn-danger>.ui-icon,.icon-action.danger>.ui-icon{
  color:#b42318;background:#fff3f1;border-color:#f2c8c3;box-shadow:0 2px 7px rgba(180,35,24,.09)
}
.icon-action.primary>.ui-icon,.search-toolbar-add>.ui-icon{
  color:#087b72;background:#ecf8f6;border-color:#bcded9;box-shadow:0 2px 7px rgba(8,123,114,.10)
}
.search-toolbar-stats>.ui-icon,.archive-year-stats-button>.ui-icon{
  color:#286b96;background:#eff7fc;border-color:#c7deed;box-shadow:0 2px 7px rgba(40,107,150,.10)
}
.nav a.nav-icon-only .ui-icon{stroke-width:2.2}
.nav-logout>.ui-icon{color:#a23b32;background:#fff4f2;border-color:#efccc7}

.app-texts-form{padding-bottom:76px}.app-text-group{margin-bottom:10px}.app-text-grid{display:grid;grid-template-columns:1fr;gap:9px}.app-text-field{padding:10px;border:1px solid var(--line);border-radius:13px;background:var(--surface-2)}.app-text-field label{margin-bottom:2px}.app-text-field .text-key{display:block;margin-bottom:7px;direction:ltr;text-align:left;font:700 9px ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--muted);opacity:.75}.app-text-field input,.app-text-field textarea{background:var(--surface)}
@media(min-width:760px){.app-text-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.app-text-field:has(textarea){grid-column:1/-1}}

html[data-theme-effective="dark"]{
  --action-icon-bg:#17282d;
  --action-icon-border:#34515a;
  --action-icon-color:#8fd6df;
  --action-icon-shadow:0 2px 8px rgba(0,0,0,.24);
}
html[data-theme-effective="dark"] .btn-primary>.ui-icon{background:rgba(6,29,31,.22);border-color:rgba(208,255,249,.28);color:#ecfffc}
html[data-theme-effective="dark"] :is(.btn-danger,.icon-action.danger)>.ui-icon{color:#ffaaa3;background:#321d1c;border-color:#5c3430}
html[data-theme-effective="dark"] :is(.icon-action.primary,.search-toolbar-add)>.ui-icon{color:#7de0d4;background:#173330;border-color:#2f5954}
html[data-theme-effective="dark"] :is(.search-toolbar-stats,.archive-year-stats-button)>.ui-icon{color:#8dc9ef;background:#162b39;border-color:#2d4c60}
html[data-theme-effective="dark"] .nav-logout>.ui-icon{color:#f0a39b;background:#321e1d;border-color:#543532}
html[data-theme-effective="dark"] .app-text-field{background:#142126;border-color:#2b3d42}html[data-theme-effective="dark"] .app-text-field input,html[data-theme-effective="dark"] .app-text-field textarea{background:#0e191c}
@media(prefers-color-scheme:dark){
  html[data-theme-mode="auto"]{
    --action-icon-bg:#17282d;
    --action-icon-border:#34515a;
    --action-icon-color:#8fd6df;
    --action-icon-shadow:0 2px 8px rgba(0,0,0,.24);
  }
  html[data-theme-mode="auto"] .btn-primary>.ui-icon{background:rgba(6,29,31,.22);border-color:rgba(208,255,249,.28);color:#ecfffc}
  html[data-theme-mode="auto"] :is(.btn-danger,.icon-action.danger)>.ui-icon{color:#ffaaa3;background:#321d1c;border-color:#5c3430}
  html[data-theme-mode="auto"] :is(.icon-action.primary,.search-toolbar-add)>.ui-icon{color:#7de0d4;background:#173330;border-color:#2f5954}
  html[data-theme-mode="auto"] :is(.search-toolbar-stats,.archive-year-stats-button)>.ui-icon{color:#8dc9ef;background:#162b39;border-color:#2d4c60}
  html[data-theme-mode="auto"] .nav-logout>.ui-icon{color:#f0a39b;background:#321e1d;border-color:#543532}
  html[data-theme-mode="auto"] .app-text-field{background:#142126;border-color:#2b3d42}html[data-theme-mode="auto"] .app-text-field input,html[data-theme-mode="auto"] .app-text-field textarea{background:#0e191c}
}
.app-text-filter-card{position:sticky;top:60px;z-index:9;padding:9px 11px;margin-bottom:10px;background:color-mix(in srgb,var(--surface) 94%,transparent);backdrop-filter:blur(12px);box-shadow:0 5px 18px rgba(26,79,89,.07)}
.app-text-filter-card .field{margin:0}.app-text-filter-card label{font-size:10px}.app-text-filter-card input{min-height:39px}
.app-text-field[hidden],.app-text-group[hidden]{display:none!important}
html[data-theme-effective="dark"] .app-text-filter-card{background:color-mix(in srgb,var(--surface) 94%,transparent);border-color:#2b3d42}
@media(prefers-color-scheme:dark){html[data-theme-mode="auto"] .app-text-filter-card{background:color-mix(in srgb,var(--surface) 94%,transparent);border-color:#2b3d42}}

/* ===== XCLINIC v1.7.4: strong framed action controls for light/dark themes ===== */
:root{
  --action-control-bg:#ffffff;
  --action-control-border:#b9ced8;
  --action-control-shadow:0 4px 12px rgba(27,74,89,.10),inset 0 0 0 1px rgba(255,255,255,.55);
  --action-control-hover-shadow:0 7px 16px rgba(27,74,89,.15),inset 0 0 0 1px rgba(255,255,255,.65);
  --action-control-focus:0 0 0 3px rgba(28,132,139,.15);
}

/* Every visible command gets a real outer frame, not only the glyph inside it. */
:is(
  .btn,
  .icon-action,
  .search-toolbar-button,
  .hero-icon-button,
  .section-icon-button,
  .print-section-button,
  .quick-buttons button,
  .rich-editor-toolbar button,
  .pagination a,
  .topbar .nav.nav-distributed a.nav-icon-only,
  .topbar .nav.nav-distributed a.nav-logout
){
  border-width:1.5px!important;
  border-style:solid!important;
  border-color:var(--action-control-border)!important;
  box-shadow:var(--action-control-shadow)!important;
  background-clip:padding-box;
}

:is(
  .btn,
  .icon-action,
  .search-toolbar-button,
  .hero-icon-button,
  .section-icon-button,
  .print-section-button,
  .quick-buttons button,
  .rich-editor-toolbar button,
  .pagination a,
  .topbar .nav.nav-distributed a.nav-icon-only,
  .topbar .nav.nav-distributed a.nav-logout
):hover{
  box-shadow:var(--action-control-hover-shadow)!important;
}

:is(
  .btn,
  .icon-action,
  .search-toolbar-button,
  .hero-icon-button,
  .section-icon-button,
  .print-section-button,
  .quick-buttons button,
  .rich-editor-toolbar button,
  .pagination a,
  .topbar .nav.nav-distributed a.nav-icon-only,
  .topbar .nav.nav-distributed a.nav-logout
):focus-visible{
  outline:none!important;
  box-shadow:var(--action-control-hover-shadow),var(--action-control-focus)!important;
}

:is(
  .btn,
  .icon-action,
  .search-toolbar-button,
  .hero-icon-button,
  .section-icon-button,
  .print-section-button,
  .quick-buttons button,
  .rich-editor-toolbar button,
  .pagination a,
  .topbar .nav.nav-distributed a.nav-icon-only,
  .topbar .nav.nav-distributed a.nav-logout
):active{
  transform:translateY(1px);
  box-shadow:0 2px 6px rgba(27,74,89,.11)!important;
}

/* Core command palette: calm medical colors with enough separation in daylight. */
.btn-soft,.btn-compact{background:#fbfdfe!important;border-color:#bfd2db!important;color:#315867!important}
.btn-primary{border-color:#0a706c!important;box-shadow:0 5px 14px rgba(15,127,120,.18)!important}
.btn-ok{background:#edf9f3!important;border-color:#a9d8bd!important;color:#137348!important}
.btn-danger{background:#fff5f3!important;border-color:#efbeb8!important;color:#a9342b!important}

.search-toolbar-add{background:#effaf7!important;border-color:#9fd4cb!important;color:#087b72!important}
.search-toolbar-stats,.archive-year-stats-button{background:#f0f7fc!important;border-color:#abcde2!important;color:#286b96!important}
.section-icon-button,.print-section-button{background:#f1faf9!important;border-color:#afd7d3!important;color:#0c7f79!important}

.patient-card-actions .icon-action{background:#fbfdfe!important;border-color:#bfd3dc!important;color:#466f82!important}
.patient-card-actions .icon-action.primary{background:#eef9f7!important;border-color:#9fd4cb!important;color:#087b72!important}
.patient-card-actions .icon-action.danger{background:#fff4f2!important;border-color:#eebeb8!important;color:#ae372e!important}

/* Make the small icon capsule itself slightly clearer inside command controls. */
:is(.btn,.icon-action,.search-toolbar-button,.archive-year-stats-button,.nav-logout,.section-icon-button,.print-section-button)>.ui-icon{
  border-width:1.25px!important;
  box-shadow:0 2px 6px rgba(31,78,91,.11)!important;
}

/* Banner icons: keep each function distinct while strengthening the frame. */
.topbar .nav.nav-distributed a.nav-home{border-color:#91cec5!important;box-shadow:0 4px 12px rgba(8,125,114,.12)!important}
.topbar .nav.nav-distributed a.nav-archive{border-color:#a7c8df!important;box-shadow:0 4px 12px rgba(52,118,168,.12)!important}
.topbar .nav.nav-distributed a.nav-quick{border-color:#c9b9e8!important;box-shadow:0 4px 12px rgba(113,86,173,.12)!important}
.topbar .nav.nav-distributed a.nav-clinics{border-color:#aad7bc!important;box-shadow:0 4px 12px rgba(42,133,84,.12)!important}
.topbar .nav.nav-distributed a.nav-admin{border-color:#dfbf93!important;box-shadow:0 4px 12px rgba(166,109,37,.12)!important}
.topbar .nav.nav-distributed a.nav-logout{border-color:#e6b9b3!important;box-shadow:0 4px 12px rgba(167,91,82,.11)!important}

/* Dark mode: brighter borders and deeper shadows so controls remain obvious. */
html[data-theme-effective="dark"]{
  --action-control-bg:#162428;
  --action-control-border:#4b6670;
  --action-control-shadow:0 4px 13px rgba(0,0,0,.28),inset 0 0 0 1px rgba(255,255,255,.025);
  --action-control-hover-shadow:0 7px 18px rgba(0,0,0,.36),inset 0 0 0 1px rgba(255,255,255,.045);
  --action-control-focus:0 0 0 3px rgba(87,205,199,.18);
}
html[data-theme-effective="dark"] :is(.btn-soft,.btn-compact){background:#17272b!important;border-color:#45616a!important;color:#d7e7ea!important}
html[data-theme-effective="dark"] .btn-primary{border-color:#3c9f98!important;box-shadow:0 5px 15px rgba(0,0,0,.30)!important}
html[data-theme-effective="dark"] .btn-ok{background:#162b22!important;border-color:#376e52!important;color:#9ae0b7!important}
html[data-theme-effective="dark"] .btn-danger{background:#321d1c!important;border-color:#6b3b36!important;color:#ffaaa3!important}
html[data-theme-effective="dark"] .search-toolbar-add{background:#16302d!important;border-color:#3f716b!important;color:#7de0d4!important}
html[data-theme-effective="dark"] :is(.search-toolbar-stats,.archive-year-stats-button){background:#162b39!important;border-color:#45677c!important;color:#8dc9ef!important}
html[data-theme-effective="dark"] :is(.section-icon-button,.print-section-button){background:#17302f!important;border-color:#3d6f6b!important;color:#81ded6!important}
html[data-theme-effective="dark"] .patient-card-actions .icon-action{background:#17272b!important;border-color:#48616a!important;color:#c8e0e5!important}
html[data-theme-effective="dark"] .patient-card-actions .icon-action.primary{background:#173330!important;border-color:#3f716b!important;color:#7de0d4!important}
html[data-theme-effective="dark"] .patient-card-actions .icon-action.danger{background:#321e1d!important;border-color:#6a3b36!important;color:#f4aaa3!important}
html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-home{border-color:#39766f!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}
html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-archive{border-color:#416678!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}
html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-quick{border-color:#5b4a77!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}
html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-clinics{border-color:#406c51!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}
html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-admin{border-color:#6b5533!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}
html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-logout{border-color:#6a4541!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}

@media(prefers-color-scheme:dark){
  html[data-theme-mode="auto"]{
    --action-control-bg:#162428;
    --action-control-border:#4b6670;
    --action-control-shadow:0 4px 13px rgba(0,0,0,.28),inset 0 0 0 1px rgba(255,255,255,.025);
    --action-control-hover-shadow:0 7px 18px rgba(0,0,0,.36),inset 0 0 0 1px rgba(255,255,255,.045);
    --action-control-focus:0 0 0 3px rgba(87,205,199,.18);
  }
  html[data-theme-mode="auto"] :is(.btn-soft,.btn-compact){background:#17272b!important;border-color:#45616a!important;color:#d7e7ea!important}
  html[data-theme-mode="auto"] .btn-primary{border-color:#3c9f98!important;box-shadow:0 5px 15px rgba(0,0,0,.30)!important}
  html[data-theme-mode="auto"] .btn-ok{background:#162b22!important;border-color:#376e52!important;color:#9ae0b7!important}
  html[data-theme-mode="auto"] .btn-danger{background:#321d1c!important;border-color:#6b3b36!important;color:#ffaaa3!important}
  html[data-theme-mode="auto"] .search-toolbar-add{background:#16302d!important;border-color:#3f716b!important;color:#7de0d4!important}
  html[data-theme-mode="auto"] :is(.search-toolbar-stats,.archive-year-stats-button){background:#162b39!important;border-color:#45677c!important;color:#8dc9ef!important}
  html[data-theme-mode="auto"] :is(.section-icon-button,.print-section-button){background:#17302f!important;border-color:#3d6f6b!important;color:#81ded6!important}
  html[data-theme-mode="auto"] .patient-card-actions .icon-action{background:#17272b!important;border-color:#48616a!important;color:#c8e0e5!important}
  html[data-theme-mode="auto"] .patient-card-actions .icon-action.primary{background:#173330!important;border-color:#3f716b!important;color:#7de0d4!important}
  html[data-theme-mode="auto"] .patient-card-actions .icon-action.danger{background:#321e1d!important;border-color:#6a3b36!important;color:#f4aaa3!important}
  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-home{border-color:#39766f!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}
  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-archive{border-color:#416678!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}
  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-quick{border-color:#5b4a77!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}
  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-clinics{border-color:#406c51!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}
  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-admin{border-color:#6b5533!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}
  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-logout{border-color:#6a4541!important;box-shadow:0 4px 13px rgba(0,0,0,.28)!important}
}

@media(max-width:560px){
  :is(.btn,.search-toolbar-button,.icon-action){box-shadow:0 3px 9px rgba(25,70,82,.10)!important}
  html[data-theme-effective="dark"] :is(.btn,.search-toolbar-button,.icon-action){box-shadow:0 3px 10px rgba(0,0,0,.26)!important}
}

/* ===== XCLINIC v1.7.5: stronger button text + one working visit per patient/day ===== */
:is(
  .btn,
  .icon-action,
  .search-toolbar-button,
  .hero-icon-button,
  .section-icon-button,
  .print-section-button,
  .quick-buttons button,
  .rich-editor-toolbar button,
  .pagination a,
  .archive-year-stats-button,
  .topbar .nav.nav-distributed a
){font-weight:900!important}

.today-visit-card{
  border:1.5px solid #a8d9d2!important;
  background:linear-gradient(180deg,#fbfffe 0%,#f6fcfb 100%);
  box-shadow:0 7px 22px rgba(22,105,101,.08);
}
.today-visit-heading{align-items:flex-start}
.today-visit-state{display:flex;align-items:center;gap:7px;flex-wrap:wrap;justify-content:flex-end}
.today-visit-date{display:inline-flex;align-items:center;gap:5px;min-height:29px;padding:5px 8px;border:1px solid #c8dfdf;border-radius:10px;background:#fff;color:#44666c;font-size:10px;font-weight:900;direction:ltr}
.today-visit-date .ui-icon{width:14px;height:14px;color:#188279}
.today-visit-card .clinical-box{border-color:#cfe5e2;background:#fff}
.today-visit-card .save-visit-button{min-width:170px}
.today-visit-thumbs{margin-top:8px;padding-top:8px;border-top:1px solid #dcebea}
.previous-visits-section{margin-top:13px}

html[data-theme-effective="dark"] .today-visit-card{
  background:linear-gradient(180deg,#122225 0%,#101d20 100%);
  border-color:#376c67!important;
  box-shadow:0 7px 23px rgba(0,0,0,.30)
}
html[data-theme-effective="dark"] .today-visit-date{background:#17272b;border-color:#3d5960;color:#c8dadd}
html[data-theme-effective="dark"] .today-visit-date .ui-icon{color:#7edbd2}
html[data-theme-effective="dark"] .today-visit-card .clinical-box{background:#122024;border-color:#2c4649}
html[data-theme-effective="dark"] .today-visit-thumbs{border-top-color:#2c4247}

@media(prefers-color-scheme:dark){
  html[data-theme-mode="auto"] .today-visit-card{
    background:linear-gradient(180deg,#122225 0%,#101d20 100%);
    border-color:#376c67!important;
    box-shadow:0 7px 23px rgba(0,0,0,.30)
  }
  html[data-theme-mode="auto"] .today-visit-date{background:#17272b;border-color:#3d5960;color:#c8dadd}
  html[data-theme-mode="auto"] .today-visit-date .ui-icon{color:#7edbd2}
  html[data-theme-mode="auto"] .today-visit-card .clinical-box{background:#122024;border-color:#2c4649}
  html[data-theme-mode="auto"] .today-visit-thumbs{border-top-color:#2c4247}
}

@media(max-width:560px){
  .today-visit-heading{display:grid;grid-template-columns:1fr;gap:8px}
  .today-visit-state{justify-content:flex-start}
  .today-visit-card .save-visit-button{width:100%;min-width:0}
}
.visit-patient-type{display:inline-flex;align-items:center;justify-content:center;min-height:29px;padding:5px 9px;border:1px solid;border-radius:999px;font-size:10px;font-weight:900;white-space:nowrap}.visit-patient-type.new{background:#fff9df;border-color:#e6cf71;color:#80610a}.visit-patient-type.returning{background:#edf8f4;border-color:#a8d5c0;color:#176b4a}html[data-theme-effective="dark"] .visit-patient-type.new{background:#312b16;border-color:#71622d;color:#f0d777}html[data-theme-effective="dark"] .visit-patient-type.returning{background:#162d24;border-color:#39644e;color:#8dd4ad}@media(prefers-color-scheme:dark){html[data-theme-mode="auto"] .visit-patient-type.new{background:#312b16;border-color:#71622d;color:#f0d777}html[data-theme-mode="auto"] .visit-patient-type.returning{background:#162d24;border-color:#39644e;color:#8dd4ad}}

/* ===== XCLINIC v1.7.6: integrated patient + today-visit intake ===== */
.integrated-patient-booking-form{display:grid;gap:12px}
.patient-intake-section{padding:12px;border:1px solid #d8e6eb;border-radius:15px;background:#fbfdfe}
.patient-intake-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:11px}
.patient-intake-heading h2{font-size:17px}
.patient-intake-heading p{margin:4px 0 0;font-size:11px;line-height:1.6}
.patient-intake-heading .section-icon{width:38px;height:38px;padding:8px;border:1px solid #bfddd8;border-radius:12px;background:#eef9f7;color:#0b7c73;box-shadow:0 3px 9px rgba(22,105,101,.08)}
.booking-intake-section{border-color:#b9ddd8;background:linear-gradient(180deg,#fbfffe,#f5fbfa)}
.booking-intake-section .money-input input{min-height:44px}
.integrated-patient-booking-form .patient-save-btn{margin-top:0!important;min-height:50px}
html[data-theme-effective="dark"] .patient-intake-section{background:#132126;border-color:#30464d}
html[data-theme-effective="dark"] .booking-intake-section{background:linear-gradient(180deg,#132525,#111f22);border-color:#3b6661}
html[data-theme-effective="dark"] .patient-intake-heading .section-icon{background:#173330;border-color:#3f716b;color:#7de0d4;box-shadow:0 3px 10px rgba(0,0,0,.25)}
@media(prefers-color-scheme:dark){
  html[data-theme-mode="auto"] .patient-intake-section{background:#132126;border-color:#30464d}
  html[data-theme-mode="auto"] .booking-intake-section{background:linear-gradient(180deg,#132525,#111f22);border-color:#3b6661}
  html[data-theme-mode="auto"] .patient-intake-heading .section-icon{background:#173330;border-color:#3f716b;color:#7de0d4;box-shadow:0 3px 10px rgba(0,0,0,.25)}
}
@media(max-width:560px){
  .patient-new-card{padding:12px}
  .patient-intake-section{padding:10px}
  .patient-intake-heading{margin-bottom:9px}
  .patient-intake-heading h2{font-size:16px}
  .integrated-patient-booking-form{gap:9px}
}

/* v1.7.7 — Daily archive numbering. View-only; no database field required. */
.archive-daily-sequence{display:inline-flex;align-items:center;justify-content:center;min-width:28px;height:22px;padding:0 8px;border:1px solid #9fcbd2;border-radius:8px;background:#eef9fa;color:#245a64;font-size:11px;font-weight:900;line-height:1;direction:ltr;box-shadow:0 2px 7px rgba(32,92,103,.08)}
html[data-theme-effective="dark"] .archive-daily-sequence{background:#173036;border-color:#3e737d;color:#d8f3f5;box-shadow:0 2px 8px rgba(0,0,0,.18)}
@media (prefers-color-scheme:dark){html[data-theme-mode="auto"] .archive-daily-sequence{background:#173036;border-color:#3e737d;color:#d8f3f5;box-shadow:0 2px 8px rgba(0,0,0,.18)}}

/* ===== XCLINIC v1.7.9: comprehensive expired-data cleanup center ===== */
.cleanup-filter-card{position:relative;overflow:hidden}
.cleanup-filter-card:before{content:"";position:absolute;inset-inline-start:0;top:0;bottom:0;width:4px;background:linear-gradient(180deg,var(--primary),var(--accent))}
.cleanup-filter-submit{display:flex;align-items:flex-end}
.cleanup-filter-submit .btn{min-width:210px}
.cleanup-summary{border-color:#cbdbe9;background:linear-gradient(180deg,#fff,#f9fcff)}
.cleanup-summary-metrics{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin-top:14px}
.cleanup-summary-metrics>div{padding:11px;border:1px solid #d9e5ef;border-radius:13px;background:#fff;box-shadow:0 3px 10px rgba(28,71,94,.05)}
.cleanup-summary-metrics span{display:block;color:var(--muted);font-size:10px;font-weight:900;margin-bottom:5px}
.cleanup-summary-metrics b{font-size:18px;direction:ltr;display:inline-block}
.cleanup-review-note{margin:11px 0 0;padding:9px 11px;border:1px solid #ead9a6;border-radius:12px;background:#fffaf0;color:#74551b;font-size:11px;font-weight:750}
.cleanup-items-grid{display:grid;grid-template-columns:1fr;gap:9px}
.cleanup-item-card{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:10px;align-items:center;padding:12px;border:1.5px solid #cbd9e5;border-radius:15px;background:#fff;box-shadow:0 4px 13px rgba(26,70,89,.055);cursor:pointer;transition:.16s ease}
.cleanup-item-card:hover{border-color:#8fb2ca;box-shadow:0 7px 18px rgba(26,70,89,.09);transform:translateY(-1px)}
.cleanup-item-card.is-empty{opacity:.66}
.cleanup-check{display:grid;place-items:center}
.cleanup-check input{width:19px;height:19px;accent-color:var(--primary);cursor:pointer}
.cleanup-item-copy{min-width:0}
.cleanup-item-copy>b{display:block;font-size:13px;margin-bottom:4px;color:#24384d}
.cleanup-item-copy small{display:block;color:var(--muted);font-size:10.5px;line-height:1.55}
.cleanup-scope{display:inline-flex!important;width:max-content;margin-top:6px;padding:3px 7px;border-radius:999px;background:#eef5fb;color:#4a657b!important;font-size:9px!important;font-weight:900!important}
.cleanup-item-metric{text-align:left;min-width:72px;direction:ltr}
.cleanup-item-metric strong{display:block;font-size:19px;color:#1b3850}
.cleanup-item-metric small{display:block;margin-top:3px;color:#6c8091;font-size:10px;font-weight:800}
.cleanup-safety-box{margin-top:14px;padding:14px;border:1.5px solid #e2a29d;border-radius:16px;background:linear-gradient(180deg,#fff8f7,#fff3f2)}
.cleanup-safety-box h3{color:#8e2c25}
.cleanup-safety-box p{margin:6px 0 11px;color:#74504c;font-size:11px}
.cleanup-safety-box .field{max-width:420px;margin-bottom:10px}
.cleanup-safety-box .field input{border-color:#ddb3af;background:#fff}
.cleanup-safety-box .btn-danger{font-weight:900}
.cleanup-static-note{border-style:dashed}
.cleanup-static-note p{margin-bottom:0;font-size:11px}

html[data-theme-effective="dark"] .cleanup-summary{background:linear-gradient(180deg,#142226,#111d21);border-color:#36515a}
html[data-theme-effective="dark"] .cleanup-summary-metrics>div{background:#17272b;border-color:#344c54;box-shadow:0 3px 11px rgba(0,0,0,.20)}
html[data-theme-effective="dark"] .cleanup-review-note{background:#2a2518;border-color:#655a31;color:#e3cc86}
html[data-theme-effective="dark"] .cleanup-item-card{background:#142327;border-color:#3c5861;box-shadow:0 4px 13px rgba(0,0,0,.24)}
html[data-theme-effective="dark"] .cleanup-item-card:hover{border-color:#5c8792;box-shadow:0 7px 18px rgba(0,0,0,.32)}
html[data-theme-effective="dark"] .cleanup-item-copy>b{color:#dcebed}
html[data-theme-effective="dark"] .cleanup-scope{background:#1d3138;color:#a9cbd2!important}
html[data-theme-effective="dark"] .cleanup-item-metric strong{color:#d8eff2}
html[data-theme-effective="dark"] .cleanup-item-metric small{color:#9db5ba}
html[data-theme-effective="dark"] .cleanup-safety-box{background:linear-gradient(180deg,#2b1b1b,#241717);border-color:#70443f}
html[data-theme-effective="dark"] .cleanup-safety-box h3{color:#ffb0a9}
html[data-theme-effective="dark"] .cleanup-safety-box p{color:#d8aaa5}
html[data-theme-effective="dark"] .cleanup-safety-box .field input{background:#172327;border-color:#6a4946;color:#eef5f6}

@media(prefers-color-scheme:dark){
  html[data-theme-mode="auto"] .cleanup-summary{background:linear-gradient(180deg,#142226,#111d21);border-color:#36515a}
  html[data-theme-mode="auto"] .cleanup-summary-metrics>div{background:#17272b;border-color:#344c54;box-shadow:0 3px 11px rgba(0,0,0,.20)}
  html[data-theme-mode="auto"] .cleanup-review-note{background:#2a2518;border-color:#655a31;color:#e3cc86}
  html[data-theme-mode="auto"] .cleanup-item-card{background:#142327;border-color:#3c5861;box-shadow:0 4px 13px rgba(0,0,0,.24)}
  html[data-theme-mode="auto"] .cleanup-item-card:hover{border-color:#5c8792;box-shadow:0 7px 18px rgba(0,0,0,.32)}
  html[data-theme-mode="auto"] .cleanup-item-copy>b{color:#dcebed}
  html[data-theme-mode="auto"] .cleanup-scope{background:#1d3138;color:#a9cbd2!important}
  html[data-theme-mode="auto"] .cleanup-item-metric strong{color:#d8eff2}
  html[data-theme-mode="auto"] .cleanup-item-metric small{color:#9db5ba}
  html[data-theme-mode="auto"] .cleanup-safety-box{background:linear-gradient(180deg,#2b1b1b,#241717);border-color:#70443f}
  html[data-theme-mode="auto"] .cleanup-safety-box h3{color:#ffb0a9}
  html[data-theme-mode="auto"] .cleanup-safety-box p{color:#d8aaa5}
  html[data-theme-mode="auto"] .cleanup-safety-box .field input{background:#172327;border-color:#6a4946;color:#eef5f6}
}

@media(min-width:720px){
  .cleanup-items-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .cleanup-summary-metrics{grid-template-columns:repeat(4,minmax(0,1fr))}
}
@media(max-width:560px){
  .cleanup-filter-submit .btn{width:100%;min-width:0}
  .cleanup-item-card{grid-template-columns:auto minmax(0,1fr);align-items:start}
  .cleanup-item-metric{grid-column:2;text-align:right;display:flex;align-items:baseline;gap:7px;min-width:0}
  .cleanup-summary-metrics{grid-template-columns:1fr 1fr}
}

/* v1.7.10.1 multi-clinic cleanup */
.cleanup-clinic-picker{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;max-height:300px;overflow:auto;padding:9px;border:1.5px solid var(--line);border-radius:14px;background:var(--surface-2)}
.cleanup-clinic-option{display:flex;align-items:center;gap:9px;padding:9px 10px;border:1px solid #cfdce6;border-radius:12px;background:var(--surface);cursor:pointer;box-shadow:0 2px 7px rgba(28,71,94,.04)}
.cleanup-clinic-option:hover{border-color:#8fb2ca}
.cleanup-clinic-option input{width:18px;height:18px;accent-color:var(--primary);flex:0 0 auto}
.cleanup-clinic-option span{display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0;width:100%}
.cleanup-clinic-option b{font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cleanup-clinic-option small{font-size:9px;color:var(--danger);font-weight:900;white-space:nowrap}
.other-sessions-panel{border:1.5px solid #c8dbea;box-shadow:0 7px 20px rgba(28,71,94,.06)}
.inline-cleanup-summary{margin:12px 0;padding:12px}
.compact-cleanup-delete{margin-top:12px}
@media (min-width:760px){.form-grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.field-span-three{grid-column:1/-1}}
html[data-theme-effective="dark"] .cleanup-clinic-option{background:#142327;border-color:#3c5861;box-shadow:0 2px 7px rgba(0,0,0,.20)}
html[data-theme-effective="dark"] .cleanup-clinic-option:hover{border-color:#5c8792}
html[data-theme-effective="dark"] .other-sessions-panel{border-color:#36515a;box-shadow:0 7px 20px rgba(0,0,0,.22)}
@media (prefers-color-scheme:dark){html[data-theme-mode="auto"] .cleanup-clinic-option{background:#142327;border-color:#3c5861;box-shadow:0 2px 7px rgba(0,0,0,.20)}html[data-theme-mode="auto"] .cleanup-clinic-option:hover{border-color:#5c8792}html[data-theme-mode="auto"] .other-sessions-panel{border-color:#36515a;box-shadow:0 7px 20px rgba(0,0,0,.22)}}
@media (max-width:680px){.cleanup-clinic-picker{grid-template-columns:1fr;max-height:260px}.other-session-filter{grid-template-columns:1fr}.field-span-three{grid-column:auto}}

/* ===== XCLINIC notes permissions patch: patient-level doctor/secretary notes + visit notes ===== */
.patient-file-notes{overflow:hidden}
.patient-page-save-bar{margin:0 0 16px}
.patient-page-save-button{min-height:50px}
.patient-notes-heading{margin-bottom:11px}
.patient-notes-heading p{margin:4px 0 0;font-size:11px}
.patient-note-grid{display:grid;grid-template-columns:1fr;gap:10px}
.patient-note-card{padding:12px;border:1.5px solid var(--line);border-radius:16px;background:var(--surface-2);min-width:0}
.patient-note-card-title{display:flex;align-items:flex-start;gap:8px;margin-bottom:9px}
.patient-note-card-title>.ui-icon{width:19px;height:19px;flex:0 0 auto;margin-top:1px}
.patient-note-card-title b{display:block;font-size:12px}
.patient-note-card-title small{display:block;margin-top:3px;color:var(--muted);font-size:9.5px;line-height:1.5}
.doctor-patient-note{border-color:#b9ddd9;background:#f4fbfa}
.doctor-patient-note .patient-note-card-title>.ui-icon{color:#0f7f78}
.secretary-patient-note{border-color:#d9c8ef;background:#faf7ff}
.secretary-patient-note .patient-note-card-title>.ui-icon{color:#7851a9}
.patient-note-form{display:grid;gap:8px}
.patient-note-form textarea,.secretary-intake-note textarea{min-height:108px;resize:vertical;line-height:1.75}
.patient-note-form textarea{width:100%;border:1px solid #cbd6e2;border-radius:13px;padding:12px 13px;background:#fff;color:var(--text);outline:none;transition:.16s ease}
.patient-note-form textarea:focus{border-color:color-mix(in srgb,var(--primary) 62%,#cbd6e2);box-shadow:0 0 0 3px color-mix(in srgb,var(--primary) 10%,transparent)}
.patient-note-save{width:100%;min-height:43px}
.patient-note-value{min-height:54px;padding:10px 11px;border:1px solid color-mix(in srgb,var(--line) 82%,transparent);border-radius:12px;background:var(--surface);white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.8;font-size:12px;color:var(--text)}
.secretary-intake-note{padding-top:2px}
.secretary-intake-note small{display:block;margin-top:5px;color:var(--muted);font-size:10px}
.visit-notes-field{margin-top:10px}
.visit-notes-field textarea{min-height:92px;line-height:1.75}
.visit-note-readonly{margin-top:10px}
.note-permissions-heading{margin-top:16px;padding-top:14px;border-top:1px solid var(--line)}
.note-permission-card{border-color:color-mix(in srgb,var(--primary) 24%,var(--line))}

html[data-theme-effective="dark"] .doctor-patient-note{background:#142927;border-color:#35635e}
html[data-theme-effective="dark"] .doctor-patient-note .patient-note-card-title>.ui-icon{color:#7de0d4}
html[data-theme-effective="dark"] .secretary-patient-note{background:#211b2b;border-color:#5f4b79}
html[data-theme-effective="dark"] .secretary-patient-note .patient-note-card-title>.ui-icon{color:#c9a7ef}
html[data-theme-effective="dark"] .patient-note-value{background:#111d21;border-color:#33494f;color:#e6f0f2}
html[data-theme-effective="dark"] .patient-note-form textarea{background:#0e191c;border-color:#31454b;color:var(--text)}
html[data-theme-effective="dark"] .patient-note-form textarea::placeholder{color:#728a91}

@media(prefers-color-scheme:dark){
  html[data-theme-mode="auto"] .doctor-patient-note{background:#142927;border-color:#35635e}
  html[data-theme-mode="auto"] .doctor-patient-note .patient-note-card-title>.ui-icon{color:#7de0d4}
  html[data-theme-mode="auto"] .secretary-patient-note{background:#211b2b;border-color:#5f4b79}
  html[data-theme-mode="auto"] .secretary-patient-note .patient-note-card-title>.ui-icon{color:#c9a7ef}
  html[data-theme-mode="auto"] .patient-note-value{background:#111d21;border-color:#33494f;color:#e6f0f2}
  html[data-theme-mode="auto"] .patient-note-form textarea{background:#0e191c;border-color:#31454b;color:var(--text)}
  html[data-theme-mode="auto"] .patient-note-form textarea::placeholder{color:#728a91}
}

@media(min-width:760px){
  .patient-note-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .patient-note-save{width:max-content;min-width:190px}
}

@media(max-width:560px){
  .patient-file-notes{padding:12px}
  .patient-note-card{padding:10px;border-radius:14px}
  .patient-note-form textarea,.secretary-intake-note textarea{min-height:96px}
  .visit-notes-field textarea{min-height:88px}
  .note-permissions-grid{grid-template-columns:1fr}
}

/* New-patient unpaid booking: fee is intentionally fixed to zero. */
.payment-fee-field.is-unpaid .money-input{opacity:.78}
.payment-fee-field.is-unpaid .money-input input:disabled{background:#edf2f5;border-color:#cbd6dc;color:#64767d;cursor:not-allowed;-webkit-text-fill-color:#64767d;opacity:1}
.payment-fee-field.is-unpaid>small{font-weight:700;color:#65787f}
html[data-theme-effective="dark"] .payment-fee-field.is-unpaid .money-input input:disabled{background:#172327;border-color:#334a51;color:#91a6ad;-webkit-text-fill-color:#91a6ad}
html[data-theme-effective="dark"] .payment-fee-field.is-unpaid>small{color:#91a6ad}
@media (prefers-color-scheme:dark){html[data-theme-mode="auto"] .payment-fee-field.is-unpaid .money-input input:disabled{background:#172327;border-color:#334a51;color:#91a6ad;-webkit-text-fill-color:#91a6ad}html[data-theme-mode="auto"] .payment-fee-field.is-unpaid>small{color:#91a6ad}}

/* Small instructional modal used for client-side validation without navigating away. */
.instruction-modal{position:fixed;inset:0;z-index:1200;display:flex;align-items:center;justify-content:center;padding:18px;background:rgba(9,16,24,.62);backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px)}
.instruction-modal[hidden]{display:none!important}
.instruction-modal-card{width:min(100%,360px);background:var(--surface);color:var(--text);border:1.5px solid var(--line);border-radius:18px;padding:20px;text-align:center;box-shadow:0 22px 60px rgba(10,28,45,.28);opacity:1}
.instruction-modal-icon{display:grid;place-items:center;width:42px;height:42px;margin:0 auto 10px;border-radius:50%;background:var(--primary-soft);border:1px solid color-mix(in srgb,var(--primary) 28%,var(--line));color:var(--primary);font-size:22px;font-weight:900}
.instruction-modal-card h2{margin:0 0 8px;font-size:18px;line-height:1.35;color:var(--text)}
.instruction-modal-card p{margin:0;color:var(--muted);font-size:14px;line-height:1.8}
.instruction-modal-ok{width:100%;min-height:46px;margin-top:16px}
.has-instruction-modal{overflow:hidden}
html[data-theme-effective="dark"] .instruction-modal{background:rgba(0,0,0,.76)}
html[data-theme-effective="dark"] .instruction-modal-card{background:#111b1f;border-color:#3a5158;box-shadow:0 24px 64px rgba(0,0,0,.56)}
html[data-theme-effective="dark"] .instruction-modal-icon{background:#173533;border-color:#355e59;color:#7de0d4}
@media (prefers-color-scheme:dark){html[data-theme-mode="auto"] .instruction-modal{background:rgba(0,0,0,.76)}html[data-theme-mode="auto"] .instruction-modal-card{background:#111b1f;border-color:#3a5158;box-shadow:0 24px 64px rgba(0,0,0,.56)}html[data-theme-mode="auto"] .instruction-modal-icon{background:#173533;border-color:#355e59;color:#7de0d4}}
@media (max-width:420px){.instruction-modal{padding:14px}.instruction-modal-card{border-radius:16px;padding:18px 16px}.instruction-modal-card h2{font-size:17px}.instruction-modal-card p{font-size:13px}}

/* ===== XCLINIC final light/dark theme hardening =====
   Consolidates late-added UI components so forced dark and auto-dark never fall back
   to light cards. Paper/template white surfaces are intentionally excluded. */
html[data-theme-effective="dark"]{
  --theme-card:#111b1f;
  --theme-card-2:#162327;
  --theme-card-3:#0f1a1d;
  --theme-field:#0e191c;
  --theme-border:#31454b;
  --theme-border-soft:#27383d;
  --theme-text:#e7f0f2;
  --theme-muted:#91a6ad;
}
html[data-theme-effective="dark"] :is(.brand,.field label,.meta-item strong,.archive-card h2,.clinical-title,.visit-date,.visit-block-title,.visit-text,.year-stat-item b,.system-validity-heading h2,.patient-edit-details summary,.archive-patient-zone summary,.delete-patient-zone summary){color:var(--theme-text)}
html[data-theme-effective="dark"] :is(.meta-label,.patient-tile-footer,.stats-date,.search-results-head,.patient-stat-footer,.archive-card p,.archive-label,.profile-code,.profile-meta span,.visit-date span,.visit-doctor){color:var(--theme-muted)}

/* Navigation and generic interactive light surfaces. */
html[data-theme-effective="dark"] .nav a:not(.nav-add-patient):not(.nav-icon-only):not(.nav-logout){background:var(--theme-card-2);border-color:var(--theme-border);color:var(--theme-text)}
html[data-theme-effective="dark"] .nav a:not(.nav-add-patient):not(.nav-icon-only):not(.nav-logout):hover{background:#1b2b30;border-color:#46636b;color:#eef8fa}
html[data-theme-effective="dark"] :is(.pagination a,.page-current,.profile-actions,.archive-breadcrumbs,.archive-card,.visit-card-modern,.year-stat-item){background:var(--theme-card);border-color:var(--theme-border-soft);color:var(--theme-text)}
html[data-theme-effective="dark"] :is(.archive-card:hover,.visit-row-card:hover){background:#152226;border-color:#405960}

/* Patient cards: legacy + modern + patient profile. */
html[data-theme-effective="dark"] :is(.visit-row-card,.meta-item,.patient-card-info>div,.patient-inline-stats,.archive-year-stats-panel){background:var(--theme-card-2);border-color:var(--theme-border-soft)}
html[data-theme-effective="dark"] :is(.avatar,.patient-avatar,.patient-avatar-modern,.profile-avatar,.archive-icon,.archive-day-number){background:linear-gradient(145deg,#17302f,#172b35);border-color:#345258;color:#7bd8d0}
html[data-theme-effective="dark"] .patient-profile-hero{background:linear-gradient(145deg,#112528,#101d22);border-color:#2e484d;box-shadow:0 12px 30px rgba(0,0,0,.24)}
html[data-theme-effective="dark"] .profile-meta span{background:#17272b;border:1px solid #2f474d}
html[data-theme-effective="dark"] .profile-actions{background:#111d21;border-color:#30464c}
html[data-theme-effective="dark"] .patient-card-chevron{background:#18272b;color:#9bb0b6}
html[data-theme-effective="dark"] .file-code{background:#18262b;color:#a9c0c6}
html[data-theme-effective="dark"] .patient-visibility-control.is-hidden{background:#171f22;border-inline-start-color:#68777b}
html[data-theme-effective="dark"] .visibility-hide-button{background:#2b1d1d!important;border-color:#65413d!important;color:#f1aaa3!important}

/* Archive years/months/days. */
html[data-theme-effective="dark"] .archive-breadcrumbs a{color:#75d6cc}
html[data-theme-effective="dark"] .archive-arrow{color:#71888e}
html[data-theme-effective="dark"] .archive-year-stats-panel{border-top-color:#2b4045}
html[data-theme-effective="dark"] .archive-year-stats-button{background:#17272b!important;border-color:#365159!important;color:#b8d4d9!important}
html[data-theme-effective="dark"] .year-stat-item b{color:#d8ecef}

/* Clinical/current-visit and previous-visit content. */
html[data-theme-effective="dark"] :is(.clinical-box,.visit-clinical-block){background:#121f23;border-color:#2d444a}
html[data-theme-effective="dark"] .visit-clinical-block.treatment{background:#132026}
html[data-theme-effective="dark"] .clinical-box textarea{background:var(--theme-field);border-color:var(--theme-border);color:var(--theme-text)}
html[data-theme-effective="dark"] .clinical-box textarea::placeholder{color:#728a91}
html[data-theme-effective="dark"] :is(.visit-card-header,.visit-thumbs,.visit-actions){border-color:#2a3e43}
html[data-theme-effective="dark"] .visit-note{background:#292416;border-color:#625631;color:#e3cc8a}
html[data-theme-effective="dark"] .fee-badge{background:#16312b;color:#8addba;border:1px solid #315845}
html[data-theme-effective="dark"] .quick-buttons button{background:#17302e!important;border-color:#315b56!important;color:#9be1d8!important}

/* Status chips and live sync. */
html[data-theme-effective="dark"] .paid{background:#153126;color:#81ddb0;border:1px solid #28513f}
html[data-theme-effective="dark"] .unpaid{background:#351d1d;color:#ffaaa3;border:1px solid #5d3330}
html[data-theme-effective="dark"] :is(.live-pill,.live-sync-pill){background:#162823;border-color:#315044;color:#a8d7c6}
html[data-theme-effective="dark"] .live-sync-pill:hover{background:#1b322c;border-color:#45685b}
html[data-theme-effective="dark"] .live-sync-pill.is-updated{background:#163126;color:#81ddb0;border-color:#315840}
html[data-theme-effective="dark"] .live-sync-pill.is-error{background:#351d1d;color:#ffaaa3;border-color:#5d3330}
html[data-theme-effective="dark"] .search-results-head b,html[data-theme-effective="dark"] .count-pill{background:#17302e;color:#91ddd5}
html[data-theme-effective="dark"] .error-hint{background:#351d1d;color:#ffaaa3;border-color:#5d3330}

/* Settings/admin surfaces added after the original theme engine. */
html[data-theme-effective="dark"] .feature-icon{background:#173330;color:#7de0d4;border:1px solid #315953}
html[data-theme-effective="dark"] .feature-toggle-card:hover{background:#18282c;border-color:#405b61}
html[data-theme-effective="dark"] .mini-toggle{background:#142327;border-color:#344a50;color:var(--theme-text)}
html[data-theme-effective="dark"] .clinic-admin-form{border-top-color:#2b4146}
html[data-theme-effective="dark"] .user-admin-details{background:#121f23;border-color:#33494f}
html[data-theme-effective="dark"] .permission-check-card{background:#142327;border-color:#344a50;color:#cbdde1}
html[data-theme-effective="dark"] .settings-save-bar{background:rgba(17,27,31,.95);border-color:#31464c;box-shadow:0 10px 30px rgba(0,0,0,.30)}
html[data-theme-effective="dark"] .system-validity-card .subscription-countdown-pill{background:#17282b;border-color:#305054}
html[data-theme-effective="dark"] .subscription-countdown-pill.is-expired{background:#351d1d;border-color:#5d3330;color:#ffaaa3}
html[data-theme-effective="dark"] .subscription-countdown-pill.is-expired :is(.ui-icon,b){color:#ffaaa3}

/* Cleanup + account pages: keep every nested surface dark. */
html[data-theme-effective="dark"] :is(.cleanup-summary-metrics>div,.cleanup-item-card,.cleanup-clinic-option){background:#142327;border-color:#3c5861}
html[data-theme-effective="dark"] .cleanup-safety-box .field input{background:var(--theme-field);color:var(--theme-text)}

/* Text library, managed/error/login and modal surfaces. */
html[data-theme-effective="dark"] :is(.managed-page-card,.error-page-card,.login-card,.instruction-modal-card){background:var(--theme-card);border-color:var(--theme-border);color:var(--theme-text)}
html[data-theme-effective="dark"] .managed-rich-content{color:#c9d9dc}
html[data-theme-effective="dark"] .managed-rich-content :is(h1,h2,h3,strong,b){color:#eef7f8}
html[data-theme-effective="dark"] .managed-rich-content :is(blockquote,pre,code){background:#162428;border-color:#30464c;color:#d4e4e7}
html[data-theme-effective="dark"] .app-text-field{background:#142126;border-color:#2b3d42}
html[data-theme-effective="dark"] .app-text-field :is(input,textarea){background:var(--theme-field);border-color:var(--theme-border);color:var(--theme-text)}

/* Semantic note cards remain distinguishable while respecting dark mode. */
html[data-theme-effective="dark"] .doctor-patient-note{background:#142927;border-color:#35635e}
html[data-theme-effective="dark"] .secretary-patient-note{background:#211b2b;border-color:#5f4b79}

/* Auto mode fallback when the OS is dark, even before/without theme JS. */
@media(prefers-color-scheme:dark){
  html[data-theme-mode="auto"]{
    --theme-card:#111b1f;--theme-card-2:#162327;--theme-card-3:#0f1a1d;--theme-field:#0e191c;--theme-border:#31454b;--theme-border-soft:#27383d;--theme-text:#e7f0f2;--theme-muted:#91a6ad;
  }
  html[data-theme-mode="auto"] :is(.brand,.field label,.meta-item strong,.archive-card h2,.clinical-title,.visit-date,.visit-block-title,.visit-text,.year-stat-item b,.system-validity-heading h2,.patient-edit-details summary,.archive-patient-zone summary,.delete-patient-zone summary){color:var(--theme-text)}
  html[data-theme-mode="auto"] :is(.meta-label,.patient-tile-footer,.stats-date,.search-results-head,.patient-stat-footer,.archive-card p,.archive-label,.profile-code,.profile-meta span,.visit-date span,.visit-doctor){color:var(--theme-muted)}
  html[data-theme-mode="auto"] .nav a:not(.nav-add-patient):not(.nav-icon-only):not(.nav-logout){background:var(--theme-card-2);border-color:var(--theme-border);color:var(--theme-text)}
  html[data-theme-mode="auto"] .nav a:not(.nav-add-patient):not(.nav-icon-only):not(.nav-logout):hover{background:#1b2b30;border-color:#46636b;color:#eef8fa}
  html[data-theme-mode="auto"] :is(.pagination a,.page-current,.profile-actions,.archive-breadcrumbs,.archive-card,.visit-card-modern,.year-stat-item){background:var(--theme-card);border-color:var(--theme-border-soft);color:var(--theme-text)}
  html[data-theme-mode="auto"] :is(.archive-card:hover,.visit-row-card:hover){background:#152226;border-color:#405960}
  html[data-theme-mode="auto"] :is(.visit-row-card,.meta-item,.patient-card-info>div,.patient-inline-stats,.archive-year-stats-panel){background:var(--theme-card-2);border-color:var(--theme-border-soft)}
  html[data-theme-mode="auto"] :is(.avatar,.patient-avatar,.patient-avatar-modern,.profile-avatar,.archive-icon,.archive-day-number){background:linear-gradient(145deg,#17302f,#172b35);border-color:#345258;color:#7bd8d0}
  html[data-theme-mode="auto"] .patient-profile-hero{background:linear-gradient(145deg,#112528,#101d22);border-color:#2e484d;box-shadow:0 12px 30px rgba(0,0,0,.24)}
  html[data-theme-mode="auto"] .profile-meta span{background:#17272b;border:1px solid #2f474d}
  html[data-theme-mode="auto"] .profile-actions{background:#111d21;border-color:#30464c}
  html[data-theme-mode="auto"] .patient-card-chevron{background:#18272b;color:#9bb0b6}
  html[data-theme-mode="auto"] .file-code{background:#18262b;color:#a9c0c6}
  html[data-theme-mode="auto"] .patient-visibility-control.is-hidden{background:#171f22;border-inline-start-color:#68777b}
  html[data-theme-mode="auto"] .visibility-hide-button{background:#2b1d1d!important;border-color:#65413d!important;color:#f1aaa3!important}
  html[data-theme-mode="auto"] .archive-breadcrumbs a{color:#75d6cc}
  html[data-theme-mode="auto"] .archive-arrow{color:#71888e}
  html[data-theme-mode="auto"] .archive-year-stats-panel{border-top-color:#2b4045}
  html[data-theme-mode="auto"] .archive-year-stats-button{background:#17272b!important;border-color:#365159!important;color:#b8d4d9!important}
  html[data-theme-mode="auto"] .year-stat-item b{color:#d8ecef}
  html[data-theme-mode="auto"] :is(.clinical-box,.visit-clinical-block){background:#121f23;border-color:#2d444a}
  html[data-theme-mode="auto"] .visit-clinical-block.treatment{background:#132026}
  html[data-theme-mode="auto"] .clinical-box textarea{background:var(--theme-field);border-color:var(--theme-border);color:var(--theme-text)}
  html[data-theme-mode="auto"] .clinical-box textarea::placeholder{color:#728a91}
  html[data-theme-mode="auto"] :is(.visit-card-header,.visit-thumbs,.visit-actions){border-color:#2a3e43}
  html[data-theme-mode="auto"] .visit-note{background:#292416;border-color:#625631;color:#e3cc8a}
  html[data-theme-mode="auto"] .fee-badge{background:#16312b;color:#8addba;border:1px solid #315845}
  html[data-theme-mode="auto"] .quick-buttons button{background:#17302e!important;border-color:#315b56!important;color:#9be1d8!important}
  html[data-theme-mode="auto"] .paid{background:#153126;color:#81ddb0;border:1px solid #28513f}
  html[data-theme-mode="auto"] .unpaid{background:#351d1d;color:#ffaaa3;border:1px solid #5d3330}
  html[data-theme-mode="auto"] :is(.live-pill,.live-sync-pill){background:#162823;border-color:#315044;color:#a8d7c6}
  html[data-theme-mode="auto"] .live-sync-pill:hover{background:#1b322c;border-color:#45685b}
  html[data-theme-mode="auto"] .live-sync-pill.is-updated{background:#163126;color:#81ddb0;border-color:#315840}
  html[data-theme-mode="auto"] .live-sync-pill.is-error{background:#351d1d;color:#ffaaa3;border-color:#5d3330}
  html[data-theme-mode="auto"] .search-results-head b,html[data-theme-mode="auto"] .count-pill{background:#17302e;color:#91ddd5}
  html[data-theme-mode="auto"] .error-hint{background:#351d1d;color:#ffaaa3;border-color:#5d3330}
  html[data-theme-mode="auto"] .feature-icon{background:#173330;color:#7de0d4;border:1px solid #315953}
  html[data-theme-mode="auto"] .feature-toggle-card:hover{background:#18282c;border-color:#405b61}
  html[data-theme-mode="auto"] .mini-toggle{background:#142327;border-color:#344a50;color:var(--theme-text)}
  html[data-theme-mode="auto"] .clinic-admin-form{border-top-color:#2b4146}
  html[data-theme-mode="auto"] .user-admin-details{background:#121f23;border-color:#33494f}
  html[data-theme-mode="auto"] .permission-check-card{background:#142327;border-color:#344a50;color:#cbdde1}
  html[data-theme-mode="auto"] .settings-save-bar{background:rgba(17,27,31,.95);border-color:#31464c;box-shadow:0 10px 30px rgba(0,0,0,.30)}
  html[data-theme-mode="auto"] .system-validity-card .subscription-countdown-pill{background:#17282b;border-color:#305054}
  html[data-theme-mode="auto"] .subscription-countdown-pill.is-expired{background:#351d1d;border-color:#5d3330;color:#ffaaa3}
  html[data-theme-mode="auto"] .subscription-countdown-pill.is-expired :is(.ui-icon,b){color:#ffaaa3}
  html[data-theme-mode="auto"] :is(.cleanup-summary-metrics>div,.cleanup-item-card,.cleanup-clinic-option){background:#142327;border-color:#3c5861}
  html[data-theme-mode="auto"] .cleanup-safety-box .field input{background:var(--theme-field);color:var(--theme-text)}
  html[data-theme-mode="auto"] :is(.managed-page-card,.error-page-card,.login-card,.instruction-modal-card){background:var(--theme-card);border-color:var(--theme-border);color:var(--theme-text)}
  html[data-theme-mode="auto"] .managed-rich-content{color:#c9d9dc}
  html[data-theme-mode="auto"] .managed-rich-content :is(h1,h2,h3,strong,b){color:#eef7f8}
  html[data-theme-mode="auto"] .managed-rich-content :is(blockquote,pre,code){background:#162428;border-color:#30464c;color:#d4e4e7}
  html[data-theme-mode="auto"] .app-text-field{background:#142126;border-color:#2b3d42}
  html[data-theme-mode="auto"] .app-text-field :is(input,textarea){background:var(--theme-field);border-color:var(--theme-border);color:var(--theme-text)}
  html[data-theme-mode="auto"] .doctor-patient-note{background:#142927;border-color:#35635e}
  html[data-theme-mode="auto"] .secretary-patient-note{background:#211b2b;border-color:#5f4b79}
}

/* Remaining semantic/command surfaces found by the final theme audit. */
html[data-theme-effective="dark"] .btn:not(.btn-primary):not(.btn-danger):not(.btn-ok){background:#172428;color:#d5e4e7;border-color:#31454b}
html[data-theme-effective="dark"] .btn:not(.btn-primary):not(.btn-danger):not(.btn-ok):hover{background:#1c2d31;border-color:#436067}
html[data-theme-effective="dark"] .hero-icon-button:not(.hero-icon-primary){background:#17272b!important;border-color:#365159!important;color:#d8e7ea!important}
html[data-theme-effective="dark"] .hero-icon-button:not(.hero-icon-primary) .ui-icon{color:#7edbd2}
html[data-theme-effective="dark"] .hero-kicker{color:#7edbd2}
html[data-theme-effective="dark"] .search-icon{color:#8da7ad}
html[data-theme-effective="dark"] .today-stat.fees{background:#142d29;border-color:#31564d}
html[data-theme-effective="dark"] .today-stat.fees b{color:#8bddc8}
html[data-theme-effective="dark"] .badge.new-patient{background:#172d3a;color:#8dccf2;border-color:#31546b}
@media(prefers-color-scheme:dark){
  html[data-theme-mode="auto"] .btn:not(.btn-primary):not(.btn-danger):not(.btn-ok){background:#172428;color:#d5e4e7;border-color:#31454b}
  html[data-theme-mode="auto"] .btn:not(.btn-primary):not(.btn-danger):not(.btn-ok):hover{background:#1c2d31;border-color:#436067}
  html[data-theme-mode="auto"] .hero-icon-button:not(.hero-icon-primary){background:#17272b!important;border-color:#365159!important;color:#d8e7ea!important}
  html[data-theme-mode="auto"] .hero-icon-button:not(.hero-icon-primary) .ui-icon{color:#7edbd2}
  html[data-theme-mode="auto"] .hero-kicker{color:#7edbd2}
  html[data-theme-mode="auto"] .search-icon{color:#8da7ad}
  html[data-theme-mode="auto"] .today-stat.fees{background:#142d29;border-color:#31564d}
  html[data-theme-mode="auto"] .today-stat.fees b{color:#8bddc8}
  html[data-theme-mode="auto"] .badge.new-patient{background:#172d3a;color:#8dccf2;border-color:#31546b}
}
html[data-theme-effective="dark"] .user-admin-details>summary{color:var(--theme-text)}
@media(prefers-color-scheme:dark){html[data-theme-mode="auto"] .user-admin-details>summary{color:var(--theme-text)}}

/* Clinic print settings editor */
.print-settings-page{display:grid;gap:16px}.print-settings-entry-card{display:flex;align-items:center;justify-content:space-between;gap:14px;text-decoration:none;color:inherit}.print-settings-entry-card>div{min-width:0}.clinic-card-actions{display:flex;flex-wrap:wrap;gap:9px;margin-top:14px}.print-settings-layout{display:grid;gap:16px}.print-settings-controls{min-width:0}.print-settings-preview-wrap{min-width:0;padding:12px;border:1px solid var(--line);border-radius:18px;background:var(--surface-2);overflow:hidden}.print-settings-paper-scaler{position:relative;margin:0 auto}.print-settings-paper{position:absolute;inset:0 auto auto 0;background:#fff;box-shadow:0 14px 42px rgba(28,67,74,.16);transform-origin:top left;overflow:hidden}.print-settings-template-image{position:absolute;inset:0;width:100%;height:100%;object-fit:fill;z-index:1;pointer-events:none}.print-settings-preview-empty{position:absolute;inset:0;z-index:0;display:grid;place-items:center;color:#a7b6ba;background:linear-gradient(135deg,#fff,#fbfefe);font-size:12px}.print-settings-box{position:absolute;z-index:3;border:1px dashed rgba(15,131,124,.75);background:rgba(255,255,255,.82);color:#111;padding:1.4mm 2mm;border-radius:2mm;cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;line-height:1.35;overflow:visible}.print-settings-box.is-dragging{cursor:grabbing;border-style:solid;background:rgba(255,255,255,.96)}.print-settings-box>span{position:absolute;top:-18px;right:0;border-radius:6px;background:#0f837c;color:#fff;padding:2px 5px;font-size:9px;line-height:1.2;white-space:nowrap;pointer-events:none}.print-settings-box>b{font:inherit;font-weight:700;color:#111}.print-settings-box.patient-box{direction:rtl;text-align:right;white-space:nowrap;min-width:42mm}.print-settings-box.date-box{direction:ltr;text-align:left;white-space:nowrap;min-width:30mm;font-variant-numeric:tabular-nums}.print-settings-box.age-box{direction:rtl;text-align:right;white-space:nowrap;min-width:24mm}.print-settings-box.text-box{min-height:12mm;white-space:pre-wrap;min-width:20mm}.print-settings-box.rights-box{direction:rtl;text-align:center;white-space:nowrap;min-width:35mm;font-size:7pt;font-weight:500;padding:.8mm 1.2mm}.print-settings-box.rights-box.is-readonly{cursor:default;border-style:dotted}.print-settings-box.rights-box.is-readonly>span{display:none}.print-rights-admin{order:90}.print-age-toggle{align-items:center}
@media(min-width:900px){.print-settings-layout{grid-template-columns:minmax(300px,.86fr) minmax(360px,1.14fr);align-items:start}.print-settings-preview-wrap{position:sticky;top:90px}}
html[data-theme-effective="dark"] .print-settings-preview-wrap{background:#101c20;border-color:#31484f}html[data-theme-effective="dark"] .print-settings-paper{box-shadow:0 18px 54px rgba(0,0,0,.5);outline:1px solid #3b4d52}
@media(prefers-color-scheme:dark){html[data-theme-mode="auto"] .print-settings-preview-wrap{background:#101c20;border-color:#31484f}html[data-theme-mode="auto"] .print-settings-paper{box-shadow:0 18px 54px rgba(0,0,0,.5);outline:1px solid #3b4d52}}


/* Clinical completion + autosave */
.badge.clinical-done{font-weight:800;letter-spacing:.01em}
.autosave-status{display:block;min-height:1.3em;margin-top:6px;font-size:.78rem;opacity:.82}
.autosave-status.is-saving{opacity:.8}
.autosave-status.is-saved{font-weight:700}
.autosave-status.is-error{font-weight:700}
.tests-followup-box{grid-column:1/-1}

/* V6: isolated hidden-patient archive + on-demand archive statistics */
.hidden-archive-entry{border-style:dashed}
.hidden-patient-archive-grid .patient-card-actions{grid-template-columns:repeat(3,minmax(0,1fr))}
.patient-card-inline-form{display:contents}
.archive-pagination{display:flex;justify-content:center;gap:8px;margin-top:12px;flex-wrap:wrap}
.archive-day-heading-stats{width:auto;min-width:132px;margin:0}
.workspace-side>.archive-year-stats-panel{flex-basis:100%;min-width:min(360px,90vw)}
@media(max-width:560px){
  .hidden-patient-archive-grid .patient-card-actions{grid-template-columns:1fr}
  .archive-day-heading-stats{min-width:110px}
}
