/* ==============================
   VARIABLES Y RESET (Modern Glassmorphism)
============================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  /* Modern High Contrast Colors */
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  
  --indigo-900: #312e81;
  --indigo-800: #3730a3;
  --indigo-700: #4338ca;
  --indigo-600: #4f46e5;
  --indigo-500: #6366f1;
  --indigo-100: #e0e7ff;
  --indigo-50:  #eef2ff;
  
  --blue-600:  #2563eb;
  --blue-500:  #3b82f6;
  --sky-400:   #38bdf8;
  --sky-100:   #e0f2fe;

  --emerald-600: #059669;
  --emerald-500: #10b981;
  --emerald-100: #d1fae5;
  --emerald-50:  #ecfdf5;

  --rose-600:    #e11d48;
  --rose-500:    #f43f5e;
  --rose-100:    #ffe4e6;
  --rose-50:     #fff1f2;

  --amber-600:   #d97706;
  --amber-500:   #f59e0b;
  --amber-100:   #fef3c7;
  --amber-50:    #fffbeb;

  /* Legacy Mappings to Modern Values for JS Compatibility */
  --navy:    var(--slate-900);
  --navy-m:  var(--indigo-600);
  --blue:    var(--blue-500);
  --sky:     var(--sky-400);
  --sky-lt:  var(--slate-300);
  --sky-xl:  var(--indigo-50);
  --gold:    var(--amber-500);
  --ok:      var(--emerald-600);
  --danger:  var(--rose-600);
  --orange:  var(--amber-600);
  
  --gray-1:  var(--slate-50);
  --gray-2:  var(--slate-200);
  --gray-3:  var(--slate-400);
  --gray-4:  var(--slate-600);
  --text:    var(--slate-800);
  --white:   #ffffff;

  /* Glassmorphism Effects & Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 0 15px rgba(79, 70, 229, 0.3);
  
  --shadow:    var(--shadow-lg);
  
  --radius-sm: 8px;
  --radius:    16px;
  --radius-lg: 24px;
  --sb-w:      260px;
  
  /* Background gradients */
  --bg-app: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
  --bg-glass: rgba(255, 255, 255, 0.75);
  --bg-glass-heavy: rgba(255, 255, 255, 0.92);
  --border-glass: 1px solid rgba(255, 255, 255, 0.6);
  --backdrop-blur: blur(16px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { 
  height: 100%; 
  font-family: 'Inter', system-ui, -apple-system, sans-serif; 
  background: var(--bg-app); 
  color: var(--text); 
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: inherit; }
a { color: var(--indigo-600); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--indigo-800); }

/* Typography Scale */
h1, h2, h3, h4, .page-title, .num, .brand-motto, .hero-card h3, .dash-hero h3 {
  font-family: 'Outfit', sans-serif;
}

/* ==============================
   LOADING
============================== */
#loading {
  position: fixed; inset: 0; 
  background: var(--slate-900);
  background-image: radial-gradient(circle at center, var(--slate-800) 0%, var(--slate-900) 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 9999; gap: 28px;
}
.loading-brand {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.loading-brand img {
  width: 140px; height: auto; filter: drop-shadow(0 12px 24px rgba(0,0,0,.3));
  transform: scale(1); animation: pulseLogo 3s infinite alternate ease-in-out;
}
@keyframes pulseLogo {
  0% { transform: scale(0.98); filter: drop-shadow(0 0 15px rgba(99, 102, 241, 0.2)); }
  100% { transform: scale(1.02); filter: drop-shadow(0 0 25px rgba(99, 102, 241, 0.4)); }
}
#loading h1 {
  font-size: 2.5rem; font-weight: 700; color: var(--white);
  letter-spacing: -0.5px; text-align: center; margin-bottom: -4px;
}
#loading p { color: var(--slate-400); font-size: 1.05rem; }
.brand-motto {
  font-size: .85rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--indigo-500); font-weight: 600;
}
.spinner {
  width: 48px; height: 48px; border: 4px solid rgba(255,255,255,.1);
  border-top-color: var(--indigo-500); border-radius: 50%;
  animation: spin 1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==============================
   LOGIN
============================== */
#screen-login {
  display: none; position: fixed; inset: 0;
  background: var(--slate-900);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.15), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(56, 189, 248, 0.15), transparent 25%);
  align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: var(--bg-glass-heavy); 
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: var(--border-glass);
  border-radius: var(--radius-lg); 
  padding: 48px 40px;
  width: 100%; max-width: 420px; 
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; gap: 28px; align-items: center;
}
.login-logo {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem; font-weight: 800; color: var(--slate-900); text-align: center;
  letter-spacing: -0.5px;
}
.login-logo img { width: 100px; height: auto; margin-bottom: 8px;}
.login-logo span { 
  display: block; font-size: .95rem; font-weight: 400; 
  color: var(--slate-500); font-family: 'Inter', sans-serif; 
  margin-top: 2px; letter-spacing: normal;
}
.login-logo .brand-motto {
  color: var(--indigo-600); letter-spacing: .15em; font-size: 0.75rem;
  margin-top: 6px;
}
.login-card h2 { 
  font-size: 1.15rem; font-weight: 600; color: var(--slate-700); 
  text-align: center;
}
.inp-wrap { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.inp-wrap label { font-size: .88rem; font-weight: 600; color: var(--slate-700); }
.inp-wrap input {
  width: 100%; padding: 14px 16px; 
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm); font-size: 1rem; 
  color: var(--slate-900);
  transition: all .2s ease;
  box-shadow: inset 0 2px 4px 0 rgba(0,0,0,0.02);
}
.inp-wrap input:focus { 
  border-color: var(--indigo-500); 
  outline: none; 
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); 
  background: #fff;
}
.btn-primary {
  width: 100%; padding: 16px; 
  background: linear-gradient(135deg, var(--indigo-600) 0%, var(--indigo-800) 100%);
  color: var(--white); border-radius: var(--radius-sm); font-size: 1.05rem;
  font-weight: 600; letter-spacing: .5px; 
  transition: all .2s ease;
  box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
}
.btn-primary:hover { 
  background: linear-gradient(135deg, var(--indigo-500) 0%, var(--indigo-700) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}
.btn-primary:active { transform: translateY(1px); box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3); }
.btn-primary:disabled { opacity: .7; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  width: 100%; padding: 14px; background: rgba(255, 255, 255, 0.5);
  color: var(--slate-700); border-radius: var(--radius-sm); font-size: 1rem;
  font-weight: 600; border: 1px solid var(--slate-300); 
  transition: all .2s ease;
}
.btn-secondary:hover { 
  background: rgba(255, 255, 255, 0.9); 
  border-color: var(--slate-400); 
  color: var(--slate-900);
}

