:root {
  --bg-primary: #f5f7fb;
  --bg-secondary: #ffffff;
  --bg-sidebar: #1e293b;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-sidebar: #cbd5e1;
  --border: #e2e8f0;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
  --radius: 12px;
  --sidebar-width: 260px;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-sidebar: #0b1120;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-sidebar: #cbd5e1;
  --border: #334155;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ============ LOGIN ============ */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #2563eb 100%);
  padding: 20px;
}

[data-theme="dark"] .login-screen {
  background: linear-gradient(135deg, #1e1b4b 0%, #1e40af 100%);
}

.login-card {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 35px 30px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-header { text-align: center; margin-bottom: 25px; }

.logo-icon {
  width: 65px; height: 65px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  font-size: 28px; color: white;
  box-shadow: 0 8px 20px rgba(59,130,246,0.4);
}

.login-header h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-header p { color: var(--text-secondary); font-size: 13px; }

.tabs {
  display: flex; gap: 5px;
  background: var(--bg-primary);
  padding: 4px; border-radius: 10px;
  margin-bottom: 22px;
}

.tab {
  flex: 1; padding: 10px; border: none;
  background: transparent; color: var(--text-secondary);
  font-weight: 500; cursor: pointer;
  border-radius: 8px; transition: all 0.2s; font-size: 13px;
}

.tab.active {
  background: var(--bg-secondary);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.input-group { position: relative; margin-bottom: 14px; }
.input-group i {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%); color: var(--text-secondary);
}

.input-group input {
  width: 100%; padding: 12px 14px 12px 42px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px; transition: all 0.2s; font-family: inherit;
}

.input-group input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* Toggle password */
.password-group { display: flex; align-items: center; }
.password-group input { padding-right: 45px; }

.toggle-password {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--text-secondary); cursor: pointer;
  font-size: 16px; padding: 5px;
  transition: color 0.2s;
}
.toggle-password:hover { color: var(--accent); }

.btn-primary {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: white; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(59,130,246,0.4);
}

.btn-primary:disabled {
  opacity: 0.6; cursor: not-allowed; transform: none;
}

.btn-secondary {
  padding: 11px 18px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.error-msg {
  margin-top: 14px; padding: 10px;
  background: rgba(239,68,68,0.1);
  color: var(--danger); border-radius: 8px;
  font-size: 13px; text-align: center; display: none;
}
.error-msg.show { display: block; }

/* ============ LAYOUT ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex; flex-direction: column;
  position: fixed; height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px 18px;
  display: flex; align-items: center; gap: 10px;
  font-size: 17px; font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-header i { font-size: 22px; color: var(--accent); }

.close-sidebar-btn {
  display: none;
  margin-left: auto;
  background: none; border: none;
  color: var(--text-sidebar); font-size: 18px; cursor: pointer;
}

.sidebar-nav {
  flex: 1; padding: 12px 10px;
  display: flex; flex-direction: column; gap: 3px;
  overflow-y: auto;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  background: transparent; border: none;
  color: var(--text-sidebar); cursor: pointer;
  border-radius: 10px; text-align: left;
  font-size: 13px; font-weight: 500;
  transition: all 0.2s; width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-item.active {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: white; box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}
.nav-item i { width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px; border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; gap: 8px;
}

.theme-btn, .logout-btn {
  flex: 1; padding: 10px;
  background: rgba(255,255,255,0.05);
  border: none; color: var(--text-sidebar);
  border-radius: 8px; cursor: pointer;
  transition: all 0.2s; font-size: 13px;
}
.theme-btn:hover, .logout-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.logout-btn:hover { background: rgba(239,68,68,0.2); color: #fca5a5; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex; flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--bg-secondary);
  padding: 16px 25px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}

.menu-toggle {
  display: none;
  background: none; border: none;
  font-size: 22px; color: var(--text-primary);
  cursor: pointer; padding: 5px;
}

.page-title h2 { font-size: 20px; font-weight: 700; }
.page-title p { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }

.user-info {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  background: var(--bg-primary);
  border-radius: 25px; font-size: 13px; font-weight: 500;
}
.user-info i { font-size: 22px; color: var(--accent); }

.content { padding: 25px; flex: 1; }

.view { display: none; animation: fadeIn 0.3s; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ CARDS ============ */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  border: 1px solid var(--border);
}

.card h3 {
  font-size: 16px; font-weight: 600;
  margin-bottom: 18px;
  display: flex; align-items: center; gap: 10px;
}
.card h3 i { color: var(--accent); }

.card-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 18px;
  flex-wrap: wrap; gap: 12px;
}
.card-header h3 { margin-bottom: 0; }

