/* ================================================================
   FoodTech Sistema — Design System (IDV v1)
   Primário : #0A73C9 | Grafite: #222222 | BG: #F4F5F7
   Refs     : Notion · Stripe · Linear · Vercel
   ================================================================ */

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Tokens ───────────────────────────────────────────────── */
:root {
  /* Marca */
  --blue:           #0A73C9;
  --blue-dark:      #085FA8;
  --blue-light:     #DCEEFF;
  --blue-muted:     #E8F3FD;

  /* Neutros */
  --graphite:       #222222;
  --graphite-2:     #2E2E2E;
  --graphite-3:     #3A3A3A;
  --graphite-muted: #6B7280;

  /* Superfícies */
  --bg:             #F4F5F7;
  --surface:        #FFFFFF;
  --border:         #E5E7EB;
  --border-light:   #F0F1F3;

  /* Texto */
  --text-primary:   #111827;
  --text-secondary: #4B5563;
  --text-muted:     #9CA3AF;

  /* Status */
  --success:        #16A34A;
  --success-bg:     #F0FDF4;
  --warning:        #F59E0B;
  --warning-bg:     #FFFBEB;
  --error:          #DC2626;
  --error-bg:       #FEF2F2;
  --info:           #2563EB;
  --info-bg:        #EFF6FF;

  /* Dark mode */
  --dm-bg:          #111827;
  --dm-surface:     #1F2937;
  --dm-border:      #374151;

  /* Sidebar */
  --sidebar-width:  256px;
  --topbar-height:  60px;

  /* Tipografia */
  --font:           'Inter', system-ui, sans-serif;

  /* Bordas */
  --radius-sm:      6px;
  --radius-md:      8px;
  --radius-lg:      12px;

  /* Sombras */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:  0 1px 4px rgba(0,0,0,.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.12);

  /* Transição */
  --ease: 0.18s ease;
}

html {
  font-size: 16px;
  overflow-x: hidden; /* bloqueia scroll horizontal — não quebra position:sticky */
}

body {
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* SEM overflow-x: hidden aqui — quebraria position:sticky das action bars */
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea, button { font-family: inherit; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue); }

/* ================================================================
   LAYOUT AUTH (login)
   ================================================================ */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.auth-container {
  width: 100%;
  max-width: 440px;
}

/* Linha decorativa topo */
.auth-container::before {
  content: '';
  display: block;
  height: 3px;
  background: var(--blue);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-bottom: -1px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 44px 40px 40px;
  box-shadow: var(--shadow-md);
}

.auth-card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}

.auth-logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-logo-icon {
  width: 42px;
  height: 42px;
}

.auth-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--graphite);
  letter-spacing: -0.5px;
}

.auth-brand span { color: var(--blue); }

.auth-tagline {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 300px;
  line-height: 1.5;
}

.auth-admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: var(--blue-muted);
  color: var(--blue);
  border: 1px solid rgba(10,115,201,.2);
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ── Alert ───────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 24px;
  border: 1px solid transparent;
}
.alert svg { flex-shrink: 0; }
.alert-error  { background: var(--error-bg);   color: var(--error);   border-color: #FECACA; }
.alert-success{ background: var(--success-bg); color: var(--success); border-color: #BBF7D0; }
.alert-warning{ background: var(--warning-bg); color: var(--warning); border-color: #FDE68A; }

/* ── Form ─────────────────────────────────────────────────── */
.auth-form { display: flex; flex-direction: column; gap: 20px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-wrapper { position: relative; display: flex; align-items: center; }

.input-icon {
  position: absolute;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--text-muted);
  pointer-events: none;
}

.form-input {
  width: 100%;
  padding: 11px 42px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: border-color var(--ease), box-shadow var(--ease);
  outline: none;
}

.form-input::placeholder { color: var(--text-muted); }

.form-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-muted);
}

/* File input: padding correto, sem compressão do texto */
input[type="file"].form-input {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  width: 100%;
}
input[type="file"].form-input::-webkit-file-upload-button {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  margin-right: 10px;
  transition: all var(--ease);
}
input[type="file"].form-input::-webkit-file-upload-button:hover {
  background: var(--blue-muted);
  border-color: var(--blue);
  color: var(--blue);
}

.input-toggle-pw {
  position: absolute;
  right: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 4px;
  transition: color var(--ease);
}
.input-toggle-pw:hover { color: var(--text-secondary); }

/* ── Botões ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  transition: all var(--ease);
  outline: none;
  line-height: 1;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover:not(:disabled) {
  background: var(--blue-dark);
  box-shadow: 0 4px 12px rgba(10,115,201,.30);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--blue);
  border: 1px solid var(--blue);
}
.btn-secondary:hover { background: var(--blue-muted); }

.btn-block { width: 100%; }

/* Spinner */
.btn-spinner {
  width: 17px; height: 17px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ================================================================
   LAYOUT APP (autenticado)
   ================================================================ */
.app-body {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  max-width: 100vw;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--graphite);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--ease);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--graphite-3);
  flex-shrink: 0;
}

