/**
 * aps.css - PWA conductor / guias asignadas
 * @version 2.1.2
 */
:root {
    --aps-ink: #111827;
    --aps-muted: #64748b;
    --aps-soft: #eef2f7;
    --aps-line: #d7dee8;
    --aps-panel: #ffffff;
    --aps-primary: #0f766e;
    --aps-primary-dark: #0f3f3b;
    --aps-blue: #2563eb;
    --aps-green: #15803d;
    --aps-amber: #b45309;
    --aps-red: #b91c1c;
    --aps-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
    --aps-header: #0d47a1;
    --aps-header-2: #1565c0;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: #e8edf3;
    color: var(--aps-ink);
    font-family: Inter, Roboto, Arial, sans-serif;
}

body {
    overflow-x: hidden;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.aps-shell {
    min-height: 100vh;
    padding: env(safe-area-inset-top) 14px calc(22px + env(safe-area-inset-bottom));
    background:
        linear-gradient(160deg, var(--aps-header) 0, var(--aps-header-2) 54%, #0f766e 190px, transparent 191px),
        #e8edf3;
}

.aps-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    color: #fff;
    padding-top: 4px;
}

.aps-driver {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.aps-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.aps-driver-copy {
    min-width: 0;
}

.aps-driver-copy strong,
.aps-driver-copy span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aps-driver-copy strong {
    font-size: 15px;
}

.aps-driver-copy span {
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
}

.aps-icon-btn,
.aps-refresh {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    color: inherit;
    background: rgba(255, 255, 255, 0.12);
    text-decoration: none;
    cursor: pointer;
}

.aps-hero {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    color: #fff;
    padding: 14px 2px 18px;
}

.aps-kicker {
    margin: 0 0 5px;
    color: #bfdbfe;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.aps-hero h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.05;
    font-weight: 800;
}

.aps-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.aps-quick-actions button {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: #fff;
    background: linear-gradient(135deg, #0f766e, #2563eb);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    font-size: 14px;
    font-weight: 900;
}

.aps-status-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.aps-stat {
    min-height: 76px;
    padding: 10px;
    border-radius: 8px;
    background: var(--aps-panel);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.aps-stat span {
    display: block;
    color: var(--aps-muted);
    font-size: 11px;
    font-weight: 700;
}

.aps-stat strong {
    display: block;
    margin-top: 8px;
    color: var(--aps-ink);
    font-size: 23px;
    line-height: 1;
}

.aps-stat-pending strong {
    color: var(--aps-amber);
}

.aps-stat-ok strong {
    color: var(--aps-green);
}

.aps-stat-m3 strong {
    color: var(--aps-blue);
    font-size: 20px;
}

.aps-gps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 48px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--aps-line);
}

.aps-gps div {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
}

.aps-gps small {
    color: var(--aps-muted);
    white-space: nowrap;
    font-size: 11px;
}

.aps-gps.ok i,
.aps-gps.ok span {
    color: var(--aps-green);
}

.aps-gps.warn i,
.aps-gps.warn span {
    color: var(--aps-amber);
}

.aps-gps.error i,
.aps-gps.error span {
    color: var(--aps-red);
}

.aps-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 12px;
}

.aps-tabs button {
    min-height: 38px;
    border: 1px solid var(--aps-line);
    border-radius: 8px;
    background: #fff;
    color: var(--aps-muted);
    font-size: 12px;
    font-weight: 800;
}

.aps-tabs button.active {
    border-color: var(--aps-primary);
    background: var(--aps-primary);
    color: #fff;
}

.aps-list {
    display: grid;
    gap: 10px;
}

.aps-loading,
.aps-empty,
.aps-error {
    min-height: 170px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    gap: 10px;
    padding: 20px;
    text-align: center;
    background: #fff;
    color: var(--aps-muted);
    border: 1px solid var(--aps-line);
}

.aps-loading i,
.aps-empty i,
.aps-error i {
    font-size: 28px;
}

.aps-guide {
    border: 1px solid var(--aps-line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.aps-guide.is-busy {
    opacity: 0.82;
}

.aps-guide-main {
    padding: 13px;
}

.aps-guide-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.aps-guide-num {
    min-width: 0;
}

.aps-guide-num strong {
    display: block;
    font-size: 18px;
}

.aps-guide-num span {
    display: block;
    margin-top: 2px;
    color: var(--aps-muted);
    font-size: 12px;
}

.aps-badge {
    align-self: flex-start;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 900;
    color: #fff;
    white-space: nowrap;
}

.aps-badge.PENDIENTE {
    background: var(--aps-amber);
}

.aps-badge.ACEPTADA {
    background: var(--aps-green);
}

.aps-badge.COMPLETADA {
    background: var(--aps-green);
}

.aps-badge.ANULADA {
    background: var(--aps-red);
}

.aps-guide-client {
    margin-top: 11px;
    font-size: 14px;
    font-weight: 800;
}

.aps-guide-address,
.aps-guide-product,
.aps-guide-sunat {
    margin-top: 6px;
    color: var(--aps-muted);
    font-size: 13px;
    line-height: 1.35;
}

.aps-guide-address {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.aps-guide-address span {
    min-width: 0;
}

.aps-route-chip {
    width: 34px;
    height: 30px;
    flex: 0 0 34px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: var(--aps-blue);
}

.aps-route-chip:disabled {
    color: #94a3b8;
    background: #e2e8f0;
}

.aps-guide-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin-top: 12px;
}

.aps-guide-meta div {
    padding: 8px;
    border-radius: 8px;
    background: var(--aps-soft);
    min-width: 0;
}

.aps-guide-meta span {
    display: block;
    color: var(--aps-muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.aps-guide-meta strong {
    display: block;
    overflow: hidden;
    margin-top: 4px;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aps-guide-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    border-top: 1px solid var(--aps-line);
}

.aps-guide-actions a,
.aps-guide-actions button {
    min-height: 42px;
    border: 0;
    border-right: 1px solid var(--aps-line);
    background: #fff;
    color: var(--aps-primary-dark);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.aps-guide-actions button:disabled {
    color: #94a3b8;
    background: #f1f5f9;
}

.aps-guide.is-busy .aps-guide-actions a[aria-disabled="true"] {
    pointer-events: none;
    color: #94a3b8;
    background: #f1f5f9;
}

.aps-guide-actions a:last-child,
.aps-guide-actions button:last-child {
    border-right: 0;
}

.aps-sheet {
    position: fixed;
    inset: 0;
    z-index: 1000;
    pointer-events: none;
}

.aps-sheet.open {
    pointer-events: auto;
}

.aps-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    opacity: 0;
    transition: opacity 180ms ease;
}

.aps-sheet.open .aps-sheet-backdrop {
    opacity: 1;
}

.aps-sheet-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    max-height: 86vh;
    overflow: auto;
    transform: translateY(100%);
    transition: transform 220ms ease;
    border-radius: 16px 16px 0 0;
    background: #fff;
    box-shadow: var(--aps-shadow);
}

.aps-sheet.open .aps-sheet-panel {
    transform: translateY(0);
}

.aps-sheet-handle {
    width: 42px;
    height: 5px;
    margin: 10px auto 6px;
    border-radius: 99px;
    background: #cbd5e1;
}

.aps-sheet-panel header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 12px;
    border-bottom: 1px solid var(--aps-line);
}

.aps-sheet-panel h2 {
    margin: 0;
    font-size: 18px;
}

.aps-sheet-panel .aps-icon-btn {
    color: var(--aps-muted);
    background: var(--aps-soft);
}

.aps-sheet-content {
    padding: 16px;
}

.aps-detail-row {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--aps-line);
    font-size: 14px;
}

.aps-detail-row span {
    color: var(--aps-muted);
    font-weight: 800;
}

.aps-detail-row strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.aps-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    background: rgba(15, 23, 42, 0.72);
}

.aps-modal.open {
    display: block;
}

.aps-modal-panel {
    min-height: 100vh;
    max-height: 100vh;
    overflow: auto;
    background: #fff;
}

.aps-modal-panel > header {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
    color: #fff;
    background: linear-gradient(135deg, var(--aps-header), var(--aps-primary));
}

.aps-modal-panel header small,
.aps-modal-panel header h2 {
    display: block;
    margin: 0;
}

.aps-modal-panel header small {
    color: #bfdbfe;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.aps-modal-panel header h2 {
    margin-top: 2px;
    font-size: 20px;
}

.aps-submit {
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    background: var(--aps-primary);
    text-decoration: none;
    font-weight: 900;
}

.aps-scan-tip {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.35;
}

.aps-scan-tip i {
    margin-top: 2px;
    color: var(--aps-blue);
}

.aps-incident-form {
    display: grid;
    gap: 13px;
    padding: 14px;
}

.aps-incident-form label {
    display: grid;
    gap: 6px;
    margin: 0;
    color: var(--aps-ink);
    font-size: 13px;
    font-weight: 900;
}

.aps-incident-form select,
.aps-incident-form textarea,
.aps-incident-form input[type="text"],
.aps-incident-form input[type="file"] {
    width: 100%;
    border: 1px solid var(--aps-line);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
    color: var(--aps-ink);
    font: inherit;
    font-weight: 600;
}

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

.aps-preview-grid figure {
    position: relative;
    margin: 0;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
    background: #e2e8f0;
}

.aps-preview-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aps-preview-grid figcaption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 4px 6px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    text-align: center;
}