/* ============ STATS ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 22px;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; align-items: center; gap: 15px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }

.stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: white; flex-shrink: 0;
}
.stat-icon.blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.stat-icon.green { background: linear-gradient(135deg, #10b981, #047857); }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }

.stat-info p { color: var(--text-secondary); font-size: 12px; margin-bottom: 3px; }
.stat-info h3 { font-size: 24px; font-weight: 700; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.list-container { display: flex; flex-direction: column; gap: 8px; }

.list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: var(--bg-primary);
  border-radius: 10px; transition: all 0.2s;
}
.list-item:hover { transform: translateX(3px); }

.list-item-info { display: flex; align-items: center; gap: 10px; }

.list-item-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}

.list-item-value { font-weight: 700; color: var(--accent); }

/* ============ CARGO SUMMARY ============ */
.cargo-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.cargo-box {
  padding: 18px;
  background: var(--bg-primary);
  border-radius: 12px;
  border-left: 4px solid var(--accent);
}

.cargo-box h4 {
  font-size: 13px; color: var(--text-secondary);
  margin-bottom: 8px; font-weight: 500;
}

.cargo-box .cargo-count {
  font-size: 22px; font-weight: 700;
  color: var(--text-primary);
}

.cargo-box .cargo-avg {
  font-size: 12px; color: var(--text-secondary);
  margin-top: 4px;
}

.cargo-box .cargo-min {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(99,102,241,0.1);
  color: var(--accent);
  border-radius: 6px;
  font-size: 11px; font-weight: 600;
  margin-top: 6px;
}

/* ============ TABLES ============ */
.table-wrapper { overflow-x: auto; border-radius: 10px; -webkit-overflow-scrolling: touch; }

.data-table { width: 100%; border-collapse: collapse; min-width: 500px; }

.data-table th {
  text-align: left; padding: 11px 14px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.data-table tr:hover { background: var(--bg-primary); }
.text-center { text-align: center; }

/* ============ FORMS ============ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; align-items: end;
}

.form-grid input, .form-grid select {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px; font-family: inherit;
  transition: all 0.2s; width: 100%;
}

.form-grid input:focus, .form-grid select:focus {
  outline: none; border-color: var(--accent);
}

.search-input {
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px; width: 220px; max-width: 100%;
}

.date-picker { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.date-picker input {
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ============ SESSION TOGGLE (Mañana/Tarde) ============ */
.session-toggle {
  display: flex;
  gap: 0;
  background: var(--bg-primary);
  padding: 4px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
}
.session-btn {
  padding: 9px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 9px;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.session-btn:hover {
  color: var(--text-primary);
  background: rgba(99,102,241,0.08);
}
.session-btn.active {
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  color: white;
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}
.session-btn i {
  font-size: 14px;
}

/* ============ SESSION TOGGLE (Mañana/Tarde) ============ */
.session-toggle {
  display: flex;
  gap: 0;
  background: var(--bg-primary);
  padding: 4px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
}
.session-btn {
  padding: 9px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 9px;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.session-btn:hover {
  color: var(--text-primary);
  background: rgba(99,102,241,0.08);
}
.session-btn.active {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}
.session-btn i {
  font-size: 14px;
}

/* ============ ATTENDANCE ============ */
.attendance-options {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}
.attendance-options label {
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  transition: all 0.2s;
  background: var(--bg-secondary);
  position: relative;
  margin: 0 auto;
}
.attendance-options label::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  transition: all 0.2s;
}
.attendance-options label:hover {
  border-color: var(--accent);
  transform: scale(1.1);
}
.attendance-options input { display: none; }

.attendance-options input[value="presente"]:checked + label {
  border-color: var(--success);
  background: rgba(16,185,129,0.1);
}
.attendance-options input[value="presente"]:checked + label::after {
  background: var(--success);
  box-shadow: 0 0 6px rgba(16,185,129,0.6);
}

.attendance-options input[value="tardanza"]:checked + label {
  border-color: var(--warning);
  background: rgba(245,158,11,0.1);
}
.attendance-options input[value="tardanza"]:checked + label::after {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(245,158,11,0.6);
}

.attendance-options input[value="ausente"]:checked + label {
  border-color: var(--danger);
  background: rgba(239,68,68,0.1);
}
.attendance-options input[value="ausente"]:checked + label::after {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(239,68,68,0.6);
}

/* Centrar encabezados de asistencia */
.data-table th.text-center {
  text-align: center !important;
}

.obs-input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 12px; width: 100%;
}

/* ============ BADGES ============ */
.badge {
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; display: inline-block;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--info); }

