/* Menu superior (header), menu lateral e rodapé do app raiz.
   Carregado globalmente por includes/head.php. Prefixo hd- (nunca "ad": bloqueadores de anúncio escondem).
   O cabeçalho e o menu ficam fora do .ck-root, então definem a própria paleta, com fallback hex.
   Estrutura Cuba (page-header, nav-menus, sidebar-list...) é mantida: assets/js/script.js, sidebar-menu.js e sidebar-pin.js dependem dela;
   por isso os overrides do menu lateral usam !important (o tema usa seletores gigantes). */

.page-header, .sidebar-wrapper, .hd-footer {
    --hd-blue: #6366f1;  --hd-blue-rgb: 99, 102, 241;
    --hd-green: #22c55e; --hd-green-rgb: 34, 197, 94;
    --hd-amber: #f59e0b; --hd-amber-rgb: 245, 158, 11;
    --hd-red: #ef4444;   --hd-red-rgb: 239, 68, 68;
    --hd-t-blue: #4338ca; --hd-t-green: #166534; --hd-t-amber: #92400e; --hd-t-red: #991b1b;
    --hd-card: #ffffff; --hd-card-2: #f4f6fb;
    --hd-line: var(--motryz-border, #e5e7eb);
    --hd-strong: var(--motryz-text-strong, #111827);
    --hd-sub: var(--motryz-text-subtle, #6b7280);
    --hd-muted: #5b6779;
}
.dark-only .page-header, .dark-only .sidebar-wrapper, .dark-only .hd-footer {
    --hd-card: #262b38; --hd-card-2: #1d2230;
    --hd-strong: #e8ecf7; --hd-sub: #a6aec1; --hd-line: #3b465b;
    --motryz-text-strong: #e8ecf7; --motryz-text-subtle: #a6aec1; --motryz-text-muted: #98a6ad; --motryz-border: #3b465b; --motryz-border-soft: #3b465b;
    --hd-t-blue: #a5b4fc; --hd-t-green: #4ade80; --hd-t-amber: #fbbf24; --hd-t-red: #f87171; --hd-muted: #98a6ad;
}

/* ====================================================================== barra superior */

/* empresa atual (lado esquerdo) */
.hd-ticker { display: flex; align-items: center; gap: 10px; height: 100%; min-width: 0; }
.hd-emp {
    flex: 0 1 auto; min-width: 0; max-width: 100%; display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; white-space: nowrap;
    background: rgba(var(--hd-blue-rgb), .1); border: 1px solid rgba(var(--hd-blue-rgb), .35); color: var(--hd-t-blue); font-size: 12.5px; line-height: 1.3;
}
.hd-emp > i { flex: 0 0 auto; }
.hd-emp > span { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-emp strong { display: inline; font-weight: 700; }

/* botões de ícone da direita: tela cheia, busca, tema */
.page-header .header-wrapper .nav-right .nav-menus > li.hd-icone { padding: 0; margin: 0 2px; height: 36px; }
.page-header .hd-icone > span, .page-header .hd-icone > .mode {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 12px; cursor: pointer; transition: background .15s ease;
}
.page-header .hd-icone > span:hover, .page-header .hd-icone > .mode:hover { background: rgba(var(--hd-blue-rgb), .1); }
.page-header .hd-icone > span:focus-visible, .page-header .hd-icone > .mode:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--hd-blue-rgb), .3); }

/* gatilhos de menu (empresa, usuário) e sino: o cabeçalho tem altura fixa (80px = 22 + 36 + 22), nada passa de 36px */
.page-header .header-wrapper .nav-right .nav-menus > li.hd-notif,
.page-header .header-wrapper .nav-right .nav-menus > li.hd-menu-item { position: relative; padding: 0; margin: 0 4px; height: 36px; }
.hd-trigger, .hd-sino {
    display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border: 0; border-radius: 12px; background: transparent; color: inherit; cursor: pointer;
    font: inherit; font-size: 13px; font-weight: 600; transition: background .15s ease;
}
.hd-trigger:hover, .hd-trigger[aria-expanded="true"] { background: rgba(var(--hd-blue-rgb), .1); }
.hd-trigger:focus-visible, .hd-sino:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--hd-blue-rgb), .3); }
.hd-trigger-seta { font-size: 10px; color: var(--hd-muted); transition: transform .15s ease; }
.hd-trigger[aria-expanded="true"] .hd-trigger-seta { transform: rotate(180deg); }
.hd-perfil-btn { padding: 0 8px 0 2px; }
.hd-avatar { width: 32px; height: 32px; border-radius: 10px; object-fit: cover; background: var(--hd-card-2); flex: 0 0 auto; }
.hd-avatar--g { width: 44px; height: 44px; border-radius: 12px; }
.hd-perfil-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; min-width: 0; max-width: 170px; text-align: left; }
.hd-perfil-nome { font-size: 13px; font-weight: 700; color: var(--hd-strong); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-perfil-sub { font-size: 11px; font-weight: 500; color: var(--hd-sub); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* sino */
.hd-sino { position: relative; justify-content: center; width: 36px; padding: 0; }
.hd-sino svg { width: 20px; height: 20px; }
.hd-sino:hover, .hd-sino[aria-expanded="true"] { background: rgba(var(--hd-blue-rgb), .1); }
.hd-sino.tem svg { animation: swing 1.5s ease 1; }
.hd-badge {
    position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--hd-red); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--hd-card);
}
.hd-badge[hidden] { display: none; }

