:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger-bg: #fee2e2;
  --success-bg: #dcfce7;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --white: #ffffff;
  --sidebar-width: 240px;
  --border-radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary-dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h1 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.sidebar-brand span {
  font-size: 11px;
  opacity: 0.6;
  display: block;
  margin-top: 2px;
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,0.12);
  color: var(--white);
}

.sidebar-nav a .icon { font-size: 18px; width: 24px; text-align: center; }

/* ── Main content ── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--white);
  padding: 16px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h2 { font-size: 18px; font-weight: 600; }

.content { padding: 24px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h3 { font-size: 15px; font-weight: 600; }

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.stat-card .stat-number {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 4px;
}

.stat-card.blue .stat-number { color: var(--primary); }
.stat-card.green .stat-number { color: var(--success); }
.stat-card.red .stat-number { color: var(--danger); }
.stat-card.orange .stat-number { color: var(--warning); }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 10px 12px;
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-600);
  white-space: nowrap;
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

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

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

tr.atrasado td { background: var(--danger-bg); }
tr.atrasado:hover td { background: #fecaca; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-green { background: var(--success-bg); color: var(--success); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-orange { background: var(--warning-bg); color: var(--warning); }
.badge-blue { background: #dbeafe; color: var(--primary); }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-light); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { opacity: 0.85; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { opacity: 0.85; }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-warning:hover { opacity: 0.85; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--gray-700);
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

textarea { resize: vertical; min-height: 80px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  margin: 16px;
}

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

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-body { padding: 20px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
}

.btn-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-600);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}

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

/* ── Alert ── */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #fca5a5; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #86efac; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fcd34d; }

/* ── Search / Filter bar ── */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar input, .filter-bar select { flex: 1; min-width: 160px; }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-600);
}

.empty .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty p { font-size: 14px; }

/* ── Tag alerta atraso ── */
.atraso-tag {
  display: inline-block;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.05em;
}

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.25s ease;
  min-width: 240px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

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

/* ── Hamburger (desktop: hidden) ── */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-700);
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.hamburger:hover { background: var(--gray-100); }

/* ── Sidebar close button (desktop: hidden) ── */
.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 22px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  margin-left: auto;
}
.sidebar-close:hover { color: var(--white); background: rgba(255,255,255,0.12); }

/* ── Sidebar overlay backdrop ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ── Responsive ── */
@media (max-width: 768px) {
  /* Sidebar becomes off-canvas drawer */
  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 101;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.35);
  }

  /* Row layout for brand + close button */
  .sidebar-brand {
    display: flex;
    align-items: center;
  }

  .sidebar-close { display: block; }
  .hamburger { display: block; }

  /* Main takes full width */
  .main { margin-left: 0; }

  .topbar { gap: 12px; }
  .content { padding: 16px; }

  /* Stats: 2 columns */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Forms collapse to single column */
  .form-grid { grid-template-columns: 1fr; }

  /* Tables: smaller and scroll horizontally */
  table { font-size: 13px; }
  th, td { padding: 8px 10px; }

  /* Filter bar stacks */
  .filter-bar { flex-direction: column; }
  .filter-bar input, .filter-bar select { min-width: 0; }

  /* Card header wraps on small screens */
  .card-header { flex-wrap: wrap; gap: 8px; }

  /* Modal full-width with small margin */
  .modal { margin: 8px; }

  /* Toast full-width at bottom */
  #toast-container { right: 12px; left: 12px; bottom: 16px; }
  .toast { min-width: 0; }
}