.sidebar-logo-icon { width: 32px; height: 32px; flex-shrink: 0; }

.sidebar-brand {
  font-size: 1.0625rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.3px;
}
.sidebar-brand span { color: var(--blue); }

.sidebar-close-btn {
  margin-left: auto;
  color: #9CA3AF;
  padding: 4px;
  display: none;
  border-radius: var(--radius-sm);
  transition: color var(--ease);
}
.sidebar-close-btn:hover { color: #fff; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 16px 10px;
  overflow-y: auto;
}

.nav-section-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #6B7280;
  padding: 0 8px;
  margin: 0 0 6px;
}

.nav-section-label:not(:first-child) { margin-top: 20px; }

.nav-list { list-style: none; display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  color: #9CA3AF;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--ease);
}
.nav-item:hover {
  background: var(--graphite-2);
  color: #E5E7EB;
}
.nav-item.active {
  background: rgba(10,115,201,.18);
  color: #60B3F4;
  border-left: 3px solid var(--blue);
  padding-left: 7px;
}

.nav-icon { width: 17px; height: 17px; flex-shrink: 0; }

/* Footer sidebar */
.sidebar-footer {
  padding: 14px 10px;
  border-top: 1px solid var(--graphite-3);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name  { font-size: 0.8125rem; font-weight: 600; color: #E5E7EB; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 0.6875rem; color: #6B7280; }

/* Avatar de letra para usuário na sidebar */
.user-avatar-initial {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* Foto da empresa no footer da sidebar do usuário */
.profile-empresa-foto {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,.12);
}

/* Thumbnail da empresa na tabela do admin */
.empresa-thumb {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
  display: block;
}

.empresa-thumb-placeholder {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.empresa-thumb-placeholder svg { width: 14px; height: 14px; }

/* Link "acesso administrativo" na página de login do usuário */
.auth-admin-link {
  text-align: center;
  margin-top: 4px;
}
.auth-admin-link a {
  font-size: 0.8125rem;
  color: var(--text-muted);
  transition: color var(--ease);
}
.auth-admin-link a:hover { color: var(--blue); }

.logout-form { flex-shrink: 0; }
.logout-btn {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: #6B7280;
  transition: all var(--ease);
}
.logout-btn:hover { background: rgba(220,38,38,.15); color: #F87171; }
.logout-btn svg { width: 17px; height: 17px; }

/* Overlay mobile */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 199;
  backdrop-filter: blur(2px);
}

/* ── App wrapper ──────────────────────────────────────── */
.app-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;          /* flex: permite encolher abaixo do conteúdo */
  max-width: 100%;       /* nunca expande além do pai */
  transition: margin-left var(--ease);
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0; z-index: 100;
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  box-shadow: var(--shadow-xs);
}

.topbar-menu-btn {
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: none;
  transition: all var(--ease);
}
.topbar-menu-btn:hover { background: var(--bg); color: var(--text-primary); }

.topbar-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Search global */
.topbar-search {
  flex: 1;
  max-width: 320px;
  position: relative;
  margin-left: 8px;
}

.topbar-search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.topbar-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-muted);
  background: var(--surface);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-icon-btn {
  position: relative;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: all var(--ease);
}
.topbar-icon-btn:hover { background: var(--bg); color: var(--text-primary); }
.topbar-icon-btn svg { width: 18px; height: 18px; }

.topbar-badge {
  position: absolute;
  top: 5px; right: 5px;
  width: 8px; height: 8px;
  background: var(--error);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.topbar-divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--ease);
}
.topbar-user:hover { background: var(--bg); }
.topbar-user .user-avatar { width: 30px; height: 30px; font-size: 0.75rem; }
.topbar-user-name { font-size: 0.8125rem; font-weight: 600; color: var(--text-primary); }

