/* =========================================================
   Planificador Universitario — Estilo Akaunting
   ========================================================= */

:root {
    --bg: #f0f2f8;
    --surface: #ffffff;
    --surface-2: #f7f8fc;
    --surface-3: #eef0f7;
    --border: #e4e7f1;
    --border-light: #edf0f7;
    --text: #1a1d36;
    --text-secondary: #5a5f82;
    --text-muted: #8b90ab;
    --primary: #00b48b;
    --primary-dark: #009e7a;
    --primary-darker: #007d61;
    --primary-light: #e6f9f4;
    --primary-ghost: #f0faf7;
    --accent: #6c5ce7;
    --accent-light: #f0eeff;
    --success: #00b48b;
    --success-light: #e6f9f4;
    --warning: #ff9f43;
    --warning-light: #fff5eb;
    --danger: #ee5253;
    --danger-light: #ffeded;
    --info: #54a0ff;
    --info-light: #ebf4ff;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 1px 3px rgba(26, 29, 54, .04), 0 4px 16px rgba(26, 29, 54, .03);
    --shadow-md: 0 4px 20px rgba(26, 29, 54, .06);
    --shadow-lg: 0 12px 48px rgba(26, 29, 54, .1);
    --shadow-sm: 0 1px 2px rgba(26, 29, 54, .05);
    --sidebar-w: 260px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition: .2s cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); text-decoration: none; }

h1, h2, h3, h4 { line-height: 1.3; color: var(--text); }
h1 { font-weight: 800; font-size: 1.6rem; letter-spacing: -.02em; }
h2 { font-weight: 700; font-size: 1.35rem; letter-spacing: -.01em; }
h3 { font-weight: 700; font-size: 1.05rem; margin-bottom: .5rem; }
h4 { font-size: .78rem; margin: 1rem 0 .5rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }

.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.empty { color: var(--text-muted); padding: .75rem 0; font-size: .9rem; }
.divider { border: 0; border-top: 1px solid var(--border-light); margin: 1.25rem 0; }
.link { font-size: .85rem; font-weight: 600; }

/* ========== Layout ========== */
.app { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.4rem;
    border-bottom: 1px solid var(--border-light);
}

.brand-mark {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-sm);
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 180, 139, .3);
}

.brand-name {
    font-weight: 800;
    font-size: .95rem;
    line-height: 1.2;
    color: var(--text);
    letter-spacing: -.01em;
}

.sidebar-nav {
    padding: .75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .85rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: .9rem;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
}
.nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}
.nav-link.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}
.nav-icon { width: 22px; text-align: center; font-size: 1.05rem; }
.nav-icon svg { vertical-align: middle; }

.sidebar-footer {
    padding: .9rem 1rem 1rem;
    border-top: 1px solid var(--border-light);
}

.user-chip { display: flex; align-items: center; gap: .7rem; padding: .5rem .5rem .6rem; }
.avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 180, 139, .25);
}
.user-meta { overflow: hidden; }
.user-meta strong { display: block; font-size: .87rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--text-muted); font-size: .73rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-link.logout { color: var(--danger); font-size: .85rem; margin-top: .25rem; }
.nav-link.logout:hover { background: var(--danger-light); color: var(--danger); }
.logout-form { display: block; margin: 0; padding: 0; background: none; border: none; width: 100%; }
.logout-btn { display: block; width: 100%; padding: .55rem .85rem; background: none; border: none; color: var(--danger); font-size: .85rem; font-family: inherit; text-align: left; cursor: pointer; border-radius: var(--radius); }
.logout-btn:hover { background: var(--danger-light); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(26, 29, 54, .4); backdrop-filter: blur(4px); z-index: 35; }

/* --- Main --- */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.8rem;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; }
.topbar-spacer { flex: 1; }
.topbar-date { color: var(--text-muted); font-size: .85rem; font-weight: 500; }

