/* ========== LAYOUT VARIABLES ==========
   Cores, tipografia e espaçamento vêm de global.css (fonte única).
   Aqui ficam só variáveis específicas de layout/estrutura. */
:root {
  --sidebar-width-expanded: 280px;
  --sidebar-width-collapsed: 72px;
  --header-height: 64px;
}

/* ========== SHELL DELFOS ONE: BUSCA, MENU, NOTIFICAÇÕES E AJUDA ========== */
.command-palette-overlay,
.screen-help-overlay {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(1, 7, 14, 0.72);
  backdrop-filter: blur(3px);
}

.command-palette-overlay { display: flex; justify-content: center; align-items: flex-start; padding: min(14vh, 120px) 16px 24px; }
.command-palette-overlay[hidden],
.screen-help-overlay[hidden],
.notifications-panel[hidden] { display: none !important; }

.command-palette {
  width: min(680px, 100%);
  max-height: min(620px, calc(100vh - 56px));
  overflow: hidden auto;
  background: var(--panel);
  border: 1px solid var(--line-strong, var(--line));
  border-radius: 14px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .48);
}

.command-palette-search { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); color: var(--muted); }
.command-palette-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: var(--text-base); }
.command-palette-search input::placeholder { color: var(--muted); }
.command-palette-search kbd,
.global-search-trigger kbd { border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; color: var(--muted); font-size: 10px; font-family: inherit; white-space: nowrap; }
.command-palette-results { padding: 8px; }
.command-palette-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; color: var(--text); text-align: left; background: transparent; border: 0; border-radius: 9px; cursor: pointer; }
.command-palette-item[hidden] { display: none !important; }
.command-palette-item:hover { background: var(--surface-alt); }
.command-palette-item-icon { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; background: color-mix(in srgb, var(--blue) 16%, transparent); color: var(--blue); }
.command-palette-item strong,
.command-palette-item small { display: block; }
.command-palette-item strong { font-size: var(--text-sm); }
.command-palette-item small { margin-top: 3px; color: var(--muted); font-size: var(--text-xs); }
.command-palette-empty { padding: 20px; margin: 0; color: var(--muted); text-align: center; font-size: var(--text-sm); }

.screen-help-overlay { display: flex; justify-content: flex-end; }
.screen-help-drawer { width: min(510px, 100%); min-height: 100%; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -18px 0 50px rgba(0, 0, 0, .35); overflow-y: auto; }
.screen-help-header { display: flex; justify-content: space-between; gap: 16px; padding: 18px; border-bottom: 1px solid var(--line); }
.screen-help-header strong,
.screen-help-header span { display: block; }
.screen-help-header strong { color: var(--text); font-size: var(--text-base); }
.screen-help-header span { margin-top: 4px; color: var(--muted); font-size: var(--text-xs); }
.shell-close-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; color: var(--muted); border: 0; background: transparent; border-radius: 7px; cursor: pointer; }
.shell-close-btn:hover { color: var(--text); background: var(--surface-alt); }
.screen-help-content { padding: 30px 18px; }
.screen-help-content h2 { margin: 0 0 10px; color: var(--text); font-size: 24px; }
.screen-help-content > p { margin: 0; color: var(--muted); line-height: 1.55; }
.screen-help-divider { height: 1px; margin: 24px 0 16px; background: var(--line); }
.screen-help-eyebrow { display: block; margin-bottom: 10px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.screen-help-steps { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.screen-help-steps li { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-alt); }
.screen-help-steps li > span { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; background: color-mix(in srgb, var(--blue) 20%, transparent); color: var(--blue); font-size: var(--text-sm); }
.screen-help-steps strong,
.screen-help-steps small { display: block; }
.screen-help-steps strong { color: var(--text); font-size: var(--text-sm); }
.screen-help-steps small { margin-top: 3px; color: var(--muted); font-size: var(--text-xs); }
.help-video-placeholder { min-height: 130px; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 18px; color: var(--muted); border: 1px solid var(--line); border-radius: 12px; background: var(--surface-alt); text-align: center; }
.help-video-placeholder svg { color: var(--green); font-size: 20px; }
.help-video-placeholder strong { color: var(--text); font-size: var(--text-sm); }
.help-video-placeholder small { max-width: 290px; line-height: 1.4; font-size: var(--text-xs); }

.notifications-panel { position: fixed; top: 76px; right: 24px; z-index: 180; width: min(360px, calc(100vw - 32px)); overflow: hidden; background: var(--panel); border: 1px solid var(--line-strong, var(--line)); border-radius: 13px; box-shadow: 0 18px 48px rgba(0, 0, 0, .38); }
.notifications-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 15px 16px; border-bottom: 1px solid var(--line); }
.notifications-panel-header strong,
.notifications-panel-header span { display: block; }
.notifications-panel-header strong { color: var(--text); font-size: var(--text-base); }
.notifications-panel-header span { margin-top: 3px; color: var(--muted); font-size: var(--text-xs); }
.notifications-panel-body { display: flex; gap: 12px; padding: 16px; }
.notification-summary-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.notifications-panel-body strong { display: block; color: var(--text); font-size: var(--text-sm); }
.notifications-panel-body p { margin: 4px 0 0; color: var(--muted); font-size: var(--text-xs); line-height: 1.45; }
.notification-open-btn { width: calc(100% - 32px); margin: 0 16px 16px; padding: 10px; color: var(--on-primary); background: var(--green); border: 0; border-radius: 8px; font-weight: 700; cursor: pointer; }