.login-note { font-size: .85rem; color: var(--slate-500); text-align: center; line-height: 1.6; min-height: 20px; }
.login-step { font-size: .95rem; color: var(--slate-600); text-align: center; line-height: 1.5; }
.login-actions { width: 100%; display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }

/* Modal general */
.modal-box {
  background: var(--bg-glass-heavy); 
  backdrop-filter: var(--backdrop-blur);
  border: var(--border-glass);
  border-radius: var(--radius-lg); padding: 36px 32px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column; gap: 24px;
  box-sizing: border-box;
}
.modal-box h3 { font-size: 1.25rem; font-weight: 700; color: var(--slate-900); letter-spacing: -0.5px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px;}
.btn-sec {
  padding: 12px 20px; border-radius: var(--radius-sm); font-size: .95rem;
  font-weight: 600; background: var(--slate-100); color: var(--slate-700);
  transition: all .2s ease; border: 1px solid transparent;
}
.btn-sec:hover { background: var(--slate-200); color: var(--slate-900); }
.btn-ok {
  padding: 12px 24px; border-radius: var(--radius-sm); font-size: .95rem;
  font-weight: 600; background: var(--indigo-600); color: var(--white); 
  transition: all .2s ease; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}
.btn-ok:hover { background: var(--indigo-500); box-shadow: 0 4px 15px rgba(79, 70, 229, 0.35); transform: translateY(-1px); }

/* Configuracion de docente */
#modal-cfg .modal-box {
  max-width: 720px;
}
.cfg-materias-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cfg-row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.cfg-row-actions label {
  font-size: .95rem;
  font-weight: 700;
  color: var(--slate-900);
}
.btn-add-materia,
.btn-del-materia {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: all .2s ease;
}
.btn-add-materia {
  padding: 8px 14px;
  background: var(--indigo-50);
  color: var(--indigo-700);
  border-color: var(--indigo-100);
}
.btn-add-materia:hover { background: var(--indigo-100); }
.cfg-materias-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cfg-materia-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px minmax(180px, 220px) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.72);
}
.cfg-materia-row input,
.cfg-materia-row select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  background: var(--white);
  color: var(--slate-800);
  font-size: .95rem;
}
.cfg-materia-row input:focus,
.cfg-materia-row select:focus {
  outline: none;
  border-color: var(--indigo-500);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.10);
}
.btn-del-materia {
  padding: 10px 14px;
  background: var(--rose-50);
  color: var(--rose-700);
  border-color: var(--rose-100);
  white-space: nowrap;
}
.btn-del-materia:hover { background: var(--rose-100); }
.cfg-materias-hint {
  font-size: .82rem;
  color: var(--slate-500);
  line-height: 1.4;
}
@media (max-width: 640px) {
  .cfg-materia-row {
    grid-template-columns: 1fr;
  }
  .btn-del-materia {
    width: 100%;
  }
}

/* ==============================
   APP LAYOUT
============================== */
#app {
  display: none; height: 100vh; flex-direction: column;
}
/* Header */
#header {
  height: 70px; 
  background: var(--bg-glass-heavy);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--slate-200);
  display: flex; align-items: center; padding: 0 28px; gap: 20px; flex-shrink: 0;
  z-index: 50; position: relative;
}
#header-logo {
  display: flex; align-items: center; gap: 16px;
  color: var(--slate-900); white-space: nowrap;
}
#header-logo img {
  width: 44px; height: 44px; object-fit: contain;
}
.header-logo-copy {
  display: flex; flex-direction: column; gap: 2px;
}
.header-logo-title {
  font-size: 1.25rem; font-weight: 800; color: var(--slate-900);
  letter-spacing: -0.5px;
}
.header-logo-copy .brand-motto {
  color: var(--indigo-600); font-size: .65rem; letter-spacing: .15em;
}
#header-user {
  margin-left: auto; display: flex; align-items: center; gap: 16px;
}
#header-name { color: var(--slate-700); font-weight: 500; font-size: 0.95rem; }
#header-session-status {
  padding: 6px 12px; border-radius: 999px; 
  background: var(--emerald-50); color: var(--emerald-600); 
  border: 1px solid var(--emerald-100);
  font-size: .8rem; font-weight: 600;
}
#btn-logout {
  padding: 8px 16px; border-radius: var(--radius-sm); 
  background: var(--slate-100); color: var(--slate-700); 
  font-size: .9rem; font-weight: 600; transition: all .2s; border: 1px solid transparent;
}
#btn-logout:hover { background: var(--rose-50); color: var(--rose-600); border-color: var(--rose-100);}

/* Body */
#body { display: flex; flex: 1; overflow: hidden; position: relative; }

/* Sidebar */
#sidebar {
  width: var(--sb-w); 
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  border-right: 1px solid rgba(255,255,255,0.8);
  box-shadow: 1px 0 10px rgba(0,0,0,0.02);
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
  z-index: 40;
}
.sb-section { padding: 24px 0 12px; }
.sb-section-title {
  padding: 0 24px 10px; font-size: .75rem; font-weight: 700;
  color: var(--slate-400); text-transform: uppercase; letter-spacing: 1.2px;
  font-family: 'Outfit', sans-serif;
}
.sb-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px; font-size: .95rem; font-weight: 500;
  color: var(--slate-600); cursor: pointer; transition: all .2s ease;
  border-left: 3px solid transparent; margin-bottom: 2px;
}
.sb-item:hover { 
  background: rgba(99, 102, 241, 0.05); 
  color: var(--indigo-700); 
}
.sb-item.active { 
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.1) 0%, transparent 100%);
  color: var(--indigo-700); 
  border-left-color: var(--indigo-600); 
  font-weight: 600; 
}
.sb-item .ico { font-size: 1.2rem; width: 24px; text-align: center; color: var(--slate-400); transition: color 0.2s;}
.sb-item:hover .ico, .sb-item.active .ico { color: var(--indigo-600); }

.sb-badge {
  margin-left: auto; padding: 2px 8px; border-radius: 20px;
  font-size: .75rem; font-weight: 700;
}
.sb-badge.ok   { background: var(--emerald-100); color: var(--emerald-600); }
.sb-badge.warn { background: var(--amber-100); color: var(--amber-600); }
.sb-badge.err  { background: var(--rose-100); color: var(--rose-600); }

