@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #1a3a5c;
  --primary-light: #2a5080;
  --primary-dark: #0f2137;
  --secondary: #00a86b;
  --secondary-light: #00c97f;
  --accent: #e74c3c;
  --warning: #f39c12;
  --info: #3498db;
  --sidebar-bg: #0f2137;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active: #00a86b;
  --bg: #f0f4f8;
  --white: #ffffff;
  --text: #2d3748;
  --text-light: #718096;
  --border: #e2e8f0;
  --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
  --sidebar-width: 265px;
  --sidebar-collapsed: 70px;
  --header-height: 64px;
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f2137 0%, #1a3a5c 50%, #0f2137 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  animation: bgMove 20s linear infinite;
}

@keyframes bgMove { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.login-box {
  background: white;
  border-radius: 20px;
  padding: 48px;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 36px;
  box-shadow: 0 8px 24px rgba(0,168,107,0.3);
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-logo p {
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

.login-form .input-wrapper {
  position: relative;
}

.login-form .input-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 15px;
}

.login-form input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s;
  outline: none;
  color: var(--text);
}

.login-form input:focus {
  border-color: var(--primary);
}

.login-btn {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.login-btn:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,58,92,0.3);
}

.login-error {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  color: var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-light);
}

/* ===== APP LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  left: 0;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  min-width: 38px;
  background: linear-gradient(135deg, var(--secondary), #007a4e);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-brand {
  overflow: hidden;
  transition: opacity 0.2s;
}

.sidebar-brand h2 {
  color: white;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.sidebar-brand p {
  color: rgba(255,255,255,0.5);
  font-size: 10px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar.collapsed .sidebar-brand { opacity: 0; width: 0; }

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

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  padding: 8px 18px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.3);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}

.sidebar.collapsed .nav-section-title { opacity: 0; }

.nav-item {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 0;
  user-select: none;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: white;
}

.nav-link.active {
  background: rgba(0,168,107,0.15);
  color: var(--secondary);
  border-left: 3px solid var(--secondary);
}

.nav-link i {
  font-size: 17px;
  min-width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-link span {
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  transition: opacity 0.2s;
}

.sidebar.collapsed .nav-link span { opacity: 0; width: 0; overflow: hidden; }

.nav-badge {
  margin-left: auto;
  background: var(--secondary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  transition: opacity 0.2s;
}

.sidebar.collapsed .nav-badge { opacity: 0; }

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.sidebar-user:hover { background: var(--sidebar-hover); }

.user-avatar {
  width: 34px;
  height: 34px;
  min-width: 34px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info { overflow: hidden; transition: opacity 0.2s; }
.user-info strong { display: block; color: white; font-size: 12px; white-space: nowrap; }
.user-info small { color: rgba(255,255,255,0.4); font-size: 10px; white-space: nowrap; }

.sidebar.collapsed .user-info { opacity: 0; width: 0; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
}

.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* ===== HEADER ===== */
.app-header {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.toggle-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-light);
  transition: all 0.2s;
  flex-shrink: 0;
}

