/* HB Telecom ERP — layout página inteira (sidebar + conteúdo full width) */

:root {
  --ui-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --ui-sidebar-width: 260px;
  --ui-topbar-height: 60px;
  --ui-radius-sm: 8px;
  --ui-radius-md: 12px;
  --ui-radius-lg: 16px;
  --ui-radius-xl: 20px;
  --ui-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --ui-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --ui-shadow-md: 0 4px 20px rgba(15, 23, 42, 0.08);
  --ui-shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --ui-border: color-mix(in srgb, var(--app-text-color) 10%, transparent);
  --ui-border-strong: color-mix(in srgb, var(--app-text-color) 16%, transparent);
  --ui-muted: color-mix(in srgb, var(--app-text-color) 58%, transparent);
  --ui-sidebar-hover-bg: #324158;
  --ui-nav-icon-size: 22px;
  --ui-nav-icon-box: 24px;
  --ui-transition: 0.18s ease;
}

/* —— Base —— */
body {
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  letter-spacing: -0.011em;
  min-height: 100vh;
}

::selection {
  background: color-mix(in srgb, var(--app-button-color) 28%, transparent);
  color: var(--app-text-color);
}

/* —— App shell: sidebar + área principal —— */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.app-sidebar {
  width: var(--ui-sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--app-header-bg-color);
  color: var(--app-header-text-color);
  border-right: 1px solid color-mix(in srgb, var(--app-header-text-color) 10%, transparent);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 90;
}

.app-sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--app-header-text-color) 10%, transparent);
}

.app-brand-link,
.app-topbar-brand-link {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  color: inherit;
  text-decoration: none;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
}

.app-brand-link:hover,
.app-brand-link:focus,
.app-topbar-brand-link:hover,
.app-topbar-brand-link:focus {
  color: inherit;
  text-decoration: none;
  background: transparent;
  opacity: 1;
  transform: none;
  filter: none;
}

.app-sidebar-brand .app-brand-link {
  width: 100%;
}

.app-sidebar-brand .brand-logo-text {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--app-header-text-color);
  line-height: 1.2;
  display: block;
}

.app-sidebar-brand .brand-logo-image {
  max-height: 40px;
  max-width: 100%;
}

.app-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 0 20px;
  flex: 1;
}

.app-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 11px 18px;
  min-height: 44px;
  border-radius: 0;
  color: var(--app-header-link-color);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--ui-transition), color var(--ui-transition);
}

.app-sidebar nav a .nav-icon,
.app-sidebar .nav-group-toggle .nav-icon,
.app-sidebar nav .nav-logout-btn .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ui-nav-icon-box);
  height: var(--ui-nav-icon-box);
  flex-shrink: 0;
  opacity: 1;
  color: #fff;
}

.app-sidebar nav a .nav-icon svg,
.app-sidebar nav a .nav-icon .nav-icon-svg-file,
.app-sidebar nav .nav-logout-btn .nav-icon svg,
.app-sidebar nav .nav-logout-btn .nav-icon .nav-icon-svg-file,
.nav-group-toggle .nav-icon svg,
.nav-group-toggle .nav-icon .nav-icon-svg-file {
  width: var(--ui-nav-icon-size);
  height: var(--ui-nav-icon-size);
  display: block;
}

.app-sidebar nav .sidebar-logout-form {
  margin: 0;
  padding: 0;
  width: 100%;
}

.app-sidebar nav .nav-logout-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 11px 18px;
  min-height: 44px;
  border-radius: 0 !important;
  color: var(--app-header-link-color);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: background var(--ui-transition), color var(--ui-transition);
  font-family: inherit;
  text-align: left;
}

.app-sidebar nav .nav-logout-btn:hover {
  background: var(--ui-sidebar-hover-bg) !important;
  color: #fff !important;
  filter: none !important;
  transform: none !important;
}

.app-sidebar nav .nav-logout-btn .nav-label {
  line-height: 1.25;
  color: inherit;
}

.app-sidebar .nav-icon-img {
  width: var(--ui-nav-icon-size);
  height: var(--ui-nav-icon-size);
  display: block;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
  opacity: 1;
}

.app-sidebar nav a .nav-label {
  line-height: 1.25;
  color: inherit;
}

.app-sidebar nav a:hover:not(.active) {
  background: var(--ui-sidebar-hover-bg);
  color: #fff;
}

.app-sidebar nav a:hover:not(.active) .nav-icon {
  opacity: 1;
  color: #fff;
}

.app-sidebar nav a.active {
  background: var(--ui-sidebar-hover-bg);
  color: #fff !important;
  font-weight: 600;
  box-shadow: none;
}

