:root {
    --green-950: #203500;
    --green-900: #283e06;
    --green-850: #31470b;
    --green-800: #3b5110;
    --green-700: #4a5a14;
    --green-600: #586e26;
    --green-500: #778c43;
    --green-400: #96ac60;
    --green-300: #b7cd7f;
    --green-200: #d9ef9f;

    --bg: #f4f6f0;
    --surface: #ffffff;
    --surface-soft: #edf2e7;

    --text: #203500;
    --text-soft: #6b765c;

    --border: #d7dfce;

    --primary: #586e26;
    --primary-hover: #4a5a14;
    --primary-text: #ffffff;

    --sidebar: #203500;
    --sidebar-soft: #31470b;
    --sidebar-text: #eef5e5;

    --danger: #b44242;
    --warning: #b78420;
    --success: #586e26;

    --shadow: 0 12px 32px rgba(32, 53, 0, 0.08);
}


/* =========================================================
   MODO OSCURO
   ========================================================= */

[data-theme="dark"] {
    --bg: #0f140c;
    --surface: #181f14;
    --surface-soft: #20291a;

    --text: #eef5e5;
    --text-soft: #b6c5a6;

    --border: #324029;

    --primary: #96ac60;
    --primary-hover: #b7cd7f;
    --primary-text: #203500;

    --sidebar: #141b10;
    --sidebar-soft: #243018;
    --sidebar-text: #f3f7ee;

    --shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}


/* =========================================================
   BASE
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: var(--bg);
    color: var(--text);

    transition:
        background-color .2s ease,
        color .2s ease;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}


/* =========================================================
   ESTRUCTURA PRINCIPAL
   ========================================================= */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.main {
    flex: 1;
    min-width: 0;
}


/* =========================================================
   SIDEBAR
   ========================================================= */

.sidebar {
    width: 260px;
    height: 100vh;

    position: sticky;
    top: 0;

    display: flex;
    flex-direction: column;

    padding: 22px 18px;

    background: var(--sidebar);
    color: var(--sidebar-text);

    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.04);
}

.sidebar-brand {
    display: flex;
    align-items: center;

    gap: 12px;

    margin-bottom: 28px;
    padding: 4px 6px;
}

.logo-box {
    width: 48px;
    height: 48px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    overflow: hidden;

    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);

    background: rgba(255, 255, 255, 0.08);
}

.logo-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-box.logo-empty::after {
    content: "AJ";

    font-size: 16px;
    font-weight: 800;
    letter-spacing: .5px;

    color: white;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-text strong {
    font-size: 17px;
    line-height: 1.1;
}

.brand-text span {
    font-size: 12px;
    color: var(--green-300);
}


/* =========================================================
   MENÚ LATERAL
   ========================================================= */

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;

    gap: 12px;

    padding: 11px 13px;

    border-radius: 12px;

    color: var(--sidebar-text);

    transition:
        background-color .18s ease,
        transform .18s ease,
        color .18s ease;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.07);
    transform: translateX(2px);
}

.sidebar-menu a.active {
    background: var(--green-600);
    color: white;

    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.menu-icon {
    width: 24px;
    height: 24px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border-radius: 8px;

    background: rgba(255, 255, 255, 0.05);

    font-size: 14px;
}

.sidebar-footer {
    margin-top: auto;

    padding: 18px 8px 4px;

    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
}


/* =========================================================
   TOPBAR
   ========================================================= */

.topbar {
    min-height: 72px;

    position: sticky;
    top: 0;
    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 28px;

    background: var(--surface);
    border-bottom: 1px solid var(--border);

    transition:
        background-color .2s ease,
        border-color .2s ease;
}

.topbar-title {
    font-size: 19px;
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    padding: 8px 12px;

    border: 1px solid var(--border);
    border-radius: 999px;

    background: var(--surface-soft);
    color: var(--text);

    font-size: 13px;
    font-weight: 600;
}

.theme-toggle {
    padding: 9px 12px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: var(--surface-soft);
    color: var(--text);

    cursor: pointer;

    transition:
        background-color .18s ease,
        border-color .18s ease,
        transform .18s ease;
}

.theme-toggle:hover {
    transform: translateY(-1px);
}


/* =========================================================
   CONTENIDO
   ========================================================= */

.content {
    padding: 30px;
}

.content h1 {
    margin: 0 0 8px;

    font-size: 30px;
    line-height: 1.1;
}

.content p {
    color: var(--text-soft);
}


/* =========================================================
   GRILLAS
   ========================================================= */

.grid {
    display: grid;
    gap: 20px;
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}


/* =========================================================
   TARJETAS
   ========================================================= */

.card {
    padding: 20px;

    border: 1px solid var(--border);
    border-radius: 16px;

    background: var(--surface);

    box-shadow: var(--shadow);

    transition:
        background-color .2s ease,
        border-color .2s ease,
        transform .18s ease;
}

.card:hover {
    transform: translateY(-1px);
}

.stat-label {
    font-size: 13px;
    font-weight: 600;

    color: var(--text-soft);
}

.stat-value {
    margin-top: 8px;

    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.4px;
}

.section-title {
    margin: 0 0 16px;

    font-size: 18px;
    font-weight: 700;
}


/* =========================================================
   BOTONES
   ========================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 10px 16px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: var(--surface-soft);
    color: var(--text);

    cursor: pointer;

    font-weight: 700;

    transition:
        background-color .18s ease,
        transform .18s ease,
        border-color .18s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    border-color: transparent;

    background: var(--primary);
    color: var(--primary-text);
}

.btn-primary:hover {
    background: var(--primary-hover);
}


/* =========================================================
   TABLAS
   ========================================================= */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;

    border-bottom: 1px solid var(--border);

    text-align: left;
}