@media (min-width: 769px) {
  .topbar-desktop { justify-content: initial; gap: 14px; padding: 12px 18px; }
  .topbar-left, .topbar-actions { display: flex; align-items: center; gap: 10px; }
  .topbar-left { flex: 0 0 auto; }
  .topbar-desktop .menu-btn { width: 42px; height: 42px; justify-content: center; padding: 0; border-radius: 11px; color: var(--green); background: color-mix(in srgb, var(--green) 9%, var(--panel)); }
  .topbar-desktop .menu-btn span { display: none; }
  .topbar-desktop .header-brand { min-width: max-content; }
  .global-search-trigger { min-width: 230px; max-width: 590px; flex: 1 1 430px; display: flex; align-items: center; gap: 10px; padding: 11px 13px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 11px; text-align: left; cursor: pointer; }
  .global-search-trigger:hover { border-color: var(--line-strong, var(--green)); color: var(--text); }
  .global-search-trigger > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); }
  .global-search-trigger kbd { margin-left: auto; }
  .topbar-actions { margin-left: auto; }
  .shell-action-btn { width: 42px; height: 42px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
  .header-unit-btn, .header-help-btn { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; }
  .header-help-btn:hover, .header-unit-btn:hover { border-color: var(--green); }
  .header-help-btn { color: var(--text); font-size: var(--text-sm); }

  .mega-menu-overlay { display: block; position: fixed; inset: 0; z-index: 170; background: rgba(1, 7, 14, 0); visibility: hidden; pointer-events: none; transition: background .18s ease, visibility .18s ease; }
  .mega-menu-overlay.active { display: block; visibility: visible; pointer-events: auto; background: rgba(1, 7, 14, .48); }
  .mega-menu-panel.module-menu-panel { position: absolute; top: 0; left: 0; width: min(365px, calc(100vw - 28px)); height: 100%; max-width: none; max-height: none; margin: 0; padding: 14px; border: 0; border-right: 1px solid var(--line); border-radius: 0 14px 14px 0; background: var(--panel); transform: translateX(-103%); transition: transform .2s ease; }
  .mega-menu-overlay.active .mega-menu-panel.module-menu-panel { transform: translateX(0); }
  .module-menu-heading { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 14px; color: var(--text); }
  .module-menu-search { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 12px; color: var(--muted); background: var(--surface-alt); border: 1px solid var(--line); border-radius: 9px; }
  .module-menu-search input { min-width: 0; flex: 1; color: var(--text); background: transparent; border: 0; outline: 0; font: inherit; font-size: var(--text-sm); }
  .module-menu-list { display: grid; gap: 4px; padding-bottom: 16px; }
  .mega-menu-card { width: 100%; min-height: 44px; display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 11px; padding: 10px; aspect-ratio: auto; color: var(--text); text-align: left; font-size: var(--text-sm); }
  .mega-menu-icon { width: 30px; display: grid; place-items: center; color: var(--blue); font-size: 16px; }
  .mega-menu-card:hover .mega-menu-icon, .mega-menu-card.active .mega-menu-icon { color: var(--green); }
}

