:root {
  --primary: #1f2937;
  --accent: #0b5ed7;
  --muted: #6b7280;
  --card: #ffffff;
  --page-bg: #f3f4f6;
  --sidebar-width: 260px;
  --ui-scale: 0.8;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--page-bg);
  margin: 0;
  color: #111827;
  font-size: 14px; /* CORRIGIDO: era 10px */

  /* Escala global do UI (20% menor) */
  zoom: var(--ui-scale);
}

/* Fallback para browsers sem suporte a zoom (ex.: Firefox) */
@supports not (zoom: 1) {
  body {
    transform: scale(var(--ui-scale));
    transform-origin: top left;
    width: calc(100% / var(--ui-scale));
  }
}

.app {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-width);
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 1000;
}

.app-sidebar .brand {
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 1.1rem;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
}

.app-sidebar .menu {
  flex: 1;
  overflow-y: auto;
}

.app-sidebar .menu a.menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: rgba(255, 255, 255, 0.92);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  margin: 0.15rem 0.75rem;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.app-sidebar .menu a.menu-item .icon {
  font-size: 1.1rem;
  opacity: 0.9;
}

.app-sidebar .menu a.menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.app-sidebar .menu a.menu-item.active {
  background: rgba(255, 255, 255, 0.12);
  font-weight: 500;
}

/* Company Select */
.app-sidebar .company-select {
  padding: 0.5rem 0.75rem;
}

.app-sidebar .company-select .form-select {
  font-size: 0.85rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 0.4rem 0.6rem;
}

.app-sidebar .company-select .form-select:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: none;
}

.app-sidebar .company-select .form-select option {
  background: var(--primary);
  color: #fff;
}

/* Topbar */
.app-topbar {
  height: 60px;
  background: #ffffff;
  border-bottom: 1px solid #e6e9ee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.04);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-left h5 {
  margin: 0;
  font-weight: 600;
  color: #0f1724;
  font-size: 1.1rem;
}

.topbar-search {
  flex: 1;
  max-width: 400px;
  margin: 0 2rem;
}

.topbar-search input {
  width: 100%;
  font-size: 0.9rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-actions .dropdown img {
  border-radius: 8px;
  object-fit: cover;
}

/* Main Content */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-width);
}

.app-content {
  padding: 1.5rem;
  flex: 1;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid #e6e9ee;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  margin-bottom: 1rem;
}

.card h6 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

/* Page Title */
.page-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e6e9ee;
}

.page-title h4 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: #111827;
}

/* Tables */
.table {
  font-size: 0.9rem;
}

.table th {
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e6e9ee;
}

/* Buttons */
.btn {
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 500;
}

.btn-sm {
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
}

/* Forms */
.form-label {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: #374151;
}

.form-control,
.form-select {
  font-size: 0.9rem;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.75rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 94, 215, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .app-sidebar.show {
    transform: translateX(0);
  }
  
  .app-main {
    margin-left: 0;
  }
  
  .topbar-search {
    display: none;
  }
  
  .app-content {
    padding: 1rem;
  }
}

/* Scrollbar personalizada para sidebar */
.app-sidebar::-webkit-scrollbar {
  width: 6px;
}

.app-sidebar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

.app-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}


/* --- Estilos do Menu Retrátil --- */

/* Esconde o submenu por padrão */
.submenu {
    display: none;
    background: rgba(0, 0, 0, 0.15);
    padding-bottom: 5px;
}

/* Identação visual para subníveis */
.submenu .menu-item {
    padding-left: 2.5rem;
    font-size: 0.85rem;
    height: 35px;
}

/* Seta de indicação */
.arrow-icon {
    transition: transform 0.3s ease;
    font-size: 1.2rem;
    opacity: 0.7;
}

/* Rotação da seta quando a pasta estiver aberta */
.folder-open > .folder-toggle .arrow-icon {
    transform: rotate(90deg);
}

/* Destaque para o container da pasta ativa */
.menu-folder-container.folder-open {
    background: rgba(255, 255, 255, 0.03);
}