/* ===================================================================
   Evaluador de Calificaciones — estilos
   =================================================================== */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1a2233;
  --muted: #6b7686;
  --line: #e6e9f0;
  --primary: #3b5bdb;
  --primary-dark: #2f49b3;
  --ok: #2f9e6b;
  --ok-bg: #e8f6ef;
  --warn: #c98a1a;
  --warn-bg: #fbf1dd;
  --danger: #d64545;
  --shadow: 0 1px 3px rgba(20, 30, 60, .06), 0 8px 24px rgba(20, 30, 60, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
a { color: var(--primary); }

/* ---------- Botones ---------- */
.btn {
  font: inherit; font-weight: 600; border: 1px solid transparent;
  border-radius: 10px; padding: 9px 16px; cursor: pointer;
  transition: .15s ease; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #eef1f8; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { background: var(--danger); color: #fff; }
.icon-btn {
  background: transparent; border: none; font-size: 18px; cursor: pointer;
  color: var(--muted); line-height: 1; padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { background: #eef1f8; }

/* ===================================================================
   Pantalla de acceso
   =================================================================== */
.auth-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e8ecfb, var(--bg));
}
.auth-card {
  background: var(--panel); width: 100%; max-width: 400px;
  border-radius: 18px; box-shadow: var(--shadow); padding: 32px;
  border: 1px solid var(--line);
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-logo {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 12px;
  background: var(--primary); color: #fff; font-size: 26px; font-weight: 700;
  display: grid; place-items: center;
}
.auth-brand h1 { font-size: 20px; margin: 0 0 4px; }
.tabs { display: flex; gap: 4px; background: #eef1f8; padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.tab {
  flex: 1; border: none; background: transparent; padding: 8px; border-radius: 8px;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
#auth-form label, .form-grid label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
#auth-form input, .form-grid input, .search {
  width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; background: #fff;
}
#auth-form input:focus, .form-grid input:focus, .search:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,91,219,.12);
}
.auth-msg { text-align: center; font-size: 13px; margin: 10px 0 0; min-height: 18px; }
.auth-msg.error { color: var(--danger); }
.auth-msg.ok { color: var(--ok); }
#auth-hint { text-align: center; margin-top: 14px; }
.auth-footer { margin-top: 20px; }

/* ===================================================================
   App shell
   =================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 0 20px; height: 58px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-weight: 700;
}
.topnav { display: flex; gap: 2px; margin-left: 8px; flex: 1; }
.navlink {
  border: none; background: transparent; font: inherit; font-weight: 600;
  color: var(--muted); padding: 8px 14px; border-radius: 9px; cursor: pointer;
}
.navlink:hover { background: #f1f3fa; color: var(--ink); }
.navlink.active { background: #eef1fe; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-email { font-size: 12.5px; color: var(--muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { max-width: 1100px; margin: 0 auto; padding: 26px 20px 60px; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.view-head h2 { margin: 0; font-size: 22px; }
.view-head p { margin: 2px 0 0; }
.view-head-actions { display: flex; gap: 10px; align-items: center; }
.search { width: 240px; margin: 0; }

/* ---------- Paneles ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.panel.no-pad { padding: 0; overflow: hidden; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Stat cards ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 720px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-size: 30px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-card.ok .stat-num { color: var(--ok); }
.stat-card.warn .stat-num { color: var(--warn); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fafbfe; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: #fafbfe; }
.cell-strong { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.neutral { background: #eef1f8; color: var(--muted); }

/* ---------- Dropzone ---------- */
.dropzone { border: 2px dashed #c7cde0; border-radius: var(--radius); padding: 34px; text-align: center; cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: #f7f9ff; }
.dz-icon { font-size: 28px; color: var(--primary); }
.dropzone p { margin: 6px 0; }

/* ---------- Empty ---------- */
.empty-state { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Mini list ---------- */
.mini-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.mini-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
.mini-item .name { font-weight: 600; font-size: 13px; }

/* ---------- Forms ---------- */
.form-grid { display: block; }
.form-grid .hint { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 4px; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Overlays / drawer / modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20,26,45,.42); z-index: 40; display: flex; }
#drawer-overlay { justify-content: flex-end; }
.drawer { width: 520px; max-width: 94vw; background: var(--bg); height: 100vh; overflow-y: auto; box-shadow: -8px 0 40px rgba(0,0,0,.14); animation: slideIn .2s ease; }
@keyframes slideIn { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-body { padding: 18px 20px; }
#modal-overlay { align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 16px; width: 460px; max-width: 94vw; box-shadow: var(--shadow); overflow: hidden; }
.modal .form-grid { padding: 20px; }
.modal .drawer-head { border-bottom: 1px solid var(--line); }

/* drawer sections */
.d-section { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.d-section h4 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.contact-line { font-size: 13px; color: var(--muted); margin: 2px 0; }

/* materia rows */
.materia-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.materia-row:last-child { border-bottom: none; }
.materia-row .m-name { flex: 1; font-weight: 500; }
.materia-row input.grade { width: 74px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; text-align: center; }
.materia-add { display: flex; gap: 8px; margin-top: 12px; }
.materia-add input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

/* documentos */
.doc-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.doc-item:last-child { border-bottom: none; }
.doc-item .doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-icon { color: var(--primary); }
.upload-row { margin-top: 12px; }

/* ===================================================================
   Constancia
   =================================================================== */
.constancia-overlay { position: fixed; inset: 0; background: #4a4f63; z-index: 60; overflow: auto; }
.constancia-toolbar { position: sticky; top: 0; display: flex; justify-content: space-between; padding: 12px 18px; background: #2c3040; }
.constancia-scroll { padding: 30px 16px 60px; display: flex; justify-content: center; }
.constancia-sheet {
  background: #fff; width: 100%; max-width: 820px; min-height: 1000px;
  padding: 70px 74px; box-shadow: 0 10px 50px rgba(0,0,0,.35);
  color: #222; position: relative;
}
.c-border { border: 3px double #b8933d; padding: 48px 44px; min-height: 860px; display: flex; flex-direction: column; }
.c-header { text-align: center; margin-bottom: 8px; }
.c-institucion { font-family: 'Playfair Display', serif; font-size: 26px; font-weight: 700; color: #1a2233; margin: 0; }
.c-subtitulo { color: #6b7686; font-size: 14px; margin: 4px 0 0; letter-spacing: .04em; }
.c-rule { height: 2px; background: linear-gradient(90deg, transparent, #b8933d, transparent); margin: 22px 0 26px; }
.c-title { text-align: center; font-family: 'Playfair Display', serif; font-size: 34px; letter-spacing: .12em; margin: 10px 0 30px; color: #1a2233; }
.c-body { font-size: 16px; line-height: 1.9; text-align: justify; color: #333; }
.c-name { text-align: center; font-family: 'Playfair Display', serif; font-size: 30px; margin: 24px 0; color: #1a2233; border-bottom: 1px solid #ddd; padding-bottom: 8px; }
.c-materias { margin: 24px 0; }
.c-materias table { width: 100%; border-collapse: collapse; font-size: 14px; }
.c-materias th { background: #f6f2e8; color: #7a5f22; text-align: left; padding: 9px 12px; border: 1px solid #e5dcc6; }
.c-materias td { padding: 9px 12px; border: 1px solid #eee; }
.c-materias td.num { text-align: center; width: 120px; }
.c-spacer { flex: 1; }
.c-footer { margin-top: 40px; display: flex; justify-content: space-between; align-items: flex-end; }
.c-fecha { font-size: 13px; color: #555; }
.c-firma { text-align: center; }
.c-firma .line { width: 240px; border-top: 1px solid #333; margin: 0 auto 6px; }
.c-firma .nombre { font-weight: 700; }
.c-firma .cargo { font-size: 13px; color: #555; }
.c-folio { position: absolute; top: 30px; right: 34px; font-size: 11px; color: #999; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1a2233; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 13.5px; z-index: 90; box-shadow: var(--shadow); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ===================================================================
   Impresión — solo la constancia
   =================================================================== */
@media print {
  body * { visibility: hidden; }
  #constancia-overlay, #constancia-overlay * { visibility: visible; }
  #constancia-overlay { position: absolute; inset: 0; background: #fff; overflow: visible; }
  .no-print { display: none !important; }
  .constancia-scroll { padding: 0; }
  .constancia-sheet { box-shadow: none; max-width: none; width: auto; padding: 24px 30px; min-height: auto; }
  .c-border { min-height: auto; }
  @page { size: A4; margin: 12mm; }
}
