/* HMEB shared visual language: blue clinical workspace, clear hierarchy and calm density. */
:root{
  --ui-blue:#5e6062;
  --ui-blue-dark:#3f4143;
  --ui-ink:#303234;
  --ui-muted:#6d8193;
  --ui-line:#dee0e2;
  --ui-canvas:#f2f4f6;
  --ui-surface:#ffffff;
  --ui-soft:#f6f8fa;
  --ui-radius:16px;
  --ui-shadow:0 10px 28px rgba(24,67,101,.09);
}

html,body{min-width:0;overflow-x:hidden}
body.gray,body.dark{background:var(--theme-bg,var(--ui-canvas))}
body:not(.dark){--theme-primary:var(--ui-blue);--theme-primary2:var(--ui-blue-dark)}
body.gray .hmb-sidebar{background:linear-gradient(180deg,#4b565f 0%,#323b43 100%)}
body.gray .topbar,body.gray>header,body.gray header.brand{background:linear-gradient(105deg,#444d55 0%,#59636c 100%)}
body.dark .hmb-sidebar{background:linear-gradient(180deg,#323436 0%,#242628 100%)}
body.dark .topbar,body.dark>header,body.dark header.brand{background:linear-gradient(105deg,#3a3c3e 0%,#56585a 100%)}

/* O topo acompanha a lateral em todos os módulos e temas. */
body.gray .topbar,body.gray>header,body.gray header.brand,
body.dark .topbar,body.dark>header,body.dark header.brand{background:linear-gradient(180deg,var(--theme-sidebar),var(--theme-sidebar2))!important}

/* A lateral fixa não pode cobrir o início do cabeçalho dos módulos. */
@media(min-width:781px){
  body[data-module="passagem"] .hmb-app-shell>header,
  body[data-module="censo"] .hmb-app-shell>header{
    margin-left:var(--hmb-side,246px)!important;
    width:calc(100% - var(--hmb-side,246px))!important;
    max-width:calc(100% - var(--hmb-side,246px))!important;
    left:auto!important;
    right:auto!important;
  }
}

@media(min-width:781px){
  body[data-module="passagem"] .hmb-app-shell>header>div:first-child,
  body[data-module="censo"] .hmb-app-shell>header>div:first-child{
    position:static!important;
    left:auto!important;
    right:auto!important;
    transform:none!important;
    margin:0!important;
    flex:1 1 auto!important;
    min-width:0!important;
    overflow:visible!important;
  }
  body[data-module="passagem"] .hmb-app-shell>header h1,
  body[data-module="censo"] .hmb-app-shell>header h1{
    margin-left:0!important;
    padding-left:0!important;
  }
}

/* Shared module frame */
.hmb-sidebar{border-right:1px solid rgba(255,255,255,.09)!important}
.hmb-sidebar-brand{padding:24px 20px 22px!important}
.hmb-sidebar-brand strong{letter-spacing:-.02em}
.hmb-nav-item{min-height:46px!important;border-radius:9px!important;transition:background .18s ease,transform .18s ease!important}
.hmb-nav-item:hover{transform:translateX(2px)}
.hmb-nav-item.active{box-shadow:inset 4px 0 0 #eaecee,0 8px 18px rgba(7,47,80,.15)}
.hmb-nav-icon{font-size:15px!important}

.topbar,body>header,header.brand{min-height:80px!important;padding:16px clamp(18px,3vw,34px)!important}
.topbar h1,header h1,.brand h1{font-size:26px!important;letter-spacing:-.03em!important}
.topbar p,header p{font-size:12px!important}
.top-actions,.top-action-group,.head-actions{gap:8px!important}
.professional-badge,.session-professional,.user-badge{border-radius:999px!important;padding:9px 13px!important;font-size:11px!important}

main,.workspace{background:transparent}
.workspace{padding-top:20px!important}
.panel,.card,.auth-card,.system-card,.kpi,.note,.userbox{border-radius:var(--ui-radius)!important;box-shadow:var(--ui-shadow)}
.section-head,.section-title,.dashboard-head{min-height:48px;padding:10px 12px;margin:-1px -1px 16px!important;border-radius:12px 12px 8px 8px!important}
.section-head h2,.section-title h2,.dashboard-head h2{color:var(--theme-text,var(--ui-ink));letter-spacing:-.02em}
.step{width:34px!important;height:34px!important;border-radius:50%!important;background:var(--ui-blue);color:#fff;border-color:var(--ui-blue);font-size:13px!important}
.panel,.card{padding:18px!important}
.patient-panel,.protocols-panel,.editor-panel,.clinical-card,.map-card{overflow:hidden}

label{color:var(--theme-text,var(--ui-ink));font-weight:750!important}
input,select,textarea{border-radius:10px!important;min-height:40px!important}
textarea{line-height:1.55!important}
input:focus,select:focus,textarea:focus{outline:0;box-shadow:0 0 0 4px rgba(17,107,176,.14)}
button,.btn{border-radius:10px!important;min-height:40px;transition:transform .16s ease,box-shadow .16s ease,filter .16s ease!important}
button:hover,.btn:hover{filter:brightness(1.03);transform:translateY(-1px)}
.btn.primary,.primary,.system-card .enter{background:linear-gradient(135deg,var(--ui-blue),var(--ui-blue-dark));box-shadow:0 8px 18px rgba(17,107,176,.2)}
.btn.success,.success{background:linear-gradient(135deg,#15945e,#11754d);box-shadow:0 8px 18px rgba(21,148,94,.18)}
.btn.secondary,.secondary,.secondary-btn,.icon-btn{background:var(--theme-panel2,var(--ui-soft));color:var(--theme-text,var(--ui-ink));border:1px solid var(--theme-border,var(--ui-line))}

/* Prescriber: keep the reference order and make the main editor dominant. */
.prescription-title-wrap{gap:10px!important}
.free-prescription-legend{color:var(--ui-muted)}
.protocol-list{gap:10px!important}
.protocol-item{border-radius:10px!important;border-color:var(--ui-line);min-height:58px!important;box-shadow:0 3px 10px rgba(24,67,101,.04)}
.protocol-item:hover{border-color:#b3b5b7;box-shadow:0 7px 16px rgba(24,67,101,.1)}
.editor-panel textarea#prescricao{min-height:150px!important;border-color:#cfd1d3;background:#fcfeff}
.tip,.footer-note{border-radius:9px!important;background:var(--ui-soft);border-color:var(--ui-line);color:var(--ui-muted)}
.actionbar{min-height:68px!important;padding:10px clamp(16px,3vw,32px)!important;background:rgba(255,255,255,.93);border-top:1px solid var(--ui-line)!important;backdrop-filter:blur(10px)!important}
#openEvolutionBtn{border-color:#bdbfc1;color:#505254}

/* Evolucao: numbered clinical sections with stronger writing surfaces. */
.clinical-card textarea{min-height:125px!important}
.clinical-card-primary textarea{min-height:145px!important}
.vitals-wide label{background:var(--ui-soft);border:1px solid var(--ui-line);border-radius:10px;padding:9px!important}
.vitals-wide input{margin-top:6px}
.whatsapp-panel{border-left:4px solid #1ca568!important}

/* Census and handoff: operational cards and map density. */
.bed-grid{gap:12px!important}
.bed-card{border-radius:12px!important;transition:transform .16s ease,box-shadow .16s ease!important}
.bed-card:hover{transform:translateY(-2px)!important}
.kpi-card,.assistance-kpi{border-radius:12px!important;box-shadow:0 5px 14px rgba(24,67,101,.05)}
.map-search-wrap input,.protocol-search input{min-height:42px!important}
.meta,.toolbar{border-radius:12px!important}

/* Portal cards use the same visual vocabulary as the modules. */
.portal-layout .portal-head,.portal-layout .admin-head{padding:4px 2px 8px}
.portal-layout .systems-grid{gap:16px!important}
.portal-layout .system-card{border-radius:16px!important;min-height:230px!important}
.portal-layout .system-card .enter{margin-top:auto}
.portal-layout .system-icon{width:52px!important;height:52px!important;border-radius:14px!important}

body.dark .actionbar{background:rgba(16,34,52,.94)}
body.dark .editor-panel textarea#prescricao{background:var(--theme-input)}
body.dark .vitals-wide label{background:var(--theme-panel2)}

@media(max-width:900px){
  .topbar,body>header,header.brand{min-height:72px!important}
  .panel,.card{padding:14px!important}
  .section-head,.section-title{padding:8px!important}
}
@media(max-width:780px){
  .hmb-sidebar{display:none!important}
  .topbar,body>header,header.brand{position:static!important;width:100%!important;margin:0!important}
  .topbar{flex-direction:column;align-items:flex-start!important}
  .top-actions,.head-actions{width:100%;align-items:stretch!important}
  .top-actions>*{max-width:100%}
  .actionbar{position:static!important;flex-direction:column;align-items:stretch!important;gap:8px!important}
  .action-left,.action-right,.action-cluster{width:100%!important;display:grid!important;grid-template-columns:1fr!important}
  .actionbar button{width:100%!important}
  .section-head,.section-title{display:flex!important;align-items:center!important}
}
@media(max-width:520px){
  .topbar,body>header,header.brand{padding:14px!important}
  .topbar h1,header h1,.brand h1{font-size:22px!important}
  .section-head,.section-title{display:block!important}
  .section-head>.status,.section-head>.pill{display:inline-flex;margin-top:8px}
  .professional-badge,.session-professional{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
}

/* Prescritor reference layout: the module keeps its clinical workflow, while
   matching the compact three-column workspace shown by the product model. */
body[data-module="prescritor"]{
  --hmb-side:194px!important;
  --hmb-top:74px!important;
  background:linear-gradient(180deg,#f0f2f4 0%,#f7f9fb 100%);
}
body[data-module="prescritor"] .app{padding-left:194px!important;background:transparent}
body[data-module="prescritor"] .hmb-sidebar{width:194px!important;background:linear-gradient(180deg,#444648 0%,#2e3032 100%)}
body[data-module="prescritor"] .hmb-sidebar-brand{padding:20px 18px 21px!important}
body[data-module="prescritor"] .hmb-sidebar-brand strong{font-size:16px!important}
body[data-module="prescritor"] .hmb-sidebar-brand span{font-size:10px!important}
body[data-module="prescritor"] .hmb-sidebar-nav{padding:12px 8px!important}
body[data-module="prescritor"] .hmb-nav-item{font-size:11px!important;min-height:38px!important;padding:0 10px!important}
body[data-module="prescritor"] .hmb-nav-icon{width:22px!important;height:22px!important}
body[data-module="prescritor"] .topbar{left:194px!important;width:calc(100% - 194px)!important;min-height:74px!important;padding:12px 24px!important}
body[data-module="prescritor"] .topbar h1{font-size:24px!important}
body[data-module="prescritor"] .topbar p{font-size:11px!important}
body[data-module="prescritor"] .top-actions{align-items:center!important;flex-wrap:nowrap!important}
body[data-module="prescritor"] .top-action-history{display:none!important}
body[data-module="prescritor"] .top-action-system{flex-wrap:nowrap!important}
body[data-module="prescritor"] .workspace{padding:16px!important;padding-bottom:100px!important;max-width:none!important}
body[data-module="prescritor"] .patient-panel{padding:14px 16px!important;margin-bottom:14px!important;border-radius:16px!important}
body[data-module="prescritor"] .patient-panel .section-head{background:linear-gradient(100deg,#f1f3f5,#f6f8fa);margin:-14px -16px 14px!important;padding:10px 14px!important}
body[data-module="prescritor"] .patient-panel .form-grid{padding:2px 6px!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:11px 12px!important}
body[data-module="prescritor"] .form-grid .wide{grid-column:span 1!important}
body[data-module="prescritor"] .form-grid .bed-wide{grid-column:span 1!important}
body[data-module="prescritor"] .content-grid{grid-template-columns:1fr!important;gap:14px!important}
body[data-module="prescritor"] .protocols-panel,body[data-module="prescritor"] .editor-panel{padding:14px 16px!important;border-radius:16px!important}
body[data-module="prescritor"] .protocols-panel .section-head{margin:-14px -16px 12px!important;padding:10px 14px!important;background:linear-gradient(100deg,#f1f3f5,#f6f8fa)}
body[data-module="prescritor"] .protocol-list{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;max-height:none!important;gap:10px!important}
body[data-module="prescritor"] .protocol-item{min-height:55px!important;padding:9px 12px!important}
body[data-module="prescritor"] .protocol-actions{margin-top:12px!important;padding-top:10px!important;border-top:1px solid var(--ui-line)!important}
body[data-module="prescritor"] .protocols-panel{min-height:0!important}
body[data-module="prescritor"] .protocol-search{margin:0 0 10px!important}
body[data-module="prescritor"] .editor-panel .section-head{margin:-14px -16px 12px!important;padding:10px 14px!important;background:linear-gradient(100deg,#f1f3f5,#f6f8fa)}
body[data-module="prescritor"] .editor-panel textarea#prescricao{min-height:86px!important;height:86px!important}
body[data-module="prescritor"] .actionbar{left:194px!important;width:calc(100% - 194px)!important;min-height:64px!important;padding:10px 24px!important}
body[data-module="prescritor"] .actionbar .action-right{gap:9px!important}
body[data-module="prescritor"] #openEvolutionBtn{border-color:#b7b9bb;color:#4e5052}
body.gray[data-module="prescritor"] .hmb-sidebar{background:linear-gradient(180deg,#4b565f 0%,#323b43 100%)}
body.gray[data-module="prescritor"] .topbar{background:linear-gradient(105deg,#444d55 0%,#59636c 100%)}
body.dark[data-module="prescritor"] .hmb-sidebar{background:linear-gradient(180deg,#323436 0%,#242628 100%)}
body.dark[data-module="prescritor"] .topbar{background:linear-gradient(105deg,#3a3c3e 0%,#56585a 100%)}
.sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0}
@media(max-width:1100px){body[data-module="prescritor"] .protocol-list{grid-template-columns:repeat(2,minmax(0,1fr))!important}}
@media(max-width:780px){body[data-module="prescritor"] .app{padding-left:0!important}body[data-module="prescritor"] .topbar{left:0!important;width:100%!important}body[data-module="prescritor"] .actionbar{left:0!important;width:100%!important}body[data-module="prescritor"] .top-actions{flex-wrap:wrap!important}body[data-module="prescritor"] .patient-panel .form-grid{grid-template-columns:1fr!important}.protocol-list{grid-template-columns:1fr!important}}

/* ============================================================
   HMEB DESIGN SYSTEM FINAL — CINZA / ESCURO
   Paleta institucional unificada. Sem alteração de lógica.
   ============================================================ */
:root{
  --hmb-bg:#151719;--hmb-bg-2:#1a1d20;--hmb-surface:#202327;--hmb-surface-2:#272b30;
  --hmb-surface-3:#2d3136;--hmb-border:#383d43;--hmb-border-soft:#30343a;
  --hmb-text:#f1f3f5;--hmb-text-2:#c5cad0;--hmb-muted:#9299a1;
  --hmb-accent:#d7dade;--hmb-accent-hover:#f0f1f2;--hmb-accent-text:#17191b;
  --hmb-success:#5c9b77;--hmb-warning:#b69a64;--hmb-danger:#b86767;--hmb-info:#7f929f;
  --hmb-radius-sm:7px;--hmb-radius:10px;--hmb-radius-lg:14px;
  --hmb-shadow:0 10px 28px rgba(0,0,0,.22);
  --theme-bg:var(--hmb-bg);--theme-panel:var(--hmb-surface);--theme-panel2:var(--hmb-surface-2);
  --theme-text:var(--hmb-text);--theme-muted:var(--hmb-muted);--theme-border:var(--hmb-border);
  --theme-input:#24272b;--theme-head:#202326;--theme-head2:#181a1d;
  --theme-sidebar:#191b1e;--theme-sidebar2:#131517;--theme-shadow:var(--hmb-shadow);
  --bg:var(--hmb-bg);--card:var(--hmb-surface);--panel:var(--hmb-surface);--text:var(--hmb-text);
  --muted:var(--hmb-muted);--border:var(--hmb-border);--accent:#bfc4c9;--navy:#292d31;--navy2:#1c1f22;
}
body.gray{
  --theme-bg:#181a1c;--theme-panel:#222529;--theme-panel2:#292d31;--theme-text:#f1f3f5;
  --theme-muted:#9da3aa;--theme-border:#3a3f45;--theme-input:#282b2f;
  --theme-head:#25282c;--theme-head2:#1d2023;--theme-sidebar:#1d2023;--theme-sidebar2:#17191b;
}
body.dark{
  --theme-bg:#101214;--theme-panel:#181b1e;--theme-panel2:#202428;--theme-text:#f3f4f5;
  --theme-muted:#8f969e;--theme-border:#30353a;--theme-input:#202327;
  --theme-head:#1c1f22;--theme-head2:#131517;--theme-sidebar:#151719;--theme-sidebar2:#0f1113;
}
html,body{background:var(--theme-bg);color:var(--theme-text);}
body{font-family:Inter,"Segoe UI",system-ui,-apple-system,sans-serif;}
.brand,.topbar,.header,.page-header,.app-header{background:linear-gradient(110deg,var(--theme-head2),var(--theme-head));color:var(--theme-text);border-color:var(--theme-border);}
.hmb-sidebar,.sidebar,.side-nav{background:linear-gradient(180deg,var(--theme-sidebar),var(--theme-sidebar2));border-color:var(--theme-border);}
.auth-card,.system-card,.panel,.card,.kpi,.note,.userbox,.toolbar,.section,.modal-card,.dialog-card,.bed-card,.prescription-card{
  background:var(--theme-panel);color:var(--theme-text);border-color:var(--theme-border);box-shadow:var(--theme-shadow);
}
input,select,textarea,.input,.select,.search-input{
  background:var(--theme-input);color:var(--theme-text);border-color:var(--theme-border);caret-color:var(--theme-text);
}
input::placeholder,textarea::placeholder{color:var(--theme-muted);opacity:1;}
input:focus,select:focus,textarea:focus{border-color:#70767d;outline:2px solid rgba(196,201,206,.18);outline-offset:1px;}
button,.btn,.primary,.secondary-btn,.action-btn{border-radius:var(--hmb-radius);}
.primary,.btn-primary,.system-card .enter{background:var(--hmb-accent);color:var(--hmb-accent-text);border-color:var(--hmb-accent);}
.primary:hover,.btn-primary:hover,.system-card .enter:hover{background:var(--hmb-accent-hover);}
.secondary-btn,.btn-secondary,.userbox button{background:var(--theme-panel2);color:var(--theme-text);border-color:var(--theme-border);}
.linkbtn,a.action-link{color:#c7ccd1;}
table,th,td{border-color:var(--theme-border-soft);}
th{background:var(--theme-panel2);color:var(--hmb-text-2);}
tbody tr:hover{background:#292d31;}
.modal,.modal-card,dialog,[role="dialog"]{color:var(--theme-text);}
dialog::backdrop,.modal-backdrop{background:rgba(0,0,0,.68);}
.hmb-nav-item.active,.nav-item.active,.menu-item.active{background:#2c3034;color:#fff;box-shadow:inset 3px 0 0 #bfc4c9;}
.hmb-nav-item:hover,.nav-item:hover,.menu-item:hover{background:#25292d;}
.pill,.badge,.tag,.status{border-color:var(--theme-border);}
::-webkit-scrollbar{width:10px;height:10px}::-webkit-scrollbar-track{background:#151719}::-webkit-scrollbar-thumb{background:#3b4045;border:2px solid #151719;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:#50565d}
:focus-visible{outline:2px solid #aeb4ba;outline-offset:2px;}
button:disabled,.btn:disabled,input:disabled,select:disabled,textarea:disabled{opacity:.48;cursor:not-allowed;}
@media(max-width:1366px){.systems-grid{gap:14px}.system-card{min-width:0}.toolbar,.head-actions{flex-wrap:wrap}}
@media(max-width:900px){.systems-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.table-wrap,.scroll-list{overflow-x:auto}.modal-card,dialog{max-width:calc(100vw - 24px)}}
@media(max-width:640px){.systems-grid{grid-template-columns:1fr}.toolbar,.head-actions,.form-row{flex-direction:column;align-items:stretch}.brand{padding-left:16px;padding-right:16px}}



/* HMEB shared visual tokens and component treatment. */
body.gray{--theme-bg:#edf2f6!important;--theme-panel:#fff!important;--theme-panel2:#f3f7fa!important;--theme-text:#1c2b38!important;--theme-muted:#607586!important;--theme-border:#cad8e2!important;--theme-input:#fff!important;--theme-head:#1a6798!important;--theme-head2:#12476d!important;--theme-sidebar:#24475e!important;--theme-sidebar2:#193546!important;--theme-primary:#176da6!important;--theme-primary2:#12527e!important;--theme-shadow:0 10px 26px rgba(20,59,87,.10)!important}
body.dark{--theme-bg:#0d1b28!important;--theme-panel:#152839!important;--theme-panel2:#1b3449!important;--theme-text:#f0f6fa!important;--theme-muted:#a9bfce!important;--theme-border:#35556b!important;--theme-input:#1a3042!important;--theme-head:#1d628f!important;--theme-head2:#123b5b!important;--theme-sidebar:#12324a!important;--theme-sidebar2:#0d2638!important;--theme-primary:#4aa0d4!important;--theme-primary2:#2f78a9!important;--theme-shadow:0 14px 34px rgba(0,0,0,.28)!important}
body.gray,body.dark{background:var(--theme-bg)!important;color:var(--theme-text)!important}
.app,.hmb-app-shell,.shell,.content,.page-content{background:transparent}
.panel,.card,.system-card,.kpi,.note,.userbox,.section,.toolbar,.bed-card,.prescription-card,.dashboard-card,.map-card,.kpi-card,.assistance-kpi,.auth-card,.modal-card,.app-dialog{box-sizing:border-box;min-width:0;max-width:100%;border-color:var(--theme-border)!important;background:var(--theme-panel)!important;color:var(--theme-text)!important;box-shadow:var(--theme-shadow)!important}
.section-head,.section-title,.card-head,.panel-head,.toolbar,.modal-head,.dialog-head{box-sizing:border-box;min-width:0;max-width:100%;color:var(--theme-text)!important;border-color:var(--theme-border)!important;background:var(--theme-panel2)!important}
.section-head>*,.section-title>*,.card-head>*,.panel-head>*,.modal-head>*{min-width:0;max-width:100%}
input,select,textarea{box-sizing:border-box;min-width:0;max-width:100%;background:var(--theme-input)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important}
input::placeholder,textarea::placeholder{color:var(--theme-muted)!important;opacity:1}
.grid,.form-grid,.systems-grid,.content-grid,.dashboard-grid,.cards-grid,.kpi-grid,.bed-grid,.map-grid{min-width:0;max-width:100%}
.grid>*,.form-grid>*,.systems-grid>*,.content-grid>*,.dashboard-grid>*,.cards-grid>*,.kpi-grid>*,.bed-grid>*,.map-grid>*{min-width:0;max-width:100%}
.systems-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr))!important;align-items:stretch!important}
.system-card{display:flex!important;flex-direction:column!important;min-height:220px!important;overflow:hidden!important}
.system-card p{color:var(--theme-muted)!important}
.system-card .enter{width:100%;margin-top:auto;text-align:center}
.bed-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr))!important;align-items:stretch!important}
.bed-card{overflow:hidden!important;word-break:normal!important}
.bed-card-top,.bed-card .patient-name,.bed-card .bed-meta,.bed-card .bed-action,.bed-card .bed-alert{min-width:0;overflow-wrap:anywhere}
body.gray .bed-card{background:#fff!important;color:#173044!important;border:1px solid #c7d7e2!important}
body.gray .bed-card .patient-name,body.gray .bed-card-top strong{color:#173044!important}
body.gray .bed-card .bed-meta{color:#587082!important}
body.gray .bed-card .bed-action{color:#176da6!important}
body.gray .bed-card.available-bed{border-top:4px solid #4d9b72!important;background:#f7fcf9!important}
body.gray .bed-card.occupied-bed{border-top:4px solid #d48732!important;background:#fffaf2!important}
body.gray .bed-card.status-vago,body.gray .bed-card.status-vazio,body.gray .bed-card.status-disponivel{border-top:4px solid #4d9b72!important;background:#f7fcf9!important}
body.gray .bed-card.status-ocupado{border-top:4px solid #d48732!important;background:#fffaf2!important}
body.gray .bed-card.status-reservado{border-top:4px solid #b47a28!important;background:#fff8e8!important}
body.gray .bed-card.status-interditado{border-top:4px solid #c45252!important;background:#fff3f3!important}
body.dark .bed-card{background:#183147!important;color:#edf6fb!important;border:1px solid #3b6078!important}
body.dark .bed-card .patient-name,body.dark .bed-card-top strong{color:#f2f8fb!important}
body.dark .bed-card .bed-meta{color:#b5cbd7!important}
body.dark .bed-card .bed-action{color:#71c0e8!important}
body.dark .bed-card.available-bed{border-top:4px solid #63b78b!important;background:#183b36!important}
body.dark .bed-card.occupied-bed{border-top:4px solid #e1a45a!important;background:#3d3021!important}
body.dark .bed-card.status-vago,body.dark .bed-card.status-vazio,body.dark .bed-card.status-disponivel{border-top:4px solid #63b78b!important;background:#183b36!important}
body.dark .bed-card.status-ocupado{border-top:4px solid #e1a45a!important;background:#3d3021!important}
body.dark .bed-card.status-reservado{border-top:4px solid #d3a354!important;background:#44351f!important}
body.dark .bed-card.status-interditado{border-top:4px solid #d87272!important;background:#43282d!important}
.modal,.app-dialog{box-sizing:border-box;max-width:100vw}
.modal-card,.app-dialog{width:min(1100px,calc(100vw - 32px));max-height:calc(100vh - 32px);overflow:auto}
.modal-head,.dialog-head{position:sticky;top:0;z-index:2}
.modal-actions,.dialog-footer{display:flex;flex-wrap:wrap;gap:10px;align-items:center;max-width:100%;background:var(--theme-panel2)!important;border-color:var(--theme-border)!important}
.hmb-theme-toggle{flex:0 0 auto;display:inline-grid;place-items:center;width:42px;height:42px;padding:0!important;border:1px solid rgba(255,255,255,.35)!important;border-radius:10px!important;background:rgba(255,255,255,.14)!important;color:#fff!important}
body.gray .hmb-theme-toggle{background:#176da6!important;color:#fff!important;border-color:#8fc2df!important}
body.dark .hmb-theme-toggle{background:#1b4f70!important;color:#f4fbff!important;border-color:#5d91ae!important}
@media(max-width:900px){.modal-card,.app-dialog{width:calc(100vw - 20px);max-height:calc(100vh - 20px)}}
@media(max-width:640px){.systems-grid,.bed-grid{grid-template-columns:1fr!important}.topbar,.brand,header{align-items:stretch!important}.top-actions,.head-actions{width:100%;flex-wrap:wrap!important}.top-actions>* ,.head-actions>*{min-width:0}.modal{padding:10px!important}.modal-card,.app-dialog{width:100%;max-height:calc(100vh - 20px);border-radius:12px!important}.modal-actions,.dialog-footer{flex-direction:column;align-items:stretch}.modal-actions button,.dialog-footer button{width:100%}}

/* All screens use the same institutional header/sidebar surface. */
body.gray[data-module] .hmb-sidebar,body.dark[data-module] .hmb-sidebar{background:linear-gradient(105deg,var(--theme-head2),var(--theme-head))!important;border-right:1px solid color-mix(in srgb,var(--theme-text) 18%,transparent)!important}
body.gray[data-module] .topbar,body.dark[data-module] .topbar,body.gray[data-module]>header,body.dark[data-module]>header{background:linear-gradient(105deg,var(--theme-head2),var(--theme-head))!important}
body.gray[data-module] .hmb-nav-item:hover,body.dark[data-module] .hmb-nav-item:hover{background:color-mix(in srgb,var(--theme-text) 13%,transparent)!important}
body.gray[data-module] .hmb-nav-item.active,body.dark[data-module] .hmb-nav-item.active{background:color-mix(in srgb,var(--theme-text) 20%,transparent)!important}

/* One palette for every portal and module screen. */
body.gray[data-module]{--theme-bg:#edf2f6!important;--theme-panel:#ffffff!important;--theme-panel2:#f3f7fa!important;--theme-text:#1c2b38!important;--theme-muted:#607586!important;--theme-border:#cad8e2!important;--theme-input:#ffffff!important;--theme-head:#1a6798!important;--theme-head2:#12476d!important;--theme-sidebar:#12476d!important;--theme-sidebar2:#1a6798!important;--theme-primary:#176da6!important;--theme-primary2:#12527e!important;--theme-success:#2f8b64!important;--theme-danger:#b14b4b!important;--theme-shadow:0 10px 26px rgba(20,59,87,.10)!important}
body.dark[data-module]{--theme-bg:#0d1b28!important;--theme-panel:#152839!important;--theme-panel2:#1b3449!important;--theme-text:#f0f6fa!important;--theme-muted:#a9bfce!important;--theme-border:#35556b!important;--theme-input:#1a3042!important;--theme-head:#1d628f!important;--theme-head2:#123b5b!important;--theme-sidebar:#123b5b!important;--theme-sidebar2:#1d628f!important;--theme-primary:#4aa0d4!important;--theme-primary2:#2f78a9!important;--theme-success:#55ad83!important;--theme-danger:#e07b7b!important;--theme-shadow:0 14px 34px rgba(0,0,0,.28)!important}
body.gray[data-module] .panel,body.gray[data-module] .card,body.gray[data-module] .system-card,body.gray[data-module] .kpi,body.gray[data-module] .note,body.gray[data-module] .userbox,body.gray[data-module] .toolbar,body.gray[data-module] .section,body.gray[data-module] .modal-card,body.gray[data-module] .app-dialog,body.gray[data-module] .auth-card,body.gray[data-module] .dashboard-card,body.gray[data-module] .map-card,body.gray[data-module] .prescription-card,body.dark[data-module] .panel,body.dark[data-module] .card,body.dark[data-module] .system-card,body.dark[data-module] .kpi,body.dark[data-module] .note,body.dark[data-module] .userbox,body.dark[data-module] .toolbar,body.dark[data-module] .section,body.dark[data-module] .modal-card,body.dark[data-module] .app-dialog,body.dark[data-module] .auth-card,body.dark[data-module] .dashboard-card,body.dark[data-module] .map-card,body.dark[data-module] .prescription-card{background:var(--theme-panel)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important;box-shadow:var(--theme-shadow)!important}
body.gray[data-module] input,body.gray[data-module] select,body.gray[data-module] textarea,body.dark[data-module] input,body.dark[data-module] select,body.dark[data-module] textarea{background:var(--theme-input)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important}
body.gray[data-module] .section-head,body.gray[data-module] .section-title,body.gray[data-module] .modal-head,body.gray[data-module] .modal-actions,body.gray[data-module] .dialog-head,body.gray[data-module] .dialog-footer,body.dark[data-module] .section-head,body.dark[data-module] .section-title,body.dark[data-module] .modal-head,body.dark[data-module] .modal-actions,body.dark[data-module] .dialog-head,body.dark[data-module] .dialog-footer{background:var(--theme-panel2)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important}
body.gray[data-module] .hmb-app-shell>header,body.dark[data-module] .hmb-app-shell>header{position:sticky!important;top:0!important;left:0!important;right:auto!important;width:100%!important;max-width:none!important;margin:0!important;box-sizing:border-box!important;background:linear-gradient(105deg,var(--theme-head2),var(--theme-head))!important;color:#fff!important}
body.gray[data-module] .primary,body.gray[data-module] .btn.primary,body.gray[data-module] .btn-primary,body.dark[data-module] .primary,body.dark[data-module] .btn.primary,body.dark[data-module] .btn-primary{background:linear-gradient(135deg,var(--theme-primary),var(--theme-primary2))!important;color:#fff!important;border-color:var(--theme-primary2)!important}
body.gray[data-module] .secondary,body.gray[data-module] .secondary-btn,body.gray[data-module] .btn.secondary,body.dark[data-module] .secondary,body.dark[data-module] .secondary-btn,body.dark[data-module] .btn.secondary{background:var(--theme-panel2)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important}
body.gray[data-module] table,body.gray[data-module] th,body.gray[data-module] td,body.dark[data-module] table,body.dark[data-module] th,body.dark[data-module] td{border-color:var(--theme-border)!important;color:var(--theme-text)!important}
body.gray[data-module] th,body.dark[data-module] th{background:var(--theme-panel2)!important}
.inline-dialog-host dialog:not(.inline-current){display:none!important}
.inline-dialog-host dialog.inline-current{display:block!important;visibility:visible!important}

/* Prescritor: the app already reserves the sidebar width; header and footer must not offset again. */
body[data-module="prescritor"] .app{padding-left:194px!important}
body[data-module="prescritor"] .hmb-sidebar{width:194px!important}
body[data-module="prescritor"] .app>.topbar{left:0!important;right:0!important;width:100%!important;max-width:none!important}
body[data-module="prescritor"] .app>.actionbar{left:194px!important;right:0!important;width:auto!important}
body[data-module="prescritor"] .app>.workspace{width:100%!important;max-width:none!important;margin:0!important;padding:16px 18px 100px!important}
body[data-module="prescritor"] .topbar>div:first-child{min-width:0!important;flex:1 1 auto!important}
body[data-module="prescritor"] .top-actions{min-width:0!important;max-width:45%!important;flex:0 1 auto!important;overflow:hidden!important}
body[data-module="prescritor"] .professional-badge{min-width:0!important;max-width:100%!important;overflow:hidden!important;text-overflow:ellipsis!important;white-space:nowrap!important}
body[data-module="prescritor"] .patient-panel,body[data-module="prescritor"] .protocols-panel,body[data-module="prescritor"] .editor-panel{width:100%!important;max-width:none!important}
@media(max-width:780px){body[data-module="prescritor"] .app{padding-left:0!important}body[data-module="prescritor"] .hmb-sidebar{width:100%!important}body[data-module="prescritor"] .app>.topbar{left:0!important;width:100%!important}body[data-module="prescritor"] .app>.actionbar{left:0!important;width:100%!important}body[data-module="prescritor"] .app>.workspace{padding:14px 12px 100px!important}}


/* =========================================================
   HMEB — TEMA ESCURO AZUL-MARINHO — 2026-09-10
   Substitui o escuro preto por azul hospitalar profundo.
   ========================================================= */
body.dark,
body.portal-layout.dark{
  --theme-bg:#0f1b26!important;
  --theme-panel:#152433!important;
  --theme-panel2:#1b2d3f!important;
  --theme-text:#f2f6f9!important;
  --theme-muted:#a8b7c4!important;
  --theme-border:#30465a!important;
  --theme-input:#182a3a!important;
  --theme-head:#1b3144!important;
  --theme-head2:#122536!important;
  --theme-sidebar:#14293a!important;
  --theme-sidebar2:#0f2130!important;
  --theme-shadow:0 14px 34px rgba(4,17,29,.32)!important;
  --bg:#0f1b26!important;
  --bg2:#12202d!important;
  --panel:#152433!important;
  --panel2:#1b2d3f!important;
  --card:#152433!important;
  --text:#f2f6f9!important;
  --muted:#a8b7c4!important;
  --border:#30465a!important;
  --input:#182a3a!important;
  --header:#1b3144!important;
  --header2:#122536!important;
  --sidebar:#14293a!important;
  --sidebar2:#0f2130!important;
  --primary:#4f86ad!important;
  --primary2:#3b6e93!important;
  --accent:#83a9c4!important;
  --navy:#173047!important;
  --navy2:#102638!important;
}
body.dark{background:linear-gradient(180deg,#0f1b26 0%,#122130 100%)!important;color:#f2f6f9!important}
body.dark .brand,
body.dark .topbar,
body.dark .header,
body.dark .page-header,
body.dark .app-header{background:linear-gradient(105deg,#102638 0%,#1d3850 100%)!important;color:#f2f6f9!important;border-color:#30465a!important}
body.dark .hmb-sidebar,
body.dark .sidebar,
body.dark .side-nav{background:linear-gradient(180deg,#173047 0%,#0f2130 100%)!important;border-color:#30465a!important}
body.dark .auth-card,
body.dark .system-card,
body.dark .panel,
body.dark .card,
body.dark .kpi,
body.dark .note,
body.dark .userbox,
body.dark .toolbar,
body.dark .section,
body.dark .modal-card,
body.dark .dialog-card,
body.dark .app-dialog,
body.dark .bed-card,
body.dark .prescription-card,
body.dark .patient-panel,
body.dark .protocols-panel,
body.dark .editor-panel,
body.dark .dashboard-card,
body.dark .map-card,
body.dark .kpi-card,
body.dark .assistance-kpi,
body.dark .security-card,
body.dark .history-detail,
body.dark .preview-sheet{background:#152433!important;color:#f2f6f9!important;border-color:#30465a!important;box-shadow:0 14px 34px rgba(4,17,29,.28)!important}
body.dark input,
body.dark select,
body.dark textarea,
body.dark .input,
body.dark .select,
body.dark .search-input{background:#182a3a!important;color:#f2f6f9!important;border-color:#36516a!important}
body.dark input::placeholder,
body.dark textarea::placeholder{color:#8fa5b8!important;opacity:1!important}
body.dark input:focus,
body.dark select:focus,
body.dark textarea:focus{border-color:#6f9dbd!important;box-shadow:0 0 0 3px rgba(111,157,189,.16)!important;outline:none!important}
body.dark .secondary-btn,
body.dark .btn-secondary,
body.dark .userbox button{background:#1b2d3f!important;color:#f2f6f9!important;border-color:#36516a!important}
body.dark .primary,
body.dark .btn-primary,
body.dark .system-card .enter,
body.dark .action-primary{background:linear-gradient(135deg,#4f86ad 0%,#3c6f94 100%)!important;color:#fff!important;border-color:#568bb0!important;box-shadow:0 8px 18px rgba(17,61,91,.32)!important}
body.dark .primary:hover,
body.dark .btn-primary:hover,
body.dark .system-card .enter:hover{background:linear-gradient(135deg,#6096ba 0%,#487da3 100%)!important}
body.dark .pill,
body.dark .badge,
body.dark .tag,
body.dark .status,
body.dark .system-icon{background:#1c3144!important;color:#c7d8e4!important;border-color:#36516a!important}
body.dark th,
body.dark .scroll-list table th,
body.dark .history-table-wrap th,
body.dark .age-table-wrap th,
body.dark .professional-table-wrap th,
body.dark .admin-table-wrap th{background:#1b2d3f!important;color:#dce8f0!important;border-color:#30465a!important}
body.dark td,
body.dark .metric-row,
body.dark .perm-user{border-color:#2b4256!important}
body.dark tbody tr:hover{background:#1a2c3d!important}
body.dark .hmb-nav-item:hover,
body.dark .nav-item:hover,
body.dark .menu-item:hover{background:#20394e!important}
body.dark .hmb-nav-item.active,
body.dark .nav-item.active,
body.dark .menu-item.active{background:#284b67!important;color:#fff!important;box-shadow:inset 3px 0 0 #8cb2cb!important}
body.dark .hmb-theme-system select,
body.dark .hmb-theme-inline select,
body.dark .hmb-theme-modal select{background:#1b3144!important;color:#fff!important;border-color:#4a6780!important}
body.dark .hmb-theme-system select option,
body.dark .hmb-theme-inline select option,
body.dark .hmb-theme-modal select option{background:#152433!important;color:#f2f6f9!important}
body.dark .hmeb-connection-strip{background:rgba(19,38,54,.96)!important;color:#a8b7c4!important;border-color:#30465a!important}
body.dark dialog::backdrop,
body.dark .modal-backdrop{background:rgba(5,14,23,.72)!important}
body.dark ::-webkit-scrollbar-track{background:#0f1b26!important}
body.dark ::-webkit-scrollbar-thumb{background:#35536b!important;border-color:#0f1b26!important}
body.dark ::-webkit-scrollbar-thumb:hover{background:#466985!important}

/* Mantém o cabeçalho da Passagem fora da área coberta pela lateral fixa. */
@media(min-width:781px){
  body[data-module="passagem"] .hmb-app-shell>header,
  body[data-module="censo"] .hmb-app-shell>header{
    margin-left:var(--hmb-side,246px)!important;
    width:calc(100% - var(--hmb-side,246px))!important;
    max-width:calc(100% - var(--hmb-side,246px))!important;
    left:auto!important;
    right:auto!important;
  }
}