@media (max-width: 1100px) and (min-width: 769px) {
  .header-help-btn span, .header-unit-btn span { display: none; }
  .header-help-btn, .header-unit-btn { width: 42px; justify-content: center; padding: 0; }
}

/* ========== NAVEGAÇÃO PRINCIPAL AGRUPADA ========== */
.module-sidebar,
.mobile-module-sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 94%, var(--bg));
  border-right: 1px solid var(--line);
}

.module-sidebar-header,
.mobile-module-sidebar-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.module-sidebar-brand {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 11px;
}

.module-sidebar-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--green) 34%, var(--line));
  border-radius: 11px;
  background: color-mix(in srgb, var(--green) 14%, var(--surface-alt));
}

.module-sidebar-logo img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.module-sidebar-brand-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.module-sidebar-brand-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: var(--text-base);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-sidebar-brand-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-sidebar-icon-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
}

.module-sidebar-icon-btn:hover {
  color: var(--text);
  background: var(--surface-alt);
  border-color: var(--line);
}

.module-menu-tools {
  flex: 0 0 auto;
  padding: 13px 12px 8px;
}

.module-menu-search {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  margin: 0;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.module-menu-search:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 16%, transparent);
}

.module-menu-search input {
  min-width: 0;
  width: 100%;
  height: 40px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: var(--text-sm);
}

.module-menu-search input::placeholder {
  color: var(--muted);
}

.module-sidebar-scroll {
  min-height: 0;
  flex: 1;
  overflow: hidden auto;
  padding: 2px 10px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong, var(--line)) transparent;
}

.module-sidebar-scroll::-webkit-scrollbar {
  width: 7px;
  display: block;
}

.module-sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--line-strong, var(--line));
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

.module-menu-group {
  margin-top: 14px;
}

.module-menu-group[hidden] {
  display: none;
}

.module-menu-group-title {
  min-height: 22px;
  padding: 0 9px 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-3xs);
  font-weight: 800;
  letter-spacing: .09em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.module-menu-items {
  display: grid;
  gap: 3px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.module-menu-link.mega-menu-card {
  position: relative;
  width: 100%;
  min-height: 42px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 11px;
  padding: 8px 10px;
  aspect-ratio: auto;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 9px;
  box-shadow: none;
  text-align: left;
  cursor: pointer;
}

.module-menu-link.mega-menu-card:hover {
  color: var(--text);
  background: var(--surface-alt);
  border-color: transparent;
}

.module-menu-link.mega-menu-card.active {
  color: var(--text);
  background: color-mix(in srgb, var(--green) 17%, transparent);
  border-color: transparent;
}

.module-menu-link.mega-menu-card.active::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px -1px;
  width: 3px;
  border-radius: 999px;
  background: var(--green);
}

.module-menu-link.mega-menu-card .mega-menu-icon {
  width: 22px;
  flex: 0 0 22px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 16px;
}

.module-menu-link.mega-menu-card:hover .mega-menu-icon,
.module-menu-link.mega-menu-card.active .mega-menu-icon {
  color: var(--green);
}

.module-menu-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  font-size: var(--text-sm);
  font-weight: 550;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-menu-no-results {
  margin: 18px 6px;
  padding: 15px 10px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
  text-align: center;
  font-size: var(--text-sm);
}

.module-menu-no-results[hidden] {
  display: none;
}