.aps-preview-grid button {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: rgba(185, 28, 28, 0.92);
}

.aps-scan-preview {
    min-height: 110px;
    border: 1px dashed var(--aps-line);
    border-radius: 8px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #f8fafc;
}

.aps-scan-preview:empty {
    display: none;
}

.aps-scan-preview figure {
    width: 100%;
    margin: 0;
}

.aps-scan-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    display: block;
}

.aps-scan-preview figcaption,
.aps-file-preview {
    padding: 10px;
    color: var(--aps-muted);
    font-size: 12px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.aps-file-preview {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.aps-file-preview i {
    color: var(--aps-red);
    font-size: 24px;
}

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

.aps-clear-scan {
    min-height: 46px;
    border: 1px solid var(--aps-line);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff;
    color: var(--aps-primary-dark);
    font-weight: 900;
}

.aps-clear-scan:disabled {
    opacity: 0.55;
}

.aps-ocr-form[hidden],
#btnEnvOcr[hidden] {
    display: none;
}

.aps-ocr-form {
    display: grid;
    gap: 13px;
    margin: 0 14px 14px;
    padding: 14px;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(240, 249, 255, 0.96), rgba(236, 253, 245, 0.96)),
        #fff;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
}

.aps-ocr-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(14, 116, 144, 0.18);
}