.cargo-badge {
  padding: 3px 8px; border-radius: 6px;
  font-size: 10px; font-weight: 600;
  display: inline-block;
}
.cargo-badge.coord { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.cargo-badge.obs { background: rgba(59,130,246,0.15); color: #3b82f6; }
.cargo-badge.jefe { background: rgba(245,158,11,0.15); color: #f59e0b; }
.cargo-badge.censista { background: rgba(16,185,129,0.15); color: #10b981; }

/* ============ ACTIONS ============ */
.action-btn {
  padding: 6px 9px; background: transparent;
  border: none; cursor: pointer;
  border-radius: 6px; transition: all 0.2s;
  color: var(--text-secondary); font-size: 13px;
}
.action-btn:hover { background: var(--bg-primary); }
.action-btn.edit:hover { color: var(--info); }
.action-btn.delete:hover { color: var(--danger); }

/* ============ RANKING ============ */
.ranking-list { display: flex; flex-direction: column; gap: 8px; }

.ranking-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg-primary); border-radius: 10px;
}

.ranking-position {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  background: var(--bg-secondary); color: var(--text-secondary);
}

.ranking-item:nth-child(1) .ranking-position { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: white; }
.ranking-item:nth-child(2) .ranking-position { background: linear-gradient(135deg, #94a3b8, #64748b); color: white; }
.ranking-item:nth-child(3) .ranking-position { background: linear-gradient(135deg, #d97706, #92400e); color: white; }

.ranking-info { flex: 1; }
.ranking-info h4 { font-size: 14px; margin-bottom: 2px; }
.ranking-info p { font-size: 11px; color: var(--text-secondary); }
.ranking-points { font-size: 18px; font-weight: 700; color: var(--accent); }

/* ============ PONDERACION ============ */
.ponderacion-info {
  margin-top: 20px;
  padding: 18px;
  background: var(--bg-primary);
  border-radius: 12px;
}

.ponderacion-info h4 {
  font-size: 14px;
  margin-bottom: 14px;
  color: var(--accent);
}

.ponderacion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.pond-item {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.pond-label {
  font-size: 18px; font-weight: 700;
  color: var(--accent);
}

.pond-desc {
  font-size: 11px; color: var(--text-secondary);
  margin-top: 2px;
}

.pond-pct {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary);
  margin-top: 4px;
}

/* ============ FINAL GRADE ============ */
.final-grade-card {
  border: 2px solid var(--accent);
}

.final-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.final-header h3 { font-size: 20px; margin-bottom: 4px; }
.final-header p { color: var(--text-secondary); font-size: 13px; }

.final-score {
  font-size: 42px; font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.final-details {
  display: flex; flex-direction: column; gap: 10px;
}

.final-item {
  display: flex; justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: var(--bg-primary);
  border-radius: 10px;
}

.final-label {
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}

.fcode {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: white;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}

.final-value {
  font-size: 18px; font-weight: 700;
  color: var(--text-primary);
}

.final-status {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  text-align: center;
  font-size: 16px; font-weight: 600;
}

.final-status.approved {
  background: rgba(16,185,129,0.1);
  color: var(--success);
  border: 1px solid var(--success);
}

.final-status.disapproved {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* ============ REPORT ============ */
.attendance-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}

.summary-box {
  padding: 18px 14px;
  background: var(--bg-primary);
  border-radius: 12px;
  text-align: center;
  transition: transform 0.2s;
}
.summary-box:hover { transform: translateY(-2px); }
.summary-box i { font-size: 24px; margin-bottom: 8px; display: block; }
.summary-box p { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.summary-box h3 { font-size: 22px; font-weight: 700; }
.summary-box.present i, .summary-box.present h3 { color: var(--success); }
.summary-box.late i, .summary-box.late h3 { color: var(--warning); }
.summary-box.absent i, .summary-box.absent h3 { color: var(--danger); }
.summary-box.participation i, .summary-box.participation h3 { color: var(--accent); }

/* ============ MODAL ============ */
.modal {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  animation: fadeIn 0.2s;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 28px;
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 20px;
}
.modal-header h3 {
  font-size: 18px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.modal-header h3 i { color: var(--accent); }
.modal-close {
  background: none; border: none;
  font-size: 20px; color: var(--text-secondary);
  cursor: pointer; padding: 5px;
}
.modal-close:hover { color: var(--danger); }

/* ============ TOAST ============ */
.toast {
  position: fixed; bottom: 25px; right: 25px;
  padding: 13px 20px;
  background: var(--bg-secondary);
  border-left: 4px solid var(--success);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 500;
  transform: translateX(400px);
  transition: transform 0.3s;
  z-index: 2000; max-width: 300px;
}
.toast.show { transform: translateX(0); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

.sidebar-overlay {
  display: none;
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .close-sidebar-btn { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .topbar { padding: 12px 15px; }
  .page-title h2 { font-size: 17px; }
  .user-info span { display: none; }
  .content { padding: 15px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; flex-direction: column; text-align: center; gap: 10px; }
  .stat-icon { width: 42px; height: 42px; font-size: 18px; }
  .stat-info h3 { font-size: 20px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .card-header { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .search-input { width: 100%; }
  .date-picker { width: 100%; flex-direction: column; }
  .date-picker input, .date-picker button { width: 100%; }
  .data-table { min-width: 450px; }
  .data-table th, .data-table td { padding: 10px; font-size: 12px; }
  .attendance-summary { grid-template-columns: repeat(2, 1fr); }
  .modal-content { padding: 20px; margin: 10px; }
  .toast { left: 15px; right: 15px; bottom: 15px; max-width: none; }
  .cargo-summary { grid-template-columns: 1fr 1fr; }
  .ponderacion-grid { grid-template-columns: 1fr; }
  .final-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .final-score { font-size: 36px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 25px 20px; }
  .attendance-summary { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .cargo-summary { grid-template-columns: 1fr; }

  .topbar-right {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }
  .datetime-display {
    padding: 5px 10px;
    font-size: 11px;
  }
  .datetime-date span {
    display: none; /* Ocultar fecha en móvil, solo mostrar hora */
  }
  .datetime-date i {
    display: none;
  }
  .user-info span {
    display: none;
  }

}






/* ============ DATETIME DISPLAY ============ */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.datetime-display {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  background: var(--bg-primary);
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}
.datetime-date,
.datetime-time {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.datetime-date i {
  color: var(--accent);
  font-size: 12px;
}
.datetime-time i {
  color: var(--success);
  font-size: 12px;
}
.datetime-time span {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}
.datetime-date span {
  color: var(--text-secondary);
}


/* ============ FOOTER ============ */
.app-footer {
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  padding: 10px 20px;
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 50;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.footer-copyright {
  font-weight: 500;
  opacity: 0.9;
}
.footer-sync {
  display: flex;
  align-items: center;
  gap: 7px;
}
.sync-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px rgba(16,185,129,0.6);
  animation: pulse 2s infinite;
}
.sync-text {
  font-weight: 500;
  color: #10b981;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Ajustar content para que no quede debajo del footer */
.content {
  padding: 25px;
  flex: 1;
  margin-bottom: 50px; /* Espacio para el footer */
}

@media (max-width: 768px) {
  .app-footer {
    left: 0;
    padding: 8px 15px;
  }
  .footer-copyright {
    display: none; /* Ocultar en móvil */
  }
  .footer-content {
    justify-content: center;
  }

  /* Ocultar fecha y hora en celular */
  .datetime-display {
    display: none !important;
  }
  
  .topbar-right {
    gap: 8px;
  }

}



/* ============ DASHBOARD CHARTS ============ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.chart-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chart-bar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.chart-bar-label {
  width: 140px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bar-track {
  flex: 1;
  height: 28px;
  background: var(--bg-primary);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s ease;
  display: flex;
  align-items: center;
  padding-left: 10px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  min-width: 30px;
}

.chart-bar-value {
  width: 50px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Colores para barras */
.bar-masculino { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.bar-femenino { background: linear-gradient(135deg, #ec4899, #db2777); }
.bar-coord { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.bar-obs { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.bar-jefe { background: linear-gradient(135deg, #f59e0b, #d97706); }
.bar-censista { background: linear-gradient(135deg, #10b981, #059669); }
.bar-nivel1 { background: linear-gradient(135deg, #10b981, #059669); }
.bar-nivel2 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.bar-nivel3 { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.bar-nivel4 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

/* Timeline de asistencias */
.timeline-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 200px;
  padding: 20px 10px 10px;
  background: var(--bg-primary);
  border-radius: 12px;
  position: relative;
}

.timeline-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.timeline-bar {
  width: 100%;
  max-width: 60px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  border-radius: 6px 6px 0 0;
  transition: height 0.6s ease;
  position: relative;
  min-height: 4px;
}

.timeline-bar-value {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.timeline-bar-label {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
}

.timeline-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  color: var(--text-secondary);
  font-size: 13px;
}


/* ============ EVALUACIÓN PARTICIPANTE ============ */
.eval-section {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.eval-section:last-of-type {
  border-bottom: none;
}
.eval-section h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
}
.eval-section h4 i {
  color: var(--accent);
}
.eval-section label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.eval-section textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  transition: all 0.2s;
}
.eval-section textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Grid de criterios */
.eval-criteria-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.eval-criterion {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.eval-criterion label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
}
.eval-criterion label small {
  color: var(--text-secondary);
  font-weight: 400;
}
.eval-input {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  transition: all 0.2s;
}
.eval-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* Total de evaluación */
.eval-total {
  margin-top: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: white;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 600;
}
.eval-total strong {
  font-size: 24px;
  font-weight: 800;
}

/* Control de tiempo */
.eval-time-check {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.eval-time-check label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}
.eval-time-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Resultado */
.eval-result-section {
  background: var(--bg-primary);
  padding: 18px;
  border-radius: 12px;
  border: 2px solid var(--accent);
}
.eval-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.eval-result-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.eval-result-item.full-width {
  grid-column: 1 / -1;
}
.eval-result-item label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.eval-result-value {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  border: 1px solid var(--border);
  min-height: 20px;
  display: flex;
  align-items: center;
}

/* Niveles de desempeño */
.perf-excelente { background: rgba(16,185,129,0.15) !important; color: var(--success) !important; border-color: var(--success) !important; }
.perf-bueno { background: rgba(59,130,246,0.15) !important; color: var(--info) !important; border-color: var(--info) !important; }
.perf-proceso { background: rgba(245,158,11,0.15) !important; color: var(--warning) !important; border-color: var(--warning) !important; }
.perf-mejora { background: rgba(239,68,68,0.15) !important; color: var(--danger) !important; border-color: var(--danger) !important; }

@media (max-width: 768px) {
  .eval-criteria-grid {
    grid-template-columns: 1fr;
  }
  .eval-result-grid {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}



/* ============ EVALUACIÓN RADIO BUTTONS ============ */
.eval-radio-group {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-radius: 10px;
}
.eval-radio-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.eval-radio-options {
  display: flex;
  gap: 15px;
}
.eval-radio-options-horizontal {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.eval-radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s;
}
.eval-radio-option:hover {
  border-color: var(--accent);
  background: rgba(99,102,241,0.05);
}
.eval-radio-option input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}
.eval-radio-option span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.eval-radio-option input[type="radio"]:checked + span {
  color: var(--accent);
  font-weight: 600;
}
.eval-radio-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(99,102,241,0.1);
}

@media (max-width: 768px) {
  .eval-radio-options {
    flex-direction: column;
    gap: 8px;
  }
}








@media print {
  .sidebar, .topbar, .menu-toggle, .btn-primary, .btn-secondary,
  .sidebar-overlay, .modal { display: none !important; }
  .main-content { margin-left: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}




/* ============ LOADER ============ */
.app-loader {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
}
[data-theme="dark"] .app-loader {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
}
.loader-content {
  text-align: center;
  color: white;
}
.loader-spinner {
  width: 50px; height: 50px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  margin: 0 auto 15px;
  animation: spin 0.8s linear infinite;
}
.loader-content p {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.5px;
  opacity: 0.9;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.app-loader.fade-out {
  opacity: 0;
  pointer-events: none;
}

.nav-item[data-view="finalgrade"],
#view-finalgrade {
  display: none !important;
}