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

body {
    font-family: 'Segoe UI', Roboto, system-ui, sans-serif;
    background: linear-gradient(135deg, #eef2f7 0%, #d9e2ec 100%);
    min-height: 100vh;
    padding: 1rem;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(255,255,255,0.96);
    border-radius: 2rem;
    box-shadow: 0 25px 45px -12px rgba(0,0,0,0.35);
    overflow: hidden;
}

.top-bar {
    background: #ffffffcc;
    padding: 1rem 2rem 0 2rem;
    border-bottom: 2px solid #cbdde6;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-btn {
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.7rem 1.6rem;
    border-radius: 2rem 2rem 0 0;
    cursor: pointer;
    color: #2c5a74;
    transition: 0.2s;
}

.nav-btn.active {
    background: white;
    color: #1f6e8c;
    border-bottom: 3px solid #1f6e8c;
}

.page {
    display: none;
    padding: 2rem;
    animation: fade 0.25s ease;
}

.page.active-page {
    display: block;
}

@keyframes fade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

h2 {
    color: #164a5f;
    margin-bottom: 0.5rem;
}

.sub {
    color: #3e6b87;
    margin-bottom: 1.5rem;
}

/* Tarjetas consejeras */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.counselor-card {
    background: white;
    border-radius: 1.2rem;
    padding: 1.2rem;
    box-shadow: 0 8px 18px rgba(0,0,0,0.05);
    border: 1px solid #e2edf2;
    transition: border-left 0.2s;
}

.class-tag {
    display: inline-block;
    padding: 0.2rem 1rem;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.birthday {
    background: #fff0db;
    border-radius: 30px;
    padding: 0.2rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #c26b1a;
    display: inline-block;
    margin-top: 6px;
}

/* Tabla responsiva */
.history-table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: 1rem;
    margin-top: 1rem;
}

.history-table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.history-table-wrapper th,
.history-table-wrapper td {
    padding: 0.8rem;
    text-align: left;
    border-bottom: 1px solid #e9edf2;
}

.history-table-wrapper th {
    background: #f3f7fb;
    color: #1f5068;
}

/* Estado badges */
.status-badge {
    padding: 0.2rem 0.8rem;
    border-radius: 40px;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-block;
}
.status-active { background-color: #2e7d32; color: white; }
.status-inactive { background-color: #9e9e9e; color: white; }
.presente { background: #c8e6d9; color: #1e6f3f; }

.class-row-active {
    background-color: #e0f7e8 !important;
    border-left: 4px solid #2e7d32;
}

/* Programación fin de semana */
.class-group {
    margin-bottom: 2rem;
    border: 1px solid #e0edf2;
    border-radius: 1.4rem;
    overflow: hidden;
}
.group-header {
    padding: 0.8rem 1.5rem;
    font-size: 1.3rem;
    font-weight: bold;
    transition: background-color 0.2s;
}
.weekend-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
}
.day-box {
    flex: 1;
    min-width: 250px;
    background: #fefefe;
    border-radius: 1rem;
    border: 1px solid #dee7ed;
}
.day-title {
    background: #f8fafc;
    padding: 0.5rem;
    text-align: center;
    font-weight: bold;
    font-size: 1.1rem;
    color: #2c7da0;
    border-bottom: 1px solid #dce5ec;
}
.activity {
    padding: 0.6rem;
    background: #fefcf5;
    font-size: 0.85rem;
    font-weight: 500;
    border-bottom: 1px solid #e9ecef;
}
.counselor-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #f0f2f5;
}
.loading {
    text-align: center;
    padding: 3rem;
    color: #3a6b8c;
}
.footer-note {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.75rem;
    color: #5d7f97;
    border-top: 1px solid #e0e9ef;
    padding-top: 1rem;
}

/* Responsive para móviles */
@media (max-width: 640px) {
    .page { padding: 1rem; }
    .nav-btn { padding: 0.4rem 1rem; font-size: 0.85rem; }
    .group-header { font-size: 1rem; padding: 0.6rem 1rem; }
    .counselor-line { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .counselor-line div:last-child { align-self: flex-end; }

    /* Tabla a tarjetas */
    .history-table-wrapper {
        overflow-x: visible;
    }
    .history-table-wrapper table,
    .history-table-wrapper thead,
    .history-table-wrapper tbody,
    .history-table-wrapper tr,
    .history-table-wrapper td {
        display: block;
    }
    .history-table-wrapper thead { display: none; }
    .history-table-wrapper tbody tr {
        background: white;
        border-radius: 1.2rem;
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05);
        border: 1px solid #e2edf2;
    }
    .history-table-wrapper td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid #eef2f5;
        text-align: right;
    }
    .history-table-wrapper td:last-child { border-bottom: none; }
    .history-table-wrapper td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #1f6e8c;
        margin-right: 1rem;
        flex: 1;
        font-size: 0.8rem;
        text-align: left;
    }
}

@media (min-width: 641px) and (max-width: 900px) {
    .history-table-wrapper { overflow-x: auto; }
    .history-table-wrapper table { min-width: 600px; }
}