:root {
    --ink: #101828;
    --muted: #667085;
    --line: #e4e7ec;
    --bg: #f4f7fb;
    --card: #fff;
    --accent: #175cd3;
    --ok: #067647;
    --warn: #b54708;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, Segoe UI, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

body {
    padding-bottom: 82px;
}


/* ================================================================
   LOGIN
   ================================================================ */

.login-body {
    padding: 0;
    background: linear-gradient(145deg, #0b1220, #1d2939);
    min-height: 100vh;
}

.login-shell {
    max-width: 460px;
    margin: auto;
    padding: 48px 22px 30px;
}

.brand {
    display: flex;
    gap: 14px;
    align-items: center;
    color: white;
    margin-bottom: 38px;
}

.brand-mark {
    width: 54px;
    height: 54px;
    border: 1px solid #98a2b3;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 23px;
    font-weight: 800;
}

.brand span,
.tiny {
    font-size: 11px;
    letter-spacing: .14em;
}

.brand h1 {
    font-size: 25px;
    margin: 2px 0;
}

.login-card {
    background: white;
    border-radius: 28px;
    padding: 28px;
    box-shadow: 0 25px 60px #0005;
}

.eyebrow {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .14em;
    color: var(--accent);
}

.login-card h2 {
    font-size: 30px;
    margin: 8px 0 4px;
}

.login-card p {
    color: var(--muted);
    margin: 0 0 24px;
}

.login-card label,
.action-form label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    margin: 16px 0 7px;
}

.input {
    width: 100%;
    min-height: 52px;
    border: 1px solid #d0d5dd;
    border-radius: 14px;
    padding: 0 15px;
    font-size: 16px;
    background: #fff;
    outline: none;
}

    .input:focus {
        border-color: #84adff;
        box-shadow: 0 0 0 4px #d1e0ff;
    }

.btn {
    display: flex;
    width: 100%;
    min-height: 54px;
    border: 0;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    letter-spacing: .03em;
    text-decoration: none;
    cursor: pointer;
    margin-top: 12px;
    font-size: 14px;
}

.primary {
    background: var(--ink);
    color: white;
}

.secondary {
    background: #fff;
    color: var(--ink);
    border: 1px solid #d0d5dd;
}

.busy {
    opacity: .65;
    pointer-events: none;
}

.secure-note,
.footer-note {
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    margin-top: 18px;
}

.footer-note {
    color: #98a2b3;
}


/* ================================================================
   CABECERA
   ================================================================ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #101828;
    color: white;
    padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 18px #10182822;
}

    .topbar strong {
        display: block;
        font-size: 18px;
        margin-top: 3px;
    }

.logout {
    font-size: 11px;
    color: #d0d5dd;
    text-decoration: none;
    font-weight: 800;
}


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

.app-shell {
    max-width: 760px;
    margin: auto;
    padding: 20px 16px;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    padding: 8px 3px 18px;
}

    .hero > div:first-child {
        min-width: 0;
    }

    .hero h1 {
        font-size: 30px;
        margin: 5px 0;
    }

    .hero p {
        color: var(--muted);
        margin: 0;
        max-width: 400px;
    }

.count {
    min-width: 74px;
    width: 74px;
    height: 74px;
    border-radius: 22px;
    background: #eaf2ff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #1849a9;
    font-size: 26px;
    font-weight: 900;
    flex: 0 0 auto;
}

    .count small {
        font-size: 8px;
        letter-spacing: .1em;
    }


/* ================================================================
   INSTALACIÓN PWA
   ================================================================ */

.install-card {
    width: 100%;
    border: 1px solid #b2ccff;
    background: #eff4ff;
    border-radius: 18px;
    padding: 14px 16px;
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    color: #1849a9;
    font-family: inherit;
}

button.install-card {
    cursor: pointer;
}

.install-icon {
    flex: 0 0 auto !important;
    width: 34px;
    height: 34px;
    display: grid !important;
    place-items: center;
    border-radius: 10px;
    background: #fff;
}

.install-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.install-card small {
    font-weight: 500;
    color: #475467;
    margin-top: 3px;
    line-height: 1.35;
}

.install-card b {
    font-size: 26px;
}


/* ================================================================
   TARJETA DESPACHO
   ================================================================ */

.dispatch-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: 0 8px 24px #1018280a;
}

