:root {
    color-scheme: light;
    --canvas: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafd;
    --text: #17243a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #2653bd;
    --primary-soft: #eaf0ff;
    --sidebar: #ffffff;
    --shadow: 0 8px 28px rgba(31, 50, 84, .06);
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --canvas: #0b1422;
    --surface: #152236;
    --surface-soft: #1b2a40;
    --text: #eef3fa;
    --muted: #a8b8cd;
    --line: #2e4059;
    --primary: #99b6ff;
    --primary-soft: #263b64;
    --sidebar: #111d2e;
    --shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { font-family: Inter, system-ui, sans-serif; background: var(--canvas); color: var(--text); }
.app-shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.app-shell main { min-width: 0; flex: 1; overflow-y: auto; background: var(--canvas) !important; }
.app-shell main .bg-white.rounded-xl,
.app-shell main .bg-white.rounded-lg,
.app-shell main .bg-white.shadow-md,
.app-shell main .bg-white.shadow-sm { border-color: var(--line); box-shadow: var(--shadow); }
.app-shell .overflow-x-auto { -webkit-overflow-scrolling: touch; }

.app-sidebar {
    width: 16rem; flex: none; flex-direction: column; height: 100%;
    background: var(--sidebar); border-right: 1px solid var(--line);
}
.app-brand, .mobile-brand {
    display: flex; align-items: center; gap: .75rem; color: var(--text);
    text-decoration: none;
}
.app-brand { min-height: 5.25rem; padding: 1.15rem 1.25rem; border-bottom: 1px solid var(--line); }
.app-brand img, .mobile-brand img { flex: none; border-radius: .85rem; box-shadow: 0 4px 12px rgba(30, 58, 138, .18); }
.app-brand-text, .mobile-brand span { display: flex; flex-direction: column; min-width: 0; line-height: 1.18; }
.app-brand-text strong, .mobile-brand strong { font-size: .93rem; letter-spacing: .075em; font-weight: 800; }
.app-brand-text small, .mobile-brand small { margin-top: .22rem; font-size: .65rem; font-weight: 700; letter-spacing: .15em; color: var(--muted); }
.app-nav { flex: 1; overflow-y: auto; padding: .85rem .75rem 1rem; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.nav-group + .nav-group { margin-top: 1.1rem; }
.nav-section-label { margin: .35rem .75rem .45rem; color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }
.nav-link {
    display: flex; align-items: center; gap: .72rem; min-height: 2.9rem;
    margin: .16rem 0; padding: .35rem .65rem; border-radius: .72rem;
    color: var(--muted); font-size: .88rem; font-weight: 600; text-decoration: none;
    transition: background .15s, color .15s, transform .15s;
}
.nav-link:hover { background: var(--surface-soft); color: var(--text); transform: translateX(2px); }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.nav-icon {
    width: 2.15rem; height: 2.15rem; flex: none; display: grid; place-items: center;
    border-radius: .58rem; background: var(--surface-soft); color: var(--muted);
}
.nav-link.is-active .nav-icon { background: var(--surface); color: var(--primary); }
.sidebar-footer, .drawer-footer { padding: .9rem .9rem 1rem; border-top: 1px solid var(--line); }
.user-card { display: flex; align-items: center; gap: .7rem; padding: .4rem .3rem .7rem; min-width: 0; }
.user-avatar { display: grid; place-items: center; width: 2.45rem; height: 2.45rem; flex: none; border-radius: .75rem; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.user-details { min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.user-details strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .8rem; color: var(--text); }
.user-details small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .7rem; color: var(--muted); }
.theme-toggle, .sidebar-action, .sidebar-logout {
    display: flex; align-items: center; gap: .7rem; width: 100%; min-height: 2.7rem;
    padding: .5rem .7rem; border-radius: .65rem; color: var(--muted);
    background: transparent; font-size: .82rem; font-weight: 700; text-decoration: none; text-align: left;
}
.theme-toggle:hover, .sidebar-action:hover, .sidebar-logout:hover { background: var(--surface-soft); color: var(--text); }
.sidebar-logout { color: #b45353; }
.sidebar-logout:hover { color: #a52626; }
.theme-toggle i, .sidebar-logout i { width: 1.25rem; text-align: center; }

.mobile-topbar { display: none; }
.menu-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(7, 17, 31, .55); backdrop-filter: blur(3px); }
.mobile-drawer {
    position: fixed; inset: 0 0 0 auto; z-index: 80; display: flex; flex-direction: column;
    width: min(21rem, 88vw); background: var(--sidebar); box-shadow: -24px 0 50px rgba(7,17,31,.25);
}
.drawer-heading { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .5rem; font-weight: 800; color: var(--text); }
.drawer-heading button, .menu-open-button {
    width: 2.65rem; height: 2.65rem; display: grid; place-items: center; border-radius: .75rem;
    border: 1px solid var(--line); color: var(--text); background: var(--surface);
}
.drawer-user { margin: 0 1rem .4rem; color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-drawer .app-nav { padding-top: .3rem; }
.mobile-drawer .nav-link { min-height: 3.1rem; }
.mobile-drawer .drawer-footer { background: var(--sidebar); }

.app-shell main h1, .app-shell main h2, .app-shell main h3 { letter-spacing: -.025em; }
.app-shell main a, .app-shell main button { -webkit-tap-highlight-color: transparent; }
.app-shell main input:not([type="radio"]):not([type="checkbox"]), .app-shell main select, .app-shell main textarea {
    min-width: 0; max-width: 100%; border-radius: .65rem;
}
.app-shell main input:focus, .app-shell main select:focus, .app-shell main textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.login-shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; background: radial-gradient(circle at 20% 15%, #e7efff, transparent 35%), var(--canvas); }
:root[data-theme="dark"] .login-shell { background: radial-gradient(circle at 20% 15%, #172b4a, transparent 40%), var(--canvas); }
.login-card { width: min(100%, 26rem); padding: 2rem; border: 1px solid var(--line); border-radius: 1.25rem; background: var(--surface); box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 2rem; }
.login-brand strong { display: block; font-weight: 800; letter-spacing: .08em; }
.login-brand small { color: var(--muted); font-size: .75rem; }
.login-card input { background: var(--surface-soft); color: var(--text); border: 1px solid var(--line); }
.login-card label { color: var(--text); }
.login-card p { color: var(--muted); }
.login-actions { margin-top: 1.1rem; padding-top: .65rem; border-top: 1px solid var(--line); }
.login-actions .theme-toggle { justify-content: center; }

:root[data-theme="dark"] .bg-white { background-color: var(--surface) !important; }
:root[data-theme="dark"] .bg-slate-50, :root[data-theme="dark"] .bg-gray-50, :root[data-theme="dark"] .bg-grey-lighter { background-color: var(--surface-soft) !important; }
:root[data-theme="dark"] .bg-slate-100, :root[data-theme="dark"] .bg-gray-100, :root[data-theme="dark"] .bg-gray-200, :root[data-theme="dark"] .bg-slate-200 { background-color: #253650 !important; }
:root[data-theme="dark"] .bg-blue-100, :root[data-theme="dark"] .bg-indigo-100, :root[data-theme="dark"] .bg-purple-100 { background-color: #263d6a !important; }
:root[data-theme="dark"] .bg-green-100, :root[data-theme="dark"] .bg-lime-100, :root[data-theme="dark"] .bg-teal-100 { background-color: #184a3f !important; }
:root[data-theme="dark"] .bg-orange-100, :root[data-theme="dark"] .bg-yellow-100, :root[data-theme="dark"] .bg-red-100 { background-color: #523d2c !important; }
:root[data-theme="dark"] .text-slate-900, :root[data-theme="dark"] .text-slate-800, :root[data-theme="dark"] .text-gray-800, :root[data-theme="dark"] .text-gray-700, :root[data-theme="dark"] .text-grey-darker { color: var(--text) !important; }
:root[data-theme="dark"] .text-slate-700, :root[data-theme="dark"] .text-slate-600, :root[data-theme="dark"] .text-gray-600 { color: #d1dbea !important; }
:root[data-theme="dark"] .text-slate-500, :root[data-theme="dark"] .text-slate-400, :root[data-theme="dark"] .text-gray-500, :root[data-theme="dark"] .text-gray-400 { color: var(--muted) !important; }
:root[data-theme="dark"] .text-blue-600, :root[data-theme="dark"] .text-blue-700, :root[data-theme="dark"] .text-blue-800, :root[data-theme="dark"] .text-indigo-600, :root[data-theme="dark"] .text-indigo-700, :root[data-theme="dark"] .text-indigo-800 { color: #a8c3ff !important; }
:root[data-theme="dark"] .text-purple-600, :root[data-theme="dark"] .text-purple-700, :root[data-theme="dark"] .text-purple-800 { color: #c4b5fd !important; }
:root[data-theme="dark"] .text-teal-600, :root[data-theme="dark"] .text-teal-700, :root[data-theme="dark"] .text-pink-600 { color: #89e4d0 !important; }
:root[data-theme="dark"] .text-orange-600, :root[data-theme="dark"] .text-orange-700, :root[data-theme="dark"] .text-yellow-600, :root[data-theme="dark"] .text-yellow-700 { color: #fcd790 !important; }
:root[data-theme="dark"] .text-green-600, :root[data-theme="dark"] .text-green-700, :root[data-theme="dark"] .text-green-800 { color: #86efac !important; }
:root[data-theme="dark"] .text-red-600, :root[data-theme="dark"] .text-red-700 { color: #fda4af !important; }
:root[data-theme="dark"] .border, :root[data-theme="dark"] .border-slate-100, :root[data-theme="dark"] .border-slate-200, :root[data-theme="dark"] .border-slate-300, :root[data-theme="dark"] .border-gray-100, :root[data-theme="dark"] .border-gray-200, :root[data-theme="dark"] .border-gray-300 { border-color: var(--line) !important; }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea {
    background-color: var(--surface-soft) !important; color: var(--text) !important; border-color: var(--line) !important;
}
:root[data-theme="dark"] input::placeholder, :root[data-theme="dark"] textarea::placeholder { color: #91a1b5; }
:root[data-theme="dark"] .hover\:bg-slate-50:hover, :root[data-theme="dark"] .hover\:bg-gray-50:hover { background-color: #23344b !important; }

@media (max-width: 1023px) {
    .app-sidebar { display: none; }
    .mobile-topbar {
        position: fixed; inset: 0 0 auto; z-index: 50; height: 4.3rem; padding: 0 1rem;
        display: flex; align-items: center; justify-content: space-between;
        background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 4px 20px rgba(20,36,58,.05);
    }
    .app-shell main { padding-top: 4.3rem; }
    .app-shell #form-evaluacion > .sticky { top: 4.3rem; }
}
@media (max-width: 639px) {
    .app-shell main > .container { padding-left: 1rem; padding-right: 1rem; }
    .app-shell main > .container > .flex.justify-between { flex-wrap: wrap; gap: .75rem; }
    .app-shell main .bg-white.shadow-md.rounded.px-8 { padding-left: 1rem; padding-right: 1rem; }
    .app-shell main h1, .app-shell main h2, .app-shell main h3 { overflow-wrap: anywhere; }
    .login-card { padding: 1.45rem; }
}
