/* 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: 200ms 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;
  align-items: stretch;
  gap: 0;
  min-height: 100vh;
  width: 100%;
  margin: 0;
  padding: 0;
}

.app-sidebar {
  width: var(--ui-sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--app-shell-bg, var(--app-header-bg-color));
  color: var(--app-header-text-color);
  border: none;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 90;
  margin: 0;
  padding: 0;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  min-height: var(--ui-topbar-height);
  height: var(--ui-topbar-height);
  padding: 0 18px;
  margin: 0;
  box-sizing: border-box;
  border: none;
}

.app-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 0 20px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.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: 4px;
  padding: 8px 0 20px;
  flex: 1;
}

.app-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 15px 18px;
  min-height: 52px;
  border-radius: 0;
  color: var(--app-header-link-color);
  text-decoration: none;
  font-size: 16px;
  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: 15px 18px;
  min-height: 52px;
  border-radius: 0 !important;
  color: var(--app-header-link-color);
  text-decoration: none;
  font-size: 16px;
  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:not(.app-sidebar--docs) 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:not(.app-sidebar--docs) 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:not(.app-sidebar--docs) .nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 14px 18px;
  min-height: 50px;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--app-header-link-color);
  font-size: 15px;
  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);
}

.app-sidebar:not(.app-sidebar--docs) .nav-group.is-open > .nav-group-toggle > .nav-chevron:not(.nav-chevron--docs) {
  transform: rotate(180deg);
}

.app-sidebar:not(.app-sidebar--docs) .nav-group-toggle:hover,
.app-sidebar:not(.app-sidebar--docs) .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;
}

.app-sidebar:not(.app-sidebar--docs) .nav-group-toggle:hover .nav-chevron,
.app-sidebar:not(.app-sidebar--docs) .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-shell-bg, var(--app-header-bg-color));
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--ui-topbar-height);
  height: var(--ui-topbar-height);
  padding: 0 24px;
  background: var(--app-shell-bg, var(--app-header-bg-color));
  border: none;
  box-shadow: none;
  position: sticky;
  top: 0;
  z-index: 80;
  transition:
    background var(--ui-layout-transition, var(--ui-transition)),
    border-color var(--ui-layout-transition, var(--ui-transition)),
    box-shadow var(--ui-layout-transition, var(--ui-transition));
}

.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 .docs-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-width: 1px;
  border-style: solid;
  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-width: 1px;
  border-style: solid;
  transition:
    transform var(--ui-layout-transition, var(--ui-transition)),
    box-shadow var(--ui-layout-transition, var(--ui-transition)),
    border-color var(--ui-layout-transition, var(--ui-transition)),
    background var(--ui-layout-transition, 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);
}

.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-width: 1px;
  border-style: solid;
}

/* —— 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(.ca-btn):not(.btn-mini):not(.mobile-menu-toggle):not(.mobile-nav-close):not(.nav-group-toggle):not(.nav-group-caret):not(.tech-phone-trigger):not(.tech-copy-pwd):not(.tech-os-cta-btn):not(.header-logout-btn):not(.header-user-chip):not(.header-user-menu-item):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):not(.admin-site-head-btn):not(.cadastro-venda-row-menu-toggle):not(.cadastro-venda-row-menu-item) {
  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-width: 1px;
  border-style: solid;
}

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-shell-bg, var(--app-header-bg-color));
  border-bottom-color: var(--app-shell-line-color, var(--app-shell-divider, #334155));
  box-shadow: var(--app-shell-line-shadow, none);
}

[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 (tema escuro, destaque verde) —— */
/* tela travada: sem rolagem e sem "borracha" no topo/rodape.
   fundo escuro tambem no <html> para o navegador pintar a barra de status e a
   barra de endereco na cor da pagina */
html.login-locked,
html.login-locked body {
  height: 100%;
  overflow: hidden;
  color-scheme: dark;
  background: #020506;
  overscroll-behavior: none;
}

body[data-page='login'] {
  background: #020506;
}

html.login-locked .login-container {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100svh;
  min-height: 0;
  overflow: hidden;
}