/* Logo da empresa na topbar */
.topbar-empresa-logo {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  object-fit: contain;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px;
  flex-shrink: 0;
}

/* ── Conteúdo principal ───────────────────────────────────── */
.app-content {
  flex: 1;
  padding: 28px 24px;
  min-width: 0;       /* flex: permite encolher */
  max-width: 100%;    /* não expande além do wrapper */
  box-sizing: border-box;
  /* sem overflow-x aqui: action bars sticky ficariam quebradas */
}

/* ── Page header ──────────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-title { font-size: 1.375rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; }
.page-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: 3px; }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-xs);
}

/* ── Dashboard placeholder ────────────────────────────────── */
.dashboard-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 72px 40px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}
.placeholder-icon-wrap {
  width: 64px; height: 64px;
  background: var(--blue-muted);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.placeholder-icon-wrap svg { width: 32px; height: 32px; color: var(--blue); }
.dashboard-placeholder h3 { font-size: 1.0625rem; font-weight: 600; color: var(--text-primary); }
.dashboard-placeholder p { font-size: 0.875rem; color: var(--text-secondary); max-width: 340px; }

/* ── Tabelas ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table th {
  background: var(--bg);
  padding: 11px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 12px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--blue-muted); }
.table tbody tr:nth-child(even) { background: #FAFAFA; }
.table tbody tr:nth-child(even):hover { background: var(--blue-muted); }

/* ── Badges de status ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error   { background: var(--error-bg);   color: var(--error);   }
.badge-info    { background: var(--info-bg);     color: var(--info);    }
.badge-neutral { background: var(--bg);          color: var(--text-secondary); border: 1px solid var(--border); }

/* ── Sidebar: overscroll fix (funciona no iOS também) ─────── */
.sidebar-nav {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sidebar-overlay.visible {
  display: block;
  touch-action: none;        /* impede scroll da página por baixo do overlay */
  overscroll-behavior: none;
}

/* Sidebar: altura dinâmica (evita problema do endereço no browser mobile) */
@supports (height: 100dvh) {
  .sidebar { height: 100dvh; }
}

/* ── Responsivo: ≤ 768px ──────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn,
  .topbar-menu-btn { display: flex; }
  .app-wrapper { margin-left: 0; }
  .app-content { padding: 16px 12px 80px; } /* bottom padding para FAB/ação flutuante */

  /* Auth */
  .auth-card { padding: 28px 20px; }

  /* Topbar */
  .topbar { padding: 0 14px; }
  .topbar-search { display: none; }
  .topbar-divider { display: none; }

  /* Page header */
  .page-header { margin-bottom: 18px; }
  .page-title { font-size: 1.2rem; }
  .page-subtitle { font-size: 0.8rem; }

  /* Card */
  .card { padding: 16px; }

  /* Tabelas: scroll horizontal */
  .table-wrapper {
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }
  .table th,
  .table td { padding: 10px 12px; font-size: 0.8125rem; }

  /* Form grid → coluna única */
  .form-grid { grid-template-columns: 1fr !important; }
  .form-card { padding: 16px; margin-bottom: 16px; }

  /* Modal → tela cheia na parte inferior (bottom sheet) */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  /* Section header actions: wrap em 2 linhas */
  .section-header { flex-wrap: wrap; gap: 10px; padding: 14px 16px; }

  /* Ação modular: wrap e tamanho touch-friendly */
  .mod-actionbar {
    padding: .5rem .75rem;
    gap: .5rem;
    top: calc(var(--topbar-height) + 4px);
    border-radius: 8px;
  }
  .mod-actions { gap: .3rem; }
  .mod-btn {
    padding: .45rem .65rem;
    font-size: .77rem;
  }
  .mod-btn svg { width: 14px; height: 14px; }

  /* Nav counter */
  .mod-nav-counter { min-width: 72px; padding: 0 10px; font-size: .74rem; }

  /* Sticky action bars de outros módulos */
  .prod-actionbar, .prod-sr-actionbar,
  .sr-actionbar, .frq-actionbar,
  .ingr-actionbar, .iav-actionbar {
    top: calc(var(--topbar-height) + 4px);
  }
}

/* ── Responsivo: ≤ 480px (celulares pequenos) ─────────────── */
@media (max-width: 480px) {
  .topbar { padding: 0 10px; }
  .app-content { padding: 12px 10px 80px; }

  /* Action bar: força scroll horizontal se não couber */
  .mod-actionbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .mod-actions { flex-wrap: nowrap; }

  /* Esconde label do botão nav e deixa só ícone em telas muito pequenas */
  .mod-btn-text-sm { display: none; }

  /* Badges */
  .badge { font-size: 0.6875rem; padding: 2px 7px; }
}


/* ── Sidebar: logo imagem ─────────────────────────────────── */
.sidebar-logo-link {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.sidebar-logo-img {
  height: 36px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

/* ── Sidebar: perfil no footer ────────────────────────────── */
.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.profile-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.08);
  padding: 4px;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}

/* ── Auth: logo imagem ────────────────────────────────────── */
.auth-logo-img {
  height: 48px;
  width: auto;
  object-fit: contain;
}

/* ── Card: em construção ──────────────────────────────────── */
.under-construction-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.uc-icon-wrap {
  width: 52px;
  height: 52px;
  background: var(--warning-bg);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--warning);
}