.aps-ocr-head span,
.aps-ocr-head strong {
    display: block;
}

.aps-ocr-head span {
    color: var(--aps-muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.aps-ocr-head strong {
    margin-top: 2px;
    font-size: 18px;
}

.aps-ocr-head i {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--aps-blue), var(--aps-primary));
}

.aps-ocr-grid {
    display: grid;
    gap: 10px;
}

.aps-ocr-row {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: 10px;
}

.aps-ocr-form label {
    display: grid;
    gap: 6px;
    margin: 0;
    color: var(--aps-primary-dark);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
}

.aps-ocr-form input[type="text"] {
    width: 100%;
    height: 46px;
    border: 1px solid #99f6e4;
    border-radius: 8px;
    padding: 0 12px;
    background: #fff;
    color: var(--aps-ink);
    font: inherit;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.aps-ocr-form input[type="text"]:focus {
    outline: 0;
    border-color: var(--aps-primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.aps-submit-confirm {
    width: 100%;
    margin: 0;
    background: linear-gradient(135deg, var(--aps-primary), var(--aps-green));
    box-shadow: 0 12px 24px rgba(21, 128, 61, 0.18);
}

.aps-submit:disabled {
    opacity: 0.7;
}

.aps-form-note {
    margin: 0;
    color: var(--aps-muted);
    font-size: 12px;
    line-height: 1.35;
}

.aps-compress-info {
    min-height: 16px;
    font-weight: 800;
}

.aps-compress-info:empty {
    display: none;
}

.aps-compress-info.is-ok {
    color: var(--aps-green);
}

.aps-compress-info.is-error {
    color: var(--aps-red);
}

.aps-compress-info.is-busy {
    color: var(--aps-blue);
}

@media (min-width: 720px) {
    .aps-shell {
        max-width: 720px;
        margin: 0 auto;
        box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
    }

    .aps-sheet-panel {
        right: calc((100vw - 720px) / 2);
        left: calc((100vw - 720px) / 2);
    }
}

@media (max-width: 430px) {
    .aps-quick-actions {
        grid-template-columns: 1fr;
    }

    .aps-status-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .aps-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .aps-scan-actions {
        grid-template-columns: 1fr;
    }

    .aps-guide-meta {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 5px;
    }

    .aps-guide-meta div {
        padding: 7px 6px;
    }

    .aps-guide-meta span {
        font-size: 9px;
    }

    .aps-guide-meta strong {
        font-size: 12px;
    }
}