/* Main */
#main { flex: 1; overflow-y: auto; padding: 40px; }

/* ==============================
   VISTAS
============================== */
.view { display: none; max-width: 1400px; margin: 0 auto; animation: fadeIn 0.4s ease-out forwards; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Títulos */
.page-title {
  font-size: 2.2rem; font-weight: 800; color: var(--slate-900); margin-bottom: 8px;
  letter-spacing: -0.5px;
}
.page-sub { font-size: 1.05rem; color: var(--slate-500); margin-bottom: 32px; font-weight: 400;}

/* Cards */
.card {
  background: var(--bg-glass-heavy);
  backdrop-filter: var(--backdrop-blur);
  border: var(--border-glass);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm); 
  padding: 28px;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

/* ==============================
   VIEW: DASHBOARD
============================== */
.dash-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: 20px; margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-glass-heavy); 
  backdrop-filter: var(--backdrop-blur);
  border: var(--border-glass);
  border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow-sm); text-align: left;
  display: flex; flex-direction: column;
}
.stat-card .num {
  font-size: 2.8rem; font-weight: 800; color: var(--indigo-600);
  line-height: 1; margin-bottom: 8px;
}
.stat-card .lbl { font-size: .95rem; font-weight: 500; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.5px; }

.diag-card { margin-bottom: 24px; }
.diag-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.diag-title { font-size: 1.15rem; font-weight: 700; color: var(--slate-900); font-family: 'Outfit', sans-serif;}
.diag-meta { font-size: .9rem; color: var(--slate-500); }
.diag-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: 16px;
}
.diag-item {
  border: 1px solid var(--slate-200); border-radius: var(--radius-sm);
  padding: 16px 20px; background: rgba(255,255,255,0.5);
}
.diag-item h4 { font-size: .85rem; color: var(--slate-500); text-transform: uppercase; font-weight: 700; letter-spacing: .5px; margin-bottom: 10px; }
.diag-item p { font-size: .95rem; color: var(--text); line-height: 1.6; }
.diag-item ul { margin: 10px 0 0 20px; color: var(--slate-600); font-size: .9rem; padding-left: 0; }
.diag-pill {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: .8rem; font-weight: 600;
}
.diag-pill.ok   { background: var(--emerald-100); color: var(--emerald-600); }
.diag-pill.warn { background: var(--amber-100); color: var(--amber-600); }
.diag-pill.bad  { background: var(--rose-100); color: var(--rose-600); }

/* CSV Guide */
.csv-guide {
  background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(240,24df,250,0.9) 100%);
  border: 1px solid var(--indigo-100);
  margin-bottom: 32px;
}

/* Heros */
.dash-hero, .hero-card {
  background: linear-gradient(135deg, var(--indigo-900) 0%, var(--indigo-600) 100%);
  color: var(--white); margin-bottom: 32px;
  position: relative; overflow: hidden;
  box-shadow: 0 10px 30px -10px rgba(79, 70, 229, 0.5);
  border: none;
}
.dash-hero::after, .hero-card::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  background: url('data:image/svg+xml;utf8,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="2" fill="rgba(255,255,255,0.1)"/></svg>') repeat;
  opacity: 0.5; pointer-events: none;
}
.dash-hero h3, .hero-card h3 {
  font-size: 2.2rem; margin-bottom: 12px; font-weight: 800; letter-spacing: -0.5px;
  position: relative; z-index: 2;
}
.dash-hero p, .hero-card p { 
  color: rgba(255,255,255,.85); line-height: 1.6; max-width: 800px; font-size: 1.1rem;
  position: relative; z-index: 2;
}

.dash-hero-metrics, .hero-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr));
  gap: 16px; margin-top: 24px; position: relative; z-index: 2;
}
.dash-hero-item, .hero-item {
  background: rgba(255,255,255,.1); border-radius: var(--radius-sm); padding: 16px 20px;
  backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.1);
}
.dash-hero-item strong, .hero-item strong { display: block; font-size: 1.4rem; margin-bottom: 6px; font-family: 'Outfit', sans-serif;}
.dash-hero-item span, .hero-item span { font-size: .85rem; color: rgba(255,255,255,.8); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;}

/* Lists & Priorities */
.dash-priority {
  background: var(--bg-glass-heavy); backdrop-filter: var(--backdrop-blur);
  border: var(--border-glass); box-shadow: var(--shadow-sm);
  margin-bottom: 24px; border-radius: var(--radius); padding: 28px;
}
.dash-priority-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.dash-priority-title { font-size: 1.15rem; font-weight: 700; color: var(--slate-900); font-family: 'Outfit', sans-serif;}
.dash-priority-sub { font-size: .9rem; color: var(--slate-500); line-height: 1.55; }
.dash-priority-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}
.dash-priority-item {
  border: 1px solid var(--slate-200); border-radius: var(--radius-sm); background: rgba(255,255,255,0.5);
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dash-priority-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); background: #fff;}
.dash-priority-item strong { font-size: 1.05rem; font-weight: 600; color: var(--slate-900); }
.dash-priority-item p { font-size: .9rem; color: var(--slate-600); line-height: 1.6; }

/* Charts */
.dash-charts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 20px; margin-bottom: 32px;
}
.chart-card {
  background: var(--bg-glass-heavy); border: var(--border-glass);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm);
}
.chart-card h3 { font-size: 1.1rem; font-weight: 700; color: var(--slate-900); margin-bottom: 8px; font-family: 'Outfit', sans-serif;}
.chart-card p { font-size: .9rem; color: var(--slate-500); margin-bottom: 20px; line-height: 1.5; }
.chart-list { display: flex; flex-direction: column; gap: 14px; }
.chart-row { display: grid; grid-template-columns: minmax(100px, 1fr) 1.5fr auto; gap: 12px; align-items: center; }
.chart-row label { font-size: .9rem; color: var(--slate-700); font-weight: 500;}
.chart-bar-track {
  width: 100%; height: 8px; border-radius: 999px; background: var(--slate-100); overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}
.chart-bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--indigo-500), var(--sky-400)); }
.chart-row strong { font-size: .9rem; color: var(--slate-900); font-weight: 700;}
.mini-donut { width: 180px; height: 180px; margin: 0 auto 20px; display: block; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.05));}
.donut-hole-label { font-size: 1.6rem; font-weight: 800; fill: var(--slate-900); font-family: 'Outfit', sans-serif;}
.donut-hole-sub { font-size: .8rem; fill: var(--slate-500); font-weight: 500;}