/* telas muito baixas (celular deitado): libera rolagem interna para o form nao ficar inacessivel */
@media (max-height: 480px) {
  html.login-locked .login-container {
    justify-content: flex-start;
    overflow-y: auto;
  }
}

.login-container {
  --login-accent: #25d366;
  --login-accent-light: #3ef083;
  --login-accent-deep: #0b7a39;
  --login-page-bg: #03070a;
  --login-btn-surface: #1c2638;
  --login-title: #f4fbf7;
  --login-subtitle: #8ea6a0;
  --login-input-bg: rgba(255, 255, 255, 0.05);
  --login-input-border: rgba(255, 255, 255, 0.14);
  --login-input-text: #f4fbf7;
  --login-input-placeholder: #7d9490;
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  background-color: var(--login-page-bg);
}

/* fundo escuro limpo: apenas o degrade de base, sem padrao nem animacao */
.login-container:not(.has-login-bg) {
  background-image: linear-gradient(168deg, #0a141b 0%, #050b10 52%, #020506 100%);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 448px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.login-container .flash {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 448px;
  border-radius: 10px;
}

.login-brand {
  display: flex;
  align-items: center;
}

.login-brand-box {
  display: inline-flex;
  border-radius: 12px;
  padding: 10px 16px;
}

.login-brand-logo {
  height: 40px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

/* logo em branco puro sobre o fundo escuro */
.login-brand-logo--white {
  filter: brightness(0) invert(1) drop-shadow(0 2px 10px rgba(0, 0, 0, 0.45));
}

.login-brand-text {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--login-title);
}

.login-card h2 {
  margin: 32px 0 0;
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--login-title);
}

.login-lead {
  margin: 8px 0 0;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--login-subtitle);
}

#login-form {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  position: relative;
  margin: 0;
}

/* rotulos ficam apenas para leitores de tela; o texto vai no placeholder */
.login-card label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

#login-form input[type='text'],
#login-form input[type='password'] {
  width: 100%;
  height: 52px;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--login-input-border);
  border-radius: 12px;
  background: var(--login-input-bg);
  color: var(--login-input-text);
  font-size: 1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

#login-form input[type='password'] {
  padding-right: 48px;
}

#login-form input::placeholder {
  color: var(--login-input-placeholder);
  opacity: 1;
}

#login-form input:focus {
  outline: none;
  border-color: var(--login-accent-light);
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--login-accent-light) 22%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* autocomplete do navegador nao pode voltar o fundo claro */
#login-form input:-webkit-autofill,
#login-form input:-webkit-autofill:hover,
#login-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--login-input-text) !important;
  caret-color: var(--login-input-text);
  -webkit-box-shadow: 0 0 0 1000px #0c1a22 inset !important;
  transition: background-color 9999s ease-out 0s;
}

.login-eye-btn {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 48px !important;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 12px 12px 0 !important;
  background: transparent !important;
  color: var(--login-accent) !important;
  box-shadow: none !important;
  cursor: pointer;
}

.login-eye-icon {
  width: 20px;
  height: 20px;
}

.login-eye-btn .login-eye-icon--on,
.login-eye-btn.is-visible .login-eye-icon--off {
  display: none;
}

.login-eye-btn.is-visible .login-eye-icon--on {
  display: block;
}

#login-form .login-submit {
  margin-top: 8px;
  width: 100%;
  height: 52px;
  min-height: 52px;
  padding: 0 16px !important;
  border: 1px solid color-mix(in srgb, var(--login-accent) 55%, transparent) !important;
  border-radius: 12px !important;
  background: color-mix(in srgb, var(--login-accent) 16%, var(--login-btn-surface)) !important;
  color: #f1f5f9 !important;
  font-size: 1rem !important;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--login-accent) 14%, transparent);
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
}

#login-form .login-submit:hover:not(:disabled) {
  background: color-mix(in srgb, var(--login-accent) 24%, var(--login-btn-surface)) !important;
  box-shadow: 0 12px 30px color-mix(in srgb, var(--login-accent) 20%, transparent);
}

