:root {
  --bg-main: #090d16;
  --bg-surface: #111827;
  --bg-card: #182234;
  --bg-card-hover: #1f2c42;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #f59e0b;
  --primary-hover: #d97706;
  --primary-glow: rgba(245, 158, 11, 0.2);
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-sky: #0ea5e9;
  --th-bg: rgba(0, 0, 0, 0.25);
  --th-color: #94a3b8;
  --tr-hover: rgba(255, 255, 255, 0.03);
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --modal-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  --input-bg: #182234;
  --input-border: rgba(255, 255, 255, 0.12);
  --sidebar-w: 260px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-theme="light"], body.theme-light {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #d97706;
  --text-main: #0f172a;
  --text-muted: #475569;
  --primary: #d97706;
  --primary-hover: #b45309;
  --primary-glow: rgba(217, 119, 6, 0.2);
  --accent-emerald: #059669;
  --accent-rose: #e11d48;
  --accent-sky: #0284c7;
  --th-bg: #f1f5f9;
  --th-color: #1e293b;
  --tr-hover: #f8fafc;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --modal-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
aside.sidebar {
  width: var(--sidebar-w);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #b45309);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #000;
  box-shadow: 0 0 15px var(--primary-glow);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-badge {
  font-size: 10px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
}

nav.nav-menu {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.8px;
  padding: 10px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(245, 158, 11, 0.12);
  color: var(--primary);
  border-color: rgba(245, 158, 11, 0.25);
  font-weight: 600;
}

.nav-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tag-soon {
  font-size: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

/* User footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--primary);
}

.user-info {
  line-height: 1.2;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* Main Container */
main.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(circle at 80% 20%, rgba(245, 158, 11, 0.03), transparent 40%);
}

header.topbar {
  height: 64px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(10px);
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

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

.unit-selector {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}

/* Views viewport */
.view-container {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: fadeIn 0.25s ease forwards;
}

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

/* Grid & Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
  border-color: rgba(245, 158, 11, 0.3);
  transform: translateY(-2px);
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.metric-sub {
  font-size: 12px;
  color: var(--accent-emerald);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #000;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

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

/* Tables */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

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

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

table.data-table th {
  background: var(--th-bg);
  color: var(--th-color);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

table.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-main);
}

table.data-table tr:hover td {
  background: var(--tr-hover);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-CONFIRMADO { background: rgba(14, 165, 233, 0.15); color: var(--accent-sky); }
.badge-CHEGOU { background: rgba(245, 158, 11, 0.15); color: var(--primary); }
.badge-EM_ATENDIMENTO { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.badge-CONCLUIDO { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge-CANCELADO { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }
.badge-ABERTA { background: rgba(245, 158, 11, 0.15); color: var(--primary); }
.badge-PAGA { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge-ESTORNADA { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }
.badge-ATIVO { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge-INATIVO { background: rgba(148, 163, 184, 0.2); color: var(--text-muted); }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.open,
.modal-overlay.active {
  display: flex !important;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 92%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--modal-shadow);
  animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.modal-close-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.modal-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  overflow-x: auto;
}

.modal-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.modal-tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.modal-tab-btn.active {
  background: var(--primary);
  color: #000;
  font-weight: 700;
}

.modal-tab-content {
  display: none;
}

.modal-tab-content.active {
  display: block;
}

/* Navegação Hierárquica e Submenus Expansíveis (Gate D2) */
.nav-group {
  margin-bottom: 4px;
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #94a3b8;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  user-select: none;
}

.nav-group-header:hover {
  color: var(--text-main);
  background: var(--bg-card);
}

.nav-group-header .chevron {
  font-size: 9px;
  transition: transform 0.2s ease;
  color: #64748b;
}

.nav-group.open .nav-group-header .chevron {
  transform: rotate(90deg);
  color: var(--primary);
}

.nav-group-items {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding-left: 10px;
  margin-top: 2px;
}

.nav-group.open .nav-group-items {
  display: flex;
}

.nav-subitem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-subitem:hover {
  color: var(--text-main);
  background: var(--bg-card);
}

.nav-subitem.active {
  background: rgba(245, 158, 11, 0.12);
  color: var(--primary);
  font-weight: 600;
  border-left: 2px solid var(--primary);
}

/* Breadcrumbs (Gate D2) */
.breadcrumb-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.breadcrumb-root {
  color: var(--text-muted);
  font-weight: 500;
}

.breadcrumb-sep {
  opacity: 0.4;
  font-size: 10px;
}

.breadcrumb-active {
  color: var(--text-main);
  font-weight: 600;
}

/* Badges e Status */
.badge-AGUARDANDO { background: rgba(245, 158, 11, 0.15); color: var(--primary); }
.badge-NOTIFICADO { background: rgba(14, 165, 233, 0.15); color: var(--accent-sky); }
.badge-AGENDADO { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge-CHAMADO { background: rgba(168, 85, 247, 0.15); color: #c084fc; }

.badge-success { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.badge-danger { background: rgba(244, 63, 94, 0.15); color: #f43f5e; border: 1px solid rgba(244, 63, 94, 0.3); border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 600; }

/* Empty States e Loading */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.6;
}

.modal-card.modal-lg {
  max-width: 720px;
}

.badge-info { background: rgba(59, 130, 246, 0.15); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.3); border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.badge-purple { background: rgba(168, 85, 247, 0.15); color: #a855f7; border: 1px solid rgba(168, 85, 247, 0.3); border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.alert-box { padding: 12px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.alert-box.alert-danger { background: rgba(244, 63, 94, 0.12); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.3); }
.alert-box.alert-success { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.3); }
.alert-box.alert-warning { background: rgba(245, 158, 11, 0.12); color: #fde68a; border: 1px solid rgba(245, 158, 11, 0.3); }

/* Identidade Institucional (Gate B4) */
.sidebar-watermark {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  background: rgba(0, 0, 0, 0.25);
  line-height: 1.4;
}

.sidebar-watermark strong {
  color: var(--primary);
  font-weight: 600;
}

/* Botão Toggle Mobile */
.mobile-nav-toggle {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.mobile-nav-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.sidebar-backdrop {
  display: none;
}

/* Toast Notifications (Gate B4) */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  width: calc(100% - 40px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  animation: toastSlideIn 0.25s ease forwards;
  transition: opacity 0.25s ease, transform 0.25s ease;
  backdrop-filter: blur(8px);
}

.toast.fade-out {
  opacity: 0;
  transform: translateY(-10px);
}

.toast-info {
  background: #1e293b;
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #f8fafc;
}

.toast-success {
  background: #064e3b;
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #ecfdf5;
}

.toast-warning {
  background: #78350f;
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fffbeb;
}

.toast-error, .toast-danger {
  background: #881337;
  border: 1px solid rgba(244, 63, 94, 0.5);
  color: #fff1f2;
}

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  background: transparent;
  border: none;
  color: currentColor;
  opacity: 0.7;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
}

.toast-close:hover {
  opacity: 1;
}

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

/* Responsividade Mobile e Tablet (Gate B4) */
@media (max-width: 992px) {
  :root {
    --sidebar-w: 240px;
  }
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .mobile-nav-toggle {
    display: inline-flex;
  }

  aside.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 9999;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
  }

  aside.sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
    z-index: 9998;
  }

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

  .main-content {
    width: 100%;
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .metrics-grid {
    grid-template-columns: 1fr !important;
  }

  .view-container {
    padding: 12px;
  }

  /* Tabelas responsivas com scroll por toque */
  .table-responsive, .data-table-container, table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Modais utilizáveis por toque */
  .modal-card {
    width: 94% !important;
    max-width: 94% !important;
    margin: 16px auto;
    padding: 20px 16px !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Touch targets adequados */
  .btn, .form-control, .nav-subitem, .unit-selector {
    min-height: 42px;
    font-size: 14px;
  }
}