/* Table */
.dash-table-card { overflow: hidden; padding: 0; }
.dash-list-card {
  display: grid;
  gap: 0;
}

.dash-list-head {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(220px, 0.9fr) minmax(280px, 1.2fr) minmax(320px, 1fr);
  gap: 18px;
  padding: 18px 24px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--slate-200);
  color: var(--slate-500);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.dash-list-body {
  display: grid;
}

.dash-list-empty {
  padding: 28px 24px;
  color: var(--slate-500);
  text-align: center;
}

.dash-row-card {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(220px, 0.9fr) minmax(280px, 1.2fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
  padding: 24px;
  border-bottom: 1px solid var(--slate-100);
  transition: background 0.2s ease;
}

.dash-row-card:last-child {
  border-bottom: none;
}

.dash-row-card:hover {
  background: var(--indigo-50);
}

.dash-row-main,
.dash-row-meta,
.dash-row-materias,
.dash-row-actions-wrap {
  min-width: 0;
}

.dash-row-main,
.dash-row-meta,
.dash-row-materias,
.dash-row-actions-wrap {
  display: grid;
  gap: 12px;
}

.dash-row-title strong {
  display: block;
  font-size: 1rem;
  color: var(--slate-900);
}

.dash-row-title small {
  display: block;
  margin-top: 6px;
  color: var(--slate-400);
  font-size: .95rem;
  overflow-wrap: anywhere;
}

.dash-row-meta {
  gap: 12px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(255, 255, 255, 0.92));
  border: 1px solid var(--slate-200);
}

.dash-row-block {
  display: grid;
  gap: 6px;
}

.dash-row-block p {
  margin: 0;
  color: var(--slate-700);
  line-height: 1.45;
}

.dash-row-block strong {
  color: var(--slate-900);
  font-size: .98rem;
}

.dash-row-label {
  display: inline-flex;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--slate-400);
  margin-bottom: 10px;
}

.dash-row-empty {
  margin: 0;
  color: var(--slate-500);
}

.tag-cluster { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: var(--radius-sm);
  padding: 6px 10px; background: var(--white); color: var(--slate-700); font-size: .85rem; font-weight: 600;
  border: 1px solid var(--slate-200); box-shadow: var(--shadow-sm);
}
.tag-chip .tag-meta { color: var(--indigo-600); font-weight: 700; font-size: 0.8rem;}

.badge {
  display: inline-block; padding: 6px 12px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; letter-spacing: 0.3px;
}
.badge.al-dia  { background: var(--emerald-100); color: var(--emerald-600); }
.badge.sin-ver { background: var(--amber-100); color: var(--amber-600); }
.badge.sincronizado { background: var(--sky-100); color: var(--sky-700); }
.badge.pendiente { background: var(--slate-100); color: var(--slate-500); }

/* Botones menores */
.btn-sm {
  padding: 8px 16px; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all .2s ease; border: 1px solid transparent;
}
.btn-cfg  { background: var(--white); color: var(--slate-700); border-color: var(--slate-300); box-shadow: var(--shadow-sm);}
.btn-cfg:hover  { background: var(--slate-50); border-color: var(--slate-400); color: var(--slate-900);}
.btn-exp  { background: var(--indigo-50); color: var(--indigo-700); border-color: var(--indigo-100); box-shadow: var(--shadow-sm);}
.btn-exp:hover  { background: var(--indigo-100); }

.dash-row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
}

.dash-row-actions .btn-sm {
  padding-inline: 12px;
}

@media (max-width: 1380px) {
  .dash-list-head,
  .dash-row-card {
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 0.9fr);
  }

  .dash-row-actions-wrap {
    grid-column: 1 / -1;
  }
}

/* ==============================
   VIEW: MATERIAS
============================== */
.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 24px; }
.mat-year {
  display: inline-flex; align-items: center; justify-content: center;
  align-self: flex-start; padding: 6px 12px; border-radius: 999px;
  background: var(--indigo-50); color: var(--indigo-600); font-size: .8rem; font-weight: 700;
  margin-bottom: 8px;
}
.mat-card {
  background: var(--bg-glass-heavy); backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 28px;
  box-shadow: var(--shadow-sm); cursor: pointer; transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden;
}
.mat-card::before {
  content: ''; position: absolute; top:0; left:0; right:0; height: 4px;
  background: linear-gradient(90deg, var(--indigo-500), var(--sky-400));
  opacity: 0; transition: opacity 0.3s;
}
.mat-card:hover { 
  transform: translateY(-4px); 
  box-shadow: var(--shadow-md); 
  border-color: var(--slate-300);
}
.mat-card:hover::before { opacity: 1; }
.mat-icon { font-size: 2.2rem; margin-bottom: 4px; }
.mat-name { font-weight: 800; font-size: 1.25rem; color: var(--slate-900); font-family: 'Outfit', sans-serif; line-height: 1.2;}
.mat-area { font-size: .95rem; color: var(--slate-500); }
.mat-status { font-size: .85rem; font-weight: 600; margin-top: auto; padding-top: 12px;}
.mat-status.ok    { color: var(--emerald-600); }
.mat-status.empty { color: var(--amber-600); }

/* ==============================
   VIEW: EDITOR
============================== */
.editor-toolbar {
  display: flex; align-items: center; gap: 16px; margin-bottom: 32px; flex-wrap: wrap;
  background: var(--bg-glass-heavy); padding: 16px 20px; border-radius: var(--radius-sm);
  border: var(--border-glass); box-shadow: var(--shadow-sm);
}
.btn-add-u {
  padding: 12px 24px; background: var(--indigo-600); color: var(--white);
  border-radius: var(--radius-sm); font-size: .95rem; font-weight: 600; transition: all .2s;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}
.btn-add-u:hover { background: var(--indigo-500); box-shadow: 0 4px 15px rgba(79, 70, 229, 0.35); transform: translateY(-1px);}
.btn-save-draft {
  padding: 12px 20px; background: var(--white); color: var(--slate-700); border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm); font-size: .95rem; font-weight: 600; transition: all .2s;
}
.btn-save-draft:hover { background: var(--slate-50); color: var(--slate-900); border-color: var(--slate-400);}
.btn-save-ver {
  padding: 12px 20px; background: var(--emerald-100); color: var(--emerald-700); border: 1px solid var(--emerald-200);
  border-radius: var(--radius-sm); font-size: .95rem; font-weight: 600; transition: all .2s;
}
.btn-save-ver:hover { background: var(--emerald-200); color: var(--emerald-800); }
.btn-historial {
  padding: 12px 20px; background: var(--slate-100); color: var(--slate-700); border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm); font-size: .95rem; font-weight: 600; transition: all .2s;
}
.btn-historial:hover { background: var(--slate-200); }
.autosave-lbl { font-size: .85rem; color: var(--slate-400); margin-left: auto; font-weight: 500;}

