:root {
  --primary:  #b30000;
  --accent:   #f0ad4e;
  --dark:     #07080e;
  --sidebar:  #0b0d1b;
  --card:     rgba(255,255,255,0.055);
  --border:   rgba(255,255,255,0.1);
  --text:     #e8e8e8;
  --muted:    #8a8a9a;
  --success:  #27ae60;
  --warning:  #e67e22;
  --danger:   #c0392b;
  --info:     #2980b9;
  --radius:   16px;
  --sidebar-w: 240px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--dark);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
}

a { color: inherit; text-decoration: none; }

/* ── Layout ────────────────────────────────────── */
.portal-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0e1020 0%, #0b0d1b 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
}
.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary));
}
.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(179,0,0,0.08) 0%, transparent 100%);
}
.sidebar-logo {
  max-width: 180px;
  max-height: 64px;
  width: auto;
  height: auto;
  filter: brightness(1.15) drop-shadow(0 0 12px rgba(240,173,78,0.3));
  transition: filter 0.3s ease;
}
.sidebar-logo:hover {
  filter: brightness(1.25) drop-shadow(0 0 18px rgba(240,173,78,0.5));
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.sidebar-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7a0000);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(179,0,0,0.35);
  border: 2px solid rgba(240,173,78,0.25);
}
.sidebar-user-info { overflow: hidden; }
.sidebar-name {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rol-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 3px;
}
.rol-alumno  { background: rgba(39,174,96,0.2);   color: #2ecc71; }
.rol-docente { background: rgba(41,128,185,0.2);   color: #3498db; }
.rol-admin   { background: rgba(179,0,0,0.2);      color: #e74c3c; }

.sidebar-nav {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-left-color: rgba(240,173,78,0.3);
}
.sidebar-link.active {
  background: rgba(240,173,78,0.08);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
}
.nav-icon { font-size: 1.05rem; width: 22px; text-align: center; }
.sidebar-logout {
  margin-top: auto;
  color: rgba(192,57,43,0.7);
  border-left-color: transparent !important;
}
.sidebar-logout:hover { background: rgba(192,57,43,0.1); color: #e74c3c; }

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

/* ── Topbar ────────────────────────────────────── */
.portal-topbar {
  position: sticky;
  top: 0; z-index: 90;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(11,13,27,0.95);
  backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}
.portal-topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(240,173,78,0.2), transparent);
}
.portal-page-title {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  color: var(--text);
  letter-spacing: 0.01em;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar-name {
  font-size: 13px;
  color: var(--muted);
}
.btn-logout {
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  color: var(--text);
}
.btn-logout:hover { background: rgba(192,57,43,0.18); border-color: rgba(192,57,43,0.4); color: #e74c3c; }

.portal-content {
  padding: 28px 32px;
  flex: 1;
}

/* ── Hamburger ─────────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Alert / Flash ─────────────────────────────── */
.alert {
  margin: 0 32px 0;
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border-left: 4px solid;
}
.alert-success { background: rgba(39,174,96,0.12);  border-color: var(--success); color: #2ecc71; }
.alert-error   { background: rgba(192,57,43,0.12);  border-color: var(--danger);  color: #e74c3c; }
.alert-warning { background: rgba(230,126,34,0.12); border-color: var(--warning); color: #e67e22; }
.alert-info    { background: rgba(41,128,185,0.12); border-color: var(--info);    color: #3498db; }

/* ── Stat grid ─────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 22px;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.25);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card::after {
  content: '';
  position: absolute;
  bottom: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: 0.06;
}
.stat-card.accent-red::before   { background: linear-gradient(90deg, var(--primary), #e74c3c); }
.stat-card.accent-red::after    { background: var(--primary); }
.stat-card.accent-red:hover     { border-color: rgba(179,0,0,0.3); }
.stat-card.accent-gold::before  { background: linear-gradient(90deg, var(--accent), #ffc16c); }
.stat-card.accent-gold::after   { background: var(--accent); }
.stat-card.accent-gold:hover    { border-color: rgba(240,173,78,0.3); }
.stat-card.accent-green::before { background: linear-gradient(90deg, var(--success), #2ecc71); }
.stat-card.accent-green::after  { background: var(--success); }
.stat-card.accent-green:hover   { border-color: rgba(39,174,96,0.3); }
.stat-card.accent-blue::before  { background: linear-gradient(90deg, var(--info), #3498db); }
.stat-card.accent-blue::after   { background: var(--info); }
.stat-card.accent-blue:hover    { border-color: rgba(41,128,185,0.3); }

.stat-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

/* ── Card ──────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}
.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}
.card-body { padding: 22px; }

/* ── Tables ────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.ptable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.ptable th {
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
}
table.ptable td {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
  color: var(--text);
  vertical-align: middle;
}
table.ptable tr:hover td { background: rgba(255,255,255,0.03); }

/* ── Badges ────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-green   { background: rgba(39,174,96,0.15);  color: #2ecc71; }
.badge-red     { background: rgba(192,57,43,0.15);  color: #e74c3c; }
.badge-yellow  { background: rgba(230,126,34,0.15); color: #e67e22; }
.badge-blue    { background: rgba(41,128,185,0.15); color: #3498db; }
.badge-gray    { background: rgba(138,138,154,0.15);color: var(--muted); }

/* ── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover { background: #d00000; }
.btn-accent    { background: var(--accent);   color: #0a0a0a; }
.btn-accent:hover  { background: #ffc16c; }
.btn-ghost     { background: rgba(255,255,255,0.07); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover   { background: rgba(255,255,255,0.12); }
.btn-danger    { background: rgba(192,57,43,0.15); color: #e74c3c; border: 1px solid rgba(192,57,43,0.3); }
.btn-danger:hover  { background: rgba(192,57,43,0.3); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }

/* ── Forms ─────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.85); }
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-select option { background: #0b0d1b; color: var(--text); }
.form-textarea { min-height: 100px; resize: vertical; }

/* ── File list ─────────────────────────────────── */
.file-list { display: flex; flex-direction: column; gap: 10px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.2s;
}
.file-item:hover { border-color: rgba(240,173,78,0.3); }
.file-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: rgba(240,173,78,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.file-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Modal ─────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #0e1022;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 20px;
}
.modal-close {
  position: absolute;
  top: 16px; right: 20px;
  background: none; border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* ── Upload area ───────────────────────────────── */
.upload-zone {
  border: 2px dashed rgba(240,173,78,0.3);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}
.upload-zone:hover,
.upload-zone.drag { border-color: var(--accent); background: rgba(240,173,78,0.04); }
.upload-zone-icon { font-size: 2.5rem; margin-bottom: 10px; }
.upload-zone-text { color: var(--muted); font-size: 14px; }
.upload-zone-text strong { color: var(--accent); }

/* ── Login page ────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(179,0,0,0.12) 0%, rgba(10,31,68,0.85) 45%, #07080e 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  top: -20%; left: -10%;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(179,0,0,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  bottom: -10%; right: -5%;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(240,173,78,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.login-card {
  background: rgba(11,13,27,0.96);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 28px;
  padding: 48px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 48px 96px rgba(0,0,0,0.5), 0 0 0 1px rgba(240,173,78,0.06);
  position: relative;
  z-index: 1;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 28px 28px 0 0;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary));
}
.login-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}
.login-logo {
  display: block;
  max-width: 200px;
  height: auto;
  margin: 0 auto 16px;
  filter: drop-shadow(0 0 20px rgba(240,173,78,0.3));
}
.login-divider {
  width: 40px; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 2px;
  margin: 0 auto;
}
.login-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 6px;
  margin-top: 20px;
  letter-spacing: -0.01em;
}
.login-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 28px;
}
.login-form .form-group { margin-bottom: 16px; }
.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #b30000, #8a0000);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 24px rgba(179,0,0,0.35);
  letter-spacing: 0.02em;
}
.login-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(179,0,0,0.45);
}
.login-back {
  display: block;
  text-align: center;
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
  transition: color 0.2s;
}
.login-back:hover { color: var(--accent); }
.login-error {
  background: rgba(192,57,43,0.12);
  border: 1px solid rgba(192,57,43,0.3);
  color: #e74c3c;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 18px;
  text-align: center;
}

/* ── Nota visual ───────────────────────────────── */
.nota-valor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 1rem;
}
.nota-aprobada { background: rgba(39,174,96,0.15);  color: #2ecc71; }
.nota-regular  { background: rgba(230,126,34,0.15); color: #e67e22; }
.nota-reprobada{ background: rgba(192,57,43,0.15);  color: #e74c3c; }

/* ── Empty state ───────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 14px; }
.empty-state-text { font-size: 15px; }

/* ── Page actions ──────────────────────────────── */
.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 8px 0 32px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .portal-main { margin-left: 0; }
  .portal-content { padding: 20px 16px; }
  .portal-topbar { padding: 12px 16px; }
  .topbar-name { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .card-header { flex-wrap: wrap; }
  table.ptable th, table.ptable td { padding: 10px 12px; }
}
