/* ════════════════════════════════════════════════════════════
   NOBRE SABOR — Sistema de Gestão
   CSS corporativo · Azul/Cinza · Mobile-first
   ════════════════════════════════════════════════════════════ */

:root {
  /* Cores principais — Azul corporativo */
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-light: #3b82f6;
  --primary-lighter: #dbeafe;
  
  /* Cinzas neutros */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Status */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  
  /* Layout */
  --sidebar-width: 260px;
  --topbar-height: 56px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  
  /* Tipografia */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.1);
  
  /* Tema CLARO (default) */
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #e5e7eb;
  --border: #e5e7eb;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --shadow-card: 0 1px 3px rgba(0,0,0,.1);
}

/* Tema ESCURO */
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --surface-3: #475569;
  --border: #334155;
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --text-3: #94a3b8;
  --shadow-card: 0 1px 3px rgba(0,0,0,.4);
  --primary-lighter: #1e3a8a;
}

/* ════════════════════════════════════════════════════════════
   RESET E BASE
═══════════════════════════════════════════════════════════ */

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Scrollbar moderna */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--gray-700); }

/* ════════════════════════════════════════════════════════════
   SPLASH SCREEN
═══════════════════════════════════════════════════════════ */

.splash-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.splash-content { text-align: center; padding: 20px; }
.splash-logo { display: inline-block; margin-bottom: 20px; animation: pulse 2s ease-in-out infinite; }
.splash-title { font-size: 2.5rem; font-weight: 700; margin-bottom: 8px; letter-spacing: -1px; }
.splash-subtitle { font-size: 1rem; opacity: 0.85; margin-bottom: 30px; }
.splash-loader { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.splash-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ════════════════════════════════════════════════════════════
   TELA DE LOGIN
═══════════════════════════════════════════════════════════ */

.login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

.login-container {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand svg { margin-bottom: 16px; }
.login-brand h1 { font-size: 1.75rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.login-brand p { color: var(--text-2); font-size: 0.9rem; }

.login-form .form-group { margin-bottom: 18px; }
.login-form label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.login-form input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: all 0.2s;
}
.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, .1);
}

.password-wrapper { position: relative; }
.password-toggle {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  font-size: 1rem;
  opacity: 0.6;
}
.password-toggle:hover { opacity: 1; }

.error-message {
  background: rgba(239, 68, 68, .1);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 14px;
  border-left: 3px solid var(--danger);
}

.login-divider {
  text-align: center;
  margin: 18px 0;
  position: relative;
  color: var(--text-3);
  font-size: 0.85rem;
}
.login-divider::before, .login-divider::after {
  content: ''; position: absolute; top: 50%;
  width: calc(50% - 30px);
  height: 1px; background: var(--border);
}
.login-divider::before { left: 0; }
.login-divider::after { right: 0; }
.login-divider span { background: var(--surface); padding: 0 12px; position: relative; }

.login-footer {
  text-align: center;
  margin-top: 18px;
  font-size: 0.85rem;
}

.login-version {
  position: absolute;
  bottom: 16px;
  color: rgba(255,255,255,.7);
  font-size: 0.78rem;
}

/* ════════════════════════════════════════════════════════════
   BOTÕES
═══════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-3); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(0.9); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(0.9); }

.btn-google {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-google:hover { background: var(--surface-2); border-color: var(--gray-400); }

.btn-block { width: 100%; padding: 12px 18px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ════════════════════════════════════════════════════════════
   APP PRINCIPAL — Layout
═══════════════════════════════════════════════════════════ */

.app-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
}

/* SIDEBAR */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
  z-index: 100;
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-text { font-size: 1.15rem; font-weight: 700; color: var(--text); }

.sidebar-close { display: none; font-size: 1.2rem; padding: 4px 8px; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.15s;
  width: calc(100% - 16px);
  text-align: left;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  background: var(--primary-lighter);
  color: var(--primary);
  font-weight: 600;
}
.nav-icon { font-size: 1.2rem; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 8px;
}
.user-card:hover { background: var(--surface-2); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role { font-size: 0.75rem; color: var(--text-3); }

.btn-logout {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}
.btn-logout:hover {
  background: rgba(239, 68, 68, .1);
  color: var(--danger);
}

/* TOPBAR */
.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 50;
}

.sidebar-toggle {
  display: none;
  font-size: 1.4rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
.sidebar-toggle:hover { background: var(--surface-2); }

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  color: var(--text-2);
  position: relative;
  transition: all 0.15s;
}
.topbar-btn:hover { background: var(--surface-2); color: var(--text); }

.notif-badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.notif-badge:empty, .notif-badge:not(:empty):where([data-zero="true"]) { display: none; }