/* Resumen Anual */
.editor-summary {
  background: var(--bg-glass-heavy);
  border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 24px;
  margin-bottom: 32px; box-shadow: var(--shadow-sm);
}
.editor-summary-head {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  flex-wrap: wrap; margin-bottom: 20px;
}
.editor-summary-title { font-size: 1.15rem; font-weight: 800; color: var(--slate-900); font-family: 'Outfit', sans-serif;}
.editor-summary-sub { font-size: .95rem; color: var(--slate-500); margin-top: 4px; line-height: 1.5;}
.editor-summary-count {
  background: var(--indigo-50); border: 1px solid var(--indigo-100); border-radius: 999px;
  padding: 8px 16px; font-size: .85rem; font-weight: 700; color: var(--indigo-700);
}
.editor-summary-wrap {
  overflow-x: auto; border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm); background: var(--white);
}
.editor-summary-table { width: 100%; min-width: 980px; border-collapse: collapse; }
.editor-summary-table th,
.editor-summary-table td {
  padding: 16px; border-bottom: 1px solid var(--slate-100);
  vertical-align: top; text-align: left; font-size: .9rem;
  color: var(--slate-700);
}
.editor-summary-table th {
  background: var(--slate-50); color: var(--slate-600); font-size: .8rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.editor-summary-table tbody tr:last-child td { border-bottom: none; }
.editor-summary-table tbody tr:hover td { background: var(--slate-50); }
.summary-empty { text-align: center; color: var(--slate-400); font-style: italic; padding: 40px !important;}
.summary-unit-title { font-weight: 700; color: var(--slate-900); margin-bottom: 6px; font-size: 1rem;}
.summary-unit-label { font-size: .75rem; color: var(--slate-400); text-transform: uppercase; font-weight: 600;}

/* Campos y Unidades */
.bib-wrap { margin-bottom: 32px; background: var(--white); padding: 24px; border-radius: var(--radius); border: 1px solid var(--slate-200); box-shadow: var(--shadow-sm);}
.bib-wrap label { font-size: 1rem; font-weight: 700; color: var(--slate-900); display: block; margin-bottom: 12px; font-family: 'Outfit', sans-serif;}
.bib-wrap textarea {
  width: 100%; padding: 16px; border: 2px solid var(--slate-200); background: var(--slate-50);
  border-radius: var(--radius-sm); font-size: 1rem; resize: vertical;
  min-height: 100px; transition: all .2s ease; line-height: 1.6;
}
.bib-wrap textarea:focus { border-color: var(--indigo-500); background: #fff; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); }

.unidades-list { display: flex; flex-direction: column; gap: 24px; }
.unidad-card {
  background: var(--bg-glass-heavy); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden; border: 1px solid var(--slate-200);
  transition: box-shadow 0.3s ease;
}
.unidad-card:hover { box-shadow: var(--shadow-md); border-color: var(--slate-300);}
.unidad-header {
  display: flex; align-items: center; gap: 16px; padding: 20px 24px;
  background: rgba(248, 250, 252, 0.8); border-bottom: 1px solid var(--slate-200);
  cursor: pointer; user-select: none; transition: background 0.2s;
}
.unidad-header:hover { background: #fff; }
.unidad-num {
  min-width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--indigo-600) 0%, var(--indigo-800) 100%);
  color: var(--white); font-size: .95rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}
.unidad-titulo-inp {
  flex: 1; border: none; background: transparent; font-size: 1.15rem;
  font-weight: 700; color: var(--slate-900); font-family: 'Outfit', sans-serif;
  padding: 4px 8px; border-radius: 4px; transition: background 0.2s;
}
.unidad-titulo-inp:hover, .unidad-titulo-inp:focus { background: rgba(0,0,0,0.03); outline: none;}
.btn-del-u {
  padding: 8px 14px; border-radius: var(--radius-sm); background: var(--rose-50);
  color: var(--rose-600); font-size: .85rem; font-weight: 600; opacity: 0;
  transition: all .2s ease; border: 1px solid transparent;
}
.unidad-card:hover .btn-del-u { opacity: 1; }
.btn-del-u:hover { background: var(--rose-100); border-color: var(--rose-200);}
.chevron { font-size: 1.2rem; color: var(--slate-400); transition: transform .3s ease; }
.chevron.open { transform: rotate(90deg); color: var(--indigo-500);}

.unidad-body { padding: 32px 24px; display: none; flex-direction: column; gap: 24px; background: #fff; }
.unidad-body.open { display: flex; animation: slideDown 0.3s ease-out; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.field-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 24px;
}
.field-group { display: flex; flex-direction: column; gap: 8px; }
.field-group label { font-size: .95rem; font-weight: 700; color: var(--slate-800); }
.field-group small { font-size: .85rem; color: var(--slate-500); line-height: 1.4; margin-bottom: 4px;}
.field-group textarea, .field-group input {
  width: 100%; padding: 14px 16px; border: 2px solid var(--slate-200); background: var(--slate-50);
  border-radius: var(--radius-sm); font-size: .95rem; resize: vertical; min-height: 90px;
  transition: all .2s ease; font-family: inherit; line-height: 1.5; color: var(--slate-800);
}
.field-group textarea:focus, .field-group input:focus { 
  border-color: var(--indigo-500); outline: none; background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.field-group input { min-height: auto; }
.u-expectativas { min-height: 160px; }


/* ==============================
   VIEW: HISTORIAL
============================== */
.hist-list { display: flex; flex-direction: column; gap: 16px; margin-top: 16px;}
.hist-item {
  background: var(--bg-glass-heavy); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 20px; border: var(--border-glass);
}
.hist-date { font-size: .95rem; color: var(--slate-500); min-width: 150px; font-weight: 500;}
.hist-motivo { flex: 1; font-size: 1.05rem; font-weight: 500; color: var(--slate-800); }
.hist-vid { font-size: .85rem; color: var(--slate-400); font-family: monospace; }
.btn-rest {
  padding: 10px 20px; border-radius: var(--radius-sm); background: var(--white);
  color: var(--indigo-700); font-size: .9rem; font-weight: 600; border: 1px solid var(--slate-300);
  flex-shrink: 0; transition: all .2s ease; box-shadow: var(--shadow-sm);
}
.btn-rest:hover { background: var(--slate-50); border-color: var(--indigo-400); color: var(--indigo-800); transform: translateY(-1px);}

/* ==============================
   VIEW: PENDIENTE / CLAVE
============================== */
.pendiente-box {
  background: var(--bg-glass-heavy); backdrop-filter: var(--backdrop-blur);
  border-radius: var(--radius-lg); padding: 56px 48px; border: var(--border-glass);
  box-shadow: var(--shadow-lg); text-align: center; max-width: 540px; margin: 40px auto 0;
}
.pendiente-box .ico { 
  font-size: 3.5rem; margin-bottom: 24px; display: inline-flex; width: 80px; height: 80px;
  align-items: center; justify-content: center; background: var(--indigo-50); color: var(--indigo-600);
  border-radius: 50%; box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); font-weight: 800; font-family: 'Outfit';
}
.pendiente-box h2 {
  font-family: 'Outfit', sans-serif; font-size: 2rem; font-weight: 800; letter-spacing: -0.5px;
  color: var(--slate-900); margin-bottom: 16px;
}
.pendiente-box p { color: var(--slate-600); line-height: 1.6; font-size: 1.05rem;}
.pendiente-meta {
  margin-top: 24px; padding: 12px 20px; border-radius: 999px; display: inline-flex;
  background: var(--slate-100); color: var(--slate-800); font-size: .95rem; font-weight: 600;
}
.pendiente-actions {
  margin-top: 32px; display: flex; flex-direction: column; gap: 16px;
}

/* ==============================
   TOAST
============================== */
#toast {
  position: fixed; bottom: 32px; right: 32px;
  padding: 16px 24px; border-radius: var(--radius-sm); font-size: 1rem; font-weight: 600;
  color: var(--white); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(20px); transition: all .4s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
  pointer-events: none; z-index: 9000;
  max-width: 400px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.info    { background: var(--slate-800); }
#toast.success { background: var(--emerald-600); }
#toast.error   { background: var(--rose-600); }
#toast.warn    { background: var(--amber-500); color: var(--slate-900);}

/* Resp. */
@media (max-width: 768px) {
  #sidebar { position: fixed; transform: translateX(-100%); transition: transform 0.3s; z-index: 100;}
  /* More mobile edits could go here */
  .editor-summary { padding: 16px; }
  .unidad-header { align-items: flex-start; flex-direction: column; gap: 12px;}
  .btn-del-u { opacity: 1; align-self: flex-start;}
  #main { padding: 24px; }
  .hist-item { flex-direction: column; align-items: flex-start; gap: 12px;}
}

/* ====== NUEVOS ESTILOS DEL PLAN DE MODERNIZACION ====== */
/* Fondo Login Animado */
@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

#screen-login {
  background: linear-gradient(-45deg, var(--sky-lt), var(--indigo-10), var(--slate-10), var(--sky-xl));
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
}

.login-card.glass-modern {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 25px 50px -12px rgba(13, 27, 110, 0.15);
  padding: 40px;
  border-radius: 24px;
  opacity: 0;
  transform: translateY(20px);
  animation: slideUpFade 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpFade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ====== MEJORAS DE RESPONSIVIDAD TOTAL (Móviles pequeños y ajustes finos) ====== */
@media (max-width: 640px) {
  /* Ajustar grillas para evitar desbordamientos en pantallas muy pequeñas */
  .mat-grid { gap: 16px; }
  .field-grid { gap: 16px; }
  .editor-summary-wrap { border-radius: 0; border-left: none; border-right: none; margin: 0 -16px; width: calc(100% + 32px); }

  /* Botones y Toolbars ocupan 100% en mobile */
  .editor-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .editor-toolbar button { width: 100%; justify-content: center; }
  .autosave-lbl { margin-left: 0; text-align: center; width: 100%; }

  /* Modales ocupan toda la pantalla en móviles muy chicos */
  .modal-box, .pendiente-box {
    padding: 24px 16px !important;
  }
  .modal-actions {
    flex-direction: column-reverse;
    width: 100%;
    gap: 8px;
  }
  .modal-actions button, .btn-add-materia {
    width: 100%;
  }

  /* Títulos más compactos */
  .page-title { font-size: 1.8rem; }
  .dash-hero h3, .hero-card h3 { font-size: 1.6rem; }
  .stat-card .num { font-size: 2.2rem; }

  /* Unidades y configuración */
  .unidad-titulo-inp { width: 100%; font-size: 1rem; }
  .unidad-header { padding: 16px; }
  .unidad-body { padding: 20px 16px; }

  /* Historial de versiones */
  .hist-item { flex-direction: column; align-items: stretch; text-align: left; }
  .hist-item button { width: 100%; }

  /* Dashboard rows - Botones apilados */
  .dash-row-actions { flex-direction: column; width: 100%; align-items: stretch; }
  .dash-row-actions .btn-sm { width: 100%; text-align: center; }
  
  /* Tarjetas base con menos padding */
  .card, .mat-card, .stat-card { padding: 16px; }
}

.login-note {
  color: var(--slate-80) !important;
  font-size: 0.9rem;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.5);
  padding: 12px;
  border-radius: 8px;
  border-left: 4px solid var(--indigo-50);
}

.login-note strong {
  color: var(--navy-m);
}

.btn-login-pulse {
  position: relative;
  overflow: hidden;
}

.btn-login-pulse::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(255,255,255,.5);
  opacity: 0;
  border-radius: 100%;
  transform: scale(1, 1) translate(-50%);
  transform-origin: 50% 50%;
}
.btn-login-pulse:active::after {
  animation: ripple 0.6s ease-out;
}