.module-sidebar-footer {
  flex: 0 0 auto;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.module-sidebar-footer-action {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 11px;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

.module-sidebar-footer-action:hover {
  color: var(--text);
  border-color: var(--line-strong, var(--line));
}

@media (min-width: 769px) {
  .delfos-nav-shell {
    display: grid;
    grid-template-columns: 306px minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
    transition: grid-template-columns .22s ease;
  }

  .delfos-nav-shell.is-sidebar-collapsed {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .desktop-module-sidebar {
    width: auto;
    height: 100vh;
  }

  .shell-desktop-workspace {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .shell-desktop-workspace .topbar-desktop {
    flex: 0 0 auto;
  }

  .shell-desktop-workspace .main-desktop {
    min-height: 0;
  }

  .is-sidebar-collapsed .module-sidebar-header {
    min-height: 118px;
    flex-direction: column;
    justify-content: center;
    padding: 12px 8px;
  }

  .is-sidebar-collapsed .module-sidebar-brand {
    flex: 0 0 auto;
  }

  .is-sidebar-collapsed .module-sidebar-brand-copy,
  .is-sidebar-collapsed .module-menu-tools,
  .is-sidebar-collapsed .module-menu-group-title,
  .is-sidebar-collapsed .module-menu-label,
  .is-sidebar-collapsed .module-sidebar-footer-action span {
    display: none;
  }

  .is-sidebar-collapsed .module-sidebar-scroll {
    padding-inline: 10px;
  }

  .is-sidebar-collapsed .module-menu-group {
    margin-top: 7px;
  }

  .is-sidebar-collapsed .module-menu-link.mega-menu-card {
    justify-content: center;
    padding-inline: 0;
  }

  .is-sidebar-collapsed .module-menu-link.mega-menu-card .mega-menu-icon {
    flex-basis: 22px;
  }

  .is-sidebar-collapsed .module-sidebar-footer-action {
    justify-content: center;
    padding: 0;
  }
}

@media (max-width: 768px) {
  .mega-menu-mobile-overlay {
    display: flex;
    align-items: stretch;
    padding: 0;
    overflow: hidden;
    background: rgba(1, 7, 14, .58);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
  }

  .mega-menu-mobile-overlay.active {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .mobile-module-sidebar {
    width: min(88vw, 340px);
    height: 100%;
    transform: translateX(-104%);
    box-shadow: 18px 0 48px rgba(0, 0, 0, .35);
    transition: transform .22s ease;
  }

  .mega-menu-mobile-overlay.active .mobile-module-sidebar {
    transform: translateX(0);
  }

  .mobile-module-sidebar-header {
    flex: 0 0 auto;
  }

  .mobile-module-sidebar .module-sidebar-scroll {
    padding-bottom: 28px;
  }

  .mobile-module-sidebar .module-menu-label {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .delfos-nav-shell,
  .mega-menu-mobile-overlay,
  .mobile-module-sidebar {
    transition: none;
  }
}

@media (max-width: 768px) {
  .shell-action-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--muted); }
  .notifications-panel { top: 58px; right: 8px; }
  .screen-help-content { padding: 24px 16px; }
}

/* ===== ABAS TIPO .tab-item (usadas em Agendamento e Gestão Estratégica) =====
   Regra global — precisa funcionar em qualquer largura de tela, não só desktop. */
.tab-item {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--green); border-bottom-color: var(--green); }

@media (max-width: 768px) {
  .tab-item { padding: 10px 10px; font-size: 12.5px; }
}

/* ========== SHELL LAYOUT ========== */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width-expanded);
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 16px;
  gap: 24px;
  overflow-y: auto;
  transition: width var(--transition-slow) ease, padding var(--transition-slow) ease;
}

/* DESKTOP: Sidebar recolhida (padrão) */
@media (min-width: 769px) {
  .sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
    padding: 16px 8px;
    align-items: center;
    gap: 12px;
    overflow-y: hidden;
  }

  .sidebar.collapsed .brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin-bottom: 8px;
  }

  .sidebar.collapsed .brand-text {
    display: none;
  }

  .sidebar.collapsed .muted {
    display: none !important;
  }

  .sidebar.collapsed .nav {
    gap: 12px;
    width: 100%;
  }

  .sidebar.collapsed .nav-item {
    padding: 0;
    justify-content: center;
    width: 48px;
    height: 48px;
    display: flex !important;
    align-items: center;
    font-size: 20px;
    border-radius: 8px;
    margin: 0 auto;
    background: transparent;
    border: none;
    color: var(--muted);
  }

  .sidebar.collapsed .nav-text {
    display: none;
  }

  .sidebar.collapsed .nav-icon {
    font-size: 24px;
  }

  .sidebar.collapsed .nav-item.active {
    background: var(--green);
    color: var(--bg);
  }

  .sidebar.collapsed .sidebar-footer {
    width: 100%;
    margin-top: auto;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .sidebar.collapsed .sidebar-footer .btn {
    width: 48px;
    height: 48px;
    padding: 0;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar.collapsed .btn-text {
    display: none;
  }

  .sidebar.collapsed .btn-icon {
    font-size: 20px;
  }

  .sidebar.toggle-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    margin-bottom: 24px;
    border-radius: 8px;
  }

  .sidebar.toggle-btn:hover {
    color: var(--green);
    background: var(--panel);
  }
}

