/* ===== Novo layout do sistema: barra lateral de ícones + abas no topo (estilo "clínica moderna") ===== */
:root{--rail-w:52px;--top-h:48px}
body{background:#f4f8fb}
html[data-theme="dark"] body{background:#0d1722}
.sidebar,.topbar-new{display:none!important}

/* ---------- barra lateral de ícones ---------- */
.rail{position:fixed;left:0;top:0;bottom:0;width:var(--rail-w);background:var(--brand);z-index:40;display:flex;flex-direction:column;box-sizing:border-box;padding:6px 0}
.rail-logo{height:46px;display:grid;place-items:center;margin-bottom:4px;text-decoration:none}
.rail-logo img{width:32px;height:32px;border-radius:9px;background:#fff;padding:2px;box-sizing:border-box}
.rail-nav{display:flex;flex-direction:column;flex:1;min-height:0}
.rail-i{position:relative;flex:0 0 auto;height:44px;display:grid;place-items:center;color:rgba(255,255,255,.93);text-decoration:none;transform:none!important}
.rail-i .ic{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.rail-i:hover,.rail-i.ativo{background:color-mix(in srgb,#000 17%,var(--brand));color:#fff}
.rail-i.ativo::before{content:"";position:absolute;left:0;top:9px;bottom:9px;width:3px;border-radius:0 3px 3px 0;background:#fff}
.rail-i::after{content:attr(data-label);position:absolute;left:100%;top:0;height:44px;display:none;align-items:center;padding:0 24px 0 16px;background:color-mix(in srgb,#000 17%,var(--brand));color:#fff;font-size:13.5px;font-weight:600;white-space:nowrap;border-radius:0 6px 6px 0;box-shadow:5px 4px 16px rgba(0,0,0,.2)}
.rail-i:hover::after,.rail-i:focus-visible::after{display:flex}
.rail-sep{height:1px;background:rgba(255,255,255,.24);margin:6px 11px}
@media(max-height:760px){.rail-i{height:38px}.rail-i::after{height:38px}.rail-logo{height:40px}}

/* ---------- barra superior com abas ---------- */
.topnav{position:fixed;top:0;left:var(--rail-w);right:0;height:var(--top-h);background:#fff;border-bottom:1px solid var(--line,#e3eaf1);z-index:35;display:flex;align-items:stretch;justify-content:space-between;gap:10px;padding:0 12px 0 6px}
.nav-tabs{display:flex;align-items:stretch;min-width:0;overflow-x:auto;scrollbar-width:none}
.nav-tabs::-webkit-scrollbar{display:none}
.nav-tabs a{display:flex;align-items:center;padding:0 15px;font-size:12px;font-weight:700;letter-spacing:.045em;text-transform:uppercase;color:color-mix(in srgb,var(--brand) 78%,#1d3249);text-decoration:none;border-bottom:3px solid transparent;white-space:nowrap;transform:none!important}
.nav-tabs a:hover{background:color-mix(in srgb,var(--brand) 8%,transparent)}
.nav-tabs a.ativo{border-bottom-color:var(--brand);color:#1d3249}
.tb-tools{display:flex;align-items:center;gap:2px;flex:0 0 auto}
.srch{display:flex;align-items:center;gap:6px;height:32px;margin-right:6px;padding:0 11px;border:1px solid var(--line,#e3eaf1);border-radius:999px;background:#f4f8fb;color:#7a8ba0}
.srch:focus-within{border-color:var(--brand);box-shadow:0 0 0 3px color-mix(in srgb,var(--brand) 14%,transparent)}
.srch input{border:0!important;background:transparent!important;width:190px;padding:0!important;height:30px;outline:none;box-shadow:none!important;font-size:13px;color:inherit}
.tb-btn{position:relative;width:36px;height:36px;display:grid;place-items:center;border:0;border-radius:50%;background:none;color:#6b7f95;cursor:pointer;padding:0;text-decoration:none}
.tb-btn:hover{background:color-mix(in srgb,var(--brand) 10%,transparent);color:var(--brand)}
.tb-btn .ic,.srch .ic{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.srch .ic{width:16px;height:16px}
.tb-btn>i{position:absolute;top:1px;right:0;min-width:17px;height:17px;padding:0 4px;box-sizing:border-box;border-radius:9px;background:#ff3b7b;color:#fff;font:700 10px/17px system-ui,sans-serif;text-align:center}
.tb-btn .sun{display:none}
html[data-theme="dark"] .tb-btn .sun{display:block}html[data-theme="dark"] .tb-btn .moon{display:none}
.tb-sep{width:1px;height:24px;background:var(--line,#e3eaf1);margin:0 8px}
.me{display:flex;align-items:center;gap:9px;padding:0 4px 0 2px}
.me-av{width:30px;height:30px;border-radius:50%;background:var(--brand);color:#fff;display:grid;place-items:center;font-weight:800;font-size:13px}
.me-t{line-height:1.15}.me-t b{display:block;font-size:13px}.me-t small{display:block;font-size:11px;color:#7a8ba0}
.logout-form{margin:0;display:inline-flex}
.notify-wrap{position:relative}
.notify-menu{top:calc(100% + 8px)}

/* ---------- conteúdo ---------- */
.page-shell{margin-left:var(--rail-w)!important;padding:calc(var(--top-h) + 22px) 24px 30px!important}
.page-shell.guest{margin:0!important;padding:0!important}
@media(max-width:1100px){.srch input{width:120px}}
@media(max-width:900px){.srch,.me-t,.tb-sep{display:none}}
@media(max-width:560px){.page-shell{padding-left:12px!important;padding-right:12px!important}.nav-tabs a{padding:0 11px}}

/* ---------- tema escuro ---------- */
html[data-theme="dark"] .topnav{background:#142332;border-color:#263d51}
html[data-theme="dark"] .nav-tabs a{color:#7fd0dc}html[data-theme="dark"] .nav-tabs a.ativo{color:#fff}
html[data-theme="dark"] .srch{background:#0f1d2a;border-color:#263d51;color:#8fa7bd}
html[data-theme="dark"] .tb-btn{color:#9db3c8}html[data-theme="dark"] .me-t b{color:#dce8f3}
html[data-theme="dark"] .tb-sep{background:#263d51}

/* ---------- impressão ---------- */
@media print{.rail,.topnav{display:none!important}.page-shell{margin:0!important;padding:0!important}}

/* ---------- menu único: ícones (recolhido) ou ícones + nomes (expandido) ---------- */
.rail-t{display:none}
.rail-toggle{flex:0 0 auto;height:44px;width:100%;display:grid;place-items:center;border:0;background:none;color:#fff;cursor:pointer;padding:0}
.rail-toggle .ic{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round}
.rail-toggle:hover{background:color-mix(in srgb,#000 17%,var(--brand))}
.nav-title{display:flex;align-items:center;padding:0 16px;font-size:16px;font-weight:700;color:#1d3249;white-space:nowrap}
html[data-theme="dark"] .nav-title{color:#dce8f3}
html.rail-open{--rail-w:208px}
html.rail-open .rail-i{display:flex;align-items:center;justify-content:flex-start;gap:15px;padding:0 17px}
html.rail-open .rail-i .ic{flex:0 0 auto}
html.rail-open .rail-t{display:inline;font-size:13.5px;font-weight:600;white-space:nowrap}
html.rail-open .rail-i::after{display:none!important}
html.rail-open .rail-logo{display:flex;justify-content:flex-start;align-items:center;gap:10px;padding:0 10px;color:#fff;font-weight:800;font-size:14px}
html.rail-open .rail-toggle{display:flex;justify-content:flex-start;padding:0 15px}
html.rail-open .rail-sep{margin:6px 14px}
@media(max-width:780px){html.rail-open{--rail-w:52px}html.rail-open .rail{width:208px;box-shadow:6px 0 24px rgba(0,0,0,.28)}}

/* ---------- listas, tabelas e cabeçalhos de página (visual novo) ---------- */
.page-shell .topbar{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:16px}
.page-shell .topbar h1{margin:0;font-size:24px;letter-spacing:-.01em}
.page-shell .topbar .subtitle{margin:4px 0 0}
.page-shell .card{border-radius:16px}
.searchbar{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.searchbar input[type=text],.searchbar input[type=search],.searchbar input:not([type]){flex:1;min-width:220px;border-radius:999px;padding:10px 16px}
.page-shell .card table{width:100%;border-collapse:separate;border-spacing:0}
.page-shell .card table th{font-size:11px;text-transform:uppercase;letter-spacing:.07em;color:var(--muted);font-weight:800;padding:10px 12px;border:0;border-bottom:1px solid var(--line);text-align:left;background:transparent}
.page-shell .card table td{padding:12px;border:0;border-bottom:1px solid var(--line);vertical-align:middle;font-size:14px;background:transparent}
.page-shell .card table tr:last-child td{border-bottom:0}
.page-shell .card table tr:hover td{background:color-mix(in srgb,var(--brand) 5%,transparent)}
.page-shell .card table td a:not(.btn){color:inherit;text-decoration:none}
.page-shell .card table td a:not(.btn):hover{color:var(--brand)}
.page-shell .metric{border-radius:16px}
.pl-nome{display:flex;align-items:center;gap:12px;min-width:0}
.pl-av{flex:0 0 auto;width:38px;height:38px;border-radius:50%;background:color-mix(in srgb,var(--brand) 18%,transparent);color:var(--text);display:grid;place-items:center;font-weight:800;font-size:15px}
.pl-nome small{display:block;color:var(--muted);font-size:12px;margin-top:1px;font-weight:600}

/* ---------- celular: barra superior que não estoura a tela ---------- */
.topnav{min-width:0}
.nav-title{min-width:0;overflow:hidden;text-overflow:ellipsis}
@media(max-width:560px){
  .me,#themeToggle{display:none}
  .nav-title{padding:0 8px;font-size:15px}
  .topnav{padding:0 6px 0 2px;gap:4px}
  .tb-btn{width:34px}
}

/* ---------- botão Sair bem visível ---------- */
.tb-sair{width:auto;border-radius:18px;padding:0 12px;gap:6px;display:inline-flex;align-items:center;font:700 13px system-ui,sans-serif}
.tb-sair span{display:inline}
.rail-sair{margin:auto 0 0;padding:0}
.rail-sair .rail-i{width:100%;background:none;border:0;cursor:pointer;font:inherit;color:inherit;text-align:left}
@media(max-width:560px){.tb-sair{padding:0 10px}}

/* ---------- modo escuro: ajustes finais ---------- */
html[data-theme="dark"] .btn-primary{background:var(--brand);color:#fff;border-color:var(--brand)}
html[data-theme="dark"] .btn:hover{border-color:var(--brand)}
html[data-theme="dark"] .clinic-banner-uploaded{background:#142332!important}
html[data-theme="dark"] .report-head{background:#142332!important;color:#dce8f3;border-bottom-color:#2f80ed!important}
html[data-theme="dark"] [style*="#fff8e8"]{background:#2b2411!important;border-color:#6b5420!important;color:#f1dfae}
html[data-theme="dark"] .finance-group .group-sub{color:#8fa7bd}
html[data-theme="dark"] .db-warn,html[data-theme="dark"] .pf-inativo{color:#ff7b6b}
html[data-theme="dark"] .ag-dlg .dt-bad{color:#ff8a7a}
html[data-theme="dark"] .ag-dlg .dt-perigo button{color:#ff8a7a}
html[data-theme="dark"] .tooth{background:#0f1d2a;border-color:#345069;color:#dce8f3;box-shadow:none}
html[data-theme="dark"] .tooth-shape,html[data-theme="dark"] .tooth-shape b,html[data-theme="dark"] .lg{background:#0f1d2a;border-color:#6b8299}
html[data-theme="dark"] .pill-green{background:rgba(22,185,120,.18);color:#5fe0a8}
html[data-theme="dark"] .pill-orange{background:rgba(232,165,29,.18);color:#f3c15c}
html[data-theme="dark"] .pill-red{background:rgba(237,75,95,.2);color:#ff8d9b}
html[data-theme="dark"] .pill-blue{background:rgba(35,136,232,.2);color:#7cc0ff}
html[data-theme="dark"] .alert,html[data-theme="dark"] .messages li{background:#142332;color:#dce8f3;border-color:#263d51}

/* ---------- aviso de licença ---------- */
.lic-aviso{margin:0 0 14px;padding:10px 14px;border-radius:12px;background:#fff4d6;color:#8a5a00;border:1px solid #f0c36d;font-size:13.5px;font-weight:600}
.lic-aviso a{color:inherit;text-decoration:underline;margin-left:6px}
.lic-aviso.lic-bloq{background:#ffe5e9;color:#b3202f;border-color:#f1a9b3}
html[data-theme="dark"] .lic-aviso{background:#2b2411;color:#f1dfae;border-color:#6b5420}
html[data-theme="dark"] .lic-aviso.lic-bloq{background:#34161c;color:#ffb3bd;border-color:#6e2a35}

/* ---------- menu lateral organizado: rola quando falta altura, Sair sempre visível no rodapé ---------- */
.rail-nav{overflow-y:auto;overflow-x:hidden;scrollbar-width:none;-ms-overflow-style:none}
.rail-nav::-webkit-scrollbar{display:none}
.rail-nav .rail-i::after{display:none!important}  /* o balão de nome seria cortado pela rolagem: o nome aparece no title e no menu expandido */
.rail-sair{flex:0 0 auto;margin:0;padding:4px 0 0;border-top:1px solid rgba(255,255,255,.24)}
.rail-sair .rail-i{height:44px}
@media(max-height:760px){.rail-sair .rail-i{height:40px}}