.app-sidebar nav a.active .nav-icon {
  opacity: 1;
  color: #fff;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.app-sidebar .nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 11px 18px;
  min-height: 44px;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--app-header-link-color);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--ui-transition), color var(--ui-transition);
}

.nav-group-toggle .nav-label {
  flex: 1;
  line-height: 1.25;
}

.nav-group-toggle .nav-chevron {
  font-size: 11px;
  opacity: 0.75;
  transition: transform var(--ui-transition);
}

.nav-group.is-open .nav-chevron {
  transform: rotate(180deg);
}

.app-sidebar .nav-group-toggle:hover,
.app-sidebar .nav-group.is-open > .nav-group-toggle {
  background: var(--ui-sidebar-hover-bg) !important;
  color: #fff !important;
  box-shadow: none !important;
}

.nav-group-toggle:hover .nav-icon,
.nav-group.is-open > .nav-group-toggle .nav-icon {
  opacity: 1;
  color: #fff;
}

.nav-group-toggle:hover .nav-chevron,
.nav-group.is-open > .nav-group-toggle .nav-chevron {
  opacity: 1;
  color: #fff;
}

.nav-submenu {
  display: none;
  flex-direction: column;
  gap: 0;
  padding-left: 0;
}

.nav-group.is-open .nav-submenu {
  display: flex;
}

.app-sidebar nav a.nav-sublink {
  padding-left: 48px;
  min-height: 40px;
  font-size: 12px;
}

.app-sidebar nav a.nav-sublink .nav-icon {
  display: none;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--app-background-color);
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--ui-topbar-height);
  padding: 0 24px;
  background: var(--app-card-bg-color);
  border-bottom: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow-xs);
  position: sticky;
  top: 0;
  z-index: 80;
}

.app-topbar-title {
  display: none;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--app-text-color);
}

.app-topbar-brand-link.app-topbar-title {
  text-decoration: none;
}

.header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--app-header-text-color);
  background: color-mix(in srgb, var(--app-header-text-color) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--app-header-text-color) 16%, transparent);
  max-width: min(220px, 48vw);
  transition: background var(--ui-transition), color var(--ui-transition);
}

.header-user-chip:hover {
  background: color-mix(in srgb, var(--app-header-text-color) 16%, transparent);
  color: #fff;
}

.header-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  flex-shrink: 0;
}

.header-user-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.theme-mode-form {
  width: auto;
  margin: 0;
}

/* —— Theme switch (moderno) —— */
.theme-switch {
  position: relative;
  width: 72px;
  height: 36px;
  flex-shrink: 0;
  --theme-thumb-offset: 36px;
}

.theme-switch-track {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(135deg, #60A5FA 0%, #818CF8 52%, #312E81 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 2px 10px rgba(37, 99, 235, 0.28),
    0 0 0 1px rgba(15, 23, 42, 0.08);
  transition: box-shadow 0.28s ease;
}

.theme-switch[data-active="dark"] .theme-switch-track {
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 55%, #020617 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 2px 14px rgba(2, 6, 23, 0.45),
    0 0 0 1px rgba(148, 163, 184, 0.12);
}

.theme-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFFFFF 0%, #F1F5F9 100%);
  box-shadow:
    0 2px 8px rgba(15, 23, 42, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.65);
  transition: transform 0.38s cubic-bezier(0.34, 1.35, 0.64, 1), box-shadow 0.28s ease;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-switch-thumb-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.72);
  transition: opacity 0.28s ease, transform 0.32s cubic-bezier(0.34, 1.35, 0.64, 1);
  pointer-events: none;
}

.theme-switch-thumb-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.theme-switch-thumb-icon--sun svg {
  width: 17px;
  height: 17px;
}

.theme-switch[data-active="light"] .theme-switch-thumb-icon--sun {
  opacity: 1;
  transform: scale(1);
  color: #F59E0B;
  filter: drop-shadow(0 1px 2px rgba(245, 158, 11, 0.35));
}

.theme-switch[data-active="dark"] .theme-switch-thumb-icon--moon {
  opacity: 1;
  transform: scale(1);
  color: #0F172A;
  filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.2));
}

.theme-switch[data-active="dark"] .theme-switch-thumb {
  transform: translateX(var(--theme-thumb-offset));
  background: linear-gradient(180deg, #E2E8F0 0%, #CBD5E1 100%);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.15);
}

.theme-switch-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.95);
  z-index: 1;
  transition: opacity 0.28s ease, transform 0.32s ease, color 0.28s ease;
  pointer-events: none;
}

