:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #64748b;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;

  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --sidebar-width: 260px;
  --header-height: 64px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  font-smooth: always;
  overflow-x: hidden;
  max-width: 100vw;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Skip Navigation */
.skip-nav {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 10000;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
}

.skip-nav:focus {
  top: 0;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 300;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo svg {
  width: 24px;
  height: 24px;
  color: #fff;
}

.sidebar-logo-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: var(--radius);
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 2px;
}

/* SMTP Log Modal */
.modal-smtp {
  max-width: 800px;
  width: 90%;
}

.smtp-status {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 8px;
  letter-spacing: 0.05em;
}

.smtp-status-ok {
  background: #10b981;
  color: #fff;
}

.smtp-status-err {
  background: #ef4444;
  color: #fff;
}

.smtp-message {
  background: #f1f5f9;
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  border-left: 4px solid var(--primary);
  font-size: 0.9rem;
  word-break: break-word;
}

.modal-smtp h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--gray-700);
}

.smtp-log {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 6px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #1e293b;
}

.smtp-log-line {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  word-break: break-all;
}

.smtp-log-line:last-child {
  border-bottom: none;
}

.smtp-log-empty {
  color: #94a3b8;
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.nav-section {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  color: var(--gray-300);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(37,99,235,.2);
  color: var(--primary-light);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--gray-400);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: var(--radius);
  transition: all 0.15s;
}

.btn-logout:hover {
  background: rgba(255,255,255,.1);
  color: var(--danger);
}

.btn-logout svg {
  width: 18px;
  height: 18px;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

/* Header */
.header {
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 200;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-bell {
  position: relative;
  background: none;
  border: none;
  color: var(--gray-500);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  transition: all 0.15s;
}

.btn-bell:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-bell svg {
  width: 22px;
  height: 22px;
}

.bell-badge, .notif-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  border-radius: 9px;
  border: 2px solid #fff;
}

/* Page Content */
.page-content {
  flex: 1;
  padding: 1.5rem;
}

/* Cards */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.cyan { background: var(--info-light); color: var(--info); }

.stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.2;
  white-space: nowrap;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-weight: 500;
  margin-top: 0.125rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5625rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
  line-height: 1;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #15803d;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}

.btn-ghost:hover {
  background: var(--gray-100);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  min-height: 36px;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--gray-50);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-active { background: var(--success-light); color: var(--success); }
.badge-inactive { background: var(--gray-100); color: var(--gray-500); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--gray-800);
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 44px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.form-input::placeholder {
  color: var(--gray-400);
}

.text-uppercase {
  text-transform: uppercase;
}

td strong, .cliente-nome {
  text-transform: uppercase;
}

.form-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.form-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  padding: 0.5rem 0;
}
.form-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.form-switch-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--gray-300);
  border-radius: 999px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.form-switch-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.form-switch input[type="checkbox"]:checked + .form-switch-slider {
  background: var(--success, #10b981);
}
.form-switch input[type="checkbox"]:checked + .form-switch-slider::before {
  transform: translateX(20px);
}
.form-switch input[type="checkbox"]:focus-visible + .form-switch-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.form-switch-label {
  font-size: 0.9rem;
  color: var(--gray-700);
  font-weight: 500;
}

.whatsapp-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #fff;
  background: #128c7e;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.2s;
  white-space: nowrap;
}
.whatsapp-link:hover {
  background: #075e54;
  text-decoration: none;
}
.phone-link {
  display: inline-flex;
  align-items: center;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}
.phone-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.98);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: var(--radius);
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--gray-900);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 280px;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
  padding: 1.5rem;
}

.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo-icon {
  width: 56px;
  height: 56px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.login-logo-icon svg {
  width: 32px;
  height: 32px;
  color: #fff;
}

.login-logo-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 1rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gray-900);
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

.login-form {
  margin-top: 1.5rem;
}

.login-form .btn {
  width: 100%;
  margin-top: 0.5rem;
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1rem;
  display: none;
}

.login-error.show {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.login-success {
  background: #dcfce7;
  color: #166534;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
}

.login-footer a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--gray-400);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--gray-400);
  font-size: 0.875rem;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */

