:root{font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#1f2937;background:#e6ebf0;line-height:1.4;color-scheme:light}*{box-sizing:border-box}html,body{margin:0;background:#e6ebf0;color:#1f2937;overscroll-behavior-y:none;touch-action:manipulation;-ms-touch-action:manipulation}body{min-height:100%}.shell{width:100%;max-width:none;margin:0 auto;padding:24px 20px 48px;box-sizing:border-box}.topbar{display:flex;align-items:flex-end;justify-content:space-between;gap:24px;margin-bottom:24px}.logout-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#3f1d1d;
  color:#fecaca;
  border:1px solid #b42318;
  font:inherit;
  cursor:pointer;
  width:36px;
  height:36px;
  min-width:36px;
  min-height:36px;
  padding:0;
  border-radius:10px;
  box-shadow:none;
  flex:0 0 auto;
  line-height:0;
}
.logout-btn svg{
  display:block;
  width:18px;
  height:18px;
}
.session-user{
  display:inline-flex;
  align-items:center;
  max-width:min(220px,42vw);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#315b7a;
  font-size:12px;
  font-weight:700;
}
.theme-dark .session-user{color:#9ac3e5}
.top-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}
.logout-btn:hover{
  background:#b42318;
  border-color:#b42318;
  color:#fff;
}
.theme-dark .logout-btn{
  background:#450a0a;
  border-color:#dc2626;
  color:#fecaca;
}
.theme-dark .logout-btn:hover{
  background:#dc2626;
  color:#fff;
}.clinic-name{margin:0 0 10px;max-width:52rem;color:#315b7a;font-size:13px;font-weight:700;line-height:1.45}.login-card .clinic-name{margin-bottom:14px;font-size:12px}.eyebrow{margin:0 0 6px;color:#54718f;text-transform:uppercase;letter-spacing:.12em;font-size:11px;font-weight:800}h1,h2{margin:0;color:#17365d}h1{font-size:34px;letter-spacing:-.04em}.subtitle{margin:8px 0 0;color:#718096}.logs-title{margin:22px 0 10px;color:#17365d;font-size:18px}.section-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap}.theme-dark .clinic-name,.theme-dark .logs-title{color:#9ac3e5}.primary,.secondary,.icon-button{border:0;border-radius:10px;font:inherit;cursor:pointer;min-height:44px}.primary{background:#17365d;color:#fff;padding:12px 18px;font-weight:750;box-shadow:0 5px 14px #17365d22}.secondary{background:#fff;color:#334e68;border:1px solid #cbd5e1;padding:10px 14px;font-weight:650}.notice{display:flex;gap:12px;padding:13px 16px;background:#fff6d9;border:1px solid #ecd894;border-radius:12px;color:#765f16;font-size:13px;margin-bottom:20px}.notice strong{white-space:nowrap}.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:20px}.stats article{background:#fff;border:1px solid #dbe5ee;border-radius:14px;padding:17px 18px;box-shadow:0 4px 16px #17365d08}.stats span{display:block;color:#718096;font-size:12px}.stats strong{display:block;color:#17365d;font-size:25px;margin-top:6px}.toolbar{display:flex;gap:10px;align-items:center;margin-bottom:14px}.search{display:flex;align-items:center;gap:8px;background:#fff;border:1px solid #cbd5e1;border-radius:10px;padding:0 12px;flex:1;max-width:560px}.search span{font-size:22px;color:#78909c}.search input,.toolbar select{border:0;background:transparent;padding:11px 4px;font:inherit;outline:0;width:100%}.toolbar select{background:#fff;border:1px solid #cbd5e1;border-radius:10px;width:180px;padding:10px 12px}.file-button{position:relative;overflow:hidden}.file-button input{position:absolute;inset:0;opacity:0;cursor:pointer}.table-card{background:#fff;border:1px solid #dbe5ee;border-radius:15px;overflow:hidden;box-shadow:0 7px 24px #17365d0a}.table-scroll{overflow:auto}table{width:100%;border-collapse:collapse;min-width:0}th{background:#e5f0f8;color:#17365d;text-align:left;font-size:12px;padding:13px 14px;white-space:nowrap}td{padding:13px 14px;border-top:1px solid #e8eef3;font-size:13px;vertical-align:top}/* hover only on real pointer devices — avoids sticky highlight while scrolling on phones */.date{display:block;font-weight:750;color:#17365d;white-space:nowrap}.time{display:block;color:#718096;font-size:12px;margin-top:3px}.patient{font-weight:750}.sub{display:block;color:#718096;font-size:12px;margin-top:3px}.status{display:inline-flex;border-radius:999px;padding:5px 9px;font-size:11px;font-weight:750;white-space:nowrap}.status-Заплановано{background:#fff2cc;color:#876b13}.status-Підтверджено{background:#e2f0d9;color:#3f6d35}.status-Виконано{background:#d9ead3;color:#356b45}.status-Скасовано{background:#f4cccc;color:#8c3030}.status-Перенесено{background:#fce4d6;color:#9a5424}.attachments-count{color:#356b9a;font-weight:700;white-space:nowrap}.row-actions{display:flex;gap:8px;align-items:center}.row-actions button{border:0;background:transparent;color:#47759b;cursor:pointer;font-weight:700;padding:7px 0}.icon-action{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border-radius:10px;border:1px solid #9fc0d8;background:#e8f2fa;color:#17365d;box-shadow:0 2px 6px #17365d14}.icon-action svg{display:block;width:18px;height:18px}.selected-attachments{margin-top:14px;padding:12px 14px;border:1px solid #7eb3d4;border-radius:12px;background:#e8f5fd}.selected-attachments-head{display:flex;flex-direction:column;gap:4px;margin-bottom:10px}.selected-attachments-head strong{color:#17365d;font-size:14px}.selected-attachments-head span{color:#315b7a;font-size:12px}.selected-attachments-list{list-style:none;margin:0;padding:0;display:grid;gap:8px}.selected-attachments-list li{display:grid;grid-template-columns:auto 1fr auto;gap:10px;align-items:center;padding:10px 12px;border-radius:10px;background:#fff;border:1px solid #cfe3f1}.selected-file-icon{font-size:20px;line-height:1}.selected-file-meta{display:flex;flex-direction:column;gap:2px;min-width:0}.selected-file-meta strong{color:#17365d;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.selected-file-meta small{color:#64748b;font-size:12px}.selected-file-status{color:#2f6b3a;font-size:11px;font-weight:800;white-space:nowrap}.upload-progress{margin-top:14px;padding:12px 14px;border:1px solid #dbe5ee;border-radius:10px;background:#f8fbfe}.upload-progress-head{display:flex;justify-content:space-between;gap:12px;align-items:center;margin-bottom:8px;color:#315b7a;font-size:13px;font-weight:700}.upload-spinner{width:16px;height:16px;border-radius:50%;border:2px solid #9fc0d8;border-top-color:#17365d;animation:spin .8s linear infinite;flex:0 0 auto}.upload-progress-track{height:10px;border-radius:999px;background:#d9eaf7;overflow:hidden}.upload-progress-bar{height:100%;width:0;border-radius:inherit;background:linear-gradient(90deg,#315b7a,#47759b);transition:width .15s linear}@keyframes spin{to{transform:rotate(360deg)}}.theme-dark .selected-attachments{background:#182b3b;border-color:#47759b}.theme-dark .selected-attachments-head strong{color:#dbeafe}.theme-dark .selected-attachments-head span,.theme-dark .selected-file-meta small{color:#9ac3e5}.theme-dark .selected-attachments-list li{background:#1f2937;border-color:#4b5563}.theme-dark .selected-file-meta strong{color:#e5e7eb}.theme-dark .selected-file-status{color:#86efac}.theme-dark .upload-progress{background:#182b3b;border-color:#4b5563}.theme-dark .upload-progress-head{color:#9ac3e5}.theme-dark .upload-progress-track{background:#243b53}.theme-dark .upload-spinner{border-color:#4b5563;border-top-color:#9ac3e5}.theme-dark .icon-button{background:#374151;color:#e5e7eb}.theme-dark .icon-action{background:#243b53;border-color:#47759b;color:#dbeafe}.theme-dark .upload-progress{background:#182b3b;border-color:#4b5563}.theme-dark .upload-progress-head{color:#9ac3e5}.theme-dark .upload-progress-track{background:#243b53}.empty{text-align:center;padding:50px;color:#718096}.dialog-head{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:20px}.icon-button{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;padding:0;line-height:0;background:#edf2f7;color:#52606d;border:0;border-radius:10px;cursor:pointer;flex:0 0 auto}.icon-button svg{display:block;flex:0 0 auto}.dialog-head h2{font-size:24px}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}.form-grid label,.login-card label{display:flex;flex-direction:column;gap:6px;font-size:12px;color:#52606d;font-weight:700}.form-grid input,.form-grid select,.form-grid textarea,.login-card input{font:inherit;font-size:16px;font-weight:400;color:#1f2937;background:#fff;border:1px solid #cbd5e1;border-radius:8px;padding:10px;outline:0;min-height:44px}.form-grid input[type=date]{text-align:left;-webkit-appearance:none;appearance:none}.form-grid input[type=date]::-webkit-date-and-time-value{text-align:left;margin:0}.form-grid input[type=date]::-webkit-datetime-edit,.form-grid input[type=date]::-webkit-datetime-edit-fields-wrapper{text-align:left;padding:0}.form-grid input:focus,.form-grid select:focus,.form-grid textarea:focus,.login-card input:focus{border-color:#47759b;box-shadow:0 0 0 3px #47759b18}.wide{grid-column:1/-1}.upload{border:1px dashed #9db7cc;background:#f6fbff;padding:14px;border-radius:10px}.upload small{font-weight:400;color:#718096}.attachments{display:flex;flex-wrap:wrap;gap:8px;margin-top:15px}.attachment-chip{background:#edf5fa;border-radius:8px;padding:7px 9px;font-size:12px;color:#315b7a}.dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:22px}
dialog{border:0;border-radius:16px;padding:0;width:min(760px,calc(100% - 28px));box-shadow:0 24px 80px #17365d33}
dialog::backdrop{background:#17365d80}
dialog form{padding:25px}
.operation-dialog{
  width:min(760px,calc(100% - 20px));
  max-height:min(92vh,920px);
  max-height:min(92dvh,920px);
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  padding:0;
  background:#fff;
  color:#1f2937;
}
.theme-dark .operation-dialog{background:#1f2937;color:#e5e7eb}
.operation-dialog form{display:block;padding:0;max-height:none;overflow:visible}
.operation-dialog .dialog-head{margin:0;padding:18px 22px 10px}
.operation-dialog .dialog-body{padding:0 22px 14px}
.operation-dialog .dialog-actions{
  position:sticky;
  bottom:0;
  margin:0;
  padding:10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top:1px solid #e2e8f0;
  background:#fff;
  gap:10px;
  z-index:2;
  display:flex;
  flex-direction:row;
  justify-content:flex-end;
  align-items:center;
  flex-wrap:nowrap;
}
.theme-dark .operation-dialog .dialog-actions{background:#1f2937;border-color:#374151}
.dialog-actions-icons{display:flex!important;flex-direction:row!important;grid-template-columns:none!important}
.dialog-icon-btn{
  width:44px;
  height:44px;
  min-width:44px;
  min-height:44px;
  padding:0;
  border:0;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow:0 2px 8px #17365d22;
}
.dialog-icon-btn.primary{background:#17365d;color:#fff}
.dialog-icon-btn.secondary{background:#e8eef5;color:#334e68;border:1px solid #cbd5e1}
.dialog-icon-btn.danger{background:#fdecec;color:#b42318;margin-right:auto;border:1px solid #f3c1c1}
.dialog-icon-btn[hidden]{display:none!important}
.theme-dark .dialog-icon-btn.primary{background:#47759b}
.theme-dark .dialog-icon-btn.secondary{background:#243b53;color:#e5e7eb;border-color:#4b5563}
.theme-dark .dialog-icon-btn.danger{background:#7f1d1d;color:#fecaca;border-color:#991b1b}
@media(max-width:760px){
  .dialog-actions.dialog-actions-icons{
    display:flex!important;
    grid-template-columns:none!important;
  }
  .dialog-actions.dialog-actions-icons button{width:44px!important}
}
html.dialog-open,
html.dialog-open body{
  overflow:hidden!important;
  overscroll-behavior:none;
}
html.dialog-open body{
  position:fixed;
  left:0;
  right:0;
  width:100%;
}
.login-screen{min-height:100vh;display:grid;place-items:center;padding:20px}.login-card{width:min(420px,100%);background:#fff;border:1px solid #dbe5ee;border-radius:18px;padding:30px;box-shadow:0 18px 60px #17365d18}.login-card h1{font-size:30px}.login-card p:not(.eyebrow){color:#718096;margin:10px 0 22px}.login-card .primary{width:100%;margin-top:16px}.login-error{display:block;color:#a33b3b;margin-top:12px;font-weight:700}.theme-dark{color-scheme:dark;background:#111827;color:#e5e7eb}.theme-dark body{background:#111827;color:#e5e7eb}.theme-dark h1,.theme-dark h2,.theme-dark .date,.theme-dark .stats strong{color:#dbeafe}.theme-dark .subtitle,.theme-dark .stats span,.theme-dark .time,.theme-dark .sub{color:#aebdca}.theme-dark .login-card,.theme-dark .stats article,.theme-dark .table-card,.theme-dark .secondary,.theme-dark .search,.theme-dark .toolbar select{background:#1f2937;border-color:#374151;color:#e5e7eb}.theme-dark .notice{background:#3d3210;border-color:#79651d;color:#f8e9a5}.theme-dark th{background:#243b53;color:#dbeafe}.theme-dark td{border-color:#374151}.theme-dark .form-grid input,.theme-dark .form-grid select,.theme-dark .form-grid textarea,.theme-dark .login-card input{background:#111827;border-color:#4b5563;color:#e5e7eb}.theme-dark .upload{background:#182b3b;border-color:#47759b}.theme-dark .icon-button{background:#374151;color:#e5e7eb}.theme-dark .attachment-chip{background:#243b53;color:#dbeafe}.theme-dark .row-actions button{color:#9ac3e5}.theme-dark .login-card p:not(.eyebrow){color:#aebdca}@media(max-width:760px){.shell{padding:20px 12px 42px}.topbar{align-items:stretch;flex-direction:column}.top-actions{display:grid;grid-template-columns:1fr 1fr}.top-actions .primary{grid-column:1/-1}.stats{grid-template-columns:1fr 1fr;gap:10px}.stats article{padding:15px}.stats strong{font-size:22px}.toolbar{display:grid;grid-template-columns:1fr 1fr}.search{max-width:none;grid-column:1/-1}.toolbar select{width:auto}.table-card{border:0;background:transparent;box-shadow:none;overflow:visible}.table-scroll{overflow:visible}table,thead,tbody,tr,td{display:block}table{min-width:0;width:100%}thead{display:none}tr{background:#fff;border:1px solid #dbe5ee;border-radius:14px;margin-bottom:12px;padding:8px 14px;box-shadow:0 4px 14px #17365d0a}td{display:flex;justify-content:space-between;gap:18px;align-items:flex-start;border:0;padding:10px 0;font-size:15px;text-align:right}td::before{content:attr(data-label);font-size:12px;font-weight:800;color:#718096;text-align:left;flex:0 0 88px}td:last-child{border-top:1px solid #e8eef3;align-items:center}.row-actions{justify-content:flex-end;gap:18px}.row-actions button{font-size:15px}.theme-dark tr{background:#1f2937;border-color:#374151}.theme-dark td:last-child{border-color:#374151}.form-grid{grid-template-columns:1fr}.wide{grid-column:auto}.notice{flex-direction:column;gap:4px}.dialog-actions{display:grid;grid-template-columns:1fr 1fr}.dialog-actions button{width:100%}}

.attachments-panel{margin-top:12px;padding:12px 14px;border:1px solid #7eb3d4;border-radius:12px;background:#e8f5fd}
.attachments-panel-head{display:flex;flex-direction:column;gap:4px;margin-bottom:10px}
.attachments-panel-head strong{color:#17365d;font-size:14px}
.attachments-panel-head span{color:#315b7a;font-size:12px}
.attachment-row.is-empty{grid-template-columns:1fr;color:#64748b;font-size:13px;font-weight:600}
.selected-file-status.is-saved{color:#315b7a}
.theme-dark .attachments-panel{background:#182b3b;border-color:#47759b}
.theme-dark .attachments-panel-head strong{color:#dbeafe}
.theme-dark .attachments-panel-head span,.theme-dark .attachment-row.is-empty{color:#9ac3e5}
.theme-dark .selected-file-status.is-saved{color:#9ac3e5}

.picker-search{width:100%;margin:0 0 8px;font:inherit;font-size:16px;color:#1f2937;background:#fff;border:1px solid #cbd5e1;border-radius:8px;padding:10px 12px;min-height:42px;outline:0}
.picker-search:focus{border-color:#47759b;box-shadow:0 0 0 3px #47759b18}
.picker.picker-scroll{max-height:220px;overflow:auto;display:grid;grid-template-columns:1fr;gap:6px;align-content:start}
.picker-option{display:flex!important;flex-direction:row!important;align-items:center;gap:10px;margin:0;padding:10px 12px;border:1px solid #dbe5ee;border-radius:8px;background:#fff;font-size:13px!important;font-weight:600!important;cursor:pointer}
.picker-option input{width:18px;min-height:18px!important}
.picker-option-ranked{position:relative}
.picker-option-ranked input{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px}
.picker-rank{display:inline-grid;place-items:center;width:22px;min-width:22px;height:22px;border-radius:50%;border:2px solid #cbd5e1;background:#fff;color:transparent;font-size:12px;font-weight:800;line-height:1;font-variant-numeric:tabular-nums;box-sizing:border-box;padding:1px 0 0;text-align:center;flex:0 0 auto}
.picker-rank.is-on{border-color:#17365d;background:#17365d;color:#fff}
.picker-option:has(input:checked),.picker-option.is-checked{background:#d9eaf7;border-color:#47759b;color:#17365d}
.picker-empty{padding:14px;color:#718096;font-size:13px;font-weight:600}
.procedure-field{position:relative}
.procedure-combo{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:stretch}
.procedure-combo #procedure{width:100%;min-width:0}
.procedure-suggest-toggle{
  border:1px solid #cbd5e1;
  background:#fff;
  color:#17365d;
  border-radius:8px;
  min-width:44px;
  min-height:44px;
  font:inherit;
  font-size:18px;
  font-weight:800;
  cursor:pointer;
  line-height:1;
}
.procedure-suggest-toggle:hover{background:#e8f2fa}
.procedure-suggest{
  margin-top:8px;
  max-height:220px;
  overflow:auto;
  display:grid;
  gap:6px;
  padding:8px;
  border:1px solid #cbd5e1;
  border-radius:10px;
  background:#f8fbfe;
}
.procedure-suggest[hidden]{display:none!important}
.procedure-suggest-item{
  display:block;
  width:100%;
  text-align:left;
  border:1px solid #dbe5ee;
  border-radius:8px;
  background:#fff;
  color:#17365d;
  padding:10px 12px;
  font:inherit;
  font-size:14px;
  font-weight:650;
  cursor:pointer;
}
.procedure-suggest-item:hover,
.procedure-suggest-item:focus{
  background:#d9eaf7;
  border-color:#47759b;
  outline:0;
}
.procedure-suggest-empty{margin:0;padding:12px;color:#718096;font-size:13px;font-weight:600}
.theme-dark .procedure-suggest-toggle{background:#1f2937;border-color:#4b5563;color:#dbeafe}
.theme-dark .procedure-suggest-toggle:hover{background:#243b53}
.theme-dark .procedure-suggest{background:#182b3b;border-color:#4b5563}
.theme-dark .procedure-suggest-item{background:#1f2937;border-color:#4b5563;color:#e5e7eb}
.theme-dark .procedure-suggest-item:hover,
.theme-dark .procedure-suggest-item:focus{background:#315b7a;border-color:#47759b;color:#fff}
.theme-dark .procedure-suggest-empty{color:#9ac3e5}
.danger{background:#b42318;color:#fff;border:0;border-radius:10px;padding:10px 14px;font:inherit;font-weight:700;cursor:pointer;min-height:44px}
.danger:hover{background:#912018}
.icon-action.danger-action{border-color:#f3b0a8;background:#fee4e2;color:#b42318}
.icon-action.danger-action:hover{background:#b42318;border-color:#b42318;color:#fff}
.dialog-actions{display:flex;justify-content:flex-end;gap:10px;align-items:center;flex-wrap:wrap}
.dialog-actions .danger{margin-right:auto}
.theme-dark .picker-search{background:#111827;border-color:#4b5563;color:#e5e7eb}
.theme-dark .picker-option{background:#1f2937;border-color:#4b5563;color:#e5e7eb}
.theme-dark .picker-option:has(input:checked),.theme-dark .picker-option.is-checked{background:#315b7a;border-color:#47759b;color:#fff}
.theme-dark .picker-rank{border-color:#4b5563;background:#1f2937}
.theme-dark .picker-rank.is-on{border-color:#9ac3e5;background:#9ac3e5;color:#0f172a}
.theme-dark .picker-empty{color:#9ac3e5}
.theme-dark .icon-action.danger-action{background:#3f1d1d;border-color:#912018;color:#fca5a5}

@media (max-width:760px){
  .shell{padding:16px 12px 36px}
  .clinic-name{font-size:12px;line-height:1.4}
  h1{font-size:26px}
  .topbar{gap:14px;margin-bottom:16px}
  .view-tabs{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    width:100%;
    gap:6px;
    margin-bottom:14px;
  }
  .view-tabs.is-admin{
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
  .view-tab{
    width:100%;
    min-width:0;
    height:58px;
    min-height:58px;
    padding:6px 4px;
    font-size:13px;
    line-height:1;
    white-space:nowrap;
    text-align:center;
    overflow:hidden;
    display:grid;
    grid-template-rows:18px 20px;
    align-content:center;
    justify-items:center;
    row-gap:4px;
  }
  .view-tab.admin-tab{
    grid-template-rows:1fr;
    align-content:center;
    align-items:center;
  }
  .view-tab.admin-tab .tab-label{
    height:auto;
    min-height:0;
    line-height:1.15;
  }
  .toolbar{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
    margin:0 0 22px;
    padding:12px;
    border:1px solid #dbe5ee;
    border-radius:16px;
    background:#fff;
    box-shadow:0 4px 16px #17365d08;
  }
  .search{grid-column:1/-1;max-width:none}
  .stats{grid-template-columns:1fr 1fr;gap:8px;margin-bottom:14px}
  .stats article{padding:12px}
  .stats strong{font-size:20px}
  .list-heading{margin:0 0 12px;padding:0 2px}
  .list-heading.mobile-only{display:block!important}
  .list-heading h2{font-size:20px;letter-spacing:-.03em}
  .operations-list{
    margin-top:4px;
    padding-top:4px;
  }
  .theme-dark .toolbar{
    background:#182b3b;
    border-color:#374151;
  }
  .table-card{border:0;background:transparent;box-shadow:none;overflow:visible}
  .table-scroll{overflow:visible}
  table{min-width:0;width:100%;border-collapse:separate;border-spacing:0}
  thead{display:none}
  tbody{display:grid;gap:12px}
  tr.op-row,tr{
    display:grid!important;
    grid-template-columns:1fr auto;
    grid-template-areas:
      "patient status"
      "when when"
      "diagnosis diagnosis"
      "procedure procedure"
      "team team"
      "anes anes"
      "notes notes"
      "files files"
      "actions actions";
    gap:10px;
    margin:0;
    padding:14px;
    border:1px solid #dbe5ee;
    border-radius:16px;
    background:#fff;
    box-shadow:0 6px 18px #17365d12;
    border-left:4px solid #47759b;
    -webkit-tap-highlight-color:transparent;
  }
  tr.op-row td,tr td{
    display:flex!important;
    flex-direction:column;
    align-items:stretch;
    justify-content:flex-start;
    gap:4px;
    width:100%;
    padding:0!important;
    border:0!important;
    text-align:left!important;
    font-size:14px;
    background:transparent!important;
    -webkit-tap-highlight-color:transparent;
  }
  tr.op-row td::before,tr td::before{
    content:attr(data-label);
    display:block;
    flex:none;
    width:auto;
    margin:0;
    color:#718096;
    font-size:11px;
    font-weight:800;
    letter-spacing:.02em;
    text-transform:uppercase;
    text-align:left;
  }
  .col-patient{grid-area:patient}
  .col-status{grid-area:status;align-items:flex-end}
  .col-status::before{align-self:flex-end}
  .col-when{grid-area:when;padding-top:8px!important;border-top:1px solid #e8eef3!important}
  .col-diagnosis{grid-area:diagnosis}
  .col-procedure{grid-area:procedure}
  .col-notes{grid-area:notes}
  .col-team{grid-area:team}
  .col-anes{grid-area:anes}
  .col-files{grid-area:files;padding-top:8px!important;border-top:1px solid #e8eef3!important}
  .col-actions{grid-area:actions}
  .col-actions::before{display:none}
  .col-age,
  .col-blood,
  .col-infection{display:none!important}
  .col-patient .patient{font-size:17px;line-height:1.25;color:#17365d}
  .col-when .date{font-size:15px}
  .people-chips{
    display:flex;
    flex-wrap:nowrap;
    gap:6px;
    max-width:100%;
    overflow-x:auto;
    padding-bottom:2px;
    -webkit-overflow-scrolling:touch;
  }
  .person-chip{flex:0 0 auto;white-space:nowrap;display:inline-flex;align-items:center;gap:6px}
  .person-rank{display:inline-grid;place-items:center;width:18px;height:18px;border-radius:50%;background:#17365d;color:#fff;font-size:11px;font-weight:800;line-height:1;font-variant-numeric:tabular-nums;box-sizing:border-box;padding:1px 0 0;text-align:center}
  .row-actions{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:8px;
    width:100%;
    justify-content:stretch;
  }
  .icon-action{
    width:100%;
    height:48px;
    border-radius:12px;
  }
  .col-diagnosis,.col-procedure,.col-notes{
    padding:10px 12px!important;
    border-radius:12px;
    background:#eef5fb;
    border:1px solid #d5e4f0;
  }
  .col-diagnosis{font-size:15px;font-weight:700;color:#1f2937}
  .col-procedure{font-size:16px;font-weight:800;color:#17365d}
  .col-notes{font-size:14px;font-weight:650;color:#334155;white-space:pre-wrap;word-break:break-word}
  .theme-dark .col-diagnosis,.theme-dark .col-procedure,.theme-dark .col-notes{
    background:#182b3b;
    border-color:#4b5563;
    color:#e5e7eb;
  }
  .theme-dark .col-procedure{color:#dbeafe}
  .theme-dark .col-notes{color:#cbd5e1}
  .theme-dark tr.op-row,.theme-dark tr{
    background:#1f2937;
    border-color:#374151;
    box-shadow:none;
    border-left-color:#47759b;
  }
  .theme-dark .col-when,.theme-dark .col-files{border-top-color:#374151!important}
  .theme-dark .col-patient .patient{color:#dbeafe}
  .theme-dark tr.op-row td::before,.theme-dark tr td::before{color:#94a3b8}
}

.media-dialog{border:0;border-radius:16px;padding:0;width:min(860px,calc(100% - 24px));max-height:min(88vh,900px);overflow:hidden;background:#fff;color:#1f2937;box-shadow:0 24px 80px #17365d33}
.media-dialog::backdrop{background:#0b1220cc}
.media-dialog-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;padding:16px 18px;border-bottom:1px solid #e2e8f0;background:#f8fbfe}
.media-dialog-head h2{margin:0;font-size:20px;color:#17365d}
.media-dialog-head .subtitle{margin:4px 0 0}
.media-dialog-body{padding:16px 18px 20px;overflow:auto;max-height:calc(88vh - 96px);display:grid;gap:14px}
.media-dialog .media-card{margin:0;padding:12px;border:1px solid #dbe5ee;border-radius:12px;background:#f8fbfe}
.media-dialog .media-card figcaption{margin:0 0 10px;color:#315b7a;font-size:13px;font-weight:700;word-break:break-word}
.media-dialog .media-card img,.media-dialog .media-card video{display:block;width:100%;max-height:60vh;object-fit:contain;background:#334155;border-radius:8px}
.media-dialog .empty-media{margin:0;padding:36px 12px;text-align:center;color:#718096;font-weight:600}
.theme-dark .media-dialog{background:#1f2937;color:#e5e7eb}
.theme-dark .media-dialog-head{background:#182b3b;border-color:#374151}
.theme-dark .media-dialog-head h2{color:#dbeafe}
.theme-dark .media-dialog .media-card{background:#111827;border-color:#374151}
.theme-dark .media-dialog .media-card figcaption{color:#9ac3e5}
.col-toggle{width:1%;white-space:nowrap;vertical-align:middle}
.collapse-toggle{display:inline-flex;align-items:center;gap:8px;border:1px solid #cbd5e1;background:#fff;color:#315b7a;border-radius:999px;padding:8px 12px;font:inherit;font-size:12px;font-weight:800;cursor:pointer}
.collapse-toggle:hover{background:#e8f2fa;border-color:#9fc0d8}
.collapse-chevron{width:8px;height:8px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:rotate(-45deg);transition:transform .2s ease;margin-top:2px}
.op-row.is-expanded .collapse-chevron{transform:rotate(45deg);margin-top:-2px}
.op-row.is-collapsed .col-diagnosis,
.op-row.is-collapsed .col-procedure,
.op-row.is-collapsed .col-team,
.op-row.is-collapsed .col-anes{display:none}
.theme-dark .collapse-toggle{background:#1f2937;border-color:#4b5563;color:#9ac3e5}
.theme-dark .collapse-toggle:hover{background:#243b53}
@media (max-width:760px){
  tr.op-row{
    grid-template-areas:
      "toggle status"
      "patient patient"
      "when when"
      "diagnosis diagnosis"
      "procedure procedure"
      "team team"
      "anes anes"
      "notes notes"
      "files files"
      "actions actions" !important;
  }
  .col-toggle{grid-area:toggle}
  .col-toggle::before{display:none!important}
  .collapse-toggle{width:100%;justify-content:center;min-height:40px;border-radius:10px}
  .op-row.is-collapsed .col-diagnosis,
  .op-row.is-collapsed .col-procedure,
  .op-row.is-collapsed .col-team,
  .op-row.is-collapsed .col-anes{display:none!important}
  .media-dialog{width:calc(100% - 16px);max-height:92vh;border-radius:14px}
  .media-dialog-body{max-height:calc(92vh - 88px);padding:12px}
}

.patient-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
.mobile-only{display:none!important}
.media-stage{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:8px;align-items:stretch;padding:12px 12px 0}
.media-dialog-body{padding:8px 4px 12px;overflow:auto;max-height:calc(88vh - 150px);display:grid;place-items:center}
.media-nav{border:0;border-radius:12px;width:44px;height:44px;background:#e8f2fa;color:#17365d;font-size:28px;line-height:1;cursor:pointer;font-weight:700}
.media-nav:hover{background:#17365d;color:#fff}
.media-footer{gap:12px;align-items:center;padding:10px 16px 14px;border-top:1px solid #e2e8f0;color:#52606d;font-size:13px;font-weight:700}
.media-footer #mediaFileName{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:right;font-weight:600;color:#315b7a}
.theme-dark .media-nav{background:#243b53;color:#dbeafe}
.theme-dark .media-nav:hover{background:#47759b;color:#fff}
.theme-dark .media-footer{border-color:#374151;color:#9ac3e5}
.theme-dark .media-footer #mediaFileName{color:#cbd5e1}
@media (min-width:761px){
  .op-row.is-collapsed .col-diagnosis,
  .op-row.is-collapsed .col-procedure,
  .op-row.is-collapsed .col-team,
  .op-row.is-collapsed .col-anes{display:table-cell!important}
  .mobile-only{display:none!important}
}
@media (max-width:760px){
  .mobile-only{display:inline-flex!important}
  .patient-head{align-items:center}
  tr.op-row{
    grid-template-areas:
      "patient patient"
      "when status"
      "diagnosis diagnosis"
      "procedure procedure"
      "team team"
      "anes anes"
      "notes notes"
      "files files"
      "actions actions" !important;
  }
  .col-patient{grid-area:patient}
  .op-row.is-collapsed .col-diagnosis,
  .op-row.is-collapsed .col-procedure,
  .op-row.is-collapsed .col-team,
  .op-row.is-collapsed .col-anes{display:none!important}
  .media-dialog-body{max-height:calc(92vh - 160px)}
}

.media-dialog{width:min(960px,calc(100% - 16px))!important;height:min(90vh,920px);max-height:90vh!important;display:flex;flex-direction:column}
.media-stage{flex:1;min-height:0;min-width:0;grid-template-columns:auto minmax(0,1fr) auto;align-items:stretch;padding:12px;position:relative}
.media-dialog-body{width:100%;height:100%;min-width:0;min-height:0;max-height:none!important;padding:0!important;display:flex!important;align-items:stretch;justify-content:stretch}
.media-dialog .media-card{width:100%;height:100%;min-width:0;min-height:0;margin:0;padding:0;display:flex;align-items:stretch;justify-content:stretch;box-sizing:border-box;overflow:hidden}
.media-dialog .media-card img,.media-dialog .media-card video{max-width:100%;max-height:100%;width:auto;height:auto;min-width:0;min-height:0;object-fit:contain;background:#334155;border-radius:10px}
.media-nav{align-self:center}
.media-nav[hidden]{display:none!important}
@media (max-width:760px){
  .media-dialog{height:92vh;max-height:92vh!important}
  .media-dialog-body,.media-dialog .media-card{min-height:0}
  .media-stage{
    grid-template-columns:minmax(0,1fr);
    gap:0;
    padding:4px 4px 0;
  }
  .media-nav{
    position:absolute;
    z-index:3;
    top:50%;
    transform:translateY(-50%);
    width:36px;
    height:44px;
    font-size:22px;
    border-radius:10px;
    background:#e8f2facc;
    backdrop-filter:blur(4px);
  }
  .media-nav-prev{left:6px}
  .media-nav-next{right:6px}
  .theme-dark .media-nav{background:#243b53cc}
}

.media-dialog{display:none}
.media-dialog[open]{display:flex!important;flex-direction:column}

.media-footer{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);
  gap:10px;
  align-items:center;
}
.media-footer #mediaCounter{justify-self:start}
.media-tools{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
  justify-content:center;
  justify-self:center;
}
.media-footer #mediaFileName{
  justify-self:end;
  max-width:100%;
  min-width:0;
}
.media-zoom-tools{display:inline-flex;align-items:center;gap:4px;padding:4px;border:1px solid #cbd5e1;border-radius:10px;background:#f8fbfe}
.media-tool-btn{border:1px solid #cbd5e1;background:#fff;color:#17365d;border-radius:8px;min-height:36px;padding:6px 10px;font:inherit;font-size:13px;font-weight:800;cursor:pointer}
.media-tool-btn:hover{background:#e8f2fa}
.media-tool-btn:disabled{opacity:.45;cursor:not-allowed}
.media-download-btn,.media-download-btn:hover,.media-download-btn:focus-visible{
  background:#17365d;
  border-color:#17365d;
  color:#fff;
}
.media-download-btn:hover{background:#244c7b;border-color:#244c7b;color:#fff}
.media-delete-btn{background:#fff;border-color:#f4cccc;color:#b42318}
.media-delete-btn:hover{background:#fef2f2;color:#9b1c1c}
#mediaZoomLabel{min-width:48px;text-align:center;font-size:12px;font-weight:800;color:#315b7a}
.media-viewport{flex:1;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;display:flex;align-items:center;justify-content:center;border-radius:10px;background:#334155;position:relative;touch-action:none;overscroll-behavior:contain}
.media-loading{
  position:absolute;
  inset:0;
  z-index:2;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:12px;
  background:linear-gradient(180deg,#475569 0%,#334155 100%);
  color:#e2e8f0;
  font-size:14px;
  font-weight:700;
  letter-spacing:.02em;
  pointer-events:none;
}
.media-viewport:not(.is-loading) .media-loading{display:none}
.media-loading-spinner{
  width:36px;
  height:36px;
  border-radius:50%;
  border:3px solid #94a3b8;
  border-top-color:#e2e8f0;
  animation:spin .8s linear infinite;
}
.media-dialog .media-card.is-image .media-zoomable{width:auto!important;height:auto!important;max-width:100%!important;max-height:100%!important;min-width:0;min-height:0;object-fit:contain;transform-origin:center center;transition:transform .15s ease;cursor:zoom-in;will-change:transform;user-select:none;-webkit-user-drag:none}
.media-dialog .media-card.is-image .media-zoomable.is-zoomed{cursor:grab;max-width:none!important;max-height:none!important;transition:none}
.media-dialog .media-card.is-image .media-zoomable.is-pinching{cursor:grabbing;transition:none}
.media-dialog .media-card.is-video video{width:100%;height:100%;max-width:100%;max-height:100%;min-width:0;min-height:0;object-fit:contain}
.theme-dark .media-zoom-tools{background:#182b3b;border-color:#4b5563}
.theme-dark .media-tool-btn{background:#1f2937;border-color:#4b5563;color:#dbeafe}
.theme-dark .media-tool-btn:hover{background:#243b53}
.theme-dark .media-download-btn{background:#47759b;border-color:#47759b;color:#fff}
.theme-dark .media-delete-btn{background:#3f1d1d;border-color:#7f1d1d;color:#fca5a5}
.theme-dark .media-delete-btn:hover{background:#7f1d1d;color:#fecaca}
.theme-dark #mediaZoomLabel{color:#9ac3e5}
@media (max-width:760px){
  .media-footer{grid-template-columns:1fr;justify-items:center;text-align:center}
  #mediaFileName{max-width:100%;text-align:center}
}

@media (max-width:760px){
  .collapse-toggle.mobile-only{
    display:inline-flex!important;
    width:auto;
    min-height:28px;
    height:28px;
    padding:4px 8px;
    gap:5px;
    border-radius:8px;
    font-size:11px;
    line-height:1;
    flex:0 0 auto;
  }
  .collapse-toggle.mobile-only .collapse-chevron{
    width:6px;
    height:6px;
    margin-top:1px;
  }
  .patient-head{
    align-items:flex-start;
    gap:8px;
  }
}

@media (max-width:760px){
  .patient-mobile-actions{
    display:inline-flex!important;
    align-items:center;
    gap:6px;
    flex:0 0 auto;
  }
  .patient-mobile-actions .collapse-toggle{
    display:inline-flex!important;
    width:auto;
    min-height:28px;
    height:28px;
    padding:4px 8px;
    gap:5px;
    border-radius:8px;
    font-size:11px;
  }
  .patient-mobile-actions .media-quick-btn{
    width:28px;
    height:28px;
    min-width:28px;
    border-radius:8px;
    padding:0;
  }
  .op-row.is-collapsed .col-files,
  .op-row.is-collapsed .col-actions{
    display:none!important;
  }
  .op-row.is-collapsed{
    grid-template-areas:
      "patient patient"
      "when status" !important;
    gap:8px;
    padding:12px;
  }
  .op-row.is-collapsed .col-patient::before,
  .op-row.is-collapsed .col-when::before,
  .op-row.is-collapsed .col-status::before{
    display:none!important;
  }
  .op-row.is-collapsed .col-when{
    border-top:0!important;
    padding-top:0!important;
  }
  .op-row.is-expanded .patient-mobile-actions .media-quick-btn{
    display:none;
  }
}

.media-viewport.is-fullscreen,
.media-viewport:fullscreen,
.media-viewport:-webkit-full-screen{
  width:100vw;
  height:100vh;
  max-width:100vw;
  max-height:100vh;
  background:#000;
  padding:12px;
  box-sizing:border-box;
}
.media-viewport:fullscreen img.media-zoomable,
.media-viewport:-webkit-full-screen img.media-zoomable,
.media-viewport.is-fullscreen img.media-zoomable{
  max-width:100%;
  max-height:100%;
  object-fit:contain;
}

.media-image-tools{display:inline-flex;align-items:center;gap:4px;padding:4px;border:1px solid #cbd5e1;border-radius:10px;background:#f8fbfe}
.media-image-tools[hidden]{display:none!important}
.media-fs-overlay{
  position:fixed;
  inset:0;
  z-index:10000;
  background:#000;
  align-items:center;
  justify-content:center;
  padding:env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
.media-fs-overlay:not([open]){display:none!important}
.media-fs-overlay[open]{
  display:flex!important;
}
.media-fs-stage{
  position:relative;
  width:100%;
  height:100%;
  overflow:hidden;
  display:flex;
  align-items:center;
  justify-content:center;
  overscroll-behavior:contain;
  touch-action:none;
}
.media-fs-stage.is-loading::before{
  content:"Завантаження…";
  position:absolute;
  inset:0;
  z-index:2;
  display:grid;
  place-items:center;
  padding-top:56px;
  box-sizing:border-box;
  background:linear-gradient(180deg,#475569 0%,#334155 100%);
  color:#e2e8f0;
  font-size:15px;
  font-weight:700;
}
.media-fs-stage.is-loading::after{
  content:"";
  position:absolute;
  top:calc(50% - 40px);
  left:50%;
  width:36px;
  height:36px;
  margin-left:-18px;
  z-index:3;
  border-radius:50%;
  border:3px solid #94a3b8;
  border-top-color:#e2e8f0;
  animation:spin .8s linear infinite;
}
.media-fs-overlay img{
  max-width:100vw;
  max-height:100vh;
  width:auto;
  height:auto;
  object-fit:contain;
  transform-origin:center center;
  transition:transform .15s ease;
  touch-action:none;
  user-select:none;
  -webkit-user-drag:none;
  will-change:transform;
}
.media-fs-overlay img.is-pinching,
.media-fs-overlay img.is-zoomed{
  transition:none;
}
.media-fs-close{
  position:fixed;
  top:max(10px, env(safe-area-inset-top));
  right:max(10px, env(safe-area-inset-right));
  z-index:10001;
  width:42px;
  height:42px;
  border:0;
  border-radius:999px;
  background:#ffffff22;
  color:#fff;
  font-size:20px;
  font-weight:800;
  cursor:pointer;
}
.media-fs-close:hover{background:#ffffff44}
body.media-fs-open{overflow:hidden}
.theme-dark .media-image-tools{background:#182b3b;border-color:#4b5563}

dialog.media-fs-overlay{
  position:fixed;
  inset:0;
  width:100vw;
  height:100vh;
  max-width:100vw;
  max-height:100vh;
  margin:0;
  border:0;
  padding:0;
  background:#000;
  z-index:2147483647;
}
dialog.media-fs-overlay[open]{
  display:flex!important;
  align-items:center;
  justify-content:center;
}
dialog.media-fs-overlay::backdrop{
  background:#000;
}

.archive-purge{
  display:inline-block;
  font-size:12px;
  font-weight:800;
  color:#9a3412;
  background:#fff7ed;
  border:1px solid #fdba74;
  border-radius:999px;
  padding:4px 10px;
  white-space:nowrap;
}
.theme-dark .archive-purge{
  color:#fdba74;
  background:#3b2412;
  border-color:#9a3412;
}
.tab-label-short{display:none}
.view-tab[hidden],
.admin-tab[hidden]{
  display:none!important;
}
.view-tab .tab-label{
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  height:18px;
  min-height:18px;
  line-height:18px;
  overflow:hidden;
}
.tab-count{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:28px;
  min-width:28px;
  height:20px;
  margin:0;
  padding:0;
  border-radius:999px;
  background:#dbe7f2;
  color:#17365d;
  font-size:12px;
  font-weight:800;
  line-height:1;
  font-variant-numeric:tabular-nums;
  box-sizing:border-box;
  flex:0 0 auto;
}
.view-tab.active .tab-count{
  background:#ffffff33;
  color:#fff;
}
.theme-dark .tab-count{
  background:#334155;
  color:#e2e8f0;
}
.theme-dark .view-tab.active .tab-count{
  background:#ffffff2e;
  color:#fff;
}
@media(max-width:760px){
  .tab-label-full{display:none}
  .tab-label-short{display:inline}
  .tab-count{width:28px;min-width:28px;height:20px;margin:0;padding:0;font-size:12px}
}

.week-bar{
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto auto;
  gap:8px;
  align-items:center;
  margin:0 0 16px;
}
.week-bar[hidden]{display:none!important}
.dept-switcher{
  display:block;
  margin:0 0 18px;
  padding:16px 12px;
  border:1px solid #dbe5ee;
  border-radius:18px;
  background:#e8f2fa;
}
.dept-switcher-main{text-align:center;min-width:0}
.dept-switcher-main .eyebrow{margin:0 0 4px}
.dept-switcher-main strong{
  display:block;
  color:#17365d;
  font-size:clamp(22px, 4vw, 34px);
  letter-spacing:-.04em;
  line-height:1.2;
}
.dept-pills{display:inline-flex;gap:8px;margin-top:10px}
.dept-pill{
  min-width:64px;
  min-height:40px;
  border:1px solid #9fc0d8;
  border-radius:999px;
  background:#fff;
  color:#17365d;
  font:inherit;
  font-size:16px;
  font-weight:800;
  cursor:pointer;
}
.dept-pill.active{
  background:#17365d;
  border-color:#17365d;
  color:#fff;
  box-shadow:0 6px 14px #17365d33;
}
.theme-dark .dept-switcher{background:#182b3b;border-color:#4b5563}
.theme-dark .dept-switcher-main strong{color:#dbeafe}
.theme-dark .dept-pill{background:#1f2937;border-color:#4b5563;color:#dbeafe}
.theme-dark .dept-pill.active{background:#47759b;border-color:#47759b;color:#fff}
.week-nav-btn{min-width:44px;padding:8px 12px;font-size:22px;font-weight:800}
.week-label-wrap{text-align:center;min-width:0}
.week-label-wrap .eyebrow{margin:0}
.week-label-wrap strong{display:block;color:#17365d;font-size:22px;letter-spacing:-.03em}
.theme-dark .week-label-wrap strong{color:#dbeafe}
.dept-board{margin:0 0 22px}
.dept-head{display:flex;align-items:center;justify-content:stretch;gap:12px;margin:0 0 14px}
.add-operation-btn{
  width:100%;
  min-height:52px;
  font-size:16px;
  font-weight:800;
  letter-spacing:.01em;
  border-radius:14px;
  background:#1d4f86;
  box-shadow:0 8px 22px #17365d44;
  transform-origin:center center;
  transform-box:border-box;
  transition:transform .12s ease, box-shadow .12s ease, filter .12s ease;
  animation:addBtnIdle 2.2s ease-in-out infinite;
}
.theme-dark .add-operation-btn{
  background:#3b82c4;
  color:#fff;
  box-shadow:0 8px 22px #0b122066;
}
@keyframes addBtnIdle{
  0%,100%{transform:scale(1);box-shadow:0 8px 22px #17365d44}
  50%{transform:scale(.985);box-shadow:0 3px 10px #17365d2e}
}
@media (prefers-reduced-motion:reduce){
  .add-operation-btn{animation:none}
}
.queue-badge{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:28px;height:28px;padding:0 8px;box-sizing:border-box;
  border-radius:999px;background:#17365d;color:#fff;font-weight:800;font-size:13px;line-height:1
}
.queue-badge.is-empty{
  background:#94a3b8;
  color:#fff;
}
.infection-ok{color:#356b45;font-weight:700}
.infection-alert{color:#9a3412;font-weight:800}
.theme-dark .infection-ok{color:#86efac}
.theme-dark .infection-alert{color:#fdba74}
.infection-picks{display:flex;flex-wrap:wrap;gap:8px}
.infection-picks label{
  display:flex!important;flex-direction:row!important;align-items:center;gap:8px;
  margin:0;padding:8px 12px;border:1px solid #dbe5ee;border-radius:10px;background:#f8fbfe;
  font-size:13px;color:#17365d;cursor:pointer
}
.infection-picks input{width:16px;min-height:16px!important}
.theme-dark .infection-picks label{background:#182b3b;border-color:#4b5563;color:#e5e7eb}
.mobile-week{display:none;min-height:260px}
.week-day{padding:12px;border:1px solid #dbe5ee;border-radius:14px;background:#fff}
.week-day h3{margin:0 0 10px;font-size:14px;color:#17365d}
.week-empty{
  display:grid;
  place-items:center;
  min-height:240px;
  margin:0;
  padding:28px 18px;
  border:1px dashed #94a3b8;
  border-radius:16px;
  background:#f8fafc;
  color:#64748b;
  font-size:15px;
  font-weight:700;
  text-align:center;
  box-sizing:border-box;
}
.theme-dark .week-empty{
  background:#1e293b;
  border-color:#475569;
  color:#94a3b8;
}
.dept-board{min-height:280px}
.week-card{padding:14px 0 16px;border-top:1px solid #e8eef3}
.week-card:first-of-type{border-top:0;padding-top:0}
.week-card .row-actions{margin-top:12px}
.week-card-date{
  margin:0 0 8px;
  color:#17365d;
  font-size:14px;
  font-weight:800;
  letter-spacing:.01em;
}
.week-card-top{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.week-clinical{
  display:grid;
  gap:8px;
  margin:10px 0 10px;
  padding:10px 12px;
  border-radius:12px;
  background:#eef5fb;
  border:1px solid #d5e4f0;
}
.week-field-label{
  display:block;
  margin:0 0 3px;
  color:#54718f;
  font-size:11px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
}
.week-field-value{display:block;line-height:1.35}
.week-procedure{margin:0;font-weight:800;color:#17365d}
.week-procedure .week-field-value{font-size:17px}
.week-diagnosis{margin:0;color:#1f2937;font-weight:700}
.week-diagnosis .week-field-value{font-size:15px}
.week-notes{
  margin:0 0 10px;
  padding:10px 12px;
  border-radius:12px;
  background:#eef5fb;
  border:1px solid #d5e4f0;
  color:#334155;
  font-weight:650;
}
.week-notes .week-field-value{font-size:14px;white-space:pre-wrap;word-break:break-word}
.week-people{margin:0 0 6px;font-size:16px;line-height:1.35;color:#334155}
.week-people span{color:#718096;font-weight:700;font-size:14px}
.col-diagnosis,.col-procedure{font-weight:700;color:#17365d}
.col-procedure{font-weight:800}
.theme-dark .week-clinical{background:#182b3b;border-color:#4b5563}
.theme-dark .week-card-date,.theme-dark .week-procedure,.theme-dark .col-diagnosis,.theme-dark .col-procedure{color:#dbeafe}
.theme-dark .week-diagnosis{color:#e5e7eb}
.theme-dark .week-notes{background:#182b3b;border-color:#4b5563;color:#cbd5e1}
.theme-dark .week-field-label{color:#9ac3e5}
.queue-badge,.col-queue{display:none!important}
.patient{display:inline-flex;align-items:center;gap:6px;flex-wrap:wrap;font-weight:750}
.danger-bang{
  display:inline-grid;
  place-items:center;
  width:22px;
  height:22px;
  border-radius:50%;
  background:#dc2626;
  color:#fff;
  font-size:14px;
  font-weight:900;
  line-height:1;
  flex:0 0 auto;
  animation:bangPulse 1.05s ease-in-out infinite;
}
@keyframes bangPulse{
  0%,100%{transform:scale(1);box-shadow:0 0 0 0 #dc262680}
  50%{transform:scale(1.14);box-shadow:0 0 0 7px #dc262600}
}
.week-undated{border-color:#f59e0b;background:#fffbeb}
.theme-dark .week-undated{background:#3b2f12;border-color:#b45309}
.theme-dark .danger-bang{background:#ef4444}
.theme-dark .week-day{background:#1f2937;border-color:#374151}
.theme-dark .week-day h3{color:#dbeafe}
.theme-dark .week-card{border-top-color:#374151}
.theme-dark .week-people{color:#e5e7eb}
@media (min-width:761px){
  .mobile-week{display:none!important}
}
@media (max-width:760px){
  .week-bar{grid-template-columns:auto minmax(0,1fr) auto}
  #thisWeek{grid-column:1/-1}
  .dept-switcher{padding:14px 8px;margin-bottom:14px}
  .dept-switcher-main strong{font-size:22px}
  .dept-head{align-items:stretch;flex-direction:column;margin-bottom:16px}
  .dept-head .add-operation-btn{width:100%}
  .toolbar{grid-template-columns:1fr}
}
@media (max-width:760px) and (orientation: portrait){
  .desktop-week{display:none!important}
  .mobile-week{display:grid!important;gap:10px;margin-bottom:8px}
}

button,
.primary,
.secondary,
.icon-button,
.icon-action,
.view-tab,
.dept-pill,
.media-tool-btn,
.media-nav,
.week-nav-btn{
  transition:transform .12s ease, box-shadow .12s ease, background-color .15s ease, filter .12s ease, color .15s ease;
}
button:active:not(:disabled),
.primary:active,
.secondary:active,
.icon-button:active,
.icon-action:active,
.view-tab:active,
.dept-pill:active,
.media-tool-btn:active,
.media-nav:active,
.week-nav-btn:active,
.add-operation-btn:active{
  transform:scale(.95);
  transform-origin:center center;
  filter:brightness(.96);
  animation:none;
}

@media (hover: hover) and (pointer: fine){
  tr:hover td{background:#f8fbfe}
  .theme-dark tr:hover td{background:#263548}
  .primary:hover{background:#244c7b}
  .icon-action:hover{background:#17365d;border-color:#17365d;color:#fff}
  .theme-dark .icon-button:hover{background:#4b5563;color:#fff}
  .theme-dark .icon-action:hover{background:#47759b;border-color:#47759b;color:#fff}
  .icon-button:hover{background:#dbe5ee;color:#17365d}
  button:hover:not(:disabled),
  .primary:hover,
  .secondary:hover,
  .icon-button:hover,
  .icon-action:hover,
  .view-tab:hover,
  .dept-pill:hover,
  .media-tool-btn:hover,
  .media-nav:hover{
    filter:brightness(1.06);
  }
}
.attachment-remove{
  border:0;
  background:transparent;
  color:#b42318;
  font-size:16px;
  font-weight:800;
  cursor:pointer;
  min-width:32px;
  min-height:32px;
  border-radius:8px;
}
.attachment-remove:hover{background:#f4cccc}
.theme-dark .attachment-remove{color:#fca5a5}
.theme-dark .attachment-remove:hover{background:#3f1d1d}

/* Day: compact cards by default; landscape phone uses the table (see below). */
#scheduleView.mode-day .desktop-week{display:none!important}
#scheduleView.mode-day .mobile-week{display:grid!important;gap:10px;margin-bottom:8px}

/* Week / Plan: table on desktop; cards only in phone portrait. */
@media (min-width:761px){
  #scheduleView.mode-week .mobile-week,
  #scheduleView.mode-plan .mobile-week{display:none!important}
  #scheduleView.mode-week .desktop-week,
  #scheduleView.mode-plan .desktop-week{display:block!important}
}
@media (max-width:760px) and (orientation: portrait){
  #scheduleView.mode-week .desktop-week,
  #scheduleView.mode-plan .desktop-week{display:none!important}
  #scheduleView.mode-week .mobile-week,
  #scheduleView.mode-plan .mobile-week{display:grid!important;gap:10px;margin-bottom:8px}
}

/* Phone landscape: real day/week/plan table (horizontal scroll), not card stack. */
@media (max-width:960px) and (orientation: landscape){
  #scheduleView.mode-day .mobile-week,
  #scheduleView.mode-week .mobile-week,
  #scheduleView.mode-plan .mobile-week{display:none!important}
  #scheduleView.mode-day .desktop-week,
  #scheduleView.mode-week .desktop-week,
  #scheduleView.mode-plan .desktop-week{
    display:block!important;
    border:1px solid #dbe5ee;
    background:#fff;
    box-shadow:0 7px 24px #17365d0a;
    border-radius:12px;
    overflow:hidden;
  }
  #scheduleView.mode-day .desktop-week .table-scroll,
  #scheduleView.mode-week .desktop-week .table-scroll,
  #scheduleView.mode-plan .desktop-week .table-scroll{
    overflow:auto;
    -webkit-overflow-scrolling:touch;
  }
  #scheduleView.mode-day .desktop-week table,
  #scheduleView.mode-week .desktop-week table,
  #scheduleView.mode-plan .desktop-week table{
    display:table!important;
    width:100%;
    min-width:980px;
    border-collapse:collapse;
    border-spacing:0;
  }
  #scheduleView.mode-day .desktop-week thead,
  #scheduleView.mode-week .desktop-week thead,
  #scheduleView.mode-plan .desktop-week thead{display:table-header-group!important}
  #scheduleView.mode-day .desktop-week tbody,
  #scheduleView.mode-week .desktop-week tbody,
  #scheduleView.mode-plan .desktop-week tbody{display:table-row-group!important;gap:0}
  #scheduleView.mode-day .desktop-week tr,
  #scheduleView.mode-week .desktop-week tr,
  #scheduleView.mode-day .desktop-week tr.op-row,
  #scheduleView.mode-week .desktop-week tr.op-row,
  #scheduleView.mode-plan .desktop-week tr,
  #scheduleView.mode-plan .desktop-week tr.op-row{
    display:table-row!important;
    margin:0;
    padding:0;
    border:0!important;
    border-radius:0;
    background:transparent;
    box-shadow:none;
    grid-template-columns:none;
    grid-template-areas:none;
    gap:0;
  }
  #scheduleView.mode-day .desktop-week th,
  #scheduleView.mode-week .desktop-week th,
  #scheduleView.mode-plan .desktop-week th{
    display:table-cell!important;
    background:#e5f0f8;
    color:#17365d;
    text-align:left;
    font-size:11px;
    padding:8px 10px;
    white-space:nowrap;
    border:0;
  }
  #scheduleView.mode-day .desktop-week td,
  #scheduleView.mode-week .desktop-week td,
  #scheduleView.mode-day .desktop-week tr.op-row td,
  #scheduleView.mode-week .desktop-week tr.op-row td,
  #scheduleView.mode-plan .desktop-week td,
  #scheduleView.mode-plan .desktop-week tr.op-row td{
    display:table-cell!important;
    flex-direction:row;
    align-items:center;
    justify-content:flex-start;
    gap:0;
    width:auto;
    padding:8px 10px!important;
    border:0!important;
    border-top:1px solid #e8eef3!important;
    text-align:left!important;
    font-size:12px;
    background:transparent!important;
    vertical-align:middle;
  }
  #scheduleView.mode-day .desktop-week td::before,
  #scheduleView.mode-week .desktop-week td::before,
  #scheduleView.mode-day .desktop-week tr.op-row td::before,
  #scheduleView.mode-week .desktop-week tr.op-row td::before,
  #scheduleView.mode-plan .desktop-week td::before,
  #scheduleView.mode-plan .desktop-week tr.op-row td::before{
    content:none!important;
    display:none!important;
  }
  #scheduleView.mode-day .desktop-week .col-age,
  #scheduleView.mode-week .desktop-week .col-age,
  #scheduleView.mode-day .desktop-week .col-blood,
  #scheduleView.mode-week .desktop-week .col-blood,
  #scheduleView.mode-day .desktop-week .col-infection,
  #scheduleView.mode-week .desktop-week .col-infection,
  #scheduleView.mode-day .desktop-week .col-status,
  #scheduleView.mode-week .desktop-week .col-status,
  #scheduleView.mode-day .desktop-week .col-notes,
  #scheduleView.mode-week .desktop-week .col-notes,
  #scheduleView.mode-day .desktop-week .col-when,
  #scheduleView.mode-week .desktop-week .col-when,
  #scheduleView.mode-day .desktop-week .col-patient,
  #scheduleView.mode-week .desktop-week .col-patient,
  #scheduleView.mode-day .desktop-week .col-diagnosis,
  #scheduleView.mode-week .desktop-week .col-diagnosis,
  #scheduleView.mode-day .desktop-week .col-procedure,
  #scheduleView.mode-week .desktop-week .col-procedure,
  #scheduleView.mode-day .desktop-week .col-team,
  #scheduleView.mode-week .desktop-week .col-team,
  #scheduleView.mode-day .desktop-week .col-anes,
  #scheduleView.mode-week .desktop-week .col-anes,
  #scheduleView.mode-day .desktop-week .col-files,
  #scheduleView.mode-week .desktop-week .col-files,
  #scheduleView.mode-day .desktop-week .col-actions,
  #scheduleView.mode-week .desktop-week .col-actions,
  #scheduleView.mode-plan .desktop-week .col-age,
  #scheduleView.mode-plan .desktop-week .col-blood,
  #scheduleView.mode-plan .desktop-week .col-infection,
  #scheduleView.mode-plan .desktop-week .col-status,
  #scheduleView.mode-plan .desktop-week .col-notes,
  #scheduleView.mode-plan .desktop-week .col-when,
  #scheduleView.mode-plan .desktop-week .col-patient,
  #scheduleView.mode-plan .desktop-week .col-diagnosis,
  #scheduleView.mode-plan .desktop-week .col-procedure,
  #scheduleView.mode-plan .desktop-week .col-team,
  #scheduleView.mode-plan .desktop-week .col-anes,
  #scheduleView.mode-plan .desktop-week .col-files,
  #scheduleView.mode-plan .desktop-week .col-actions{
    display:table-cell!important;
    grid-area:auto;
    padding:8px 10px!important;
    border-radius:0;
    border:0!important;
    border-top:1px solid #e8eef3!important;
  }
  #scheduleView.mode-day .desktop-week td.col-age,
  #scheduleView.mode-week .desktop-week td.col-age,
  #scheduleView.mode-day .desktop-week td.col-blood,
  #scheduleView.mode-week .desktop-week td.col-blood,
  #scheduleView.mode-day .desktop-week td.col-infection,
  #scheduleView.mode-week .desktop-week td.col-infection,
  #scheduleView.mode-day .desktop-week td.col-status,
  #scheduleView.mode-week .desktop-week td.col-status,
  #scheduleView.mode-day .desktop-week td.col-notes,
  #scheduleView.mode-week .desktop-week td.col-notes,
  #scheduleView.mode-day .desktop-week td.col-when,
  #scheduleView.mode-week .desktop-week td.col-when,
  #scheduleView.mode-day .desktop-week td.col-patient,
  #scheduleView.mode-week .desktop-week td.col-patient,
  #scheduleView.mode-day .desktop-week td.col-diagnosis,
  #scheduleView.mode-week .desktop-week td.col-diagnosis,
  #scheduleView.mode-day .desktop-week td.col-procedure,
  #scheduleView.mode-week .desktop-week td.col-procedure,
  #scheduleView.mode-day .desktop-week td.col-team,
  #scheduleView.mode-week .desktop-week td.col-team,
  #scheduleView.mode-day .desktop-week td.col-anes,
  #scheduleView.mode-week .desktop-week td.col-anes,
  #scheduleView.mode-day .desktop-week td.col-files,
  #scheduleView.mode-week .desktop-week td.col-files,
  #scheduleView.mode-day .desktop-week td.col-actions,
  #scheduleView.mode-week .desktop-week td.col-actions,
  #scheduleView.mode-plan .desktop-week td.col-age,
  #scheduleView.mode-plan .desktop-week td.col-blood,
  #scheduleView.mode-plan .desktop-week td.col-infection,
  #scheduleView.mode-plan .desktop-week td.col-status,
  #scheduleView.mode-plan .desktop-week td.col-notes,
  #scheduleView.mode-plan .desktop-week td.col-when,
  #scheduleView.mode-plan .desktop-week td.col-patient,
  #scheduleView.mode-plan .desktop-week td.col-diagnosis,
  #scheduleView.mode-plan .desktop-week td.col-procedure,
  #scheduleView.mode-plan .desktop-week td.col-team,
  #scheduleView.mode-plan .desktop-week td.col-anes,
  #scheduleView.mode-plan .desktop-week td.col-files,
  #scheduleView.mode-plan .desktop-week td.col-actions{
    background:transparent!important;
  }
  #scheduleView.mode-day .desktop-week th.col-age,
  #scheduleView.mode-week .desktop-week th.col-age,
  #scheduleView.mode-day .desktop-week th.col-blood,
  #scheduleView.mode-week .desktop-week th.col-blood,
  #scheduleView.mode-day .desktop-week th.col-infection,
  #scheduleView.mode-week .desktop-week th.col-infection,
  #scheduleView.mode-day .desktop-week th.col-status,
  #scheduleView.mode-week .desktop-week th.col-status,
  #scheduleView.mode-day .desktop-week th.col-notes,
  #scheduleView.mode-week .desktop-week th.col-notes,
  #scheduleView.mode-day .desktop-week th.col-when,
  #scheduleView.mode-week .desktop-week th.col-when,
  #scheduleView.mode-day .desktop-week th.col-patient,
  #scheduleView.mode-week .desktop-week th.col-patient,
  #scheduleView.mode-day .desktop-week th.col-diagnosis,
  #scheduleView.mode-week .desktop-week th.col-diagnosis,
  #scheduleView.mode-day .desktop-week th.col-procedure,
  #scheduleView.mode-week .desktop-week th.col-procedure,
  #scheduleView.mode-day .desktop-week th.col-team,
  #scheduleView.mode-week .desktop-week th.col-team,
  #scheduleView.mode-day .desktop-week th.col-anes,
  #scheduleView.mode-week .desktop-week th.col-anes,
  #scheduleView.mode-day .desktop-week th.col-files,
  #scheduleView.mode-week .desktop-week th.col-files,
  #scheduleView.mode-day .desktop-week th.col-actions,
  #scheduleView.mode-week .desktop-week th.col-actions,
  #scheduleView.mode-plan .desktop-week th.col-age,
  #scheduleView.mode-plan .desktop-week th.col-blood,
  #scheduleView.mode-plan .desktop-week th.col-infection,
  #scheduleView.mode-plan .desktop-week th.col-status,
  #scheduleView.mode-plan .desktop-week th.col-notes,
  #scheduleView.mode-plan .desktop-week th.col-when,
  #scheduleView.mode-plan .desktop-week th.col-patient,
  #scheduleView.mode-plan .desktop-week th.col-diagnosis,
  #scheduleView.mode-plan .desktop-week th.col-procedure,
  #scheduleView.mode-plan .desktop-week th.col-team,
  #scheduleView.mode-plan .desktop-week th.col-anes,
  #scheduleView.mode-plan .desktop-week th.col-files,
  #scheduleView.mode-plan .desktop-week th.col-actions{
    background:#e5f0f8!important;
    border-top:0!important;
    color:#17365d;
  }
  .theme-dark #scheduleView.mode-day .desktop-week th.col-age,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-age,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-blood,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-blood,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-infection,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-infection,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-status,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-status,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-notes,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-notes,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-when,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-when,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-patient,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-patient,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-diagnosis,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-diagnosis,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-procedure,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-procedure,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-team,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-team,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-anes,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-anes,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-files,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-files,
  .theme-dark #scheduleView.mode-day .desktop-week th.col-actions,
  .theme-dark #scheduleView.mode-week .desktop-week th.col-actions,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-age,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-blood,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-infection,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-status,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-notes,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-when,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-patient,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-diagnosis,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-procedure,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-team,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-anes,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-files,
  .theme-dark #scheduleView.mode-plan .desktop-week th.col-actions{
    background:#243b53!important;
    color:#dbeafe;
  }
  #scheduleView.mode-day .desktop-week .col-diagnosis,
  #scheduleView.mode-week .desktop-week .col-diagnosis,
  #scheduleView.mode-day .desktop-week .col-procedure,
  #scheduleView.mode-week .desktop-week .col-procedure,
  #scheduleView.mode-day .desktop-week .col-notes,
  #scheduleView.mode-week .desktop-week .col-notes,
  #scheduleView.mode-plan .desktop-week .col-diagnosis,
  #scheduleView.mode-plan .desktop-week .col-procedure,
  #scheduleView.mode-plan .desktop-week .col-notes{
    padding:8px 10px!important;
    border-radius:0;
    background:transparent!important;
    border:0!important;
    border-top:1px solid #e8eef3!important;
  }
  #scheduleView.mode-day .desktop-week .row-actions,
  #scheduleView.mode-week .desktop-week .row-actions,
  #scheduleView.mode-plan .desktop-week .row-actions{
    display:flex;
    grid-template-columns:none;
    gap:6px;
    width:auto;
    justify-content:flex-start;
  }
  #scheduleView.mode-day .desktop-week .icon-action,
  #scheduleView.mode-week .desktop-week .icon-action,
  #scheduleView.mode-plan .desktop-week .icon-action{
    width:36px;
    height:36px;
    border-radius:10px;
  }
  #scheduleView.mode-day .desktop-week .empty:not([hidden]),
  #scheduleView.mode-week .desktop-week .empty:not([hidden]),
  #scheduleView.mode-plan .desktop-week .empty:not([hidden]){
    display:block;
    padding:24px;
    text-align:center;
  }
  #scheduleView.mode-day .desktop-week .empty[hidden],
  #scheduleView.mode-week .desktop-week .empty[hidden],
  #scheduleView.mode-plan .desktop-week .empty[hidden]{
    display:none!important;
  }
  .theme-dark #scheduleView.mode-day .desktop-week,
  .theme-dark #scheduleView.mode-week .desktop-week,
  .theme-dark #scheduleView.mode-plan .desktop-week{
    background:#1f2937;
    border-color:#374151;
    box-shadow:none;
  }
  .theme-dark #scheduleView.mode-day .desktop-week th,
  .theme-dark #scheduleView.mode-week .desktop-week th,
  .theme-dark #scheduleView.mode-plan .desktop-week th{
    background:#243b53;
    color:#dbeafe;
  }
  .theme-dark #scheduleView.mode-day .desktop-week td,
  .theme-dark #scheduleView.mode-week .desktop-week td,
  .theme-dark #scheduleView.mode-day .desktop-week tr.op-row td,
  .theme-dark #scheduleView.mode-week .desktop-week tr.op-row td,
  .theme-dark #scheduleView.mode-plan .desktop-week td,
  .theme-dark #scheduleView.mode-plan .desktop-week tr.op-row td,
  .theme-dark #scheduleView.mode-day .desktop-week .col-diagnosis,
  .theme-dark #scheduleView.mode-week .desktop-week .col-diagnosis,
  .theme-dark #scheduleView.mode-day .desktop-week .col-procedure,
  .theme-dark #scheduleView.mode-week .desktop-week .col-procedure,
  .theme-dark #scheduleView.mode-day .desktop-week .col-notes,
  .theme-dark #scheduleView.mode-week .desktop-week .col-notes,
  .theme-dark #scheduleView.mode-plan .desktop-week .col-diagnosis,
  .theme-dark #scheduleView.mode-plan .desktop-week .col-procedure,
  .theme-dark #scheduleView.mode-plan .desktop-week .col-notes{
    border-top-color:#374151!important;
    background:transparent!important;
  }
}

.blood-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:42px;
  height:24px;
  padding:0 10px;
  box-sizing:border-box;
  border-radius:999px;
  font-weight:800;
  font-size:11px;
  line-height:1;
  letter-spacing:0;
  font-variant-numeric:tabular-nums;
  background:#e0f2fe;
  color:#075985;
  border:1px solid #7dd3fc;
  white-space:nowrap;
  vertical-align:middle;
}
.blood-badge.is-empty{
  opacity:.55;
  font-weight:700;
  min-width:28px;
  background:#e2e8f0;
  color:#64748b;
  border-color:#cbd5e1;
}
.theme-dark .blood-badge{
  background:#0c4a6e;
  color:#bae6fd;
  border-color:#0369a1;
}
.theme-dark .blood-badge.is-empty{
  background:#334155;
  color:#94a3b8;
  border-color:#475569;
}
.status-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  max-width:100%;
  min-height:24px;
  padding:5px 10px;
  box-sizing:border-box;
  border-radius:999px;
  font-weight:800;
  font-size:11px;
  line-height:1.25;
  border:1px solid transparent;
  white-space:normal;
  text-align:center;
}
.status-badge.status-ok{background:#dcfce7;color:#166534;border-color:#86efac}
.status-badge.status-check{background:#ffedd5;color:#9a3412;border-color:#fdba74}
.status-badge.status-cancel{background:#fee2e2;color:#991b1b;border-color:#fca5a5}
.status-badge.status-pending{background:#dbeafe;color:#1d4ed8;border-color:#93c5fd}
.theme-dark .status-badge.status-ok{background:#14532d;color:#bbf7d0;border-color:#166534}
.theme-dark .status-badge.status-check{background:#7c2d12;color:#fed7aa;border-color:#c2410c}
.theme-dark .status-badge.status-cancel{background:#7f1d1d;color:#fecaca;border-color:#b91c1c}
.theme-dark .status-badge.status-pending{background:#1e3a8a;color:#bfdbfe;border-color:#3b82f6}
.week-status{margin:8px 0 4px}

@media (min-width:761px){
  .shell{padding:20px 16px 40px}
  .desktop-week .table-scroll{overflow-x:auto}
  .desktop-week table{width:100%;min-width:0;table-layout:auto}
  .desktop-week td,
  .desktop-week th{vertical-align:middle}
  .desktop-week .col-queue,
  .desktop-week .col-age,
  .desktop-week .col-blood,
  .desktop-week .col-status{
    text-align:center;
    width:1%;
    white-space:nowrap;
  }
  .desktop-week .col-diagnosis,
  .desktop-week .col-procedure,
  .desktop-week .col-team,
  .desktop-week .col-anes{
    word-break:break-word;
  }
  .desktop-week .col-notes{
    max-width:220px;
    white-space:pre-wrap;
    word-break:break-word;
    font-size:13px;
    color:#334155;
  }
  .desktop-week .col-queue .queue-badge,
  .desktop-week .col-blood .blood-badge{
    margin:0 auto;
  }
  .theme-dark .desktop-week .col-notes{color:#cbd5e1}
}

.flag-chip{
  display:inline-flex;align-items:center;margin-left:6px;padding:4px 10px;
  border-radius:999px;font-size:13px;font-weight:800;letter-spacing:.04em;line-height:1.35
}
.flag-zsu{background:#1d4ed8;color:#fde047}
.flag-vip{background:#a16207;color:#fef9c3}
.theme-dark .flag-zsu{background:#1e40af;color:#fde047}
.theme-dark .flag-vip{background:#854d0e;color:#fde68a}
.patient .flag-chip,
.week-card-top .flag-chip,
.col-blood .flag-chip{vertical-align:middle;margin-left:0}
.week-card-top .flag-chip,
.col-blood .flag-chip{margin-left:4px}
.col-blood{
  align-items:center;
  flex-wrap:wrap;
  gap:4px;
}
td.col-blood{
  display:table-cell;
}
td.col-blood .blood-badge,
td.col-blood .flag-chip{vertical-align:middle}
@media (max-width:760px){
  td.col-blood{display:inline-flex}
}

.patient-age{
  display:inline-block;
  color:#475569;
  font-size:16px;
  font-weight:800;
  line-height:1.2;
  letter-spacing:.01em;
}
.week-card-top .patient-age{
  font-size:18px;
}
.col-age{
  font-size:16px;
  font-weight:800;
  color:#334155;
}
.theme-dark .patient-age,
.theme-dark .col-age{
  color:#e2e8f0;
}

/* Light theme: slightly greyer surfaces (keep dark theme unchanged). */
html:not(.theme-dark) .stats article,
html:not(.theme-dark) .search,
html:not(.theme-dark) .toolbar select,
html:not(.theme-dark) .table-card,
html:not(.theme-dark) .login-card,
html:not(.theme-dark) .form-grid input,
html:not(.theme-dark) .form-grid select,
html:not(.theme-dark) .form-grid textarea,
html:not(.theme-dark) .login-card input,
html:not(.theme-dark) .picker-search,
html:not(.theme-dark) .picker-option,
html:not(.theme-dark) .media-dialog,
html:not(.theme-dark) .collapse-toggle,
html:not(.theme-dark) .media-tool-btn:not(.media-download-btn),
html:not(.theme-dark) .week-day,
html:not(.theme-dark) .dept-switcher{
  background:#f1f4f7;
}
html:not(.theme-dark) .media-download-btn,
html:not(.theme-dark) .media-download-btn:hover,
html:not(.theme-dark) .media-download-btn:focus-visible{
  background:#17365d;
  border-color:#17365d;
  color:#fff;
}
html:not(.theme-dark) .media-download-btn:hover{
  background:#244c7b;
  border-color:#244c7b;
  color:#fff;
}
html:not(.theme-dark) .media-delete-btn{
  background:#fff;
  border-color:#f4cccc;
  color:#b42318;
}
html:not(.theme-dark) .secondary{
  background:#fff;
  border:1px solid #94a3b8;
  color:#1e293b;
  box-shadow:0 1px 2px #0f172a12;
}
html:not(.theme-dark) .dept-pill:not(.active){
  background:#fff;
  border-color:#64748b;
  color:#17365d;
}
html:not(.theme-dark) .dept-pill.active{
  background:#17365d;
  border-color:#17365d;
  color:#fff;
  box-shadow:0 6px 14px #17365d33;
}
html:not(.theme-dark) .icon-action{
  background:#17365d;
  border-color:#17365d;
  color:#fff;
  box-shadow:0 2px 8px #17365d33;
}
html:not(.theme-dark) .icon-action.danger-action{
  background:#b42318;
  border-color:#912018;
  color:#fff;
}
html:not(.theme-dark) .media-dialog-head,
html:not(.theme-dark) .media-dialog .media-card,
html:not(.theme-dark) .week-clinical,
html:not(.theme-dark) .week-notes,
html:not(.theme-dark) .media-zoom-tools,
html:not(.theme-dark) .media-image-tools,
html:not(.theme-dark) .notice,
html:not(.theme-dark) .upload,
html:not(.theme-dark) .selected-attachments,
html:not(.theme-dark) .attachments-panel,
html:not(.theme-dark) .upload-progress{
  background:#e8edf2;
}
html:not(.theme-dark) .toolbar{
  background:#f1f4f7;
}
@media (max-width:760px){
  html:not(.theme-dark) tr.op-row,
  html:not(.theme-dark) tr{
    background:#f1f4f7;
  }
  html:not(.theme-dark) .toolbar{
    background:#f1f4f7;
  }
  .top-actions{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
  }
  .top-actions .logout-btn{
    margin-left:auto;
  }
}

@media (max-width:760px){
  #thisDay{grid-column:1/-1}
}

/* Theme switch fade (light ↔ dark). */
::view-transition-old(root),
::view-transition-new(root){
  animation-duration:.32s;
  animation-timing-function:ease;
}
html.theme-fade-out{
  animation:themeScreenFadeOut .16s ease forwards;
}
html.theme-fade-in{
  animation:themeScreenFadeIn .28s ease forwards;
}
@keyframes themeScreenFadeOut{
  from{opacity:1}
  to{opacity:0}
}
@keyframes themeScreenFadeIn{
  from{opacity:0}
  to{opacity:1}
}
@media (prefers-reduced-motion:reduce){
  html.theme-fade-out,
  html.theme-fade-in{
    animation:none;
  }
  ::view-transition-old(root),
  ::view-transition-new(root){
    animation:none;
  }
}