#login-form .login-submit:active:not(:disabled) {
  transform: translateY(1px);
}

@media (max-width: 900px) {
  .login-card,
  .login-container .flash {
    max-width: 100%;
  }
}

/* —— 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;
    background: var(--app-shell-bg, var(--app-header-bg-color));
    border-bottom: 1px solid var(--app-shell-divider, var(--ui-border));
    box-shadow: none;
  }

  [data-theme-preset="dark"] .app-topbar {
    background: var(--app-shell-bg, var(--app-header-bg-color));
    border-bottom-color: var(--app-shell-divider, #334155);
    box-shadow: none;
  }

  .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-shell-bg, var(--app-header-bg-color));
    color: var(--app-header-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(--app-shell-divider, 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;
  }
}

.produtos-xml-upload-form .field {
  max-width: none;
}

.produtos-xml-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.produtos-xml-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.produtos-xml-preview-actions form {
  margin: 0;
}

.produtos-xml-preview-title {
  margin: 0;
  font-size: 1.05rem;
}

.produtos-xml-itens-title {
  margin: 18px 0 10px;
  font-size: 0.98rem;
}

/* Abas Ativos / Passivos — importação XML */
.produtos-xml-resumo-contagem {
  margin: 0 0 12px;
  font-size: 0.92rem;
}

.produtos-xml-itens-table .produtos-xml-tipo-form {
  margin: 0;
}

.produtos-xml-tipo-select {
  min-width: 108px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--app-surface-border, rgba(255, 255, 255, 0.12));
  background: var(--app-elevated-bg, #1c2638);
  color: inherit;
  font: inherit;
}

.produtos-xml-import-form {
  width: 100%;
  margin: 0;
}

.produtos-xml-import-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
  margin-top: 14px;
  gap: 8px;
}

.produtos-xml-import-form td:first-child,
.produtos-xml-import-form th:first-child {
  width: 36px;
  text-align: center;
}

.produtos-xml-import-form td:last-child,
.produtos-xml-import-form th:last-child {
  width: 130px;
}

@media (max-width: 900px) {
  .produtos-xml-tipo-select {
    min-width: 92px;
  }
}

.produtos-xml-edit-cell.is-editable {
  cursor: pointer;
}

.produtos-xml-edit-cell.is-editable:hover .produtos-xml-edit-label {
  text-decoration: underline;
  text-decoration-style: dotted;
}

.produtos-xml-inline-input {
  width: 100%;
  min-width: 120px;
  box-sizing: border-box;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(52, 211, 153, 0.45);
  background: rgba(15, 23, 42, 0.95);
  color: inherit;
}

.produtos-xml-ean-cell {
  font-variant-numeric: tabular-nums;
}

.produtos-xml-ean-cell.is-copied .produtos-xml-edit-label {
  color: #34d399;
}

.produtos-xml-actions-cell {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  vertical-align: middle;
}

.produtos-xml-abastecer-dialog {
  border: 1px solid color-mix(in srgb, var(--app-text-color) 14%, transparent);
  border-radius: 12px;
  padding: 0;
  background: var(--cv-content, #1c2129);
  color: inherit;
  max-width: 420px;
  width: calc(100vw - 32px);
}

.produtos-xml-abastecer-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.produtos-xml-abastecer-form {
  padding: 18px;
}

.produtos-xml-abastecer-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.produtos-estoque-row.is-editing,
.produtos-passivos-row.is-editing {
  background: color-mix(in srgb, var(--cv-accent, #00D084) 6%, transparent);
}

.produtos-estoque-edit {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  height: 34px;
  padding: 0 8px;
  font-size: 13px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 6px;
  background: color-mix(in srgb, var(--app-text-color) 6%, transparent);
  color: inherit;
}

.produtos-estoque-edit[name="descricao"] {
  text-transform: uppercase;
}

.produtos-estoque-row-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
}

.produtos-estoque-actions-edit .produtos-estoque-row-edit-actions button {
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  padding: 0 12px !important;
  font-size: 12px !important;
}
