:root {
  --primary: #1a4b8c;
  --primary-light: #dbeafe;
  --primary-dark: #0f3a6b;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --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: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

body {
  background-color: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Navbar ===== */
.navbar {
  background-color: #fff !important;
  border-bottom: 1px solid var(--gray-200);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.navbar-brand {
  font-weight: 700;
  color: var(--primary) !important;
}

.navbar-brand small {
  color: var(--gray-500) !important;
}

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

.user-label {
  font-size: 0.85rem;
  color: var(--gray-500);
  font-weight: 500;
}

.btn-logout {
  font-size: 0.8rem;
  color: var(--gray-400);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  transition: all 0.15s;
}

.btn-logout:hover {
  color: var(--danger);
  background: var(--danger-light);
}

/* ===== Tabs ===== */
.nav-tabs {
  border-bottom: 1px solid var(--gray-200);
}

.nav-tabs .nav-link {
  color: var(--gray-500);
  border: none;
  padding: 0.75rem 1.25rem;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}

.nav-tabs .nav-link:hover {
  color: var(--gray-700);
  border: none;
}

.nav-tabs .nav-link.active {
  color: var(--primary);
  background: transparent;
  border-bottom: 2px solid var(--primary);
}

.tab-content {
  padding-top: 1.5rem;
}

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

.card-header {
  background-color: #fff;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-800);
  font-weight: 600;
}

.card.dashboard-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.card .big-number {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--gray-900);
}

.dashboard-icon {
  font-size: 2rem;
  opacity: 0.25;
}

/* ===== Skeleton Loading ===== */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 6px;
  height: 1.2rem;
  margin-bottom: 0.5rem;
}

.skeleton-card {
  height: 100px;
  border-radius: var(--radius);
}

.skeleton-text { width: 60%; }
.skeleton-text-sm { width: 40%; height: 0.8rem; }

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Tables ===== */
.table {
  color: var(--gray-700);
  margin-bottom: 0;
}

.table thead th {
  border-bottom: 2px solid var(--gray-200);
  color: var(--gray-500);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background-color: var(--gray-50);
  white-space: nowrap;
}

.table td {
  vertical-align: middle;
  border-color: var(--gray-100);
}

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

/* ===== Ala Cards ===== */
.ala-card {
  background-color: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.ala-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.ala-card .ala-code {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-500);
}

.ala-card .ala-count {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--gray-900);
}

.ala-card.status-ok {
  border-left: 4px solid var(--success);
}

.ala-card.status-critico {
  border-left: 4px solid var(--danger);
}

.ala-regime {
  font-size: 0.7rem;
  background: var(--gray-100);
  color: var(--gray-500);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
  margin-top: 0.25rem;
}

.ala-regime.regime-24x72 {
  background: #1e3a5f;
  color: #93c5fd;
}

.ala-regime.regime-12x24 {
  background: #14532d;
  color: #86efac;
}

/* ===== Badges ===== */
.badge-ok {
  background-color: var(--success-light);
  color: var(--success);
  font-weight: 600;
}

.badge-critico {
  background-color: var(--danger-light);
  color: var(--danger);
  font-weight: 600;
}

.bg-purple {
  background-color: #7c3aed !important;
  color: #fff !important;
}

/* ===== Progress bar ===== */
.progress {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.progress i {
  display: block;
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.status-critico .progress i {
  background: var(--danger);
}

/* ===== List Items ===== */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.1s;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background: var(--gray-50);
}

.list-item strong {
  color: var(--gray-800);
  font-size: 0.9rem;
}

.list-item span {
  color: var(--gray-500);
  font-size: 0.8rem;
}

.alert-item-critico {
  background-color: #fff;
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

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

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--gray-400);
  font-size: 0.9rem;
}

/* ===== Tags ===== */
.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag.warning {
  background: var(--warning-light);
  color: var(--warning);
}

/* ===== Chip Filters ===== */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

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

/* ===== Calendar ===== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.25rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.75rem;
}

.calendar-day:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.calendar-day.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.calendar-day strong {
  font-size: 0.9rem;
  color: var(--gray-800);
}

.calendar-day span {
  color: var(--gray-500);
}

.calendar-day small {
  color: var(--gray-400);
}

.calendar-blank {
  min-height: 60px;
}

/* ===== Buttons ===== */
.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  border-radius: 8px;
}

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

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
  border-radius: 8px;
}

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

.btn-outline-danger {
  border-radius: 8px;
}

.btn-secondary {
  border-radius: 8px;
}

.danger.ghost {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.danger.ghost:hover {
  background: var(--danger-light);
}

.primary-button {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

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

.primary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== Forms ===== */
.form-control, .form-select {
  background-color: #fff;
  border: 1px solid var(--gray-300);
  color: var(--gray-800);
  border-radius: 8px;
}

.form-control:focus, .form-select:focus {
  background-color: #fff;
  border-color: var(--primary);
  color: var(--gray-800);
  box-shadow: 0 0 0 0.2rem rgba(26, 75, 140, 0.1);
}

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

.form-label {
  color: var(--gray-700);
  font-weight: 500;
  font-size: 0.875rem;
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.input-group-text {
  background-color: var(--gray-50);
  border: 1px solid var(--gray-300);
  color: var(--gray-500);
}

.search-box {
  background-color: #fff;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  width: 100%;
  max-width: 320px;
}

.search-box:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(26, 75, 140, 0.1);
}

.search-box::placeholder {
  color: var(--gray-400);
}

/* ===== Modal ===== */
.modal-content {
  background-color: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
}

.modal-header {
  border-bottom: 1px solid var(--gray-200);
}

.modal-footer {
  border-top: 1px solid var(--gray-200);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
}

.toast {
  background-color: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}

.toast-body {
  color: var(--gray-700);
}

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

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

/* ===== Login Page ===== */
.login-page {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-shell {
  width: 100%;
  max-width: 400px;
}

.login-panel {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem 2rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  justify-content: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 800;
}

.login-brand strong {
  display: block;
  font-size: 1.25rem;
  color: var(--gray-900);
}

.login-brand small {
  display: block;
  font-size: 0.8rem;
  color: var(--gray-500);
}

.login-panel h1 {
  font-size: 1.1rem;
  color: var(--gray-700);
  text-align: center;
  font-weight: 500;
  margin-bottom: 1.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-700);
}

.login-form input {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 75, 140, 0.1);
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 1rem;
}

.login-error.info {
  background: var(--warning-light);
  color: var(--warning);
}

/* ===== Text colors ===== */
.text-info { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary) !important; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .search-box {
    max-width: 100%;
  }

  .card .big-number {
    font-size: 1.75rem;
  }

  .ala-card .ala-count {
    font-size: 1.5rem;
  }

  .table-responsive table {
    font-size: 0.85rem;
  }

  .table td, .table th {
    white-space: nowrap;
  }

  .login-panel {
    padding: 1.5rem;
  }

  .user-label {
    display: none;
  }

  .navbar-brand small {
    display: none !important;
  }

  .calendar-grid {
    gap: 2px;
  }

  .calendar-day {
    padding: 0.35rem 0.1rem;
    font-size: 0.65rem;
  }
}

@media (max-width: 576px) {
  .nav-tabs .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
}
