* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f6f9;
    color: #2c3e50;
}

a {
    text-decoration: none;
    color: inherit;
}

.layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.sidebar {
    width: 290px;
    background: #243447;
    color: #fff;
    padding: 0;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.25s ease, transform 0.25s ease;
    z-index: 20;
}

.layout.sidebar-collapsed .sidebar {
    width: 78px;
}

.sidebar-brand {
    padding: 18px 16px 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-link {
    display: block;
    color: inherit;
}

.brand-link:hover {
    text-decoration: none;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon-wrap {
    flex: 0 0 42px;
    width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-icon {
    display: block;
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.brand-text-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
    transition: opacity 0.2s ease;
}

.brand-title {
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    line-height: 1.1;
    margin: 0;
    white-space: nowrap;
}

.brand-subtitle {
    margin-top: 2px;
    font-size: 11px;
    color: #b8c7ce;
    line-height: 1.1;
    white-space: nowrap;
}

.brand-link.active .brand-title {
    color: #3498db;
}

.sidebar .menu-title {
    font-size: 12px;
    text-transform: uppercase;
    color: #b8c7ce;
    padding: 16px 20px 8px 20px;
    margin-top: 8px;
    letter-spacing: 0.5px;
    transition: opacity 0.2s ease;
}

.sidebar a {
    display: block;
    padding: 12px 20px;
    color: #d7dde4;
    font-size: 15px;
    border-left: 4px solid transparent;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, padding 0.2s ease;
    white-space: nowrap;
}

.sidebar a:hover {
    background: #1b2836;
    color: #fff;
}

.sidebar a.active {
    background: #1b2836;
    color: #ffffff;
    font-weight: bold;
    border-left: 4px solid #3498db;
}

.layout.sidebar-collapsed .brand-text-wrap,
.layout.sidebar-collapsed .sidebar .menu-title {
    opacity: 0;
    pointer-events: none;
}

.layout.sidebar-collapsed .sidebar a {
    padding-left: 16px;
    padding-right: 16px;
    overflow: hidden;
    text-overflow: clip;
}

.content {
    flex: 1;
    padding: 24px;
    overflow-x: auto;
    min-width: 0;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.sidebar-toggle {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 8px;
    font-size: 20px;
    line-height: 1;
    background: #243447;
    color: #fff;
    border: none;
    cursor: pointer;
}

.sidebar-toggle:hover {
    background: #1b2836;
}

.top-nav-title {
    font-size: 16px;
    font-weight: bold;
    color: #5d6d7e;
}

.page-title {
    margin: 0 0 20px 0;
    font-size: 36px;
    font-weight: bold;
}

.card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

input,
select,
button,
textarea {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    box-sizing: border-box;
    border: 1px solid #ccd6dd;
    border-radius: 6px;
    background: #fff;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.15);
}

textarea {
    resize: vertical;
    min-height: 90px;
}

button {
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

button:hover {
    background: #2d83be;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    min-width: 760px;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    vertical-align: top;
}

th {
    background: #ecf0f1;
}

.estado-activo {
    color: green;
    font-weight: bold;
}

.estado-inactivo {
    color: #999;
    font-weight: bold;
}

.footer {
    margin-top: 30px;
    font-size: 12px;
    color: #777;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.acciones {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-link {
    display: inline-block;
    background: #3498db;
    color: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
}

.btn-link:hover {
    background: #2d83be;
    color: #fff;
}

.btn-link-secondary {
    display: inline-block;
    background: #95a5a6;
    color: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
}

.btn-link-secondary:hover {
    background: #7f8c8d;
    color: #fff;
}

.btn-link-warning {
    display: inline-block;
    background: #f39c12;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
}

.btn-link-warning:hover {
    background: #d68910;
    color: #fff;
}

.btn-link-success {
    display: inline-block;
    background: #27ae60;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
}

.btn-link-success:hover {
    background: #1e8449;
    color: #fff;
}

.btn-link-edit {
    display: inline-block;
    background: #2980b9;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
}

.btn-link-edit:hover {
    background: #21618c;
    color: #fff;
}

.mensaje-exito {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.mensaje-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
}

.codigo-readonly {
    background: #eef2f5;
    color: #5d6d7e;
}

.tabla-acciones {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 900px) {
    .layout {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 290px;
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    }

    .layout.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .layout.sidebar-collapsed .sidebar {
        width: 290px;
    }

    .layout.sidebar-collapsed .brand-text-wrap,
    .layout.sidebar-collapsed .sidebar .menu-title {
        opacity: 1;
        pointer-events: auto;
    }

    .layout.sidebar-collapsed .sidebar a {
        padding-left: 20px;
        padding-right: 20px;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        display: none;
        z-index: 15;
    }

    .layout.sidebar-open .sidebar-overlay {
        display: block;
    }

    .content {
        padding: 16px;
    }

    .page-title {
        font-size: 28px;
    }

    .brand-title {
        font-size: 17px;
    }

    .brand-subtitle {
        font-size: 10px;
    }

    .tabla-acciones {
        flex-direction: column;
        align-items: flex-start;
    }

    table {
        min-width: 680px;
    }
}
