* {
    box-sizing: border-box;
}

:root {
    --azul-oscuro: #132c3d;
    --azul-medio: #1f4d6b;
    --azul-claro: #edf4f8;
    --borde: #d8e2e8;
    --texto: #17202a;
    --texto-suave: #5f7483;
    --verde: #1f7a3a;
    --ambar: #ad6b06;
    --rojo: #a12626;
    --blanco: #ffffff;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(180deg, #f3f6f8 0%, #eef3f6 100%);
    color: var(--texto);
}

.topbar {
    background: linear-gradient(135deg, var(--azul-oscuro) 0%, #0f2537 45%, var(--azul-medio) 100%);
    color: white;
    padding: 16px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-logo-box {
    background: white;
    border-radius: 18px;
    padding: 8px 10px;
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand img {
    height: 58px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
    display: block;
}

.brand strong {
    display: block;
    font-size: 20px;
    letter-spacing: .2px;
}

.brand span {
    display: block;
    font-size: 13px;
    opacity: .9;
    margin-top: 3px;
}

.topbar nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.topbar a {
    color: white;
    text-decoration: none;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.16);
    padding: 10px 13px;
    border-radius: 10px;
    transition: .2s ease;
}

.topbar a:hover {
    background: rgba(255,255,255,.2);
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 18px 30px;
}

.card {
    background: var(--blanco);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 8px 26px rgba(12, 35, 52, .08);
    border: 1px solid rgba(19,44,61,.05);
}

.card h1, .card h2, .card h3 {
    margin-top: 0;
    color: var(--azul-oscuro);
}

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

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

label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
    color: var(--azul-oscuro);
}

input, select, textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--borde);
    border-radius: 10px;
    font-size: 15px;
    background: white;
    color: var(--texto);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #7fa6bd;
    box-shadow: 0 0 0 3px rgba(31,77,107,.10);
}

textarea {
    min-height: 88px;
}

button, .btn {
    display: inline-block;
    background: var(--azul-medio);
    color: white;
    border: none;
    padding: 11px 15px;
    border-radius: 10px;
    text-decoration: none;
    cursor: pointer;
    font-weight: bold;
    font-size: 15px;
    transition: .2s ease;
}

button:hover, .btn:hover {
    filter: brightness(1.04);
}

.btn.secondary {
    background: #607d8b;
}

.btn.success {
    background: var(--verde);
}

.btn.warning {
    background: var(--ambar);
}

.btn.danger {
    background: var(--rojo);
}

.btn.light {
    background: #eef3f6;
    color: var(--texto);
    border: 1px solid #dde7ec;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    overflow: hidden;
    border-radius: 14px;
}

th, td {
    padding: 11px 10px;
    border-bottom: 1px solid #e6edf1;
    text-align: left;
    vertical-align: top;
}

th {
    background: #eef3f6;
    color: var(--azul-oscuro);
}

.badge {
    display: inline-block;
    padding: 6px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: bold;
}

.estado-pendiente { background: #eceff1; color: #37474f; }
.estado-en_ruta { background: #e3f2fd; color: #0d47a1; }
.estado-entregado { background: #e8f5e9; color: #1b5e20; }
.estado-incidencia { background: #ffebee; color: #b71c1c; }
.estado-en_reparto { background: #e3f2fd; color: #0d47a1; }
.estado-finalizada { background: #e8f5e9; color: #1b5e20; }

.alert {
    padding: 13px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
    font-weight: 600;
}

.alert.ok {
    background: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #cde7d2;
}

.alert.error {
    background: #ffebee;
    color: #b71c1c;
    border: 1px solid #f2c8cc;
}

.reparto-card {
    border-left: 6px solid var(--azul-medio);
}

.reparto-card h2 {
    margin-top: 0;
}

.big-actions .btn, .big-actions button {
    width: 100%;
    text-align: center;
    margin-bottom: 8px;
    padding: 15px;
    font-size: 17px;
}

.kpi {
    background: #fff;
    padding: 16px;
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(12,35,52,.07);
    border: 1px solid rgba(19,44,61,.05);
}

.kpi strong {
    display: block;
    font-size: 24px;
    margin-top: 5px;
    color: var(--azul-oscuro);
}

.small {
    font-size: 13px;
    color: var(--texto-suave);
}

pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: #f8fbfc;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #e6edf1;
}

@media (max-width: 760px) {
    .grid, .grid-3 {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 14px 12px 24px;
    }

    .topbar {
        align-items: flex-start;
        padding: 14px;
    }

    .brand {
        align-items: flex-start;
    }

    .brand img {
        height: 52px;
        max-width: 130px;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead {
        display: none;
    }

    tr {
        margin-bottom: 12px;
        border: 1px solid #e5e9ec;
        border-radius: 12px;
        overflow: hidden;
        background: white;
    }

    td {
        border-bottom: 1px solid #eef3f6;
    }

    td::before {
        content: attr(data-label);
        display: block;
        font-weight: bold;
        color: var(--texto-suave);
        margin-bottom: 4px;
    }
}