/* Overlay da sidebar — sempre no DOM, invisível por padrão */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 250;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.active {
  display: block;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--gray-700);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.menu-toggle svg {
  width: 24px;
  height: 24px;
  display: block;
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Stats grid 2 colunas */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .stat-card {
    padding: 1rem;
    gap: 0.625rem;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  /* Cards */
  .card-header {
    flex-wrap: wrap;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
  }

  .card-body {
    padding: 1rem;
    overflow-x: hidden;
  }

  .card-actions {
    flex-wrap: wrap;
    width: 100%;
    gap: 0.5rem;
  }

  .search-input {
    min-width: 0;
    flex: 1;
  }

  .filter-select {
    flex: 1;
    min-width: 0;
  }

  /* Tabelas — tabela responsiva sem scroll horizontal */
  .table-wrapper {
    overflow-x: hidden;
  }

  table {
    width: 100%;
    table-layout: fixed;
  }

  th, td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* WhatsApp link pode quebrar linha no mobile */
  .whatsapp-link {
    white-space: normal;
  }

  /* Page */
  .page-content {
    padding: 1rem;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Header */
  .header {
    padding: 0 1rem;
    z-index: 200;
  }

  .header-title {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Modal bottom sheet */
  .modal-overlay {
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  /* Form rows coluna única */
  .form-row {
    grid-template-columns: 1fr;
  }

  /* Toast na parte inferior */
  .toast-container {
    left: 0.75rem;
    right: 0.75rem;
    top: auto;
    bottom: 1rem;
  }

  .toast {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
  }

  .stat-icon {
    width: 38px;
    height: 38px;
  }

  .stat-icon svg {
    width: 18px;
    height: 18px;
  }

  .stat-value {
    font-size: 0.95rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .btn-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
    min-height: 32px;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-footer {
    padding: 0.875rem 1rem;
    flex-wrap: wrap;
  }

  .modal-footer .btn {
    flex: 1;
    justify-content: center;
  }

  .login-card {
    padding: 1.5rem 1.25rem;
  }

  .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }

  /* Ocultar colunas menos importantes nas tabelas */
  .col-hide-mobile {
    display: none;
  }

  /* Filtros e busca empilhados no mobile */
  .card-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    min-width: 0;
    width: 100%;
  }

  .filter-select {
    min-width: 0;
    width: 100%;
  }
}

/* Accessibility - Focus Visible */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}

/* Print */
/* Filters & Search */
.card-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.search-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  min-width: 220px;
  transition: border-color 0.15s;
}

.search-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-input input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.875rem;
  width: 100%;
  color: var(--gray-700);
}

.search-input svg {
  width: 16px;
  height: 16px;
  color: var(--gray-400);
  flex-shrink: 0;
}

.filter-select {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--gray-700);
  cursor: pointer;
  min-width: 140px;
}

.filter-select:focus {
  border-color: var(--primary);
  outline: none;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.pagination button {
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  font-size: 0.875rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.pagination button:hover:not(:disabled) {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.pagination button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 0.5rem;
  text-align: center;
}

.chart-container {
  width: 100%;
  overflow-x: auto;
}

.chart-container canvas {
  display: block;
}

.chart-legend {
  min-width: 140px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.8125rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-text {
  color: var(--gray-700, #334155);
  text-transform: uppercase;
  font-weight: 500;
}

.legend-value {
  color: var(--gray-500, #64748b);
  margin-left: auto;
  font-weight: 600;
  font-size: 0.75rem;
}

.help-section {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--gray-800, #1e293b);
  border: 1px solid var(--gray-700, #334155);
  border-radius: var(--radius-lg, 0.5rem);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
}

.help-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius, 0.375rem);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.help-icon svg {
  width: 24px;
  height: 24px;
}

.help-icon.blue { background: var(--primary-light); color: var(--primary); }
.help-icon.green { background: var(--success-light); color: var(--success); }
.help-icon.yellow { background: var(--warning-light); color: var(--warning); }
.help-icon.red { background: var(--danger-light); color: var(--danger); }
.help-icon.cyan { background: var(--info-light); color: var(--info); }
.help-icon.purple { background: rgba(139,92,246,0.1); color: #8b5cf6; }

.help-content h3 {
  margin: 0 0 0.375rem 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-100, #f1f5f9);
}

.help-content p {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  color: var(--gray-400, #94a3b8);
}

.help-content ul {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.8125rem;
  color: var(--gray-300, #cbd5e1);
  line-height: 1.8;
}

.help-content li {
  margin-bottom: 0.25rem;
}

.help-content strong {
  color: var(--gray-100, #f1f5f9);
}

@media print {
  .sidebar,
  .header,
  .skip-nav,
  .menu-toggle,
  .toast-container,
  .modal-overlay,
  .btn,
  .btn-bell,
  .btn-logout {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .page-content {
    padding: 0 !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }

  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }

  .stat-card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }
}