@keyframes ripple {
  0% { transform: scale(0, 0); opacity: 0.5; }
  100% { transform: scale(20, 20); opacity: 0; }
}

/* Dashboard Tabs */
.dashboard-header-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.dash-tabs {
  display: flex;
  gap: 8px;
  background: rgba(255,255,255,0.6);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.8);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.dash-tab {
  background: transparent;
  border: none;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  color: var(--slate-70);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.dash-tab:hover {
  color: var(--navy-m);
  background: rgba(255,255,255,0.5);
}

.dash-tab.active {
  background: #ffffff;
  color: var(--navy);
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tab-content {
  animation: fadeInTab 0.4s ease forwards;
}

@keyframes fadeInTab {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Fix Contraste Textos */
body {
  color: var(--slate-80);
}
.page-sub, .dash-sub, .login-step {
  color: var(--slate-60);
  font-weight: 500;
}
.dash-list-head {
  color: var(--navy);
}
.dash-row-title strong,
.dash-row-block strong,
.dash-row-block p {
  color: var(--slate-80);
}
.dash-stat-value {
  color: var(--navy);
}
.dash-stat-label {
  color: var(--slate-70);
}

/* Responsividad General */
@media (max-width: 768px) {
  /* Login Responsive */
  .login-card.glass-modern {
    padding: 24px;
    margin: 16px;
    width: 90%;
  }
  
  /* Tabs Responsive */
  .dashboard-header-container {
    flex-direction: column;
    align-items: stretch;
  }
  .dash-tabs {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Dashboard Materias Responsive */
  .dash-list-head {
    display: none;
  }
  .dash-row-card {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  /* Stats Responsive */
  .dash-stats {
    flex-direction: column;
    gap: 12px;
  }
  .dash-stat {
    width: 100%;
  }
}

/* ====== HOTFIX: RESTORE MODALS & MOBILE SPACING ====== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 110, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

@media (max-width: 768px) {
  .login-card.glass-modern {
    padding: 32px 24px !important;
    margin: 16px auto !important;
    max-width: 95% !important;
  }

  .login-logo img {
    height: 48px;
  }

  .inp-wrap {
    margin-bottom: 20px;
  }

  /* Prevent iOS zoom on focus */
  input[type="text"], input[type="email"], input[type="password"], textarea, select {
    font-size: 16px !important;
    padding: 14px 16px !important;
  }

  #main {
    padding: 16px !important;
  }
  
  .dashboard-header-container {
    gap: 20px;
  }
}

/* ====== MOBILE BURGER MENU AND SIDEBAR ====== */
.btn-burger {
  display: none;
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--navy);
  cursor: pointer;
  padding: 4px 12px;
  margin-right: 8px;
  align-items: center;
  justify-content: center;
}

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 110, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
}

@media (max-width: 768px) {
  /* Mostrar botón menú */
  .btn-burger {
    display: flex;
  }
  
  /* Ajustar logo */
  .header-logo-title {
    font-size: 1.1rem; /* un poco menor para que quepa */
  }

  /* Login Cutoff Fix */
  #screen-login {
    align-items: flex-start !important;
    overflow-y: auto !important;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 16px !important;
  }
  .login-card.glass-modern {
    margin: auto !important;
    width: min(100%, 420px) !important;
    max-width: 420px !important;
    height: auto !important;
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }

  /* Sidebar Off-Canvas */
  #sidebar {
    position: fixed;
    top: 70px; /* height of header */
    left: -280px;
    bottom: 0;
    width: 280px;
    z-index: 999;
    transition: left 0.3s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.1);
  }
  
  #sidebar.sidebar-open {
    left: 0;
  }
  
  #sidebar-overlay.overlay-open {
    display: block;
  }
}

