:root {
  --ink: #172033;
  --muted: #64748b;
  --line: #d8e2ee;
  --blue: #1663b7;
  --cyan: #0f9abf;
  --green: #168251;
  --amber: #b7791f;
  --red: #b42318;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --shadow: 0 18px 48px rgba(23, 32, 51, .10);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { min-width: 0; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(15, 154, 191, .14), transparent 28rem),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 55%, #eef4fb 100%);
}
a { color: var(--blue); text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(22, 99, 183, .28); outline-offset: 2px; }
.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px);
}
.brand, .side-brand { font-weight: 900; letter-spacing: .08em; color: var(--ink); }
.topbar nav { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.user-chip { display: grid; gap: 1px; text-align: right; margin-left: auto; }
.user-chip small { color: var(--muted); font-size: 11px; font-weight: 700; }
.menu-toggle { display: none; width: 44px; padding: 0; background: #e8eef6; color: var(--ink); }
.container { width: min(1180px, calc(100% - 32px)); margin: 28px auto 56px; animation: rise .35s ease both; }
.role-administrador .container, .role-docente .container { margin-left: min(300px, calc(230px + 4vw)); width: min(1180px, calc(100% - min(330px, calc(260px + 4vw)))); }
.sidebar {
  position: fixed;
  top: 64px;
  left: 0;
  bottom: 0;
  width: 248px;
  padding: 18px 14px;
  background: #fff;
  border-right: 1px solid var(--line);
  z-index: 20;
  display: grid;
  align-content: start;
  gap: 8px;
}
.sidebar a { padding: 12px 14px; border-radius: var(--radius); color: var(--ink); font-weight: 700; }
.sidebar a:hover { background: #eef4fb; color: var(--blue); }
.side-brand { margin-bottom: 10px; padding: 12px 14px; }
.hero { min-height: calc(100vh - 110px); display: grid; align-content: center; gap: 24px; position: relative; overflow: hidden; }
.hero-modern { grid-template-columns: minmax(0, 1fr) minmax(260px, 420px); align-items: center; }
.hero h1 { font-size: clamp(42px, 8vw, 96px); margin: 0; letter-spacing: 0; line-height: .95; }
.hero p { font-size: clamp(18px, 2vw, 24px); color: var(--muted); margin: 0; max-width: 680px; }
.hero-art { min-height: 360px; position: relative; }
.cloud-shape, .device-shape, .file-shape { position: absolute; display: block; border: 1px solid rgba(22, 99, 183, .18); box-shadow: var(--shadow); }
.cloud-shape { width: 260px; height: 120px; border-radius: 70px; background: linear-gradient(135deg, #fff, #dff7ff); left: 52px; top: 54px; }
.cloud-shape::before, .cloud-shape::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud-shape::before { width: 110px; height: 110px; left: 42px; top: -50px; }
.cloud-shape::after { width: 86px; height: 86px; right: 42px; top: -34px; }
.device-shape { width: 300px; height: 190px; border-radius: 18px; background: #182235; right: 10px; bottom: 20px; }
.device-shape::after { content: ""; position: absolute; inset: 18px; border-radius: 10px; background: linear-gradient(135deg, #e8f7ff, #bfe8f4); }
.file-shape { width: 96px; height: 120px; border-radius: 12px; background: #fff; }
.file-shape.one { left: 26px; bottom: 58px; transform: rotate(-8deg); }
.file-shape.two { right: 28px; top: 24px; transform: rotate(9deg); }
.institution-slot { border: 2px dashed var(--line); padding: 18px; width: min(520px, 100%); background: rgba(255, 255, 255, .72); border-radius: var(--radius); }
.actions, .grid-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.compact-actions input { max-width: 180px; }
.btn, button {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--blue), #0f7fc2);
  color: #fff;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}
.btn:hover, button:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(22, 99, 183, .18); }
.btn:active, button:active { transform: translateY(0); }
.btn.secondary, button.secondary { background: #e8eef6; color: var(--ink); }
.btn.danger, button.danger { background: var(--red); }
.btn.success, button.success { background: var(--green); }
button:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: .65; transform: none; box-shadow: none; }
.is-loading::before { content: ""; width: 14px; height: 14px; margin-right: 8px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.panel, .card, .login-card {
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 10px 28px rgba(23, 32, 51, .06);
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.card { animation: rise .35s ease both; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.big-card { min-height: 132px; display: grid; align-content: center; gap: 8px; font-size: 20px; font-weight: 900; }
.card-icon { font-size: 30px; }
.muted { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
label { display: grid; gap: 6px; font-weight: 800; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
.field-hint { color: var(--muted); font-weight: 700; }
.field-hint.valid { color: var(--green); }
.password-wrap { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.password-toggle { min-width: 96px; padding-inline: 12px; }
.login-shell { min-height: calc(100vh - 120px); display: grid; grid-template-columns: 1fr minmax(300px, 430px); gap: clamp(24px, 5vw, 70px); align-items: center; }
.login-copy h1 { font-size: clamp(42px, 7vw, 84px); margin: 8px 0; }
.eyebrow { color: var(--cyan); font-weight: 900; letter-spacing: .18em; }
.login-card { display: grid; gap: 16px; }
.login-progress { display: grid; gap: 8px; }
.progress-track { height: 12px; background: #e7eef6; border-radius: 999px; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--green)); transition: width .18s ease; }
.upload-meter { display: grid; gap: 8px; margin: 14px 0; }
progress { width: 100%; height: 16px; accent-color: var(--green); }
.upload-success { margin-top: 12px; background: #e3f8ed; border: 1px solid #b6ebcd; padding: 12px; border-radius: var(--radius); }
.quota { height: 14px; border-radius: 999px; overflow: hidden; background: #e2e8f0; }
.quota span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--cyan)); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; background: #fff; min-width: 760px; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #eef4fb; font-size: 13px; text-transform: uppercase; }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 900; background: #e5e7eb; }
.badge.activo, .badge.abierta, .badge.subido, .badge.revisado { background: #dff7eb; color: #08643b; }
.badge.pendiente { background: #fff3cd; color: #7a4b00; }
.badge.corregir { background: #fde2e1; color: #971b12; }
.badge.cerrada, .badge.inactivo, .badge.eliminado, .badge.rechazado, .badge.archivado { background: #eee; color: #555; }
.alert { display: none; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.file-info { border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px; color: var(--muted); background: #fff; }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: grid; gap: 10px; width: min(360px, calc(100vw - 36px)); }
.toast { opacity: 0; transform: translateY(12px); background: #fff; border-left: 5px solid var(--green); box-shadow: var(--shadow); border-radius: var(--radius); padding: 12px; display: flex; justify-content: space-between; gap: 10px; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.warning { border-left-color: var(--amber); }
.toast.danger { border-left-color: var(--red); }
.toast button { min-height: 28px; padding: 0 8px; background: #eef4fb; color: var(--ink); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 70; display: grid; place-items: center; padding: 16px; }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(440px, 100%); background: #fff; border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.page-leaving { opacity: .25; transition: opacity .5s ease; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (min-width: 1800px) {
  .container { width: min(1440px, calc(100% - 64px)); }
  .role-administrador .container, .role-docente .container { width: min(1440px, calc(100% - 340px)); }
}
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .user-chip { text-align: left; }
  .sidebar { transform: translateX(-105%); transition: transform .18s ease; top: 64px; width: min(280px, 86vw); }
  .sidebar-open .sidebar { transform: translateX(0); }
  .role-administrador .container, .role-docente .container, .container { width: min(100% - 20px, 1180px); margin: 16px auto 44px; }
  .hero-modern, .login-shell { grid-template-columns: 1fr; }
  .hero-art { min-height: 230px; order: -1; }
  .device-shape { width: 230px; height: 145px; }
  .cloud-shape { width: 210px; height: 96px; }
  .password-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topbar nav { width: 100%; }
  .cards { grid-template-columns: 1fr; }
  .actions { align-items: stretch; }
  .actions > * { width: 100%; }
  .btn, button { width: 100%; }
  th, td { padding: 9px; }
}