.sidebar-toggle-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
  color: var(--green);
  background: var(--panel);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
}
/* ========== HEADER (MOBILE) ========== */
.header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 100;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.menu-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  width: auto;
  height: auto;
  display: inline-block;
  visibility: visible;
}
.menu-btn:hover {
  color: var(--green);
}
.header-brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--green);
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0;
}

/* ========== NAVBAR DESKTOP ========== */
.navbar-desktop {
  display: none;
  position: fixed;
  top: 16px;
  right: 24px;
  z-index: 50;
}

@media (min-width: 769px) {
  .navbar-desktop {
    display: flex;
  }
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-alt);
  border: 1.5px solid var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  font-weight: 800;
  font-size: 14px;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.user-unit {
  font-size: 12px;
  color: var(--muted);
}
/* ========== BRAND ========== */
.brand {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 8px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  background: var(--green);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
  font-weight: 800;
  overflow: hidden;
}
.brand-mark:has(img) { background: transparent !important; }
.brand-mark img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.brand-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

/* Marca institucional Delfos One. */
.delfos-one-mark { color: var(--green); display: inline-flex; align-items: center; white-space: nowrap; }
.muted {
  font-size: 12px;
  color: var(--muted);
  padding: 12px;
  background: var(--panel);
  border-radius: 6px;
}
/* ========== NAVIGATION ========== */
.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.nav-item {
  padding: 12px 16px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-item:hover {
  background: var(--panel);
  color: var(--text);
}
.nav-item.active {
  background: var(--menu-active);
  color: var(--text);
  border-left-color: var(--green);
  font-weight: 600;
}
/* ========== BUTTONS ========== */
/* Botões são definidos em components.css. Não sobrescrever estados aqui. */
/* ========== SIDEBAR FOOTER ========== */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
/* ========== RESPONSIVE: MOBILE ========== */
@media (max-width: 768px) {
  /* Gráficos e containers responsivos */
  canvas {
    max-width: 100% !important;
    height: auto !important;
  }
  .dashboard-cards {
    grid-template-columns: 1fr;
  }
  .dashboard-charts {
    grid-template-columns: 1fr;
  }

  /* ===== NOVO SHELL MOBILE: mega menu tela cheia + bottom sheet ===== */
  .shell-mobile {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* corrige barra de endereço do navegador comendo altura no mobile */
    overflow: hidden;
    position: relative;
  }

  .topbar-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    flex-shrink: 0;
    position: relative;
    z-index: 60;
  }

  .user-dropdown {
    position: absolute;
    top: 56px;
    right: 12px;
    left: 12px;
    max-width: 280px;
    margin-left: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 70;
  }

  .user-dropdown.active {
    display: flex;
  }

  .user-dropdown-header {
    padding: 10px 12px 12px 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
  }

  .user-dropdown-name {
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
  }

  .user-dropdown-unit {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
  }

  .user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    text-align: left;
    color: var(--text);
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
  }

  .user-dropdown-danger {
    color: var(--danger);
  }

  .menu-btn-mobile {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
  }

  .brand-mobile {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    flex-shrink: 1;
  }

  .brand-mobile .brand-mark {
    width: 28px;
    height: 28px;
    background: var(--green);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg);
    font-weight: 800;
    font-size: 13px;
    flex-shrink: 0;
  }

  .brand-mobile-text {
    color: var(--green);
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-avatar-btn-mobile {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-alt);
    border: 1.5px solid var(--green);
    color: var(--green);
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .user-avatar-btn-mobile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* ===== SELETOR DE SEÇÃO (substitui as abas roláveis) ===== */
  .section-picker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-alt);
    flex-shrink: 0;
    cursor: pointer;
  }

  .section-picker .sp-current {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
  }

  .section-picker .sp-current .sp-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
  }

  .section-picker .sp-chevron {
    color: var(--muted);
    font-size: 11px;
    transition: transform 0.2s ease;
  }

  .section-picker.open .sp-chevron {
    transform: rotate(180deg);
  }

  .section-list {
    display: none;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
  }

  .section-list.open {
    display: block;
  }

  .section-list .sp-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid var(--line);
  }

  .section-list .sp-option:last-child {
    border-bottom: none;
  }

  .section-list .sp-option.active {
    color: var(--green);
    font-weight: 700;
    background: rgba(34, 197, 94, 0.06);
  }

  .section-list .sp-option .sp-check {
    color: var(--green);
    font-size: 12px;
  }

  .main-mobile {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .main-mobile #view {
    padding: 16px;
  }

  /* ===== MEGA MENU TELA CHEIA ===== */
  .mega-menu-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 200;
    padding: 20px 16px;
    overflow-y: auto;
  }

  .mega-menu-mobile-overlay.active {
    display: block;
  }

  .mega-menu-mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
  }

  .mega-menu-mobile-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
  }

  .mega-menu-mobile-close {
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--muted);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 16px;
  }

  .mega-card-mobile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 0 4px;
    overflow-y: auto;
  }

  .mega-card-mobile-grid-item {
    background: var(--surface-alt);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
  }

  .mega-card-mobile-grid-item.active {
    border-color: var(--green);
    background: rgba(34, 197, 94, 0.12);
  }

  .mega-card-mobile-icon {
    font-size: 18px;
    flex-shrink: 0;
    color: var(--muted);
  }

  .mega-card-mobile-grid-item.active .mega-card-mobile-icon {
    color: var(--green);
  }

  .mega-card-mobile-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
  }

  .mega-card-mobile-grid-item.active .mega-card-mobile-title {
    color: var(--green);
  }

  /* ===== BOTTOM SHEET DO USUÁRIO ===== */
  .user-sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    align-items: flex-end;
  }

  .user-sheet-overlay.active {
    display: flex;
  }

  .user-sheet {
    width: 100%;
    background: var(--panel);
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    padding: 10px 18px 28px 18px;
  }

  .sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--line);
    border-radius: 4px;
    margin: 6px auto 16px auto;
  }

  .sheet-header {
    padding-bottom: 14px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--line);
  }

  .sheet-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
  }

  .sheet-unit {
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
  }

  .sheet-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    padding: 14px 6px;
    font-size: 14px;
    color: var(--text);
    border-bottom: 1px solid var(--line);
  }

  .sheet-item:last-child {
    border-bottom: none;
  }

  .sheet-item.sheet-danger {
    color: var(--danger);
  }
}
/* ========== DESKTOP: MEGA MENU + ABAS (novo shell) ========== */
@media (min-width: 769px) {
  .shell-desktop {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  .topbar-desktop {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    position: relative;
    z-index: 60;
  }

  .topbar-desktop .menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .topbar-desktop .menu-btn:hover {
    border-color: var(--green);
    color: var(--green);
  }

  .topbar-desktop .header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--green);
    font-size: 16px;
  }

  .topbar-desktop .header-brand .brand-mark {
    width: 32px;
    height: 32px;
    background: var(--green);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg);
    font-weight: 800;
  }

  /* ===== MENU DO USUÁRIO (dropdown no ícone) ===== */
  .user-menu-wrapper {
    position: relative;
  }

  .user-avatar-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface-alt);
    border: 1.5px solid var(--green);
    color: var(--green);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .user-avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 240px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 70;
  }

  .user-dropdown.active {
    display: flex;
  }

  .user-dropdown-header {
    padding: 10px 12px 12px 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
  }

  .user-dropdown-name {
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
  }

  .user-dropdown-unit {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
  }

  .user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    text-align: left;
    color: var(--text);
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
    width: 100%;
  }

  .user-dropdown-item:hover {
    background: var(--surface-alt);
  }

  .user-dropdown-danger {
    color: var(--danger);
  }

  /* ===== MEGA MENU (Agendamentos / Configurações) ===== */
  .mega-menu-overlay {
    display: none;
    position: absolute;
    top: 100%;
    left: 24px;
    z-index: 65;
  }

  .mega-menu-overlay.active {
    display: block;
  }

  .mega-menu-panel {
    margin-top: 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
    padding: 16px;
    max-width: min(860px, calc(100vw - 48px));
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Scroll fino no mesmo padrão do .perm-tree-box, com hover verde — só aqui,
     não mexe na regra global que esconde scrollbar no resto do app. */
  .mega-menu-panel::-webkit-scrollbar { width: 6px; display: block; }
  .mega-menu-panel::-webkit-scrollbar-track { background: transparent; }
  .mega-menu-panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; transition: background 0.15s; }
  .mega-menu-panel::-webkit-scrollbar-thumb:hover { background: var(--green); }
  .mega-menu-panel { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

  .mega-menu-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
  }

  /* Telas bem estreitas: reduz pra 4 colunas e encolhe cards/ícone/fonte
     em vez de depender só do scroll. */
  @media (max-width: 480px) {
    .mega-menu-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
    .mega-menu-card { padding: 10px 4px; font-size: 9px; gap: 4px; }
    .mega-menu-icon { font-size: 14px; }
  }

  .mega-menu-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 8px;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    color: var(--text);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    transition: all 0.2s ease;
  }

  .mega-menu-card:hover,
  .mega-menu-card.active {
    border-color: var(--green);
    background: rgba(34, 197, 94, 0.1);
    color: var(--green);
  }

  .mega-menu-card.not-implemented {
    opacity: 0.7;
  }

  .mega-menu-card.not-implemented:hover {
    border-color: var(--line);
    background: var(--surface-alt);
    color: var(--text);
    opacity: 1;
  }

  .mega-menu-icon {
    font-size: 18px;
  }

  /* ===== ABAS HORIZONTAIS (dentro de Agendamentos) ===== */
  .schedule-tabs {
    display: flex;
    gap: 4px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    flex-shrink: 0;
  }

  .main-desktop {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* ===== CONFIGURAÇÕES: sidebar fixa (padrão mockup) ===== */
  .settings-desktop-body {
    display: flex;
    flex: 1;
    overflow: hidden;
  }

  .settings-side {
    width: 238px;
    flex: 0 0 238px;
    border-right: 1px solid var(--line);
    padding: 16px 0;
    overflow-y: auto;
  }

  .settings-side-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 9px 20px;
    font-size: 12.5px;
    color: var(--muted);
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
  }

  .settings-side-item:hover {
    color: var(--text);
  }

  .settings-side-item.active {
    color: var(--text);
    border-left-color: var(--green);
    background: rgba(34, 197, 94, 0.06);
  }

  .settings-main {
    flex: 1;
    overflow-y: auto;
  }

  /* Conteúdo segue o respiro padrão do guia em relação à sidebar. */
  .settings-main > * {
    padding-left: var(--space-4) !important;
  }

  /* A faixa institucional encosta diretamente no menu de Configurações. */
  .module-identity-band + .settings-desktop-body {
    margin-top: calc(0px - var(--space-3-5));
    margin-left: calc(0px - var(--space-6));
    margin-right: calc(0px - var(--space-6));
  }
  .module-identity-band + .settings-desktop-body .settings-side {
    padding-top: var(--space-3);
  }

  /* Navegação agora é pela sidebar — botões "voltar" internos ficam redundantes */
  #lookupBackBtn,
  #userBackBtn,
  #groupBackBtn {
    display: none;
  }
}