.modal-box-wide {
  width: min(1120px, 92vw);
  max-width: min(1120px, 92vw);
}

.plan-preview-body {
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

.plan-preview-wrap {
  display: grid;
  gap: 18px;
}

.plan-preview-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
  gap: 16px;
  padding: 20px;
  border-radius: 20px;
  background:
    radial-gradient(circle at top left, rgba(20, 42, 120, 0.12), transparent 42%),
    linear-gradient(135deg, #f8fbff 0%, #eef4ff 100%);
  border: 1px solid rgba(20, 42, 120, 0.08);
}

.plan-preview-kicker {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(20, 42, 120, 0.08);
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.plan-preview-hero-main h4 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--navy);
}

.plan-preview-hero-main {
  min-width: 0;
}

.plan-preview-hero-main p {
  margin: 8px 0 0;
  color: var(--gray-4);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.plan-preview-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.plan-preview-stat {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(20, 42, 120, 0.08);
}

.plan-preview-stat span {
  display: block;
  font-size: 0.8rem;
  color: var(--gray-4);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.plan-preview-stat strong {
  display: block;
  margin-top: 6px;
  color: var(--navy);
  font-size: 1.15rem;
}

.plan-preview-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.plan-preview-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: var(--gray-4);
  font-size: 0.84rem;
  white-space: normal;
}

.plan-preview-content {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.plan-preview-main {
  min-width: 0;
}

.plan-preview-biblio {
  position: sticky;
  top: 0;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffdf6 0%, #fff9eb 100%);
  border: 1px solid rgba(222, 181, 77, 0.28);
}

.plan-preview-biblio h4 {
  margin: 0 0 10px;
  color: #7c5b12;
}

.plan-preview-biblio p {
  margin: 0;
  line-height: 1.65;
  color: #5b4a1e;
  overflow-wrap: anywhere;
}

.plan-unit-list {
  display: grid;
  gap: 14px;
}

.plan-unit-card {
  border: 1px solid rgba(20, 42, 120, 0.1);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.9);
}

.plan-unit-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.plan-unit-head h4 {
  margin: 8px 0 0;
  font-size: 1.05rem;
  color: var(--navy);
}

.plan-unit-index {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(20, 42, 120, 0.08);
  color: var(--navy);
  font-size: 0.8rem;
  font-weight: 700;
}

.plan-unit-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3b4bb3;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.plan-unit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.plan-unit-field {
  border-radius: 14px;
  background: #f8fafc;
  padding: 14px;
}

.plan-unit-field-highlight {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
  border: 1px solid rgba(20, 42, 120, 0.08);
}

.plan-unit-field.is-compact p {
  font-weight: 600;
  color: var(--navy);
}

.plan-unit-field h5 {
  margin: 0 0 8px;
  font-size: 0.86rem;
  color: var(--gray-4);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.plan-unit-field p,
.plan-unit-field ul {
  margin: 0;
  line-height: 1.5;
}

.plan-unit-field ul {
  padding-left: 18px;
}

.dash-areas-card {
  margin: 16px 0;
}

.dash-areas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.dash-area-item {
  padding: 16px;
  border: 1px solid rgba(20, 42, 120, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.dash-area-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  align-items: baseline;
}

.dash-area-head span {
  color: var(--gray-3);
  font-size: 0.82rem;
}

.btn-danger {
  background: #8c1d18;
  color: #fff;
}

.delete-docente-note {
  color: var(--gray-4);
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.delete-docente-summary {
  margin-bottom: 14px;
}

.delete-docente-card {
  padding: 14px;
  border: 1px solid rgba(140, 29, 24, 0.16);
  border-radius: 16px;
  background: rgba(140, 29, 24, 0.04);
}

.delete-docente-card p {
  margin: 0 0 8px;
}

.delete-docente-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 768px) {
  .plan-preview-hero,
  .plan-preview-content {
    grid-template-columns: 1fr;
  }

  .plan-preview-stats {
    grid-template-columns: 1fr 1fr;
  }

  .plan-preview-biblio {
    position: static;
  }

  .plan-unit-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .plan-unit-grid {
    grid-template-columns: 1fr;
  }
}

/* ==============================
   MATERIAS SIN PLANIFICACIÓN
   ============================== */
.dash-faltantes-card {
  margin-bottom: 16px;
  border-left: 4px solid #f59e0b;
}

.dash-faltantes-card.ok {
  border-left-color: #22c55e;
}

.dash-faltantes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  cursor: pointer;
  gap: 12px;
}

.dash-faltantes-head:hover {
  background: var(--slate-50);
}

.dash-faltantes-card.ok .dash-faltantes-head {
  cursor: default;
}

.dash-faltantes-card.ok .dash-faltantes-head:hover {
  background: transparent;
}

.dash-faltantes-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f59e0b;
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  border-radius: 20px;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  flex-shrink: 0;
}

.dash-faltantes-body {
  border-top: 1px solid var(--slate-100);
  padding: 16px 24px;
}

.dash-faltantes-areas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.dash-faltantes-area {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  overflow: hidden;
}

.dash-faltantes-area-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--slate-600);
  padding: 8px 14px;
  background: var(--slate-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dash-faltantes-count {
  background: #fef3c7;
  color: #92400e;
  font-size: .72rem;
  border-radius: 12px;
  padding: 1px 8px;
  font-weight: 700;
}

.dash-faltantes-rows {
  padding: 6px 0;
}

.dash-faltantes-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--slate-100);
}

