:root {
    --op-bg: #020617;
    --op-bg2: #030712;
    --op-bg3: #0f172a;
    --op-tx: #e5e7eb;
    --op-tx-dim: #9ca3af;
    --op-border: #1f2933;
    --op-accent: #22c55e;
    --op-danger: #ef4444;
}

/* ========== Panel principal viajes ========== */

.viajes-panel {
    background: var(--op-bg2);
    border-radius: 14px;
    border: 1px solid var(--op-border);
    padding: 12px 12px 14px;
    color: var(--op-tx);
    box-shadow: 0 14px 35px rgba(0, 0, 0, .45);
    margin-top: 6px;
}

.viajes-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.viajes-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.viajes-subtitle {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: var(--op-tx-dim);
}

.viajes-header-meta {
    font-size: 12px;
    color: var(--op-tx-dim);
    white-space: nowrap;
}

/* Tabla: móvil, una sola tarjeta estable */

.viajes-table-wrapper {
    border-radius: 12px;
    border: 1px solid #111827;
    background: #020617;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.viajes-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
}

.viajes-table thead {
    background: #020617;
}

.viajes-table th,
.viajes-table td {
    padding: 7px 8px;
    border-bottom: 1px solid #111827;
    white-space: nowrap;
}

.viajes-table th {
    text-align: left;
    font-weight: 500;
    font-size: 11px;
    color: #9ca3af;
}

.viajes-table tbody tr:hover {
    background: #020617;
}

.viajes-loading {
    text-align: center;
    color: #6b7280;
    padding: 10px 0;
}

/* ========== Botones ========== */

.btn-op {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 11px;
    border-radius: 999px;
    border: 1px solid var(--op-border);
    background: #111827;
    color: var(--op-tx);
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
}

.btn-op:hover {
    background: #1f2937;
}

.btn-primary {
    background: var(--op-accent);
    border-color: rgba(34, 197, 94, .5);
    color: #022c22;
    font-weight: 600;
}

.btn-ghost {
    background: transparent;
}

.btn-full {
    flex: 1;
}

/* Badges status */

.op-status {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    text-transform: lowercase;
}

.op-status-borrador,
.op-status-por_aprobar {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
}

.op-status-aprobado,
.op-status-impreso {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
}

.op-status-enviado {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
}

.op-status-cancelado {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

/* ========== Modal escáner (op-modal) ========== */

.op-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .8);
    display: none;
    z-index: 60;
}

.op-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* móvil: full screen para que el QR no quede lejos */
.op-modal-content {
    width: min(760px, 100vw);
    max-height: 100vh;
    background: var(--op-bg2);
    border-radius: 0;
    border: 1px solid var(--op-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.op-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--op-border);
    gap: 8px;
    flex-wrap: wrap;
    background: #020617;
}

.op-modal-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.op-modal-id {
    color: #93c5fd;
}

.op-modal-subtitle {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--op-tx-dim);
}

.op-modal-toolbar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.op-modal-body {
    padding: 10px 12px 14px;
    overflow-y: auto;
}

.op-toolbar-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.op-select {
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid var(--op-border);
    background: var(--op-bg3);
    color: var(--op-tx);
    font-size: 12px;
}

.qr-box {
    margin-top: 10px;
    max-width: 100%;
}

#qr-reader {
    width: 100%;
}

.op-hint {
    margin-top: 8px;
    font-size: 11px;
    color: var(--op-tx-dim);
}

.btn-history {
    margin-top: 10px;
}

.op-history-box {
    margin-top: 8px;
    display: none;
}

.op-history-box.show {
    display: block;
}

.op-history-title {
    margin: 0 0 6px 0;
    font-size: 13px;
    font-weight: 600;
}

.op-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 11px;
}

.op-history-list li {
    padding: 6px 8px;
    border-radius: 8px;
    background: #020617;
    border: 1px solid #111827;
    margin-bottom: 4px;
}

/* ========== Sheet entrega (deliver-sheet) ========== */

/* full-screen estable, sin movimientos raros */
.deliver-sheet {
    position: fixed;
    inset: 0;
    background: var(--op-bg2);
    display: none;
    flex-direction: column;
    padding: env(safe-area-inset-top) 14px
             calc(14px + env(safe-area-inset-bottom)) 14px;
    z-index: 70;
    overflow: hidden;
}

.deliver-sheet.show {
    display: flex;
}

/* Header fijo dentro de la sheet */
.sheet-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 2px 10px 2px;
    border-bottom: 1px solid var(--op-border);
}

.sheet-title {
    margin: 0;
    font-size: 15px;
}

.sheet-id {
    color: #93c5fd;
}

/* Cuerpo: único que scrollea */
.sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 2px 12px 2px;
}

/* Campos */
.field {
    margin-bottom: 14px;
}

.label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--op-tx-dim);
    font-weight: 600;
}

.control-lg {
    width: 100%;
    padding: 12px 11px;
    border-radius: 12px;
    border: 1px solid var(--op-border);
    background: var(--op-bg3);
    color: var(--op-tx);
    font-size: 15px;
}

/* Fotos */
.toolbar-photos {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.thumbs {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

@media (min-width: 380px) {
    .thumbs {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 520px) {
    .thumbs {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.thumb {
    position: relative;
}

.thumb img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--op-border);
}

.thumb button {
    position: absolute;
    top: 5px;
    right: 5px;
}

.photos-hint {
    margin-top: 6px;
    font-size: 11px;
    color: var(--op-tx-dim);
}

/* Barra de acciones pegada al fondo de la sheet */
.deliver-sheet .actions {
    flex-shrink: 0;
    margin-top: 8px;
    padding: 10px 0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(0deg, rgba(11, 16, 32, 1) 70%, rgba(11, 16, 32, 0));
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Ajustes en pantallas medianas / desktop */

@media (min-width: 640px) {
    .viajes-panel {
        padding: 14px 14px 16px;
        margin-top: 10px;
    }

    .deliver-sheet {
        padding-inline: 24px;
    }
}

@media (min-width: 900px) {
    .op-modal-content {
        border-radius: 14px;
        max-height: 92vh;
    }
}