.toggle-btn:hover { background: var(--border); color: var(--text); }

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.header-breadcrumb h1 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.header-breadcrumb span {
  font-size: 13px;
  color: var(--text-light);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-unidade-badge {
  background: var(--primary);
  color: white;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.header-unidade-badge.all { background: var(--secondary); }

.header-date {
  font-size: 12px;
  color: var(--text-light);
}

.header-logout {
  width: 36px;
  height: 36px;
  border: none;
  background: #fff5f5;
  color: var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.2s;
}

.header-logout:hover { background: var(--accent); color: white; }

.header-sync {
  width: 36px;
  height: 36px;
  border: none;
  background: #e6fffa;
  color: #319795;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.2s;
}

.header-sync:hover { background: #319795; color: white; }

/* ===== PAGE CONTENT ===== */
.page-content {
  padding: 24px;
  flex: 1;
}

.page-section { display: none; }
.page-section.active { display: block; }

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

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue { background: #ebf8ff; color: var(--info); }
.stat-icon.green { background: #f0fff4; color: var(--secondary); }
.stat-icon.orange { background: #fffaf0; color: var(--warning); }
.stat-icon.red { background: #fff5f5; color: var(--accent); }
.stat-icon.purple { background: #faf5ff; color: #9b59b6; }
.stat-icon.teal { background: #e6fffa; color: #38b2ac; }

.stat-info { flex: 1; }
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
}
.stat-sub {
  font-size: 11px;
  color: var(--secondary);
  margin-top: 2px;
  font-weight: 500;
}

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

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i { color: var(--primary); }

.card-body { padding: 20px; }

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

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

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

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13.5px;
  color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: #f0fff4; color: #276749; }
.badge-red { background: #fff5f5; color: #c53030; }
.badge-yellow { background: #fffff0; color: #975a16; }
.badge-blue { background: #ebf8ff; color: #2b6cb0; }
.badge-gray { background: #f7fafc; color: #718096; }
.badge-purple { background: #faf5ff; color: #6b46c1; }
.badge-orange { background: #fffaf0; color: #c05621; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

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

.btn-success {
  background: var(--secondary);
  color: white;
}
.btn-success:hover { background: var(--secondary-light); }

.btn-danger {
  background: var(--accent);
  color: white;
}
.btn-danger:hover { background: #c0392b; }

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); border-color: var(--text-light); }

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  border-radius: var(--radius-sm);
}

/* ===== FORM ELEMENTS ===== */
.form-row { display: grid; gap: 16px; margin-bottom: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-control {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: white;
  transition: border-color 0.2s;
  outline: none;
  width: 100%;
}

.form-control:focus { border-color: var(--primary); }
.form-control:disabled { background: #f8fafc; color: var(--text-light); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ===== FILTERS BAR ===== */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-input {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 14px;
}

.search-input input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.search-input input:focus { border-color: var(--primary); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

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

.modal {
  background: white;
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.2s;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-overlay.open .modal { transform: scale(1); }

.modal-lg { max-width: 900px; }
.modal-sm { max-width: 440px; }

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 16px;
  transition: all 0.2s;
}

.modal-close:hover { background: #fee; color: var(--accent); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: #fafafa;
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== UNIDADE CARDS ===== */
.unidade-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.unidade-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: transform 0.2s;
}

.unidade-card:hover { transform: translateY(-2px); }

.unidade-card-header {
  padding: 20px;
  color: white;
  position: relative;
  overflow: hidden;
}

.unidade-card-header.julio {
  background: linear-gradient(135deg, #1a3a5c, #2a5080);
}

.unidade-card-header.caio {
  background: linear-gradient(135deg, #00a86b, #007a4e);
}

.unidade-card-header h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.unidade-card-header p {
  font-size: 12px;
  opacity: 0.8;
}

.unidade-card-stats {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.unidade-stat {
  text-align: center;
}

.unidade-stat .num {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.unidade-stat .lbl {
  font-size: 10px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ===== PRESENÇA TABLE ===== */
.presenca-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.presenca-col-aluno {
  border-right: 1px solid var(--border);
}

.presenca-header {
  padding: 10px 14px;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
}

.presenca-row {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.presenca-row:last-child { border-bottom: none; }

.presenca-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  color: transparent;
  flex-shrink: 0;
}

.presenca-check.presente {
  background: var(--secondary);
  border-color: var(--secondary);
  color: white;
}

.presenca-check.falta {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ===== CHART CONTAINER ===== */
.chart-container {
  position: relative;
  height: 240px;
}

/* ===== ALERT ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-info { background: #ebf8ff; color: #2b6cb0; border-left: 3px solid var(--info); }
.alert-success { background: #f0fff4; color: #276749; border-left: 3px solid var(--secondary); }
.alert-warning { background: #fffaf0; color: #975a16; border-left: 3px solid var(--warning); }
.alert-danger { background: #fff5f5; color: #c53030; border-left: 3px solid var(--accent); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
}

.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 13px; }

/* ===== TOOLTIP ===== */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: #1a2940;
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-light);
}

.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== SPINNER ===== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 380px;
  border-left: 4px solid var(--secondary);
  animation: slideIn 0.3s ease;
}

.toast.error { border-left-color: var(--accent); }
.toast.warning { border-left-color: var(--warning); }

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

.toast i { font-size: 18px; color: var(--secondary); }
.toast.error i { color: var(--accent); }
.toast.warning i { color: var(--warning); }
.toast-msg { font-size: 13px; font-weight: 500; flex: 1; }

/* ===== REPORT PRINT ===== */
@media print {
  .sidebar, .app-header, .btn, .filters-bar, .modal-overlay { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ===== RESPONSIVE ===== */

/* Overlay sidebar mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1050;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {

  /* Sidebar some por padrão, aparece como drawer */
  .sidebar, .sidebar.collapsed {
    transform: translateX(-100%) !important;
    transition: transform 0.3s ease, width 0.3s ease;
    width: var(--sidebar-width) !important;
    z-index: 1100;
  }
  .sidebar.mobile-open, .sidebar.collapsed.mobile-open {
    transform: translateX(0) !important;
  }

  /* Textos do sidebar sempre visíveis quando aberto */
  .sidebar .sidebar-brand,
  .sidebar .nav-link span,
  .sidebar .user-info,
  .sidebar .nav-section-title,
  .sidebar .nav-badge {
    opacity: 1 !important;
    width: auto !important;
  }

  /* Conteúdo ocupa 100% */
  .main-content, .main-content.expanded {
    margin-left: 0 !important;
  }

  /* Header */
  .app-header { padding: 0 12px; gap: 6px; }
  .header-date { display: none; }
  .header-unidade-badge { display: none !important; }
  .header-breadcrumb h1 { font-size: 14px; }
  .header-right { gap: 6px !important; }

  /* Page */
  .page-content { padding: 12px; }

  /* Grids */
  .grid-2, .grid-3, .unidade-cards { grid-template-columns: 1fr !important; }
  .grid-2 > *, .grid-3 > *, .unidade-cards > *, .card { min-width: 0 !important; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* Cabeçalho de Modalidades Responsivo */
  #section-modalidades > .d-flex.align-center {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }
  #section-modalidades > .d-flex.align-center > .d-flex {
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
  }
  #section-modalidades > .d-flex.align-center > .d-flex .btn {
    flex: 1 1 auto !important;
    justify-content: center !important;
    font-size: 12px !important;
    padding: 8px 12px !important;
    white-space: nowrap !important;
    min-width: 110px !important;
  }

  /* Cards */
  .card-header { flex-wrap: wrap !important; gap: 8px !important; padding: 12px 14px !important; }
  .card-header .d-flex {
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
    margin-top: 4px !important;
  }
  .card-header .d-flex .btn {
    flex: 1 1 auto !important;
    justify-content: center !important;
    font-size: 12px !important;
    padding: 8px 12px !important;
    white-space: nowrap !important;
    min-width: 120px !important;
  }
  .card-body { padding: 14px; }
  .stat-card {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    padding: 16px 10px !important;
    gap: 8px !important;
  }
  .stat-icon {
    width: 44px !important;
    height: 44px !important;
    font-size: 18px !important;
  }
  .stat-info {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
  }
  .stat-value {
    font-size: 20px !important;
    margin-bottom: 2px !important;
  }
  .stat-label {
    font-size: 11px !important;
    line-height: 1.2 !important;
  }
  .stat-sub {
    font-size: 9px !important;
    margin-top: 1px !important;
  }

  /* Tabelas com scroll */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }
  thead th, tbody td { padding: 9px 10px; font-size: 12px; white-space: nowrap; }

  /* Filtros empilhados */
  .filters-bar { flex-direction: column; align-items: stretch; gap: 8px !important; }
  .filters-bar .d-flex { flex-wrap: wrap !important; width: 100% !important; gap: 6px !important; }
  .search-input { min-width: unset; width: 100% !important; }
  .filters-bar select, .filters-bar input, .filters-bar button {
    flex: 1 1 auto !important;
  }

  /* Previne zoom automático chato no iOS Safari */
  input[type="text"], input[type="number"], input[type="email"], input[type="password"], select, textarea {
    font-size: 16px !important;
  }

  /* Sobrescrever grids inline de estatísticas/widgets com 3 ou 4 colunas nos módulos para 2 colunas no celular */
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"],
  .stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Em celulares muito estreitos (largura <= 480px), passa para 1 coluna */
  @media (max-width: 480px) {
    [style*="grid-template-columns:repeat(4,1fr)"],
    [style*="grid-template-columns:repeat(3,1fr)"],
    [style*="grid-template-columns: repeat(4, 1fr)"],
    [style*="grid-template-columns: repeat(3, 1fr)"],
    .stats {
      grid-template-columns: 1fr !important;
    }
  }

  /* Sobrescrever grids inline de 2 colunas para 1 coluna no celular */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:200px 1fr"],
  [style*="grid-template-columns: 200px 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Garantir que qualquer div pai direto de tabela tenha scroll horizontal */
  div:has(> table) {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Modais sobem da parte inferior */
  .modal-overlay { padding: 0 !important; align-items: flex-end; }
  .modal, .modal-lg, .modal-sm {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }
  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .modal-footer .btn { flex: 1; justify-content: center; }

  /* Tabs scroll */
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tab-btn { white-space: nowrap; }

  /* Toast */
  .toast-container { right: 10px; left: 10px; bottom: 12px; }
  .toast { min-width: unset; max-width: 100%; }

  /* Login */
  .login-box { padding: 28px 20px; margin: 12px; }

  /* Estilo Card Table responsivo para mobile */
  .responsive-table-cards table, 
  .responsive-table-cards thead, 
  .responsive-table-cards tbody, 
  .responsive-table-cards th, 
  .responsive-table-cards td, 
  .responsive-table-cards tr { 
    display: block !important; 
  }
  
  .responsive-table-cards thead tr { 
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
  }
  
  .responsive-table-cards tr {
    background: #ffffff !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 12px !important;
    margin-bottom: 16px !important;
    padding: 12px 16px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
  }
  
  .responsive-table-cards td { 
    border: none !important;
    border-bottom: 1px solid #f1f5f9 !important; 
    position: relative !important;
    padding: 10px 0 !important;
    text-align: right !important;
    font-size: 13.5px !important;
    white-space: normal !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
  }
  
  .responsive-table-cards td:last-child {
    border-bottom: 0 !important;
    padding-bottom: 0 !important;
  }
  
  .responsive-table-cards td::before { 
    content: attr(data-label) !important;
    font-weight: 700 !important;
    color: #4a5568 !important;
    text-align: left !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    padding-right: 12px !important;
  }
}

/* ===== MISC ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-light); }
.text-success { color: var(--secondary); }
.text-danger { color: var(--accent); }
.text-warning { color: var(--warning); }
.fw-600 { font-weight: 600; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.flex-1 { flex: 1; }
.separator { height: 1px; background: var(--border); margin: 16px 0; }