/* popovers (sino, empresa, usuário) */
.hd-pop {
    position: absolute; top: calc(100% + 22px); right: -8px; z-index: 30; width: 380px; max-width: calc(100vw - 16px); text-align: left;
    background: var(--hd-card); border: 1px solid var(--hd-line); border-radius: 16px; box-shadow: 0 24px 60px rgba(15, 23, 42, .28); overflow: hidden;
}
.hd-pop[hidden] { display: none; }
.hd-pop--menu { width: 290px; }
.hd-perfil .hd-pop { right: 0; }
.hd-pop-topo { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--hd-line); background: linear-gradient(135deg, rgba(var(--hd-blue-rgb), .12), rgba(var(--hd-blue-rgb), .02)); }
.hd-pop-topo h6 { margin: 0; font-size: var(--motryz-font-base, .9375rem); font-weight: 700; color: var(--hd-strong); }
.hd-todas { border: 0; background: transparent; padding: 0; color: var(--hd-t-blue); font-size: 12px; font-weight: 700; cursor: pointer; }
.hd-todas:hover:not(:disabled) { text-decoration: underline; }
.hd-todas:disabled { color: var(--hd-muted); cursor: default; }
.hd-lista { list-style: none; margin: 0; padding: 6px; max-height: 420px; overflow-y: auto; }
.hd-n { margin: 0; padding: 0; }
.hd-n-a { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; color: var(--hd-strong); text-decoration: none; }
.hd-n-a:hover { background: var(--hd-card-2); color: var(--hd-strong); }
.hd-n-ponto { flex: 0 0 auto; align-self: flex-start; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: transparent; }
.hd-n.is-nova .hd-n-ponto { background: var(--hd-blue); box-shadow: 0 0 0 3px rgba(var(--hd-blue-rgb), .25); }
.hd-n-c { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hd-n-c strong { font-size: var(--motryz-font-sm, .8125rem); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.hd-notif .hd-n:not(.is-nova) .hd-n-c strong { font-weight: 500; color: var(--hd-sub); }
.hd-n-c small { font-size: 12px; color: var(--hd-sub); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.hd-n-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 2px; font-size: 11px; color: var(--hd-muted); }
.hd-tag { padding: 0 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; border: 1px solid transparent; }
.hd-tag--aviso { background: rgba(var(--hd-amber-rgb), .16); border-color: rgba(var(--hd-amber-rgb), .5); color: var(--hd-t-amber); }
.hd-tag--ok { background: rgba(var(--hd-green-rgb), .16); border-color: rgba(var(--hd-green-rgb), .5); color: var(--hd-t-green); }
.hd-tag--erro { background: rgba(var(--hd-red-rgb), .14); border-color: rgba(var(--hd-red-rgb), .5); color: var(--hd-t-red); }
.hd-nvazio { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 32px 12px; color: var(--hd-sub); font-size: var(--motryz-font-sm, .8125rem); list-style: none; }
.hd-pop-pe { padding: 10px 16px; border-top: 1px solid var(--hd-line); text-align: center; background: var(--hd-card); }
.hd-pop-pe a { font-size: var(--motryz-font-sm, .8125rem); font-weight: 700; color: var(--hd-t-blue); }

/* troca de empresa */
.hd-emp-ico { flex: 0 0 auto; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: rgba(var(--hd-blue-rgb), .12); color: var(--hd-t-blue); font-size: 13px; }
.hd-emp-item.is-atual { background: rgba(var(--hd-blue-rgb), .1); }
.hd-emp-check { flex: 0 0 auto; color: var(--hd-t-blue); font-size: 12px; }

/* menu do usuário */
.hd-perfil-cab { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--hd-line); background: linear-gradient(135deg, rgba(var(--hd-blue-rgb), .12), rgba(var(--hd-blue-rgb), .02)); }
.hd-perfil-cab .hd-n-c strong { color: var(--hd-strong); }
.hd-perfil-cab .hd-n-c small { display: block; -webkit-line-clamp: unset; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-perfil-cab .hd-n-c small.hd-perfil-emp { display: none; }
.hd-menu-link { font-size: var(--motryz-font-sm, .8125rem); font-weight: 600; }
.hd-menu-link i { width: 18px; text-align: center; color: var(--hd-muted); }
.hd-menu-link--sair, .hd-menu-link--sair i { color: var(--hd-t-red); }
.hd-menu-link--sair:hover { background: rgba(var(--hd-red-rgb), .1); color: var(--hd-t-red); }

/* busca de telas */
.page-header .header-wrapper .search-full .hd-res { text-align: left; padding: 8px; max-height: min(70vh, 520px); overflow-y: auto; border-radius: 14px; border: 1px solid var(--hd-line); background: var(--hd-card); box-shadow: 0 18px 40px rgba(15, 23, 42, .22); }
.page-header .header-wrapper .search-full.hd-carregando .form-group::after {
    content: ""; position: absolute; right: 64px; top: 24px; width: 16px; height: 16px; border: 2px solid var(--hd-line); border-top-color: var(--hd-blue);
    border-radius: 50%; animation: hd-giro .7s linear infinite;
}
@keyframes hd-giro { to { transform: rotate(360deg); } }
.hd-grupo + .hd-grupo { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--hd-line); }
.hd-grupo-t { display: flex; align-items: center; gap: 8px; padding: 6px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--hd-sub); }
.hd-grupo-t i { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; background: rgba(var(--hd-blue-rgb), .14); color: var(--hd-t-blue); font-size: 10px; }
.hd-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--hd-strong); text-decoration: none; }
.hd-item.is-ativo { background: rgba(var(--hd-blue-rgb), .12); }
.hd-item-c { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.hd-item-c strong { font-size: var(--motryz-font-sm, .8125rem); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-item-c small { font-size: 11.5px; color: var(--hd-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-item > i { flex: 0 0 auto; font-size: 11px; color: var(--hd-muted); opacity: 0; }
.hd-item.is-ativo > i { opacity: 1; color: var(--hd-t-blue); }
.hd-item mark { padding: 0; background: rgba(var(--hd-amber-rgb), .35); color: inherit; border-radius: 3px; }
.hd-vazio { display: flex; align-items: center; gap: 10px; padding: 16px 12px; color: var(--hd-sub); font-size: var(--motryz-font-sm, .8125rem); }
.hd-vazio i { color: var(--hd-muted); }

/* chip do modo suporte (suporte-banner.php): só complementa o escuro e o espaçamento */
.page-header .suporte-chip-item { margin: 0 4px; }
.dark-only .suporte-chip { background: rgba(224, 161, 0, .16); border-color: rgba(224, 161, 0, .5); color: #fcd34d; }
.dark-only .suporte-chip:hover, .dark-only .suporte-chip[aria-expanded="true"] { background: rgba(224, 161, 0, .26); }

/* ====================================================================== menu lateral */
.sidebar-wrapper .sidebar-main-title h6 {
    font-size: 11px !important; font-weight: 700 !important; letter-spacing: .08em !important; text-transform: uppercase !important; color: var(--hd-muted) !important;
}
.sidebar-wrapper .sidebar-links li.sidebar-main-title { padding-left: 26px !important; }
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link {
    display: flex !important; align-items: center; gap: 12px; margin: 2px 12px !important; padding: 10px 14px !important; border-radius: 12px !important;
    font-weight: 600 !important; transition: background .15s ease, color .15s ease;
}
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link .hd-sb-ico { flex: 0 0 auto; width: 20px; text-align: center; font-size: 15px; color: var(--hd-sub) !important; transition: color .15s ease; }
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link span {
    flex: 1 1 auto; min-width: 0; letter-spacing: .01em !important; text-transform: none !important; font-size: 13.5px; color: var(--hd-sub) !important;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link .according-menu { position: absolute !important; right: 14px !important; top: 50% !important; transform: translateY(-50%); }
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link .according-menu i { color: var(--hd-muted) !important; font-size: 11px; }
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link:hover { background: rgba(var(--hd-blue-rgb), .08) !important; }
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link:hover span,
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link:hover .hd-sb-ico { color: var(--hd-t-blue) !important; }
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link:focus-visible { outline: 2px solid var(--hd-blue); outline-offset: -2px; }

/* item atual (marcado no servidor pela URL) e grupo aberto/ativo (marcado pelo tema) */
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link.hd-atual,
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link.active {
    background: rgba(var(--hd-blue-rgb), .14) !important; box-shadow: inset 3px 0 0 var(--hd-blue);
}
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link.hd-atual span,
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link.hd-atual .hd-sb-ico,
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link.active span,
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link.active .hd-sb-ico,
.sidebar-wrapper .sidebar-links li.hd-sb-item.hd-atual-grupo > a.sidebar-link span,
.sidebar-wrapper .sidebar-links li.hd-sb-item.hd-atual-grupo > a.sidebar-link .hd-sb-ico { color: var(--hd-t-blue) !important; }
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link.hd-atual span,
.sidebar-wrapper .sidebar-links li.hd-sb-item.hd-atual-grupo > a.sidebar-link span { font-weight: 700; }
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link.hd-atual::after,
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link.active::after { display: none !important; }

/* submenu */
.sidebar-wrapper .sidebar-links li.hd-sb-item .sidebar-submenu { padding: 2px 0 6px !important; }
.sidebar-wrapper .sidebar-links li.hd-sb-item .sidebar-submenu li a {
    margin: 1px 12px; padding: 7px 14px 7px 48px !important; border-radius: 10px; font-size: 13px !important; font-weight: 500 !important; letter-spacing: .01em !important; color: var(--hd-sub) !important;
}
.sidebar-wrapper .sidebar-links li.hd-sb-item .sidebar-submenu li a:hover { background: rgba(var(--hd-blue-rgb), .08); color: var(--hd-t-blue) !important; }
.sidebar-wrapper .sidebar-links li.hd-sb-item .sidebar-submenu li a.hd-atual,
.sidebar-wrapper .sidebar-links li.hd-sb-item .sidebar-submenu li a.active { background: rgba(var(--hd-blue-rgb), .12); color: var(--hd-t-blue) !important; font-weight: 700 !important; }
.sidebar-wrapper .sidebar-links li.hd-sb-item .sidebar-submenu li a:focus-visible { outline: 2px solid var(--hd-blue); outline-offset: -2px; }

/* selo de tickets e fixados */
.sidebar-wrapper .sidebar-links li.hd-sb-item .badge { position: static !important; margin: 0 !important; order: 3; flex: 0 0 auto; font-size: 10.5px !important; padding: .3em .6em !important; border-radius: 999px !important; }
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link .badge { margin-left: auto !important; }
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link span { order: 2; }
.sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link .hd-sb-ico { order: 1; }
.sidebar-wrapper .sidebar-links li.hd-sb-item > i.fa-thumbtack { color: var(--hd-blue) !important; }

/* menu recolhido: só o ícone, centralizado (o tema expande no hover) */
.sidebar-wrapper.close_icon:not(:hover) .sidebar-links li.hd-sb-item > a.sidebar-link { justify-content: center; gap: 0; padding: 10px 0 !important; }
.sidebar-wrapper.close_icon:not(:hover) .sidebar-links li.hd-sb-item > a.sidebar-link .badge { display: none; }

/* ====================================================================== rodapé e avisos */
.hd-footer-in { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.hd-footer-txt { font-size: 12.5px; color: var(--hd-sub); }
.hd-footer-txt strong { color: var(--hd-strong); }
.hd-footer-selo img { max-height: 30px; width: auto; }
.hd-toast.swal2-popup { border-radius: 14px; box-shadow: 0 18px 40px rgba(15, 23, 42, .22); font-size: .875rem; }
.dark-only .hd-toast.swal2-popup { background: #262b38; color: #e8ecf7; }
.dark-only .hd-toast .swal2-title { color: #e8ecf7; }

/* lista do autocomplete (jquery-ui, cores fixas no head.php): escuro */
.dark-only .ui-autocomplete { background: #262b38 !important; border-color: #3b465b !important; color: #e8ecf7; }
.dark-only .ui-menu-item:hover { background: rgba(99, 102, 241, .22) !important; color: #e8ecf7 !important; }

/* ====================================================================== responsivo */
@media (max-width: 1399px) {
    .hd-emp-rotulo { display: none; }
}
@media (max-width: 1199px) {
    .hd-perfil-txt { max-width: 120px; }
}
@media (max-width: 991px) {
    .hd-perfil-txt, .hd-perfil-btn .hd-trigger-seta { display: none; }
    .hd-perfil-btn { padding: 0 2px; }
    .hd-trigger--txt .hd-trigger-t { display: none; }
}
@media (max-width: 767px) {
    .page-header .left-header { display: none; }
    .hd-perfil-cab .hd-n-c small.hd-perfil-emp { display: block; }
}
@media (max-width: 575px) {
    .hd-pop, .hd-pop--menu, .hd-perfil .hd-pop { position: fixed; top: 70px; left: 8px; right: 8px; width: auto; }
    .page-header .header-wrapper .nav-right .nav-menus > li.hd-notif,
    .page-header .header-wrapper .nav-right .nav-menus > li.hd-menu-item { margin: 0 1px; }
    .page-header .header-wrapper .nav-right .nav-menus > li.hd-icone { margin: 0; }
    .hd-footer-in { justify-content: center; text-align: center; }
}
@media (pointer: coarse) {
    .page-header .hd-icone > span, .page-header .hd-icone > .mode, .hd-sino { width: 40px; height: 40px; }
    .hd-trigger { height: 40px; }
    .hd-n-a, .hd-menu-link { min-height: 44px; }
    .sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link { padding-top: 12px !important; padding-bottom: 12px !important; }
    .sidebar-wrapper .sidebar-links li.hd-sb-item .sidebar-submenu li a { padding-top: 10px !important; padding-bottom: 10px !important; }
}
@media (prefers-reduced-motion: reduce) {
    .hd-sino.tem svg, .page-header .header-wrapper .search-full.hd-carregando .form-group::after { animation: none; }
    .hd-trigger, .hd-trigger-seta, .sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link, .sidebar-wrapper .sidebar-links li.hd-sb-item > a.sidebar-link .hd-sb-ico { transition: none; }
}

/* acessibilidade: foco visível em tudo do cabeçalho */
.hd-notif :is(a, button):focus-visible, .hd-pop :is(a, button):focus-visible, .hd-ticker :is(a, button):focus-visible, .hd-menu-item :is(a, button):focus-visible,
.hd-res :is(a, button):focus-visible { outline: 2px solid var(--hd-blue, #6366f1); outline-offset: 2px; }
.dark-only .hd-notif :is(a, button):focus-visible, .dark-only .hd-pop :is(a, button):focus-visible, .dark-only .hd-menu-item :is(a, button):focus-visible { outline-color: #a5b4fc; }