.card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

    .card-head > div {
        min-width: 0;
    }

.dispatch-id {
    display: block;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .1em;
    color: var(--muted);
    margin-bottom: 5px;
}

.card-head strong {
    font-size: 18px;
    text-transform: uppercase;
}

.badge {
    height: 28px;
    white-space: nowrap;
    border-radius: 999px;
    padding: 7px 9px;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .06em;
    background: #f2f4f7;
    flex: 0 0 auto;
}

.s-asignado {
    background: #fff6ed;
    color: #b54708;
}

.s-retirado-oficina {
    background: #eff8ff;
    color: #175cd3;
}

.s-entregado-destinatario {
    background: #ecfdf3;
    color: #067647;
}

.s-recuperado-junior {
    background: #f4f3ff;
    color: #5925dc;
}


/* ================================================================
   DESTINO
   ================================================================ */

.address {
    display: flex;
    gap: 10px;
    margin: 17px 0;
    background: #f9fafb;
    border-radius: 14px;
    padding: 13px;
}

.address-icon {
    flex: 0 0 auto;
}

.address > div {
    min-width: 0;
}

.address strong,
.address small {
    display: block;
}

.address strong {
    overflow-wrap: anywhere;
}

.address small {
    color: var(--muted);
    margin-top: 4px;
    line-height: 1.35;
}


/* ================================================================
   RESUMEN DEL PAQUETE
   ================================================================ */

.document-summary {
    margin: 15px 0 10px;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
}

.document-count {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
}

.document-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: #eff4ff;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    font-size: 20px;
}

.document-count > div {
    min-width: 0;
}

.document-count strong {
    display: block;
    font-size: 14px;
    letter-spacing: .03em;
}

.document-count small {
    display: block;
    color: var(--muted);
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .08em;
    margin-top: 4px;
    line-height: 1.35;
}

.documents-toggle {
    width: 100%;
    border: 0;
    border-top: 1px solid var(--line);
    background: #f9fafb;
    min-height: 43px;
    padding: 0 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--accent);
    font-family: inherit;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .06em;
    cursor: pointer;
}

    .documents-toggle:active {
        background: #f2f4f7;
    }

    .documents-toggle span {
        font-size: 14px;
    }


/* ================================================================
   LISTADO DE DOCUMENTOS / OT
   ================================================================ */

.documents-panel {
    background: #f9fafb;
    border: 1px solid var(--line);
    border-radius: 16px;
    margin-bottom: 12px;
    overflow: hidden;
}

    .documents-panel[hidden] {
        display: none;
    }