.content { padding: 1.8rem; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ========== Botones ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .6rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: .88rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface-2);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 180, 139, .3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-darker));
    box-shadow: 0 6px 20px rgba(0, 180, 139, .35);
}
.btn-secondary { background: var(--primary-light); color: var(--primary-dark); border-color: transparent; }
.btn-secondary:hover { background: #d4f5ec; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-secondary); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn-success { background: linear-gradient(135deg, var(--success), #009e7a); color: #fff; box-shadow: 0 4px 14px rgba(0, 180, 139, .3); }
.btn-success:hover { background: linear-gradient(135deg, #009e7a, #007d61); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #d63031); color: #fff; box-shadow: 0 4px 14px rgba(238, 82, 83, .3); }
.btn-danger:hover { background: linear-gradient(135deg, #d63031, #c0392b); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; border-radius: var(--radius-xs); }
.btn-block { width: 100%; }

.icon-btn {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    transition: all var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-light); color: var(--danger); }

/* ========== Tarjetas ========== */
.card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.3rem 1.4rem;
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-head h3 { margin: 0; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.4rem;
}
.page-head p { margin: 0; color: var(--text-secondary); }

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .65rem;
    border-radius: 999px;
    font-size: .73rem;
    font-weight: 600;
    letter-spacing: .01em;
}
.badge-ok { background: var(--success-light); color: #007d61; }
.badge-warn { background: var(--warning-light); color: #cc7a00; }
.badge-danger { background: var(--danger-light); color: #c0392b; }
.badge-info { background: var(--info-light); color: #2e7dd1; }
.badge-p-1 { background: var(--info-light); color: #2e7dd1; }
.badge-p-2 { background: var(--warning-light); color: #cc7a00; }
.badge-p-3 { background: var(--danger-light); color: #c0392b; }

.chip {
    display: inline-block;
    padding: .18rem .7rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    color: var(--text);
    border: 1px solid var(--chip, var(--border));
    background: color-mix(in srgb, var(--chip, #00b48b) 10%, #fff);
}
@supports not (background: color-mix(in srgb, red 10%, #fff)) {
    .chip { background: var(--surface-2); }
}

/* ========== Formularios ========== */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; flex: 1; min-width: 0; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; }

label { font-size: .82rem; font-weight: 600; color: var(--text); }

.input {
    padding: .65rem .9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    width: 100%;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 180, 139, .12);
}
.input::placeholder { color: var(--text-muted); }
textarea.input { resize: vertical; min-height: 80px; }
.color-input { padding: .25rem .4rem; height: 44px; border-radius: var(--radius-sm); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b90ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.2rem; }
.hint { color: var(--text-muted); font-size: .76rem; }

/* ========== Alertas ========== */
.alert {
    padding: .8rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 500;
    margin-bottom: .75rem;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.alert-danger { background: var(--danger-light); color: #c0392b; border-left-color: var(--danger); }
.alert-success { background: var(--success-light); color: #007d61; border-left-color: var(--success); }
.alert-warning { background: var(--warning-light); color: #b47a00; border-left-color: var(--warning); }
.alert-info { background: var(--info-light); color: #2e7dd1; border-left-color: var(--info); }

.alerts-box { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.alerts-box .alert { margin: 0; }

/* ========== Tablas ========== */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
    padding: .7rem .8rem;
    text-align: left;
    border-bottom: 2px solid var(--border-light);
    color: var(--text-muted);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
}
.table td {
    padding: .7rem .8rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tr { transition: background var(--transition); }
.table tr:hover td { background: var(--surface-2); }
.th-actions { width: 76px; text-align: right; }

/* ========== Modales ========== */
.modal { display: none; position: fixed; inset: 0; z-index: 100; align-items: center; justify-content: center; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(26, 29, 54, .5); backdrop-filter: blur(4px); }
.modal-panel {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: min(580px, calc(100vw - 2rem));
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    padding: 1.5rem 1.6rem;
    animation: modal-in .25s cubic-bezier(.4,0,.2,1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-light); }
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: .5rem; padding-top: 1rem; border-top: 1px solid var(--border-light); }

/* ========== Toasts ========== */
.toast-root {
    position: fixed;
    bottom: 1.4rem;
    right: 1.4rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.toast {
    padding: .85rem 1.2rem;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: .88rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: toast-in .3s cubic-bezier(.4,0,.2,1);
    max-width: 360px;
    backdrop-filter: blur(8px);
}
.toast-success { background: linear-gradient(135deg, #00b48b, #009e7a); }
.toast-danger { background: linear-gradient(135deg, #ee5253, #d63031); }
.toast-info { background: linear-gradient(135deg, #54a0ff, #2e7dd1); }
.toast-warning { background: linear-gradient(135deg, #ff9f43, #e67e22); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.95); } to { opacity: 1; transform: none; } }
.toast.fade { opacity: 0; transition: opacity .3s; }

/* ========== Dashboard ========== */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.4rem;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text);
    text-decoration: none;
    transition: all var(--transition);
}
.stat-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.stat-icon {
    font-size: 1.5rem;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.stat-card strong { display: block; font-size: 1.5rem; line-height: 1.1; font-weight: 800; color: var(--text); }
.stat-card small { color: var(--text-muted); font-size: .82rem; font-weight: 500; }

.grid-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 900px) { .grid-cols { grid-template-columns: 1fr; } }

.event-list { list-style: none; display: flex; flex-direction: column; gap: .85rem; }
.event-item { display: flex; gap: .8rem; align-items: flex-start; }
.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: .5rem;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 20%, transparent);
}
@supports not (background: color-mix(in srgb, red 10%, #fff)) {
    .dot { box-shadow: none; }
}
.event-info strong { display: block; font-size: .9rem; color: var(--text); }
.event-info small { color: var(--text-muted); font-size: .8rem; }

.day-classes { display: flex; flex-direction: column; gap: .6rem; }
.day-class {
    padding: .7rem .9rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border-left: 4px solid var(--c, var(--primary));
    display: flex;
    flex-direction: column;
    transition: background var(--transition);
}
.day-class:hover { background: var(--surface-3); }
.day-class strong { font-size: .9rem; color: var(--text); }
.day-class small { color: var(--text-muted); font-size: .8rem; }
.day-class-activity { border-left-color: var(--accent); background: var(--accent-light); }
.day-class-activity:hover { background: #e8e5ff; }
.day-class-event { border-left-color: var(--info); background: var(--info-light); }
.day-class-event:hover { background: #ddeeff; }

.study-progress { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border-light); }
.study-progress-head { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .5rem; font-weight: 500; }
.progress-track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--info));
    border-radius: 999px;
    transition: width .5s cubic-bezier(.4,0,.2,1);
}

.fab {
    position: fixed;
    bottom: 1.6rem;
    right: 1.6rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    box-shadow: 0 8px 24px rgba(0, 180, 139, .35);
    z-index: 20;
    transition: all var(--transition);
}
.fab:hover { transform: scale(1.08); text-decoration: none; box-shadow: 0 12px 32px rgba(0, 180, 139, .4); }

/* ========== Cursos ========== */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.course-card { position: relative; overflow: hidden; }
.course-bar { position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.course-top { display: flex; gap: .7rem; align-items: flex-start; margin-bottom: .8rem; }
.course-head { flex: 1; }
.course-head h3 { margin: 0; font-size: 1.05rem; }
.course-actions { display: flex; gap: 3px; }
.course-meta { display: flex; gap: 1rem; font-size: .82rem; color: var(--text-muted); margin-bottom: .6rem; font-weight: 500; }

.schedule-block { margin-top: .9rem; border-top: 1px solid var(--border-light); padding-top: .8rem; }
.schedule-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.schedule-list { list-style: none; display: flex; flex-direction: column; gap: .45rem; }
.schedule-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .84rem;
    padding: .5rem .65rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.schedule-item:hover { background: var(--surface-3); }
.schedule-item > span:nth-child(3) { flex: 1; }
.schedule-actions { display: flex; gap: 3px; }

/* ========== Tabs ========== */
.tabs {
    display: flex;
    gap: .3rem;
    margin-bottom: 1.2rem;
    border-bottom: 2px solid var(--border-light);
}
.tab {
    padding: .6rem 1.1rem;
    font-size: .88rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ========== Empty state ========== */
.empty-state { text-align: center; padding: 3rem 1.5rem; display: flex; flex-direction: column; align-items: center; gap: .75rem; }
.empty-emoji { font-size: 2.8rem; filter: grayscale(.2); }
.empty-state p { color: var(--text-muted); max-width: 420px; font-size: .92rem; line-height: 1.6; }

/* ========== Horario (grid semanal) ========== */
.schedule-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.week-nav { display: flex; align-items: center; gap: .6rem; }
.schedule-actions { display: flex; gap: .6rem; }

.legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.legend-dot { width: 14px; height: 14px; border-radius: 4px; background: var(--lg, var(--primary)); display: inline-block; }
.legend-dot.legend-proposed { border: 2px dashed #0e7490; }

.schedule-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.sched-grid {
    display: grid;
    min-width: 940px;
    grid-template-columns: 70px repeat(7, 1fr);
    grid-auto-rows: 30px;
    position: relative;
}
.sched-grid .sched-head-spacer { grid-column: 1; grid-row: 1; border-bottom: 2px solid var(--border-light); }
.sched-day-head {
    border-bottom: 2px solid var(--border-light);
    border-left: 1px solid var(--border-light);
    padding: 8px;
    text-align: center;
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--surface-2);
    position: sticky;
    top: 0;
    z-index: 5;
    grid-row: 1;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.sched-day-head.today { color: var(--primary); background: var(--primary-light); }
.sched-day-head.today strong { color: var(--primary); }

.day-chips { display: flex; flex-direction: column; gap: 2px; margin-top: 3px; }
.sched-task-chip {
    border: 0;
    background: color-mix(in srgb, var(--tc, #ff9f43) 16%, #fff);
    color: #8a5a1e;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: .7rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: filter var(--transition);
}
@supports not (background: color-mix(in srgb, red 10%, #fff)) {
    .sched-task-chip { background: var(--warning-light); }
}
.sched-task-chip:hover { filter: brightness(.96); }
.sched-task-more { font-size: .66rem; color: var(--primary); font-weight: 700; }

.sched-time-label {
    grid-column: 1;
    font-size: .68rem;
    color: var(--text-muted);
    padding-right: 6px;
    text-align: right;
    transform: translateY(-8px);
    white-space: nowrap;
    user-select: none;
    font-weight: 500;
}
.sched-rowline { grid-column: 1 / -1; border-top: 1px solid var(--border-light); }

.sched-day {
    border-left: 1px solid var(--border-light);
    grid-row: 2 / -1;
    position: relative;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 29px,
        var(--border-light) 29px,
        var(--border-light) 30px
    );
}
.sched-day.today { background-color: var(--primary-ghost); }

.sched-item {
    position: absolute;
    left: 3px;
    right: 3px;
    border-radius: var(--radius-xs);
    padding: 4px 7px;
    font-size: .72rem;
    line-height: 1.3;
    overflow: hidden;
    border-left-width: 3px;
    border-left-style: solid;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(26, 29, 54, .1);
    z-index: 2;
    transition: all var(--transition);
}
.sched-item:hover { box-shadow: var(--shadow-md); z-index: 8; transform: scale(1.01); }
.sched-item .sched-title { font-weight: 700; display: block; }
.sched-item .sched-sub { font-size: .66rem; opacity: .85; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-item.proposed { border-left-style: dashed; outline: 2px dashed rgba(0, 180, 139, .4); outline-offset: -2px; }

.sched-loading { padding: 2.5rem; text-align: center; color: var(--text-muted); font-weight: 500; }

.sched-popover {
    position: fixed;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: .8rem 1rem;
    min-width: 240px;
    max-width: 320px;
    font-size: .85rem;
}
.sched-popover h4 { margin: 0 0 .35rem; font-size: .95rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.sched-popover p { margin: .2rem 0; color: var(--text-muted); font-size: .8rem; }

.warnings-box { margin-bottom: 1rem; }

/* ========== Calendario ========== */
.view-switch { display: flex; gap: .3rem; }
.cal-month {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
    min-width: 720px;
}
.cal-month-day {
    background: var(--surface);
    min-height: 115px;
    padding: 8px;
    font-size: .8rem;
    transition: background var(--transition);
}
.cal-month-day:hover { background: var(--surface-2); }
.cal-month-day.other { opacity: .4; }
.cal-month-day.today { background: var(--primary-light); }
.cal-day-num { font-weight: 700; color: var(--text-muted); margin-bottom: 5px; display: block; font-size: .85rem; }
.cal-day-num.today { color: var(--primary); }
.cal-event {
    display: block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 500;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: filter var(--transition);
}
.cal-event:hover { filter: brightness(.95); }

.cal-day-view .sched-day { grid-row: 2 / -1; }
.cal-day-view .sched-grid { grid-template-columns: 70px 1fr; min-width: 480px; }

/* ========== Estadísticas ========== */
.stat-big { display: flex; flex-direction: column; align-items: center; margin-bottom: 1rem; }
.stat-big strong { font-size: 2.5rem; color: var(--primary); font-weight: 800; }
.stat-big small { color: var(--text-muted); font-weight: 500; }
.stacked-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.stack-done { background: linear-gradient(90deg, var(--primary), var(--primary-dark)); }
.stack-progress { background: linear-gradient(90deg, var(--warning), #e67e22); }
.legend-list { list-style: none; margin-top: .8rem; display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; }

.bar-chart { display: flex; align-items: flex-end; gap: .6rem; height: 190px; padding-top: 12px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 5px; }
.bar {
    width: 70%;
    max-width: 44px;
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    border-radius: 6px 6px 0 0;
    min-height: 3px;
    transition: height .5s cubic-bezier(.4,0,.2,1);
}
.bar-value { font-size: .7rem; color: var(--text-muted); font-weight: 600; }
.bar-col small { font-size: .7rem; color: var(--text-muted); font-weight: 500; }

.row-bar { display: flex; align-items: center; gap: .7rem; margin-bottom: .6rem; font-size: .85rem; }
.row-bar .progress-track { flex: 1; }
.row-label { width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

/* ========== Auth (Login/Register) ========== */
.auth-body {
    background: linear-gradient(135deg, #f0f2f8 0%, #e6f9f4 50%, #f0eeff 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.auth-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    max-width: 920px;
    width: 100%;
    align-items: center;
}
@media (max-width: 780px) { .auth-wrap { grid-template-columns: 1fr; } .auth-brand { text-align: center; } }
.auth-brand { color: var(--text); }
.auth-logo {
    font-size: 3.5rem;
    display: inline-block;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.auth-brand h1 { font-size: 2.2rem; color: var(--text); margin-bottom: .7rem; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; }
.auth-brand p { color: var(--text-secondary); font-size: 1rem; line-height: 1.6; max-width: 380px; }
.auth-card {
    padding: 2rem 2.2rem;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius);
}
.auth-card h2 { margin-bottom: .3rem; font-size: 1.4rem; }
.auth-switch { margin-top: 1.2rem; text-align: center; font-size: .9rem; color: var(--text-muted); }
.auth-switch a { font-weight: 600; }

.stars { color: var(--border); font-size: .85rem; white-space: nowrap; }
.stars .on { color: var(--warning); }

/* ========== Responsive ========== */

/* --- Tables: overflow wrapper + hidden columns on mobile --- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.course-meta { flex-wrap: wrap; }
.form-row .form-group { min-width: 180px; }

.calendar-view { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }

.tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.row-label { width: 120px; min-width: 80px; }

@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
    .sidebar-overlay.open { display: block; }
    .main { margin-left: 0; }
    .topbar-date { display: none; }
    .topbar { padding: 0 1rem; }
    .topbar-title { font-size: 1.1rem; }
    .content { padding: 1.2rem; }
    .grid-stats { grid-template-columns: repeat(2, 1fr); }
    .grid-stats .stat-card { flex-direction: column; text-align: center; gap: .5rem; }
    .grid-stats .stat-icon { width: 44px; height: 44px; }
    .page-head { flex-direction: column; align-items: flex-start; }
    .form-row { flex-direction: column; }
    .form-row .form-group { min-width: 100%; }
    .schedule-toolbar { flex-direction: column; align-items: stretch; }
    .schedule-toolbar .week-nav { justify-content: center; }
    .schedule-toolbar .schedule-actions { justify-content: center; flex-wrap: wrap; }
    .course-grid { grid-template-columns: 1fr; }
    .card { padding: 1rem 1.1rem; }

    /* Exams: hide stars + importance columns */
    .table .col-hide-tablet { display: none; }
}

@media (max-width: 480px) {
    html { font-size: 14px; }
    .grid-stats { grid-template-columns: 1fr; }
    .content { padding: .9rem; }
    .topbar { height: 56px; }
    .modal-panel { width: calc(100vw - 1rem); padding: 1.1rem; }
    .stat-card strong { font-size: 1.25rem; }
    .row-label { width: 90px; }
    .auth-card { padding: 1.4rem 1.2rem; }
    .auth-brand h1 { font-size: 1.6rem; }
    .auth-brand p { font-size: .88rem; }

    /* Tables: hide low-priority columns */
    .table .col-hide-mobile { display: none; }
    .table th, .table td { padding: .5rem .55rem; font-size: .8rem; }
    .th-actions { width: 52px; }
}

@media (max-width: 360px) {
    .table .col-hide-small { display: none; }
}