.theme-switch-icon svg {
  width: 15px;
  height: 15px;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.18));
}

.theme-switch-icon--sun svg {
  width: 16px;
  height: 16px;
}

.theme-switch-icon--sun {
  left: 9px;
}

.theme-switch-icon--moon {
  right: 8px;
}

/* Ícone no track = lado inativo (oposto ao thumb) */
.theme-switch[data-active="light"] .theme-switch-icon--sun {
  opacity: 0;
  transform: translateY(-50%) scale(0.6);
}

.theme-switch[data-active="light"] .theme-switch-icon--moon {
  opacity: 0.92;
  transform: translateY(-50%) scale(1);
}

.theme-switch[data-active="dark"] .theme-switch-icon--moon {
  opacity: 0;
  transform: translateY(-50%) scale(0.6);
}

.theme-switch[data-active="dark"] .theme-switch-icon--sun {
  opacity: 0.92;
  transform: translateY(-50%) scale(1);
}

.theme-switch-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 28%,
    rgba(255, 255, 255, 0.28) 50%,
    transparent 72%
  );
  transform: translateX(-120%);
  opacity: 0;
  pointer-events: none;
}

.theme-switch:hover .theme-switch-track {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 4px 16px rgba(37, 99, 235, 0.34),
    0 0 0 1px rgba(15, 23, 42, 0.08);
}

.theme-switch[data-active="dark"]:hover .theme-switch-track {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 18px rgba(2, 6, 23, 0.55),
    0 0 0 1px rgba(148, 163, 184, 0.16);
}

.theme-switch.is-switching .theme-switch-shimmer {
  animation: theme-switch-shimmer 0.65s ease;
}

.theme-switch[data-active="light"].is-switching .theme-switch-thumb {
  animation: theme-switch-pulse-light 0.45s ease;
}

.theme-switch[data-active="dark"].is-switching .theme-switch-thumb {
  animation: theme-switch-pulse-dark 0.45s ease;
}

.theme-switch-zone {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 3;
  box-shadow: none !important;
  border-radius: 0;
}

.theme-switch-zone--light {
  left: 0;
  border-radius: 999px 0 0 999px;
}

.theme-switch-zone--dark {
  right: 0;
  border-radius: 0 999px 999px 0;
}

.theme-switch-zone:focus-visible {
  outline: 2px solid var(--app-button-color);
  outline-offset: 2px;
}

.theme-switch:has(.theme-switch-zone:active) .theme-switch-thumb {
  transform: scale(0.92);
}

.theme-switch[data-active="dark"]:has(.theme-switch-zone:active) .theme-switch-thumb {
  transform: translateX(var(--theme-thumb-offset)) scale(0.92);
}

.theme-switch.is-switching .theme-switch-track {
  animation: theme-track-glow 0.55s ease;
}

@keyframes theme-track-glow {
  0%, 100% { filter: brightness(1); }
  45% { filter: brightness(1.12); }
}

@keyframes theme-switch-shimmer {
  0% {
    opacity: 0;
    transform: translateX(-120%);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(120%);
  }
}

@keyframes theme-switch-pulse-light {
  0%, 100% {
    transform: translateX(0) scale(1);
    box-shadow:
      0 2px 8px rgba(15, 23, 42, 0.22),
      0 0 0 0 rgba(59, 130, 246, 0.45);
  }
  50% {
    transform: translateX(0) scale(1.06);
    box-shadow:
      0 4px 14px rgba(15, 23, 42, 0.28),
      0 0 0 6px rgba(59, 130, 246, 0);
  }
}

@keyframes theme-switch-pulse-dark {
  0%, 100% {
    transform: translateX(var(--theme-thumb-offset)) scale(1);
    box-shadow:
      0 2px 10px rgba(0, 0, 0, 0.45),
      0 0 0 0 rgba(148, 163, 184, 0.35);
  }
  50% {
    transform: translateX(var(--theme-thumb-offset)) scale(1.06);
    box-shadow:
      0 4px 16px rgba(0, 0, 0, 0.5),
      0 0 0 6px rgba(148, 163, 184, 0);
  }
}

html.theme-transitioning,
html.theme-transitioning body {
  transition: background-color 0.4s ease, color 0.35s ease;
}

html.theme-transitioning .app-sidebar,
html.theme-transitioning .app-topbar,
html.theme-transitioning .card,
html.theme-transitioning .app-main {
  transition: background-color 0.4s ease, border-color 0.35s ease, color 0.35s ease;
}