.documents-panel-title {
    min-height: 43px;
    padding: 0 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

    .documents-panel-title span {
        font-size: 9px;
        font-weight: 900;
        letter-spacing: .08em;
        color: var(--muted);
    }

    .documents-panel-title strong {
        min-width: 28px;
        height: 28px;
        padding: 0 7px;
        border-radius: 9px;
        background: #fff;
        display: grid;
        place-items: center;
        color: var(--accent);
        font-size: 12px;
    }

.ot-list {
    max-height: 270px;
    overflow-y: auto;
    padding: 7px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.ot-item {
    min-height: 42px;
    padding: 9px 10px;
    background: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 5px;
}

    .ot-item:last-child {
        margin-bottom: 0;
    }

.ot-check {
    width: 23px;
    height: 23px;
    border-radius: 50%;
    background: #ecfdf3;
    color: var(--ok);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    font-size: 11px;
}

.ot-empty {
    padding: 15px;
    color: var(--muted);
    text-align: center;
    font-size: 11px;
    font-weight: 700;
}


/* ================================================================
   HORARIOS
   ================================================================ */

.facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

    .facts div {
        padding: 10px;
        background: #f9fafb;
        border-radius: 12px;
        min-width: 0;
    }

    .facts small {
        display: block;
        font-size: 9px;
        color: var(--muted);
        font-weight: 800;
    }

    .facts strong {
        display: block;
        margin-top: 4px;
        font-size: 12px;
        overflow-wrap: anywhere;
    }


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

.action-form {
    border-top: 1px solid var(--line);
    margin-top: 14px;
    padding-top: 2px;
}

.actions {
    margin-top: 4px;
}


/* ================================================================
   MENSAJES
   ================================================================ */

.alert {
    padding: 13px 15px;
    border-radius: 14px;
    margin-bottom: 15px;
    background: #eff8ff;
    color: #175cd3;
    font-weight: 700;
    font-size: 13px;
}

    .alert.success {
        background: #ecfdf3;
        color: #067647;
    }

    .alert.error {
        background: #fef3f2;
        color: #b42318;
    }


/* ================================================================
   SIN DESPACHOS
   ================================================================ */

.empty {
    text-align: center;
    background: white;
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 42px 20px;
}

    .empty div {
        font-size: 35px;
    }

    .empty h2 {
        margin-bottom: 5px;
    }

    .empty p {
        color: var(--muted);
    }


/* ================================================================
   NAVEGACIÓN INFERIOR
   ================================================================ */

.bottom {
    position: fixed;
    z-index: 30;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(68px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: #fff;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: center;
    gap: 70px;
}

    .bottom a,
    .bottom button {
        border: 0;
        background: none;
        text-decoration: none;
        color: #667085;
        font-family: inherit;
        font-size: 22px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .bottom span {
        font-size: 9px;
        font-weight: 800;
        margin-top: 3px;
    }

    .bottom .active {
        color: #175cd3;
    }


/* ================================================================
   MODAL DE CONFIRMACIÓN
   ================================================================ */

body.modal-open {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(16, 24, 40, .68);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
    opacity: 0;
    transition: opacity .18s ease;
}

    .modal-overlay[hidden] {
        display: none;
    }

    .modal-overlay.visible {
        opacity: 1;
    }

.modal-card {
    position: relative;
    width: 100%;
    max-width: 470px;
    background: #fff;
    border-radius: 26px;
    padding: 27px 20px 18px;
    box-shadow: 0 24px 70px rgba(16, 24, 40, .35);
    transform: translateY(25px) scale(.98);
    transition: transform .18s ease;
}

.modal-overlay.visible .modal-card {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    right: 15px;
    top: 14px;
    width: 35px;
    height: 35px;
    border: 0;
    border-radius: 50%;
    background: #f2f4f7;
    color: #475467;
    display: grid;
    place-items: center;
    font-family: inherit;
    font-size: 23px;
    line-height: 1;
    cursor: pointer;
}

.modal-icon {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    margin-bottom: 16px;
    background: #eff4ff;
    font-size: 26px;
}

.modal-eyebrow {
    display: block;
    color: var(--accent);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .12em;
    margin-bottom: 6px;
}

.modal-card h2 {
    margin: 0;
    padding-right: 28px;
    font-size: 22px;
    line-height: 1.15;
    color: var(--ink);
}

.modal-client {
    margin: 8px 0 15px;
    color: #344054;
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
}

.modal-summary {
    padding: 13px 14px;
    border-radius: 14px;
    background: #f9fafb;
    border: 1px solid #eaecf0;
    margin-bottom: 14px;
}

    .modal-summary strong {
        display: block;
        color: var(--ink);
        font-size: 13px;
    }

    .modal-summary small {
        display: block;
        margin-top: 5px;
        color: var(--muted);
        font-size: 10px;
        line-height: 1.45;
    }

.modal-description {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
    margin: 0 0 18px;
}

.modal-confirm {
    width: 100%;
    min-height: 55px;
    border: 0;
    border-radius: 15px;
    padding: 10px 14px;
    background: var(--ink);
    color: #fff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .035em;
    cursor: pointer;
}

    .modal-confirm:active {
        transform: scale(.99);
    }

    .modal-confirm.busy {
        opacity: .65;
        pointer-events: none;
    }

.modal-cancel {
    width: 100%;
    min-height: 45px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 11px;
    font-weight: 900;
    margin-top: 5px;
    cursor: pointer;
}


/* ================================================================
   TOAST
   ================================================================ */

.toast {
    position: fixed;
    z-index: 1200;
    left: 50%;
    top: calc( 14px + env(safe-area-inset-top) );
    transform: translateX(-50%);
    width: calc( 100% - 28px );
    max-width: 440px;
    padding: 13px 15px;
    border-radius: 15px;
    background: var(--ink);
    color: #fff;
    box-shadow: 0 15px 40px rgba(16, 24, 40, .25);
    display: flex;
    align-items: center;
    gap: 11px;
}

    .toast[hidden] {
        display: none;
    }

    .toast > span {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: #ecfdf3;
        color: var(--ok);
        display: grid;
        place-items: center;
        flex: 0 0 auto;
        font-weight: 900;
    }

    .toast strong,
    .toast small {
        display: block;
    }

    .toast strong {
        font-size: 12px;
    }

    .toast small {
        margin-top: 2px;
        color: #d0d5dd;
        font-size: 10px;
    }


/* ================================================================
   MÓVIL
   ================================================================ */

@media (max-width: 480px) {

    .app-shell {
        padding: 16px 14px;
    }

    .hero {
        align-items: center;
    }

        .hero h1 {
            font-size: 27px;
        }

        .hero p {
            font-size: 13px;
        }

    .count {
        min-width: 66px;
        width: 66px;
        height: 66px;
    }

    .dispatch-card {
        padding: 17px;
    }

    .card-head {
        align-items: flex-start;
    }

        .card-head strong {
            font-size: 16px;
        }

    .facts {
        grid-template-columns: 1fr 1fr;
    }

    .modal-card {
        border-radius: 24px;
    }
}


/* ================================================================
   TABLET / ESCRITORIO
   ================================================================ */

@media (min-width: 600px) {

    .modal-overlay {
        align-items: center;
    }
}


/* ================================================================
   RECUPERACIÓN PARCIAL
   ================================================================ */
.server-action-hidden { display:none !important; }
.ot-name { flex:1; }
.ot-status { font-size:9px; font-weight:900; letter-spacing:.04em; }
.ot-status.recovered { color:var(--ok); }
.ot-status.pending { color:var(--warn); }
.ot-status.no-return { color:var(--muted); }
.ot-item.recovered { background:#f6fef9; }
.modal-partial { width:100%; min-height:50px; border:1px solid #d0d5dd; border-radius:15px; background:#fff; color:var(--ink); font-family:inherit; font-size:11px; font-weight:900; margin-top:8px; cursor:pointer; }
.modal-partial[hidden] { display:none; }
.recovery-list { max-height:300px; overflow-y:auto; margin:12px 0; }
.recovery-item { position:relative; min-height:54px; padding:10px 12px; margin-bottom:7px; border:1px solid var(--line); border-radius:13px; display:flex; align-items:center; gap:11px; cursor:pointer; }
.recovery-item input { position:absolute; opacity:0; pointer-events:none; }
.recovery-check { width:27px; height:27px; border:2px solid #98a2b3; border-radius:8px; display:grid; place-items:center; flex:0 0 auto; }
.recovery-item input:checked + .recovery-check { background:var(--ok); border-color:var(--ok); }
.recovery-item input:checked + .recovery-check:after { content:'✓'; color:#fff; font-size:15px; font-weight:900; }
.recovery-item strong { font-size:12px; }
.recovery-counter { margin:10px 0 14px; text-align:center; color:var(--muted); font-size:10px; font-weight:900; letter-spacing:.06em; }
.modal-confirm:disabled { opacity:.45; cursor:not-allowed; }

/* ================================================================
   V8 · FLUJO DOCUMENTAL HOMOLOGADO CON OFICINA
   ================================================================ */
.workflow-zone{margin-top:14px;padding:15px;border:1px solid var(--line);border-radius:16px;background:#fbfcfe}
.workflow-zone-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:12px}
.workflow-zone-head strong{display:block;font-size:12px;letter-spacing:.04em}
.workflow-zone-head small{display:block;color:var(--muted);line-height:1.35;margin-top:4px}
.workflow-count{min-width:32px;height:32px;border-radius:10px;background:#eef4ff;display:grid;place-items:center;font-weight:800;color:var(--accent)}
.pickup-zone{background:#f8faff}.delivery-zone{background:#f8fbff}.recovery-zone{background:#f7fcfa}.return-zone{background:#fffaf3}.failed-zone{background:#fff7f6;border-color:#fecdca}.waiting-zone{background:#f9fafb}
.document-checks{width:100%;border-collapse:separate;border-spacing:0 7px;margin:4px 0 10px}
.document-checks td{display:block}
.document-checks label{display:flex;align-items:center;gap:10px;padding:12px 13px;background:white;border:1px solid var(--line);border-radius:12px;font-weight:750}
.document-checks input{width:20px;height:20px;accent-color:var(--accent);flex:0 0 auto}
.workflow-fields{display:grid;gap:8px;margin:10px 0}.workflow-fields label{font-size:11px;font-weight:800;color:var(--muted);letter-spacing:.04em}
.form-control{width:100%;border:1px solid #d0d5dd;border-radius:11px;padding:12px 13px;font:inherit;background:#fff;color:var(--ink);outline:none}.form-control:focus{border-color:#84adff;box-shadow:0 0 0 3px rgba(23,92,211,.09)}
.workflow-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:10px}.btn-main,.btn-secondary{border:0;border-radius:11px;padding:12px 13px;font-weight:850;font-size:11px;text-align:center;text-decoration:none;cursor:pointer}.btn-main{background:var(--accent);color:#fff}.btn-secondary{background:#eef2f6;color:#344054}.btn-main.full{display:block;width:100%;margin-top:8px}.btn-main.busy{opacity:.65;pointer-events:none}
.workflow-note{padding:11px 12px;border-radius:11px;background:#fff;border:1px solid #fecdca;margin:8px 0;display:grid;gap:3px}.workflow-note strong{font-size:10px;color:var(--danger);letter-spacing:.05em}.workflow-note span{font-size:12px}
.document-status-row{display:flex;justify-content:space-between;gap:10px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line)}.document-status-row:last-child{border-bottom:0}.document-status-row>strong{font-size:12px}.doc-state{font-size:9px;font-weight:900;text-align:right;letter-spacing:.03em;color:#475467}.s-retirado-oficina{color:#175cd3}.s-entregado-destinatario{color:#067647}.s-recuperado-junior{color:#b54708}.s-devuelto-oficina{color:#6941c6}.s-recibido-oficina{color:#067647}
.modal-overlay{position:fixed;inset:0;background:rgba(16,24,40,.58);backdrop-filter:blur(4px);display:grid;place-items:center;padding:18px;z-index:9999;opacity:0;transition:opacity .18s ease}.modal-overlay.visible{opacity:1}.modal-card{width:min(100%,420px);background:#fff;border-radius:22px;padding:22px;box-shadow:0 24px 70px rgba(16,24,40,.28);transform:translateY(8px) scale(.985);transition:transform .18s ease}.modal-overlay.visible .modal-card{transform:none}.modal-icon{width:46px;height:46px;border-radius:14px;background:#eef4ff;color:var(--accent);display:grid;place-items:center;font-size:20px;font-weight:900}.modal-eyebrow{display:block;margin-top:14px;color:var(--muted);font-size:10px;font-weight:900;letter-spacing:.08em}.modal-card h2{margin:5px 0 8px;font-size:20px}.modal-card p{margin:0;color:var(--muted);line-height:1.45}.modal-actions{display:grid;grid-template-columns:1fr 1.25fr;gap:8px;margin-top:18px}body.modal-open{overflow:hidden}
.empty{padding:36px 18px;text-align:center;background:#fff;border:1px solid var(--line);border-radius:18px;display:grid;gap:6px}.empty>span{font-size:30px;color:var(--ok)}.empty small{color:var(--muted)}
@media(max-width:520px){.workflow-actions{grid-template-columns:1fr}.modal-actions{grid-template-columns:1fr}.document-status-row{align-items:flex-start;flex-direction:column}.doc-state{text-align:left}}
