:root {
    --azul-oscuro: #1B3A5C;
    --azul: #2C5F8A;
    --verde: #3E9C7A;
    --gris-fondo: #F4F6F8;
    --gris-borde: #DCE3E8;
    --texto: #1F2A33;
    --texto-suave: #5B6B76;
    --rojo: #C0392B;
    --blanco: #FFFFFF;
    --radio: 8px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--gris-fondo);
    color: var(--texto);
}
a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Barra superior */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--azul-oscuro);
    color: var(--blanco);
    padding: 0.75rem 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 0.6rem; }
.brand-logo { height: 34px; width: auto; filter: drop-shadow(1px 0 0 #000) drop-shadow(-1px 0 0 #000) drop-shadow(0 1px 0 #000) drop-shadow(0 -1px 0 #000); }
.brand-text { line-height: 1; }
.mainnav { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.mainnav a { color: #E5EEF5; font-size: 0.92rem; }
.mainnav a:hover { color: var(--verde); text-decoration: none; }
.userbox { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; }
.userbox a { color: #E5EEF5; border: 1px solid #43607C; padding: 0.3rem 0.7rem; border-radius: var(--radio); }

.content { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* Login */
.login-box {
    max-width: 360px;
    margin: 8vh auto;
    background: var(--blanco);
    padding: 2rem;
    border-radius: var(--radio);
    border: 1px solid var(--gris-borde);
    text-align: center;
}
.login-logo { width: 120px; height: auto; display: block; margin: 0 auto 0.8rem; filter: drop-shadow(1px 0 0 #000) drop-shadow(-1px 0 0 #000) drop-shadow(0 1px 0 #000) drop-shadow(0 -1px 0 #000); }
.login-box h1 { font-size: 1.3rem; margin-bottom: 0.1rem; color: var(--azul-oscuro); }
.subtitle { color: var(--texto-suave); margin-top: 0; margin-bottom: 1.5rem; }
.login-box form { text-align: left; display: flex; flex-direction: column; gap: 0.4rem; }
.login-box label { font-size: 0.85rem; color: var(--texto-suave); margin-top: 0.5rem; }
.login-box input {
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio);
    font-size: 1rem;
}
.login-box button {
    margin-top: 1.2rem;
    background: var(--azul-oscuro);
    color: var(--blanco);
    border: none;
    padding: 0.7rem;
    border-radius: var(--radio);
    font-size: 1rem;
    cursor: pointer;
}
.login-box button:hover { background: var(--azul); }

/* Resumen Ejecutivo */
.resumen-ejecutivo {
    background: var(--azul-oscuro);
    border-radius: var(--radio);
    padding: 1.4rem 1.5rem;
    margin-bottom: 1.5rem;
    color: #fff;
}
.resumen-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.resumen-header h2 { margin: 0; font-size: 1.15rem; color: #fff; }
.resumen-mes { font-size: 0.85rem; color: #B9CBDC; }
.resumen-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.resumen-card { background: rgba(255,255,255,0.08); border-radius: var(--radio); padding: 0.8rem 1rem; }
.resumen-label { font-size: 0.78rem; color: #B9CBDC; text-transform: uppercase; letter-spacing: 0.03em; }
.resumen-valor { font-size: 1.35rem; font-weight: 700; margin-top: 0.25rem; color: #fff; }
.resumen-valor.verde { color: #6FD9AE; }
.resumen-valor.rojo { color: #F0968B; }
.resumen-nota { font-size: 0.78rem; color: #B9CBDC; margin: -0.5rem 0 1rem; }
.resumen-chart { background: rgba(255,255,255,0.06); border-radius: var(--radio); padding: 1rem 1.1rem; }
.resumen-chart h3 { margin: 0 0 0.7rem; font-size: 0.95rem; color: #E5EEF5; font-weight: 600; }

/* Tarjetas del dashboard */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.charts-grid .panel { margin-bottom: 0; }

.banner-alerta {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: #FBEAE8;
    border: 2px solid var(--rojo);
    border-radius: var(--radio);
    padding: 0.9rem 1.2rem;
    margin-bottom: 1.3rem;
    animation: parpadeoAlerta 2s ease-in-out infinite;
}
.banner-alerta-icono {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--rojo);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
.banner-alerta-texto { flex: 1; font-size: 0.94rem; color: #7A241A; }
.banner-alerta-texto strong { color: var(--rojo); }
.banner-alerta .btn { flex-shrink: 0; }
@keyframes parpadeoAlerta {
    0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,0.25); }
    50% { box-shadow: 0 0 0 6px rgba(192,57,43,0); }
}
.card {
    background: var(--blanco);
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio);
    padding: 1.1rem 1.3rem;
}
.card .label { font-size: 0.8rem; color: var(--texto-suave); text-transform: uppercase; letter-spacing: 0.03em; }
.card .value { font-size: 1.6rem; font-weight: 700; color: var(--azul-oscuro); margin-top: 0.3rem; }
.card.alerta .value { color: var(--rojo); }

/* Tablas */
table { width: 100%; border-collapse: collapse; background: var(--blanco); border-radius: var(--radio); overflow: hidden; }
thead th {
    background: var(--azul-oscuro);
    color: var(--blanco);
    text-align: left;
    padding: 0.65rem 0.8rem;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
tbody td { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--gris-borde); font-size: 0.92rem; }
tbody tr:hover { background: #F0F5F9; }
.table-wrap { border: 1px solid var(--gris-borde); border-radius: var(--radio); overflow-x: auto; }

.stock-bajo { color: var(--rojo); font-weight: 700; }

.btn-link-rojo {
    background: none;
    border: none;
    padding: 0;
    color: var(--rojo);
    text-decoration: none;
    font-size: inherit;
    cursor: pointer;
    font-family: inherit;
}
.btn-link-rojo:hover { text-decoration: underline; }

/* Formularios generales */
.panel { background: var(--blanco); border: 1px solid var(--gris-borde); border-radius: var(--radio); padding: 1.3rem; margin-bottom: 1.3rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.9rem; }
.form-grid label { display: block; font-size: 0.82rem; color: var(--texto-suave); margin-bottom: 0.25rem; }
.form-grid input, .form-grid select, .form-grid textarea {
    width: 100%;
    padding: 0.6rem 0.65rem;
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio);
    font-size: 1rem;
}

.btn {
    display: inline-block;
    background: var(--azul-oscuro);
    color: var(--blanco);
    border: none;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radio);
    font-size: 0.92rem;
    cursor: pointer;
}
.btn:hover { background: var(--azul); text-decoration: none; color: var(--blanco); }
.btn-verde { background: var(--verde); }
.btn-rojo { background: var(--rojo); }
.btn-secundario { background: var(--blanco); color: var(--azul-oscuro); border: 1px solid var(--gris-borde); }

.pagehead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.6rem; }
.pagehead h1 { font-size: 1.3rem; color: var(--azul-oscuro); margin: 0; }

.subnav { display: flex; gap: 1.2rem; border-bottom: 1px solid var(--gris-borde); margin-bottom: 1.2rem; }
.subnav a { padding: 0.5rem 0.1rem; font-size: 0.92rem; color: var(--texto-suave); border-bottom: 2px solid transparent; }
.subnav a.activo, .subnav a:hover { color: var(--azul-oscuro); border-bottom-color: var(--azul-oscuro); text-decoration: none; }

.hint { font-size: 0.88rem; color: var(--texto-suave); background: #F0F5F9; border: 1px solid var(--gris-borde); border-radius: var(--radio); padding: 0.6rem 0.9rem; margin-bottom: 1rem; }

.autocomplete-lista {
    display: none;
    position: absolute;
    z-index: 20;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--blanco);
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    max-height: 220px;
    overflow-y: auto;
    margin-top: 2px;
}
.autocomplete-item { padding: 0.5rem 0.7rem; font-size: 0.88rem; cursor: pointer; border-bottom: 1px solid var(--gris-borde); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #F0F5F9; }
.autocomplete-item.activo { background: #DCE9F3; }

.alert { padding: 0.7rem 1rem; border-radius: var(--radio); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-ok { background: #E3F4EC; color: #1E6B4C; border: 1px solid #B9E3CB; }
.alert-error { background: #FBEAE8; color: #A6362A; border: 1px solid #F1C3BD; }

.footer { text-align: center; color: var(--texto-suave); font-size: 0.8rem; padding: 1.5rem; }

/* ===== Responsive: tablets ===== */
@media (max-width: 900px) {
    .content { padding: 1.2rem; }
}

/* ===== Responsive: celulares y tablets chicas ===== */
@media (max-width: 720px) {
    .topbar { flex-direction: column; align-items: flex-start; padding: 0.75rem 1rem; }
    .mainnav { gap: 0.6rem 1rem; }
    .userbox { width: 100%; justify-content: space-between; }

    .content { padding: 1rem; }

    /* Fuerza una sola columna en TODOS los formularios, incluso los que
       traen un grid-template-columns fijo puesto en línea (inline style) */
    .form-grid { grid-template-columns: 1fr !important; }

    .pagehead { align-items: flex-start; }
    .pagehead > div { display: flex; flex-wrap: wrap; gap: 0.5rem; width: 100%; }
    .pagehead .btn, .pagehead a.btn { flex: 1 1 auto; text-align: center; }

    .banner-alerta { flex-wrap: wrap; }
    .banner-alerta .btn { width: 100%; text-align: center; }

    .btn { padding: 0.65rem 1.1rem; }

    table { font-size: 0.85rem; }
    thead th, tbody td { padding: 0.5rem 0.6rem; }
}

/* ===== Responsive: celulares chicos ===== */
@media (max-width: 420px) {
    .login-box { margin: 5vh auto; width: calc(100% - 2rem); padding: 1.5rem; }
    .card .value { font-size: 1.3rem; }
    .pagehead h1 { font-size: 1.15rem; }
}