.login-theme-wrap {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.login-theme-wrap::before {
  content: 'Aparência';
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ui-muted);
}

.despesa-rec-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  color: #1D4ED8;
  background: color-mix(in srgb, #3B82F6 14%, transparent);
  vertical-align: middle;
}

.mobile-menu-toggle {
  display: none;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  height: 36px;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-menu-toggle-icon {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 18px;
  height: 18px;
}

.mobile-menu-toggle-icon span {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.24s ease, opacity 0.18s ease;
  transform-origin: center;
}

.mobile-menu-toggle[aria-expanded="true"] .mobile-menu-toggle-icon span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle[aria-expanded="true"] .mobile-menu-toggle-icon span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.mobile-menu-toggle[aria-expanded="true"] .mobile-menu-toggle-icon span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-nav-close {
  display: none;
}

.mobile-nav-overlay {
  display: none;
}

/* Conteúdo ocupa toda a largura disponível */
.container.app-content {
  max-width: none !important;
  width: 100%;
  margin: 0 !important;
  flex: 1;
  padding: 24px 28px 36px;
  box-sizing: border-box;
}

/* —— Cards —— */
.card {
  border-radius: var(--ui-radius-lg);
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow-sm);
  padding: 22px 24px;
}

.app-page > h2,
.inst-page > h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* —— Métricas —— */
.metric-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--ui-radius-md);
  border: 1px solid var(--ui-border);
  transition: transform var(--ui-transition), box-shadow var(--ui-transition);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--app-button-color),
    color-mix(in srgb, var(--app-button-color) 55%, #818cf8)
  );
}

.metric-card.cat-cor-metric-card::before {
  display: none;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--ui-shadow-md);
}

.metric-card strong {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.despesas-total-card::before {
  background: linear-gradient(90deg, #991b1b, #dc2626);
}

.os-page-form-panel {
  border-radius: var(--ui-radius-md);
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow-xs);
}

/* —— Formulários —— */
label {
  font-size: 13px;
  font-weight: 600;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--app-button-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-button-color) 22%, transparent);
}

button:not(.btn-mini):not(.mobile-menu-toggle):not(.mobile-nav-close):not(.nav-group-toggle):not(.tech-phone-trigger):not(.tech-copy-pwd):not(.header-logout-btn):not(.theme-switch-zone):not(.btn-danger):not(.btn-cancel-like):not(.doc-card-btn):not(.receita-mes-card):not(.venda-mes-pick):not(.receita-filter-btn):not(.nav-logout-btn) {
  border-radius: var(--ui-radius-sm);
  font-weight: 700;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--btn-primary) 32%, transparent);
  transition: filter var(--ui-transition), transform 0.12s ease;
}

/* —— Tabelas —— */
table {
  border-radius: var(--ui-radius-md);
  overflow: hidden;
  border: 1px solid var(--ui-border);
}

th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ui-muted);
  padding: 12px 14px !important;
}

td {
  padding: 11px 14px !important;
  font-size: 13px;
}

/* —— Botões / status —— */
.btn-mini {
  border-radius: var(--ui-radius-sm);
  font-weight: 700;
  transition: filter var(--ui-transition), transform 0.1s ease;
}

.theme-palette > summary,
.header-logout-btn {
  border-radius: var(--ui-radius-sm) !important;
  background: color-mix(in srgb, var(--app-text-color) 6%, var(--app-form-bg-color)) !important;
  border: 1px solid var(--ui-border) !important;
  color: var(--app-text-color) !important;
}

.header-logout-btn:hover {
  filter: brightness(1.04);
}

/* —— Tema escuro: legibilidade —— */
[data-theme-preset="dark"] {
  color-scheme: dark;
}

[data-theme-preset="dark"] .muted,
[data-theme-preset="dark"] .inst-lead,
[data-theme-preset="dark"] .app-page .inst-lead {
  color: #94A3B8 !important;
}

[data-theme-preset="dark"] label {
  color: #E2E8F0;
}