.uc-icon-wrap svg { width: 26px; height: 26px; }

.uc-content { flex: 1; }

.uc-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.uc-content p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

@media (max-width: 600px) {
  .under-construction-card { flex-direction: column; align-items: flex-start; }
}

/* ================================================================
   MÓDULO EMPRESAS
   ================================================================ */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-xs);
  margin-bottom: 24px;
}

.section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

.required-mark { color: var(--error); margin-left: 2px; }
.required-hint { font-size: 0.8125rem; color: var(--text-muted); }

.input-error {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 3px #FEE2E2 !important;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
}

.section-header .section-title { margin-bottom: 0; }

.section-actions, .actions-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all var(--ease);
  flex-shrink: 0;
}
.btn-icon svg { width: 16px; height: 16px; }

.btn-icon-neutral { background: var(--bg); border: 1px solid var(--border); color: var(--text-secondary); }
.btn-icon-neutral:hover { background: var(--blue-muted); border-color: var(--blue); color: var(--blue); }

.btn-icon-primary { background: var(--blue-muted); border: 1px solid #93C5FD; color: var(--blue); }
.btn-icon-primary:hover { background: var(--blue); color: #fff; border-color: var(--blue); }

.btn-icon-danger { background: var(--error-bg); border: 1px solid #FECACA; color: var(--error); }
.btn-icon-danger:hover { background: var(--error); color: #fff; border-color: var(--error); }

.col-check { width: 44px; text-align: center; }
.col-actions { width: 90px; text-align: center; }
.col-actions .btn-icon { display: inline-flex; margin: 0 2px; }

.tbl-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--blue); }

.table-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 40px 16px !important;
}

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h4 { font-size: 1rem; font-weight: 600; color: var(--text-primary); }

.modal-close-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--ease);
}
.modal-close-btn:hover { background: var(--bg); color: var(--text-primary); }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; }

.modal-desc { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 16px; }

.modal-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: 320px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

@media (max-width: 1024px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .form-grid { grid-template-columns: 1fr; } }