th {
    color: var(--text-soft);

    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}


/* =========================================================
   INPUTS
   ========================================================= */

input,
select,
textarea {
    width: 100%;

    padding: 10px 12px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: var(--surface);
    color: var(--text);

    outline: none;

    transition:
        border-color .18s ease,
        box-shadow .18s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green-500);

    box-shadow:
        0 0 0 3px rgba(119, 140, 67, 0.14);
}


/* =========================================================
   FORMULARIOS
   ========================================================= */

.form-page {
    max-width: 1100px;
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 20px;

    margin-bottom: 24px;
}

.form-section {
    margin-bottom: 20px;
}

.form-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 20px;

    margin-bottom: 16px;
}

.form-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 18px;
}

.form-field {
    display: flex;
    flex-direction: column;

    gap: 7px;
}

.form-field label {
    font-size: 13px;
    font-weight: 700;

    color: var(--text-soft);
}

.form-field-small {
    max-width: 300px;
}

.form-help {
    margin-top: -6px;
    margin-bottom: 18px;

    font-size: 13px;

    color: var(--text-soft);
}


/* =========================================================
   SELECTOR DE CLASES
   ========================================================= */

.class-selector {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 14px;
}

.class-card {
    position: relative;

    display: flex;
    align-items: center;

    gap: 14px;

    padding: 16px 18px;

    border: 2px solid var(--border);
    border-radius: 14px;

    background: var(--surface);

    cursor: pointer;

    transition:
        border-color .18s ease,
        background-color .18s ease,
        transform .18s ease,
        box-shadow .18s ease;
}

.class-card:hover {
    border-color: var(--green-500);

    transform: translateY(-1px);
}

.class-card-check {
    flex-shrink: 0;
}

.class-card-check input {
    width: 22px;
    height: 22px;

    cursor: pointer;

    accent-color: var(--green-600);
}

.class-card-content {
    display: flex;
    flex-direction: column;

    gap: 6px;
}

.class-card-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
}

.class-card-status {
    font-size: 12px;
    font-weight: 700;
}

.status-selected {
    display: none;

    color: var(--green-600);
}

.status-unselected {
    color: var(--text-soft);
}


/* Estado seleccionado */

.class-card:has(input:checked) {
    border-color: var(--green-600);

    background: var(--surface-soft);

    box-shadow:
        0 0 0 3px rgba(88, 110, 38, 0.08);
}

.class-card:has(input:checked) .status-selected {
    display: inline;
}

.class-card:has(input:checked) .status-unselected {
    display: none;
}


/* =========================================================
   ACCIONES DE FORMULARIO
   ========================================================= */

.form-actions {
    display: flex;
    align-items: center;

    gap: 12px;

    margin-top: 24px;
    margin-bottom: 40px;
}


/* =========================================================
   ERRORES
   ========================================================= */

.form-errors,
.errorlist {
    color: var(--danger);
}

.errorlist {
    margin: 4px 0 0;
    padding-left: 18px;

    font-size: 13px;
}

.empty-state {
    padding: 10px 0;

    color: var(--text-soft);
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1100px) {

    .grid-4 {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 820px) {

    .sidebar {
        width: 82px;

        padding-left: 12px;
        padding-right: 12px;
    }

    .brand-text,
    .sidebar-menu a span:last-child,
    .sidebar-footer {
        display: none;
    }

    .sidebar-brand {
        justify-content: center;
    }

    .sidebar-menu a {
        justify-content: center;
    }

    .content {
        padding: 20px;
    }

}


@media (max-width: 760px) {

    .form-grid,
    .class-selector {
        grid-template-columns: 1fr;
    }

    .form-header,
    .form-section-header {
        flex-direction: column;
    }

}


@media (max-width: 600px) {

    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-title {
        font-size: 16px;
    }

    .user-chip {
        display: none;
    }

}