* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f4f7fb;
    margin: 0;
    padding: 0;
}

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #1f3b5b;
    color: #ffffff;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 14px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.topbar-menu {
    display: contents;
}

.topbar-left {
    grid-column: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
}

.topbar-left .logo {
    margin: 0;
    font-size: 22px;
    color: #ffffff;
}

.topbar-nav {
    grid-column: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.topbar-nav a {
    color: #ffffff;
    text-decoration: none;
    font-weight: bold;
    padding: 8px 10px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.topbar-nav a:hover {
    background-color: #2d527a;
}

.topbar-right {
    grid-column: 3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

.logout {
    color: #ffffff;
    text-decoration: none;
    background-color: #c0392b;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: bold;
}

.logout:hover {
    background-color: #a93226;
}

.menu-toggle {
    display: none;

    width: 42px;
    height: 42px;

    margin: 0 0 0 auto;
    padding: 8px;

    background: transparent;
    border: none;

    cursor: pointer;
}

.menu-toggle:hover {
    background-color: #2d527a;
}

.menu-toggle span {
    display: block;

    width: 24px;
    height: 2px;

    margin: 5px auto;

    background-color: #ffffff;

    border-radius: 2px;
}

.captcha-box {
    margin: 10px 0 15px 0;
}

.login-container,
.dashboard,
.container {
    width: 100%;
    max-width: 700px;
    margin: 80px auto;
    background: #ffffff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.08);
}

.containerModulo {
    width: 90%;
    max-width: 1100px;
    margin: 80px auto;
    background: #ffffff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.08);
}

.containerFull {
    width: 90%;
    margin: 80px auto;
    background: #ffffff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.08);
}

.actions {
    margin-bottom: 20px;
}

.actions a,
.actions-rep a,
.btn,
.btn-secondary,
.btn-small {
    display: inline-block;
    padding: 10px 14px;
    /*margin-right: 10px;*/
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}

.actions-rep {
    display: inline-block;
    width: 100%;
    text-align: center;
}

.btn,
.btn-small {
    background-color: #1f6fb2;
    color: white;
}

.btn:hover,
.btn-small:hover {
    background-color: #195b91;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    width: 130px;
    text-align: center;
    margin: 0 10px;
}

.btn-secondary:hover {
    background-color: #565e64;
}

.btn-danger {
    background-color: #c0392b;
    color: white;
}

.btn-danger:hover {
    background-color: #a93226;
}

.search-form {
    margin-bottom: 20px;
    display: inline-block;
    width: 100%;
    text-align: center;
}

.search-form input[type="text"] {
    width: 300px;
    margin-right: 10px;
}

.search-form input[type="date"] {
    width: 300px;
    margin-right: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: #fff;
}

table th,
table td {
    border: 1px solid #dce3ea;
    padding: 10px;
    text-align: center;
    vertical-align: top;
}

table th {
    background-color: #eef4fa;
    color: #1f3b5b;
}

.error-box {
    background-color: #fdecea;
    color: #b71c1c;
    border: 1px solid #f5c6cb;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.success-box {
    background-color: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #c8e6c9;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.detail-card {
    background-color: #f9fbfd;
    border: 1px solid #dce3ea;
    border-radius: 8px;
    padding: 20px;
}

h1, h2 {
    text-align: center;
    color: #1f3b5b;
}

form {
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.form-login {
    display: flex;
    flex-direction: column;
    max-width: 300px;
    margin: 0 auto;
}

label {
    margin-top: 10px;
    margin-bottom: 5px;
    font-weight: bold;
}

input, textarea, select, button {
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #cfd8e3;
    border-radius: 6px;
    font-size: 14px;
}

button {
    background-color: #1f6fb2;
    color: white;
    border: none;
    cursor: pointer;
    width: 130px;
}

button:hover {
    background-color: #195b91;
}

.error {
    color: red;
    text-align: center;
}

nav ul {
    list-style: none;
    padding: 0;
}

nav ul li {
    margin: 12px 0;
}

nav ul li a {
    text-decoration: none;
    color: #1f6fb2;
    font-weight: bold;
}

.logo {
    display: block;
    margin: 0 auto 20px auto;
}

.logo-preview {
    max-width: 220px;
    max-height: 160px;
    object-fit: contain;
    border: 1px solid #dce3ea;
    border-radius: 8px;
    padding: 8px;
    background-color: #ffffff;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px 20px;
}

.data-item {
    /*background: #ffffff;
    border: 1px solid #dce3ea;
    border-radius: 6px;*/
    padding: 0px 0px 0px 0px;
}

.data-item.full-width {
    grid-column: 1 / -1;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px 20px;
}

.info-item {
    background: #ffffff;
    border: 1px solid #dce3ea;
    border-radius: 6px;
    padding: 0px 20px 0px 20px;
}

.info-item.full-width {
    grid-column: 1 / -1;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

/* Estadisticas */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin: 25px 0;
}

.kpi-card {
    background: #ffffff;
    border: 1px solid #dce3ea;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 0 8px rgba(0,0,0,0.05);
}

.kpi-circle {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 8px solid #1f6fb2;
    background: #eef4fa;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px auto;
}

.kpi-circle span {
    font-size: 28px;
    font-weight: bold;
    color: #1f3b5b;
}

.kpi-card h3 {
    margin: 8px 0 4px 0;
    color: #1f3b5b;
}

.kpi-card p {
    margin: 0;
    font-size: 14px;
    color: #5f6f7f;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin: 25px 0;
}

.chart-card {
    background: #ffffff;
    border: 1px solid #dce3ea;
    border-radius: 12px;
    padding: 18px;
    min-height: 330px;
    box-shadow: 0 0 8px rgba(0,0,0,0.05);
}

.chart-card h2 {
    text-align: center;
    font-size: 18px;
    margin-bottom: 15px;
}

.chart-card canvas {
    width: 100% !important;
    height: 240px !important;
}

.catalog-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 8px;
}

.catalog-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1px 1px;
    background: #ffffff;
    border: 1px solid #dce3ea;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s ease;
}

.catalog-option:hover {
    background: #f5f9fc;
    border-color: #1f6fb2;
}

.catalog-option input {
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.catalog-empty {
    margin-top: 8px;
    padding: 12px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
}

.login-success-panel {
    text-align: center;
    padding: 30px 20px;
    animation: fadeIn 0.4s ease;
}

.success-icon {
    width: 65px;
    height: 65px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 36px;
    font-weight: bold;
}

.login-success-panel h2 {
    margin-bottom: 10px;
    color: #1f3b5b;
}

.login-success-panel p {
    margin: 5px 0;
}

.redirect-text {
    margin-top: 15px !important;
    font-size: 13px;
    color: #607080;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Catalogos */
@media (max-width: 1000px) {

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

}

@media (max-width: 600px) {

    .catalog-options {
        grid-template-columns: 1fr;
    }

}

/* Estadisticas */
@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        
    }
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .data-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 800px) {
        .kpi-grid {
        grid-template-columns: 1fr;
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .info-grid {
        grid-template-columns: 1fr;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Menu responsivo */

@media (max-width: 1400px) {

    .topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 0;
        padding: 10px 20px;
    }

    .topbar-left {
        display: flex;
        align-items: center;
    }

    /* Mostrar botón hamburguesa */
    .menu-toggle {
        display: block;
        margin-left: auto;
    }


    /* Menú desplegable */
    .topbar-menu {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        display: none;
        flex-direction: column;
        align-items: stretch;
        padding: 10px 20px 18px;
        background-color: #1f3b5b;
        box-shadow: 0 5px 8px rgba(0, 0, 0, 0.15);
    }

    /* Cuando JavaScript agrega .active */
    .topbar-menu.active {
        display: flex;
    }

    /* Navegación vertical */
    .topbar-nav {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 3px;
    }

    .topbar-nav a {
        display: block;
        width: 100%;
        font-size: 14px;
    }

    /* Cerrar sesión */
    .topbar-right {
        width: 100%;
        display: flex;
        margin-top: 8px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
    }

    .logout {
        display: block;
        width: 100%;
        text-align: center;
    }
}