/* Hint inline em labels */
.field-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 4px;
}

/* Input-wrapper dentro do form-grid ocupa 100% da célula */
.form-grid .input-wrapper { width: 100%; }
.form-grid .input-wrapper .form-input { padding-right: 42px; }

/* ================================================================
   BARRA DE AÇÃO MODULAR (mod-actionbar · mod-btn · mod-nav)
   Usada por: monitoramento.ejs · pac.ejs · plano-acao.ejs
   ================================================================ */

/* ── Container principal — sticky logo abaixo do topbar ───────── */
.mod-actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .625rem 1.25rem;
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: .75rem;
  gap: 1rem;
  flex-wrap: wrap;
  /* Sticky: gruda 8px abaixo do topbar — gap visual evita o efeito "colado no teto" */
  position: sticky;
  top: calc(var(--topbar-height) + 8px);
  z-index: 50;
  /* Shadow sempre elevada — evita snap visual ao grudar no topo */
  box-shadow: 0 4px 20px rgba(0,0,0,.09);
}

/* ── Sticky universal — todas as barras de ação do sistema ────── */
/* Cobre: prod-actionbar, prod-sr-actionbar, sr-actionbar, frq-actionbar, ingr-actionbar, iav-actionbar */
.prod-actionbar, .prod-sr-actionbar,
.sr-actionbar,
.frq-actionbar,
.ingr-actionbar,
.iav-actionbar {
  position: sticky;
  top: calc(var(--topbar-height) + 8px);
  z-index: 50;
  background: rgba(255, 255, 255, .97) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0,0,0,.09);
}

/* ── Grupo de botões de ação (esquerda) ─────────────────────────── */
.mod-actions {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Separador vertical entre ações e controle de navegação ────── */
.mod-sep {
  width: 1px;
  height: 26px;
  background: var(--border);
  align-self: center;
  flex-shrink: 0;
}

/* ── Grupo: separador + controle de navegação (lado direito) ────── */
.mod-nav-group {
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-shrink: 0;
}

/* ── Botão genérico da action bar ───────────────────────────────── */
.mod-btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .375rem .825rem;
  border-radius: 7px;
  font-size: .79rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .13s, border-color .13s, color .13s;
  line-height: 1.2;
  white-space: nowrap;
}

.mod-btn-neutral {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border);
}
.mod-btn-neutral:not(:disabled):hover {
  background: var(--bg);
  border-color: #c4c9d4;
}

.mod-btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.mod-btn-primary:not(:disabled):hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.mod-btn-danger {
  background: var(--surface);
  color: var(--error);
  border-color: #fca5a5;
}
.mod-btn-danger:not(:disabled):hover {
  background: var(--error-bg);
  border-color: #f87171;
}

.mod-btn:disabled { opacity: .38; cursor: not-allowed; }

/* ── Indicador de filtro ativo no botão Filtrar ─────────────────── */
.mod-btn-filtro { position: relative; }

.mod-btn-filtro.active {
  background: var(--blue-muted);
  border-color: #93C5FD;
  color: var(--blue);
}
.mod-btn-filtro.active::after {
  content: '';
  position: absolute;
  top: 3px; right: 4px;
  width: 6px; height: 6px;
  background: var(--blue);
  border-radius: 50%;
  border: 1.5px solid #fff;
}

/* ── Controle de navegação entre registros (direita) ────────────── */
/* Pill-group: [‹] [1 de 100] [›] — agrupados visualmente */
.mod-nav {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
  height: 32px;
}

.mod-nav-btn {
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .13s, color .13s;
  flex-shrink: 0;
  padding: 0;
}
.mod-nav-btn:not(:disabled):hover {
  background: var(--blue);
  color: #fff;
}
.mod-nav-btn:disabled {
  color: var(--border);
  cursor: not-allowed;
}

.mod-nav-counter {
  padding: 0 14px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-primary);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  white-space: nowrap;
  min-width: 88px;
  justify-content: center;
  background: var(--surface);
  letter-spacing: .01em;
}

