:root {
    --bg: #eef3f9;
    --bg-soft: #f8fbff;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #dbe4f0;
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --primary-soft: #eaf2ff;
    --success: #166534;
    --success-soft: #ecfdf5;
    --danger: #b91c1c;
    --danger-soft: #fef2f2;
    --shadow: 0 12px 24px rgba(15, 23, 42, 0.065);
    --radius-xl: 16px;
    --radius-lg: 12px;
    --radius-md: 10px;
}

/* ================================
   BASE GENERAL
================================ */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(29, 78, 216, 0.12), transparent 25%),
        linear-gradient(180deg, #f8fbff 0%, #eef3f9 100%);
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ================================
   LAYOUT GENERAL
================================ */
.layout-shell { min-height: 100vh; display: flex; }
.public-shell { display: block; }
.main-content { flex: 1; padding: 16px; }
.main-content.no-sidebar { width: 100%; padding: 0; }

/* ================================
   SIDEBAR
================================ */
.sidebar {
    width: 235px;
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #fff;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand-card {
    display: flex;
    gap: 12px;
    align-items: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: var(--radius-lg);
    padding: 10px;
}
.brand-card img {
    width: 46px;
    height: 46px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    padding: 5px;
}
.brand-card strong, .brand-card small { display: block; }
.brand-card small { color: #cbd5e1; margin-top: 4px; }
.menu { display: grid; gap: 6px; }
.sidebar-footer { margin-top: auto; display: grid; gap: 6px; }
.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #dbeafe;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.04);
    transition: 0.2s ease;
    font-weight: 600;
}
.menu-link:hover { background: rgba(255, 255, 255, 0.1); transform: translateX(2px); }
.menu-link.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.32), rgba(29, 78, 216, 0.48));
    color: #fff;
    border-color: rgba(147, 197, 253, 0.4);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.menu-link.ghost { background: rgba(255,255,255,.03); }
.menu-link.danger { background: rgba(185, 28, 28, 0.22); color: #fee2e2; }
.menu-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.10);
    font-size: 14px;
}
.logout-form { margin: 0; }
.logout-button {
    width: 100%;
    margin-top: 0;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

/* ================================
   TOPBAR
================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(219,228,240,0.9);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}
.eyebrow {
    margin: 0 0 4px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 10px;
    color: var(--muted);
    font-weight: 700;
}
.topbar h1 { margin: 0; font-size: 22px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 10px 5px 5px;
}
.user-chip strong, .user-chip small { display: block; }
.user-chip small { color: var(--muted); }
.user-avatar {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 700;
}

/* ================================
   BOTONES
================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 9px 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
    box-shadow: 0 6px 12px rgba(29, 78, 216, 0.14);
}
.btn:hover { transform: translateY(-1px); }
.btn-light {
    background: #fff;
    color: var(--primary-dark);
    border: 1px solid var(--border);
    box-shadow: none;
}
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 9px;
    background: var(--primary-soft);
    border: 1px solid #c9dcff;
    color: var(--primary-dark);
    font-weight: 700;
}

/* ================================
   TARJETAS Y GRID
================================ */
.card {
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(219,228,240,0.95);
    border-radius: var(--radius-xl);
    padding: 14px;
    box-shadow: var(--shadow);
}
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 12px; }
.two-columns { grid-template-columns: 1.05fr 0.95fr; margin-bottom: 12px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 12px; }
.stats-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.full-col { grid-column: 1 / -1; }