.dash-faltantes-row:last-child {
  border-bottom: none;
}

.dash-faltantes-materia {
  font-size: .84rem;
  color: var(--slate-800);
  font-weight: 500;
  flex: 1;
}

.dash-faltantes-docente {
  font-size: .76rem;
  color: var(--slate-500);
  text-align: right;
  flex-shrink: 0;
}

/* ==============================
   BUSCADOR EN DASHBOARD
   ============================== */
.dash-search-wrap {
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--slate-200);
}

#dash-search {
  width: 100%;
  max-width: 440px;
  padding: 9px 14px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  font-size: .9rem;
  background: var(--white);
  color: var(--slate-700);
  outline: none;
  transition: border-color .15s;
}

#dash-search:focus {
  border-color: var(--primary);
}

/* ==============================
   VISTA PSICOPEDAGOGA
   ============================== */
.psicoped-search-wrap {
  margin-bottom: 20px;
}

#psicoped-search {
  width: 100%;
  max-width: 480px;
  padding: 10px 16px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  font-size: .92rem;
  background: var(--white);
  color: var(--slate-700);
  outline: none;
  transition: border-color .15s;
}

#psicoped-search:focus {
  border-color: var(--primary);
}

.psicoped-loading,
.psicoped-empty {
  padding: 32px 20px;
  color: var(--slate-500);
  text-align: center;
  font-size: .95rem;
}

.psicoped-docente-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}

.psicoped-docente-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  transition: background .12s;
  gap: 12px;
}

.psicoped-docente-head:hover {
  background: var(--slate-50);
}

.psicoped-docente-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.psicoped-nombre {
  font-weight: 600;
  font-size: .97rem;
  color: var(--slate-800);
}

.psicoped-area {
  font-size: .78rem;
  color: var(--slate-500);
  background: var(--slate-100);
  border-radius: 6px;
  padding: 2px 8px;
}

.psicoped-badge {
  font-size: .75rem;
  font-weight: 600;
  border-radius: 20px;
  padding: 3px 10px;
}

.psicoped-badge.ok {
  background: #dcfce7;
  color: #166534;
}

.psicoped-badge.empty {
  background: #fef9c3;
  color: #854d0e;
}

.psicoped-toggle-ico {
  color: var(--slate-400);
  font-size: .85rem;
  flex-shrink: 0;
}

.psicoped-docente-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--slate-100);
}

.psicoped-empty-inner {
  padding: 16px 0;
  color: var(--slate-400);
  font-size: .88rem;
  text-align: center;
}

.psicoped-materia-card {
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  margin-top: 10px;
  overflow: hidden;
}

.psicoped-materia-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  cursor: pointer;
  background: var(--slate-50);
  transition: background .12s;
}

.psicoped-materia-head:hover {
  background: var(--slate-100);
}

.psicoped-materia-nombre {
  font-weight: 600;
  font-size: .88rem;
  color: var(--slate-700);
  flex: 1;
}

.psicoped-fecha {
  font-size: .75rem;
  color: var(--slate-400);
  flex-shrink: 0;
}

.psicoped-mat-ico {
  color: var(--slate-400);
  font-size: .8rem;
  flex-shrink: 0;
}

.psicoped-copy-btn {
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 12px;
  border: 1px solid var(--primary);
  color: var(--primary);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}

.psicoped-copy-btn:hover {
  background: var(--primary);
  color: var(--white);
}

.psicoped-materia-body {
  padding: 14px 16px;
}

.psicoped-no-plan {
  color: var(--slate-400);
  font-size: .88rem;
  padding: 8px 0;
}

.psicoped-tabla-wrap {
  overflow-x: auto;
}

.psicoped-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  color: var(--slate-700);
}

.psicoped-tabla th {
  background: var(--slate-100);
  font-weight: 700;
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: .04em;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--slate-200);
}

.psicoped-tabla td {
  padding: 10px 10px;
  vertical-align: top;
  border-bottom: 1px solid var(--slate-100);
  white-space: pre-wrap;
  word-break: break-word;
}

.psicoped-tabla tr:last-child td {
  border-bottom: none;
}

.psicoped-bib {
  margin-top: 14px;
  font-size: .85rem;
  color: var(--slate-600);
  line-height: 1.6;
  padding: 10px 12px;
  background: var(--slate-50);
  border-radius: 6px;
  border: 1px solid var(--slate-200);
}