/* Sobrescritas finais do shell moderno: vêm depois do shell legado. */
@media (min-width: 769px) {
  .topbar-desktop { justify-content: initial; gap: 14px; padding: 12px 18px; }
  .topbar-left, .topbar-actions { display: flex; align-items: center; gap: 10px; }
  .topbar-left { flex: 0 0 auto; }
  .topbar-desktop .menu-btn { width: 42px; height: 42px; justify-content: center; padding: 0; border-radius: 11px; color: var(--green); background: color-mix(in srgb, var(--green) 9%, var(--panel)); }
  .topbar-desktop .menu-btn span { display: none; }
  .topbar-desktop .header-brand { min-width: max-content; }
  .global-search-trigger { min-width: 230px; max-width: 590px; flex: 1 1 430px; display: flex; align-items: center; gap: 10px; padding: 11px 13px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 11px; text-align: left; cursor: pointer; }
  .global-search-trigger:hover { border-color: var(--line-strong, var(--green)); color: var(--text); }
  .global-search-trigger > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); }
  .global-search-trigger kbd { margin-left: auto; }
  .topbar-actions { margin-left: auto; }
  .shell-action-btn { width: 42px; height: 42px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
  .header-unit-btn, .header-help-btn { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; }
  .header-help-btn:hover, .header-unit-btn:hover { border-color: var(--green); }
  .header-help-btn { color: var(--text); font-size: var(--text-sm); }
  .mega-menu-overlay { display: block; position: fixed; inset: 0; z-index: 170; background: rgba(1, 7, 14, 0); visibility: hidden; pointer-events: none; transition: background .18s ease, visibility .18s ease; }
  .mega-menu-overlay.active { display: block; visibility: visible; pointer-events: auto; background: rgba(1, 7, 14, .48); }
  .mega-menu-panel.module-menu-panel { position: absolute; top: 0; left: 0; width: min(365px, calc(100vw - 28px)); height: 100%; max-width: none; max-height: none; margin: 0; padding: 14px; border: 0; border-right: 1px solid var(--line); border-radius: 0 14px 14px 0; background: var(--panel); transform: translateX(-103%); transition: transform .2s ease; }
  .mega-menu-overlay.active .mega-menu-panel.module-menu-panel { transform: translateX(0); }
  .module-menu-heading { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 14px; color: var(--text); }
  .module-menu-search { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 12px; color: var(--muted); background: var(--surface-alt); border: 1px solid var(--line); border-radius: 9px; }
  .module-menu-search input { min-width: 0; flex: 1; color: var(--text); background: transparent; border: 0; outline: 0; font: inherit; font-size: var(--text-sm); }
  .module-menu-list { display: grid; gap: 4px; padding-bottom: 16px; }
  .mega-menu-card { width: 100%; min-height: 44px; display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 11px; padding: 10px; aspect-ratio: auto; color: var(--text); text-align: left; font-size: var(--text-sm); }
  .mega-menu-icon { width: 30px; display: grid; place-items: center; color: var(--blue); font-size: 16px; }
  .mega-menu-card:hover .mega-menu-icon, .mega-menu-card.active .mega-menu-icon { color: var(--green); }
}

@media (max-width: 1100px) and (min-width: 769px) {
  .header-help-btn span, .header-unit-btn span { display: none; }
  .header-help-btn, .header-unit-btn { width: 42px; justify-content: center; padding: 0; }
}