[data-theme-preset="dark"] th {
  color: #94A3B8 !important;
  background: color-mix(in srgb, var(--app-table-bg-color) 85%, #000) !important;
}

[data-theme-preset="dark"] .theme-switch-track {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 2px 14px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(148, 163, 184, 0.14);
}

[data-theme-preset="dark"] .app-topbar {
  background: var(--app-card-bg-color);
  border-bottom-color: #334155;
}

[data-theme-preset="dark"] .os-field label,
[data-theme-preset="dark"] .inst-dl dt {
  color: #94A3B8;
}

[data-theme-preset="dark"] input,
[data-theme-preset="dark"] select,
[data-theme-preset="dark"] textarea {
  color: var(--app-text-color);
  background: var(--app-form-bg-color);
  border-color: #475569;
}

[data-theme-preset="dark"] .flash.success {
  background: #064E3B;
  color: #A7F3D0;
  border-color: #059669;
}

[data-theme-preset="dark"] .flash.error {
  background: #7F1D1D;
  color: #FECACA;
  border-color: #DC2626;
}

.flash {
  border-radius: var(--ui-radius-md);
  border: 1px solid transparent;
}

.flash.success {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.flash.error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.muted {
  color: var(--ui-muted);
}

.dashboard-chart-mode-btn {
  border-radius: 999px;
}

.dashboard-chart-mode-btn.is-active {
  box-shadow: 0 2px 10px color-mix(in srgb, var(--app-button-color) 40%, transparent);
}

/* —— Login (tela cheia) —— */
.login-container:not(.has-login-bg) {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, color-mix(in srgb, var(--app-button-color) 22%, transparent), transparent),
    linear-gradient(160deg, #0f172a 0%, #1e293b 45%, #0f172a 100%);
}

.login-card {
  border-radius: var(--ui-radius-xl);
  box-shadow: var(--ui-shadow-lg);
  padding: 28px;
}

/* —— Scrollbar —— */
@media (min-width: 901px) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--app-text-color) 22%, transparent);
    border-radius: 999px;
  }
}

/* —— Mobile: drawer lateral —— */
@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .theme-mode-label {
    display: none;
  }

  .theme-switch {
    width: 68px;
    height: 34px;
    --theme-thumb-offset: 34px;
  }

  .theme-switch[data-active="dark"] .theme-switch-thumb {
    transform: translateX(var(--theme-thumb-offset));
  }

  .theme-switch[data-active="dark"]:has(.theme-switch-zone:active) .theme-switch-thumb {
    transform: translateX(var(--theme-thumb-offset)) scale(0.92);
  }

  .app-topbar {
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 130;
    border-bottom-color: #000;
  }

  [data-theme-preset="dark"] .app-topbar {
    border-bottom-color: #000;
  }

  .app-sidebar-brand {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .app-sidebar {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--mobile-topbar-bottom, var(--ui-topbar-height, 60px));
    width: 100%;
    height: calc(100dvh - var(--mobile-topbar-bottom, var(--ui-topbar-height, 60px)));
    max-height: none;
    z-index: 120;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    background: var(--app-card-bg-color);
    color: var(--app-text-color);
    transform: translateX(-100%);
    overflow-x: hidden;
    overflow-y: auto;
    opacity: 1;
    visibility: visible;
    pointer-events: none;
    box-shadow: none;
    border-top: none;
    border-bottom: 1px solid var(--ui-border);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s ease;
    will-change: transform;
  }

  body.mobile-menu-open .app-sidebar {
    transform: translateX(0);
    pointer-events: auto;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.24);
  }

  .app-sidebar nav,
  #app-side-nav {
    padding: 0 0 max(12px, env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    gap: 0 !important;
  }

  .app-sidebar nav a,
  .app-sidebar nav .nav-logout-btn,
  .app-sidebar .nav-group-toggle {
    color: var(--app-text-color);
  }

  .app-sidebar nav a .nav-icon,
  .app-sidebar .nav-group-toggle .nav-icon,
  .app-sidebar nav .nav-logout-btn .nav-icon {
    color: var(--app-text-color);
  }

  .app-sidebar nav a:hover:not(.active),
  .app-sidebar .nav-group-toggle:hover,
  .app-sidebar .nav-group.is-open > .nav-group-toggle,
  .app-sidebar nav .nav-logout-btn:hover {
    background: color-mix(in srgb, var(--app-text-color) 8%, transparent);
    color: var(--app-text-color);
  }

  .app-sidebar nav a.active {
    background: color-mix(in srgb, var(--app-text-color) 12%, transparent);
    color: var(--app-text-color);
  }

  .mobile-menu-toggle {
    display: inline-flex !important;
  }

  .mobile-nav-close {
    display: none !important;
  }

  .mobile-nav-overlay {
    display: block;
    position: fixed;
    top: var(--mobile-topbar-bottom, var(--ui-topbar-height, 60px));
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(2, 6, 23, 0.55);
    z-index: 110;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
  }

  body.mobile-menu-open .mobile-nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .app-topbar-title {
    display: block;
    flex: 1;
    min-width: 0;
  }

  .container.app-content {
    padding: 16px;
  }
}