/* ================================
   DASHBOARD / MINI CARDS
================================ */
.stat-card {
    position: relative;
    overflow: hidden;
    min-height: 92px;
    padding: 12px;
}
.stat-card::after {
    content: '';
    position: absolute;
    right: -16px;
    top: -16px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(59,130,246,.10);
}
.stat-card h3 { font-size: 26px; margin-bottom: 4px; line-height: 1; }
.stat-card p { margin: 0; color: var(--muted); font-weight: 600; }
.mini-card {
    display: block;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid var(--border);
    padding: 11px 12px;
    border-radius: 12px;
    color: var(--text);
    font-weight: 700;
    min-height: 70px;
    box-shadow: 0 6px 14px rgba(15,23,42,.035);
}
.mini-card:hover { border-color: #bfd4ff; color: var(--primary-dark); }

/* ================================
   FORMULARIOS
================================ */
label {
    display: block;
    margin: 8px 0 5px;
    font-weight: 700;
    color: var(--primary-dark);
}
input, select, button, textarea {
    width: 100%;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1px solid #cdd8e6;
    background: #fff;
    font-size: 13px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #8eb5ff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}
button { margin-top: 12px; }
.helper { display:block; margin-top:6px; color: var(--muted); font-size: 13px; }

/* ================================
   TABLAS
================================ */
.table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td {
    padding: 12px 14px;
    border-bottom: 1px solid #edf2f7;
    text-align: left;
    vertical-align: top;
}
th {
    background: #f8fbff;
    color: var(--primary-dark);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
tr:hover td { background: #fbfdff; }
.table-actions { display: grid; gap: 10px; min-width: 260px; }
.inline-form {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(120px, 1fr) auto;
    gap: 8px;
    align-items: center;
    min-width: 440px;
}
.inline-form input, .inline-form button {
    margin: 0;
}
.inline-form button {
    white-space: nowrap;
}
.link-field {
    margin: 0;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f8fbff;
    color: var(--muted);
    font-size: 12px;
}

/* ================================
   ALERTAS
================================ */
.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
    font-weight: 600;
}
.alert.success { background: var(--success-soft); color: var(--success); border: 1px solid #bbf7d0; }
.alert.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }

/* ================================
   VISTAS PUBLICAS / LOGIN
================================ */
.auth-wrapper, .public-wrapper {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.auth-card, .public-card {
    width: min(100%, 980px);
    background: rgba(255,255,255,0.96);
}
.auth-card { max-width: 500px; }
.auth-logo { width: 88px; display: block; margin: 0 auto 16px; }
.public-brand-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(135deg, #fbfdff 0%, #f1f6ff 100%);
    text-align: center;
}
.public-brand-logo {
    width: 46px;
    height: 46px;
    object-fit: contain;
    border-radius: 12px;
    background: #fff;
    padding: 5px;
    border: 1px solid #dbe4f0;
}
.public-brand-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.public-brand-name {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1.1;
}
.public-brand-subtitle {
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}
.public-link { display: block; text-align: center; margin-top: 14px; font-weight: 700; }
.verified-box {
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--success-soft);
    color: var(--success);
    font-weight: 800;
    margin-bottom: 14px;
    border: 1px solid #bbf7d0;
}
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.info-grid > div {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
}
.clean-list { margin: 0; padding-left: 18px; line-height: 1.9; }
.clean-list li::marker { color: var(--primary); }
.feature-list li { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.feature-list li:last-child { border-bottom: none; }
.section-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom: 14px; }
.badge {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:6px 10px;
    border-radius:999px;
    font-size:12px;
    font-weight:700;
    background: var(--primary-soft);
    color: var(--primary-dark);
    border:1px solid #c9dcff;
}
.badge.info { background:#ecfeff; color:#155e75; border-color:#a5f3fc; }
.app-footer { margin-top: 24px; text-align: center; color: var(--muted); font-size: 14px; }

/* ================================
   RESPONSIVE
================================ */
@media (max-width: 1200px) {
    .cards-4, .stats-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
    .sidebar { width: 250px; }
    .topbar { flex-direction: column; align-items: flex-start; }
    .topbar-actions { width: 100%; }
}
@media (max-width: 980px) {
    .layout-shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    .main-content { padding: 16px; }
    .stats-grid, .cards-3, .two-columns, .info-grid { grid-template-columns: 1fr; }
    .topbar { padding: 18px; }
    .user-chip { width: 100%; border-radius: 18px; }
}
@media (max-width: 900px) {
    .form-2, .cards-4, .stats-grid-4 { grid-template-columns: 1fr; }
    .students-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .auth-wrapper, .public-wrapper { padding: 14px; }
    .public-brand-header {
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
    }
    .public-brand-logo {
        width: 42px;
        height: 42px;
    }
    .public-brand-name { font-size: 16px; }
    .public-brand-subtitle { font-size: 12px; }
    .card { padding: 18px; }
    .topbar h1 { font-size: 24px; }
    table { min-width: 640px; }
    .inline-form {
        min-width: 320px;
        grid-template-columns: 1fr;
    }
}