/* MAIN */
.main-content {
  grid-area: main;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}

/* ════════════════════════════════════════════════════════════
   PÁGINAS DE CONTEÚDO
═══════════════════════════════════════════════════════════ */

.page-header {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  transition: all 0.2s;
}
.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, .1);
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 0;
  outline: none;
}
.search-bar-icon { color: var(--text-3); margin-right: 8px; }

/* CARDS */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--gray-300); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* PESSOA CARD */
.pessoa-card {
  display: flex;
  align-items: start;
  gap: 12px;
  padding: 14px;
}

.pessoa-avatar {
  width: 44px; height: 44px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.pessoa-info { flex: 1; min-width: 0; }
.pessoa-nome { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.pessoa-detalhes { font-size: 0.78rem; color: var(--text-3); line-height: 1.4; }
.pessoa-funcoes {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-cliente    { background: rgba(245,158,11,.15);  color: #d97706; }
.badge-tecnico    { background: rgba(59,130,246,.15);  color: #2563eb; }
.badge-condutor   { background: rgba(34,197,94,.15);   color: #16a34a; }
.badge-usuario    { background: rgba(168,85,247,.15);  color: #9333ea; }
.badge-fornecedor { background: rgba(239,68,68,.15);   color: #dc2626; }
.badge-master     { background: rgba(30,64,175,.15);   color: var(--primary); font-weight: 700; }

.pessoa-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 0.95rem;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: rgba(239,68,68,.1); color: var(--danger); }

/* ════════════════════════════════════════════════════════════
   MODAIS
═══════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease-out;
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text-3);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

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

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* FORMS dentro de modais */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: all 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, .1);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Função selector dentro do modal de pessoa */
.funcao-selector {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  transition: all 0.2s;
}
.funcao-selector.active {
  border-color: var(--primary);
  background: var(--primary-lighter);
}
.funcao-selector label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}
.funcao-selector input[type="checkbox"] {
  width: 18px; height: 18px;
  cursor: pointer;
}
.funcao-fields {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: none;
}
.funcao-selector.active .funcao-fields { display: block; }

/* ════════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-xl);
  animation: toastIn 0.3s ease-out;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

@keyframes toastIn { from { transform: translate(-50%, 100%); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ════════════════════════════════════════════════════════════
   BOT FAB
═══════════════════════════════════════════════════════════ */

.bot-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-size: 1.5rem;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  transition: all 0.2s;
  user-select: none;
}
.bot-fab:hover { transform: scale(1.1); box-shadow: var(--shadow-xl); }
.bot-fab:active { transform: scale(1.05); }

/* ════════════════════════════════════════════════════════════
   SYNC BANNER
═══════════════════════════════════════════════════════════ */

.sync-banner {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  right: 20px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
  box-shadow: var(--shadow-lg);
  z-index: 89;
  cursor: pointer;
  max-width: 280px;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.sync-banner.offline { background: var(--danger); }
.sync-banner.syncing { background: var(--warning); }
.sync-banner.success { background: var(--success); }

/* ════════════════════════════════════════════════════════════
   EMPTY STATES
═══════════════════════════════════════════════════════════ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty-state-icon { font-size: 3.5rem; margin-bottom: 12px; }
.empty-state-title { font-size: 1.1rem; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.empty-state-text { font-size: 0.88rem; line-height: 1.5; }

/* ════════════════════════════════════════════════════════════
   STATS / KPI
═══════════════════════════════════════════════════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-label { font-size: 0.78rem; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.stat-trend { font-size: 0.78rem; margin-top: 4px; color: var(--text-3); }

/* ════════════════════════════════════════════════════════════
   FILTERS / PILLS
═══════════════════════════════════════════════════════════ */

.filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.pill {
  padding: 5px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.pill:hover { border-color: var(--gray-400); }
.pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 600;
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVO (Mobile-first)
═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .app-screen {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  
  .sidebar {
    position: fixed;
    top: 0; left: -100%;
    width: 280px;
    transition: left 0.3s;
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { left: 0; }
  .sidebar-close { display: block; }
  .sidebar-toggle { display: block; }
  
  .main-content { padding: 16px; }
  
  .card-grid { grid-template-columns: 1fr; }
  
  .form-row { grid-template-columns: 1fr; }
  
  .modal { max-width: 95vw; }
  
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .topbar-title { font-size: 1rem; }
  .topbar-actions { gap: 0; }
  .topbar-btn { width: 34px; height: 34px; font-size: 1rem; }
  .page-title { font-size: 1.2rem; }
  
  .login-container { padding: 28px 20px; }
  .login-brand h1 { font-size: 1.5rem; }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
}

/* Animação de loading */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Utilitários */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.hidden { display: none !important; }
