:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Garantiza que el atributo HTML 'hidden' siempre oculte el elemento,
   incluso si una regla CSS tiene un 'display' que ganaría por especificidad */
[hidden] {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
}

body.modal-open {
    overflow: hidden;
}

.home-screen {
    min-height: calc(100vh - 40px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 28px;
}

.home-logo {
    display: block;
    width: 88px;
    height: 88px;
    object-fit: contain;
    margin: 0 auto 16px;
    border-radius: 18px;
}

.home-card h1 {
    font-size: 26px;
    text-align: center;
    margin-bottom: 8px;
}

.home-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 22px;
}

.login-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
}

.home-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 12px;
}

.app-menu-card {
    max-width: 460px;
}

.app-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
}

.app-menu-section {
    margin: 22px 0 2px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    color: #475569;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.app-menu-section:first-child {
    margin-top: 4px;
    padding-top: 0;
    border-top: none;
}

.app-menu-button {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 84px;
    border: none;
    border-radius: 14px;
    background: #1e293b;
    color: #ffffff;
    padding: 16px 18px;
    text-align: left;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
    cursor: pointer;
    position: relative;
    transition: transform 0.13s ease-out, box-shadow 0.13s ease-out, filter 0.13s ease-out;
}

.app-menu-button .tile-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.16);
}

.app-menu-button .tile-icon svg {
    width: 22px;
    height: 22px;
}

.app-menu-button .tile-body {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.app-menu-button .tile-title {
    display: block;
    color: #ffffff;
    font-size: 18px;
    font-weight: 900;
    line-height: 1.2;
}

.app-menu-button small {
    display: block;
    color: #f1f5f9;
    font-size: 12px;
    font-weight: 700;
}

.app-menu-button .tile-badge {
    position: absolute;
    top: 10px;
    right: 12px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #ffffff;
    color: #1e3a8a;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.02em;
}

.app-notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    z-index: 2;
    display: grid;
    place-items: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 3px solid #ffffff;
    border-radius: 999px;
    background: #dc2626;
    color: #ffffff;
    box-shadow: 0 5px 14px rgba(127, 29, 29, 0.48);
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    animation: pedidos-notification-pulse 1.15s ease-in-out infinite;
}

.app-notification-badge[hidden] {
    display: none;
}

@keyframes pedidos-notification-pulse {
    0%, 100% {
        transform: scale(1);
        background: #dc2626;
        box-shadow: 0 5px 14px rgba(127, 29, 29, 0.48);
    }
    50% {
        transform: scale(1.13);
        background: #ef4444;
        box-shadow: 0 0 0 7px rgba(239, 68, 68, 0.2), 0 6px 18px rgba(127, 29, 29, 0.55);
    }
}

.app-menu-button.tile-hero {
    min-height: 100px;
}

.app-menu-button.tile-hero .tile-title {
    font-size: 20px;
}

.app-menu-button.tile-hero .tile-icon {
    width: 46px;
    height: 46px;
}

.app-menu-button.tile-hero .tile-icon svg {
    width: 24px;
    height: 24px;
}

.app-menu-button.tile-primary {
    min-height: 88px;
}

.app-menu-button.tile-standard {
    min-height: 76px;
}

.app-menu-button.tile-standard .tile-title {
    font-size: 17px;
}

.app-menu-button.tile-compact {
    min-height: 64px;
    padding: 12px 16px;
}

.app-menu-button.tile-compact .tile-title {
    font-size: 15px;
}

.app-menu-button.tile-compact .tile-icon {
    width: 34px;
    height: 34px;
}

.app-menu-button.tile-compact .tile-icon svg {
    width: 18px;
    height: 18px;
}

.app-menu-button.admin {
    background: #1e293b;
}

.app-menu-button.hub {
    background: #334155;
}

.app-menu-button.close-day {
    background: #1d4ed8;
}

.app-menu-button.v2 {
    background: #1e3a8a;
}

.app-menu-button.cosecha {
    background: #9b5311;
}

.app-menu-button.collect {
    background: #1f7a38;
}

.app-menu-button.debt {
    background: #bb3c37;
}

.app-menu-button.stock {
    background: #115e59;
}

.app-menu-button.products {
    background: #0f766e;
}

.app-menu-button.purchase {
    background: #92400e;
}

.app-menu-button.finance {
    background: #312e81;
}

.app-menu-button.store-orders {
    background: #134e4a;
}

.app-menu-button.clients {
    background: #176b58;
}

.app-menu-button.preventa {
    background: #0f766e;
}

.legacy-home-entry[hidden] {
    display: none !important;
}

.operations-menu-card {
    max-width: 680px;
}

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

.operations-menu .app-menu-button {
    min-height: 132px;
}

.operations-menu .tile-title {
    font-size: 21px;
}

@media (max-width: 560px) {
    .operations-menu {
        grid-template-columns: 1fr;
    }

    .operations-menu .app-menu-button {
        min-height: 104px;
    }
}

@media (hover: hover) and (pointer: fine) {
    .app-menu-button:hover {
        transform: translateY(-2px);
        filter: brightness(1.07);
        box-shadow: 0 12px 24px rgba(15, 23, 42, 0.24);
    }
}

.app-menu-button:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(15, 23, 42, 0.55);
}

.btn:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px #1e40af;
}

@media (prefers-reduced-motion: reduce) {
    .app-menu-button {
        transition: filter 0.13s ease-out, box-shadow 0.13s ease-out;
    }

    .app-menu-button:hover,
    .app-menu-button:active {
        transform: none;
    }

    .app-notification-badge {
        animation: none;
    }
}

@media (min-width: 640px) {
    .admin-menu-card {
        max-width: 760px;
    }

    .admin-menu-card .app-menu {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 12px;
    }

    .admin-menu-card .app-menu-section {
        grid-column: 1 / -1;
    }

    .admin-menu-card .app-menu-button.tile-hero {
        grid-column: span 2;
    }
}

@media (min-width: 1024px) {
    .admin-menu-card {
        max-width: 1040px;
    }
}

.pedidos-tienda-shell {
    width: min(1480px, calc(100% - 32px));
    max-width: 1480px;
    margin: 24px auto;
    background: #fff;
    border: 1px solid #dbe3ea;
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, .11);
    overflow: hidden;
}

.pedidos-tienda-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 24px 28px;
    background: #153f35;
    color: #fff;
    text-align: left;
}

.pedidos-tienda-header h1 { margin: 2px 0 4px; font-size: 28px; }
.pedidos-tienda-header p { margin: 0; color: #d8eee7; }
.pedidos-tienda-header .home-nav-button { background: #fff; color: #153f35; }
.section-kicker { display: block; color: #f5c66d; font-size: 12px; font-weight: 800; text-transform: uppercase; }

.pedidos-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-bottom: 1px solid #dbe3ea;
    background: #f8faf9;
}
.pedidos-kpis > div { padding: 18px 22px; border-right: 1px solid #dbe3ea; }
.pedidos-kpis > div:last-child { border-right: 0; }
.pedidos-kpis span { display: block; color: #64748b; font-size: 12px; font-weight: 700; }
.pedidos-kpis strong { display: block; margin-top: 4px; color: #132a24; font-size: 24px; }

.pedidos-toolbar {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 220px auto;
    align-items: end;
    gap: 12px;
    padding: 20px 22px 8px;
}
.pedidos-toolbar label span,
.pedido-detail-routing label span { display: block; margin-bottom: 5px; color: #475569; font-size: 12px; font-weight: 800; }
.pedidos-toolbar input,
.pedidos-toolbar select,
.pedido-detail-routing select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; font: inherit; }
.pedidos-tienda-shell > .section-desc { padding: 0 22px 10px; }
.pedidos-report-actions {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) repeat(4, auto);
    align-items: center;
    gap: 10px;
    margin: 8px 22px 14px;
    padding: 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}
.pedidos-selection-summary { min-width: 0; }
.pedidos-selection-summary strong,
.pedidos-selection-summary span { display: block; }
.pedidos-selection-summary strong { color: #153f35; font-size: 14px; }
.pedidos-selection-summary span { margin-top: 3px; color: #64748b; font-size: 11px; }
.pedidos-report-actions .btn { min-height: 42px; white-space: nowrap; }
.pedidos-table-wrap { overflow: auto; border-top: 1px solid #e2e8f0; }
.pedidos-table { width: 100%; min-width: 1120px; border-collapse: collapse; }
.pedidos-table th { padding: 11px 12px; background: #edf3f0; color: #334155; font-size: 11px; text-align: left; text-transform: uppercase; }
.pedidos-table td { padding: 13px 12px; border-bottom: 1px solid #e2e8f0; color: #1e293b; vertical-align: middle; }
.pedidos-table td span,
.pedidos-table td small { display: block; margin-top: 3px; color: #64748b; }
.pedido-location-link { display: inline-flex; margin-top: 6px; color: #166534; font-size: 12px; font-weight: 800; text-decoration: underline; }
.pedido-select-column { width: 48px; text-align: center !important; }
.pedido-select-checkbox,
#pedidosTiendaSelectAll { width: 18px; height: 18px; margin: 0; accent-color: #15803d; cursor: pointer; }
.pedido-select-checkbox:disabled { cursor: not-allowed; opacity: .35; }
.pedidos-route-generate { white-space: nowrap; }
.pedido-row.nuevo { background: #fffbeb; }
.pedido-row.preparando { background: #eff6ff; }
.pedido-row.pendiente-entrega { background: #fff7ed; }
.pedido-row.rechazado,
.pedido-row.cancelado { background: #fff1f2; }
.pedido-total { font-weight: 900; white-space: nowrap; }
.pedido-state { display: inline-flex !important; min-height: 28px; align-items: center; padding: 5px 9px; border-radius: 999px; background: #e2e8f0; color: #334155 !important; font-size: 11px; font-weight: 900; white-space: nowrap; }
.pedido-state.nuevo { background: #fde68a; color: #713f12 !important; }
.pedido-state.preparando { background: #bfdbfe; color: #1e3a8a !important; }
.pedido-state.en-reparto { background: #ddd6fe; color: #4c1d95 !important; }
.pedido-state.pendiente-entrega { background: #fed7aa; color: #9a3412 !important; }
.pedido-state.entregado { background: #d1fae5; color: #065f46 !important; }
.pedido-state.rechazado { background: #fecaca; color: #991b1b !important; }
.pedido-state.cancelado { background: #fecdd3; color: #881337 !important; }

.pedidos-tienda-modal:not([hidden]) { display: flex; align-items: center; justify-content: center; padding: 18px; }
.pedido-tienda-detail { position: relative; width: min(1040px, 100%); max-height: calc(100vh - 36px); overflow: auto; padding: 0; border-radius: 8px; background: #fff; }
.pedido-detail-close { position: absolute; top: 12px; right: 14px; z-index: 2; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.94); color: #334155; font-size: 26px; cursor: pointer; }
.pedido-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 24px 64px 22px 24px; background: #153f35; color: #fff; }
.pedido-detail-heading span:first-child { color: #f5c66d; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.pedido-detail-heading h2 { margin: 2px 0; font-size: 28px; }
.pedido-detail-heading p { margin: 0; color: #d8eee7; }
.pedido-detail-customer { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; padding: 1px; background: #e2e8f0; }
.pedido-detail-customer > div { padding: 14px 18px; background: #fff; }
.pedido-detail-customer .wide { grid-column: 1 / -1; }
.pedido-detail-customer span { display: block; color: #64748b; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.pedido-detail-customer strong { display: block; margin-top: 3px; }
.pedido-detail-customer small { display: block; margin-top: 4px; color: #64748b; }
.pedido-edit-audit { background: #f8fafc !important; }
.pedido-detail-items { padding: 14px 20px; }
.pedido-detail-items > div { display: flex; justify-content: space-between; gap: 18px; padding: 10px 0; border-bottom: 1px solid #e2e8f0; }
.pedido-detail-total { display: flex; justify-content: space-between; padding: 16px 20px; background: #f8fafc; font-size: 20px; font-weight: 900; }
.pedido-detail-routing { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; padding: 18px 20px; border-top: 1px solid #e2e8f0; }
.pedido-lifecycle-message {
    margin: 0;
    padding: 12px 20px;
    border-top: 1px solid #ddd6fe;
    background: #f5f3ff;
    color: #4c1d95;
    font-size: 13px;
    font-weight: 800;
}
.pedido-lifecycle-message.danger {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}
.pedido-detail-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 16px 20px 22px; }
.pedido-shipping-label-btn { border-color: #7c3aed; color: #5b21b6; }
.pedido-edit-heading p { max-width: 620px; font-size: 13px; }
.pedido-edit-search { position: relative; padding: 18px 20px 10px; border-bottom: 1px solid #e2e8f0; }
.pedido-edit-search label > span,
.pedido-edit-reason > span { display: block; margin-bottom: 6px; color: #475569; font-size: 12px; font-weight: 800; }
.pedido-edit-search input,
.pedido-edit-reason textarea { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: #172033; font: inherit; }
.pedido-edit-search-results { position: absolute; z-index: 5; top: 78px; left: 20px; right: 20px; max-height: 310px; overflow: auto; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; box-shadow: 0 18px 38px rgba(15, 23, 42, .2); }
.pedido-edit-search-results[hidden] { display: none; }
.pedido-edit-search-results > p { margin: 0; padding: 14px; color: #64748b; }
.pedido-edit-search-results > p.error { color: #991b1b; }
.pedido-edit-search-results button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 13px; border: 0; border-bottom: 1px solid #e2e8f0; background: #fff; color: #1e293b; text-align: left; cursor: pointer; }
.pedido-edit-search-results button:last-child { border-bottom: 0; }
.pedido-edit-search-results button:hover:not(:disabled),
.pedido-edit-search-results button:focus-visible:not(:disabled) { background: #f0fdf4; }
.pedido-edit-search-results button:disabled { cursor: not-allowed; opacity: .55; }
.pedido-edit-search-results button > span:last-child { text-align: right; }
.pedido-edit-search-results strong,
.pedido-edit-search-results small { display: block; }
.pedido-edit-search-results small { margin-top: 2px; color: #64748b; font-size: 11px; }
.pedido-edit-table-wrap { max-height: 420px; overflow: auto; }
.pedido-edit-table { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: fixed; }
.pedido-edit-table th { position: sticky; top: 0; z-index: 1; padding: 10px 12px; background: #edf3f0; color: #475569; font-size: 11px; text-align: left; text-transform: uppercase; }
.pedido-edit-table th:nth-child(1) { width: 43%; }
.pedido-edit-table th:nth-child(2) { width: 17%; }
.pedido-edit-table th:nth-child(3) { width: 14%; }
.pedido-edit-table th:nth-child(4) { width: 19%; }
.pedido-edit-table th:nth-child(5) { width: 7%; }
.pedido-edit-table td { padding: 11px 12px; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
.pedido-edit-table td small { display: block; margin-top: 3px; color: #64748b; font-size: 11px; }
.pedido-edit-table td:nth-child(2),
.pedido-edit-table td:nth-child(4) { white-space: nowrap; }
.pedido-edit-table input { width: 86px; min-height: 38px; padding: 7px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; text-align: right; }
.pedido-edit-remove { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #fecaca; border-radius: 6px; background: #fff1f2; color: #991b1b; font-size: 24px; line-height: 1; cursor: pointer; }
.pedido-edit-empty { margin: 0; padding: 18px 20px; color: #991b1b; font-weight: 800; }
.pedido-edit-summary { display: flex; align-items: center; justify-content: flex-end; gap: 24px; padding: 15px 20px; border-top: 1px solid #cbd5e1; background: #f8fafc; }
.pedido-edit-summary span { color: #475569; font-weight: 700; }
.pedido-edit-summary strong { color: #153f35; font-size: 22px; }
.pedido-edit-reason { display: block; padding: 16px 20px 0; }
.pedido-edit-reason small { color: #64748b; font-weight: 500; }
.pedido-edit-actions { border-top: 0; }

.pedido-route-form-card {
    position: relative;
    width: min(720px, calc(100vw - 36px));
    max-width: 720px;
    max-height: calc(100vh - 36px);
    overflow: auto;
    padding: 0;
    border-radius: 8px;
}
.pedido-route-form-heading { padding: 24px 64px 20px 24px; background: #153f35; color: #fff; }
.pedido-route-form-heading > span { color: #f5c66d; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.pedido-route-form-heading h2 { margin: 4px 0; font-size: 26px; }
.pedido-route-form-heading p { margin: 0; color: #d8eee7; }
.pedido-route-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 22px 24px 24px; }
.pedido-route-form label > span { display: block; margin-bottom: 6px; color: #475569; font-size: 12px; font-weight: 800; }
.pedido-route-form input,
.pedido-route-form textarea {
    width: 100%;
    margin: 0;
    padding: 10px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #172033;
    font: inherit;
    box-sizing: border-box;
}
.pedido-route-form input { min-height: 42px; }
.pedido-route-form input[readonly] {
    border-color: #94a3b8;
    background: #f1f5f9;
    color: #334155;
    font-weight: 800;
}
.pedido-route-form label > small {
    display: block;
    margin-top: 5px;
    color: #64748b;
    font-size: 11px;
    line-height: 1.35;
}
.pedido-route-form textarea { min-height: 78px; resize: vertical; }
.pedido-route-form .wide { grid-column: 1 / -1; }
.pedido-route-form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 2px; }

@media (max-width: 800px) {
    .pedidos-tienda-shell { width: 100%; margin: 0; border: 0; border-radius: 0; }
    .pedidos-tienda-header { padding: 18px; }
    .pedidos-kpis { grid-template-columns: 1fr 1fr; }
    .pedidos-kpis > div:nth-child(2) { border-right: 0; }
    .pedidos-toolbar { grid-template-columns: 1fr; padding: 16px; }
    .pedidos-report-actions {
        grid-template-columns: 1fr;
        margin: 0 16px 14px;
    }
    .pedidos-table { min-width: 0; }
    .pedidos-table thead { display: none; }
    .pedidos-table tbody, .pedidos-table tr, .pedidos-table td { display: block; width: 100%; }
    .pedidos-table tr { padding: 12px 16px; border-bottom: 8px solid #e2e8f0; }
    .pedidos-table td { display: grid; grid-template-columns: 105px 1fr; gap: 8px; padding: 6px 0; border: 0; }
    .pedidos-table td::before { content: attr(data-label); color: #64748b; font-size: 11px; font-weight: 800; text-transform: uppercase; }
    .pedido-detail-customer, .pedido-detail-routing { grid-template-columns: 1fr; }
    .pedido-detail-customer .wide { grid-column: auto; }
    .pedido-detail-actions { display: grid; }
    .pedido-edit-table-wrap { max-height: none; }
    .pedido-edit-summary { justify-content: space-between; }
    .pedido-edit-search-results { left: 12px; right: 12px; }
    .pedido-route-form { grid-template-columns: 1fr; padding: 18px; }
    .pedido-route-form .wide { grid-column: auto; }
    .pedido-route-form-actions { display: grid; }
}

.deposito-danger-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(69, 10, 10, 0.72);
}

.deposito-danger-panel {
    width: min(760px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: #ffffff;
    border: 3px solid #dc2626;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(69, 10, 10, 0.38);
}

.deposito-danger-heading {
    display: grid;
    grid-template-columns: 48px 1fr 40px;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: #991b1b;
    color: #ffffff;
}

.deposito-danger-heading span {
    display: block;
    margin-bottom: 2px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.deposito-danger-heading h2 {
    margin: 0;
    font-size: 24px;
}

.deposito-danger-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    font-size: 28px;
    font-weight: 900;
}

.deposito-danger-close {
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
    color: #ffffff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
}

.deposito-danger-instruction {
    margin: 0;
    padding: 16px 20px;
    background: #fef2f2;
    border-bottom: 1px solid #fecaca;
    color: #7f1d1d;
    font-size: 16px;
    font-weight: 800;
}

.deposito-danger-list {
    display: grid;
    gap: 1px;
    background: #e5e7eb;
}

.deposito-danger-item {
    padding: 20px;
    background: #ffffff;
}

.deposito-danger-item h3 {
    margin: 8px 0;
    font-size: 19px;
}

.deposito-danger-item p {
    margin: 0;
    color: #374151;
}

.deposito-danger-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    color: #6b7280;
    font-size: 13px;
    font-weight: 700;
}

.deposito-danger-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.deposito-action-done {
    background: #15803d;
    color: #ffffff;
}

.deposito-action-missing {
    background: #f59e0b;
    color: #451a03;
}

.cobranza-previa-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 8px;
    border: 1px solid #86efac;
    border-radius: 6px;
    background: #f0fdf4;
    color: #166534;
    font-size: 12px;
    font-weight: 800;
}

.cobranza-card-actions {
    display: grid;
    justify-items: end;
    gap: 7px;
}

.cobranza-remove-btn {
    border: 1px solid #fecaca;
    background: #fff7ed;
    color: #b91c1c;
}

@media (max-width: 640px) {
    .deposito-danger-modal { padding: 12px; }
    .deposito-danger-panel { max-height: calc(100vh - 24px); }
    .deposito-danger-heading { grid-template-columns: 42px 1fr 34px; padding: 15px; }
    .deposito-danger-heading h2 { font-size: 20px; }
    .deposito-danger-actions { display: grid; grid-template-columns: 1fr 1fr; }
}

.app-menu-button:active {
    transform: translateY(0) scale(0.97);
    filter: brightness(0.92);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

.container {
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.stock-shell {
    width: min(1180px, calc(100vw - 40px));
    max-width: 1180px;
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 24px;
    text-align: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.header p {
    font-size: 14px;
    opacity: 0.9;
}

.stock-header {
    background: linear-gradient(135deg, #0f766e 0%, #0e7490 100%);
}

.session-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.session-link {
    border: none;
    background: #e0f2fe;
    color: #075985;
    cursor: pointer;
    font-weight: 700;
    padding: 7px 10px;
    border-radius: 999px;
    text-decoration: none;
}

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

.home-nav-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 10px;
    border: 1px solid rgba(14, 116, 144, 0.14);
    background: linear-gradient(135deg, #f8fbff 0%, #dbeafe 100%);
    color: #0f172a;
    box-shadow: 0 10px 22px rgba(14, 116, 144, 0.14);
    font-weight: 800;
}

.home-nav-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 26px rgba(14, 116, 144, 0.18);
}

.home-nav-button:active {
    transform: translateY(0);
}

.home-nav-icon {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
    color: #ffffff;
    flex-shrink: 0;
}

.home-nav-icon svg {
    width: 14px;
    height: 14px;
}

.sync-banner {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    background: #fef3c7;
    color: #92400e;
    border-bottom: 1px solid #fde68a;
}

.sync-banner.success {
    background: #dcfce7;
    color: #166534;
    border-bottom-color: #bbf7d0;
}

/* Progress Bar */
.progress-container {
    background: var(--bg-secondary);
    padding: 16px 24px;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    margin-bottom: 12px;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border-color);
    z-index: 0;
}

.progress-line {
    position: absolute;
    top: 15px;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    transition: width 0.3s ease;
    z-index: 1;
}

.progress-step {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: var(--text-secondary);
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
}

.progress-step.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.progress-step.completed {
    border-color: var(--success-color);
    background: var(--success-color);
    color: white;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
}

.progress-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    flex: 1;
}

.progress-label.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* Form Steps */
.form-content {
    padding: 24px;
}

.step {
    display: none;
    animation: fadeIn 0.3s ease;
}

.step.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step h2 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 600;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input.error {
    border-color: var(--danger-color);
}

.info-display {
    background: var(--bg-secondary);
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Cash Breakdown Table */
.cash-table {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.cash-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.cash-row:last-child {
    border-bottom: none;
}

.cash-denomination {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
    min-width: 100px;
}

.cash-input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    text-align: center;
    transition: all 0.2s ease;
}

.cash-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.cash-total {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    margin-top: 16px;
}

.cash-total-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.cash-total-amount {
    font-size: 28px;
    font-weight: 700;
}

/* Client Search */
.search-section {
    margin-bottom: 24px;
}

.search-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.section-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.section-desc.text-success {
    color: var(--success-color);
    font-weight: 800;
}

.section-desc.text-warn {
    color: var(--warning-color);
    font-weight: 800;
}

.import-status-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 8px;
    margin-bottom: 14px;
}

.autocomplete-wrapper {
    position: relative;
    margin-bottom: 16px;
}

.autocomplete-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.2s ease;
}

.autocomplete-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    box-shadow: var(--shadow);
}

.autocomplete-results.show {
    display: block;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid var(--bg-secondary);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: var(--bg-secondary);
}

.autocomplete-item strong {
    color: var(--primary-color);
}

.selected-clients {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.client-tag {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border-color);
}

.client-tag-id {
    font-weight: 700;
    margin-right: 8px;
    color: var(--primary-color);
}

.client-tag-method {
    display: block;
    color: var(--text-secondary);
    font-size: 11px;
    margin-top: 2px;
}

.client-tag-amount {
    font-weight: 600;
}

.client-tag-remove {
    cursor: pointer;
    font-weight: 700;
    color: var(--danger-color);
    padding: 4px 8px;
}

.no-cobrado-list {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

.no-cobrado-row {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--bg-secondary);
}

.no-cobrado-row strong,
.no-cobrado-row span,
.no-cobrado-row small {
    display: block;
}

.no-cobrado-row span {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 12px;
}

.no-cobrado-row small {
    margin-top: 4px;
    color: var(--success-color);
    font-weight: 800;
}

.no-cobrado-row.queued small {
    color: var(--warning-color);
}

.saldo-toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-bottom: 12px;
}

.saldo-toolbar input,
.saldo-toolbar select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.saldo-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 2px;
}

.saldo-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
}

.pending-actions {
    display: grid;
    gap: 6px;
    min-width: 94px;
}

.saldo-name {
    font-weight: 700;
    color: var(--text-primary);
}

.saldo-meta {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 2px;
}

.saldo-meta span {
    display: inline-block;
    margin-right: 6px;
}

.saldo-meta strong {
    color: var(--text-primary);
    font-weight: 700;
}

.saldo-responsable {
    display: inline-flex;
    margin-top: 6px;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    font-size: 11px;
    font-weight: 800;
}

.saldo-amount {
    color: var(--primary-color);
    font-weight: 800;
    white-space: nowrap;
}

.saldo-payment-summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg-secondary);
    margin-bottom: 16px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 16px;
}

.checkbox-row input {
    width: auto;
    margin: 0;
}

.form-grid.two-cols-mobile {
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 12px;
}

.stock-search-wrap {
    position: relative;
}

.stock-suggestions {
    position: absolute;
    z-index: 30;
    top: calc(100% - 12px);
    left: 0;
    right: 0;
    display: grid;
    gap: 6px;
    max-height: 250px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
}

.stock-suggestion {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
}

.stock-suggestion strong,
.stock-suggestion small {
    display: block;
}

.stock-suggestion small,
.stock-suggestion-empty {
    color: var(--text-secondary);
    font-size: 12px;
}

.stock-selected {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #ecfeff;
    border: 1px solid #bae6fd;
}

.stock-selected strong,
.stock-selected span {
    display: block;
}

.stock-selected span {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 3px;
}

.stock-edit-notice {
    display: grid;
    gap: 3px;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    background: #fff7ed;
    color: #9a3412;
}

.stock-edit-notice strong,
.stock-edit-notice span {
    display: block;
}

.stock-edit-notice span {
    font-size: 12px;
    font-weight: 700;
}

.stock-role-notice {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 18px;
    padding: 11px 13px;
    border-left: 4px solid #0f766e;
    background: #f0fdfa;
    color: #134e4a;
}

.stock-role-notice strong {
    white-space: nowrap;
}

.stock-role-notice span {
    color: #47615f;
    font-size: 13px;
}

.stock-last-sent {
    display: block;
    margin-top: 5px;
    color: #166534 !important;
    font-size: 12px;
    font-weight: 800;
}

.stock-transfer-batch {
    margin-top: 24px;
    border: 1px solid #86efac;
    border-top: 4px solid #15803d;
    border-radius: 8px;
    background: #f8fff9;
    padding: 18px;
}

.stock-transfer-batch-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.stock-transfer-batch-heading h2,
.stock-transfer-batch-heading p {
    margin: 0;
}

.stock-transfer-batch-heading h2 {
    color: #14532d;
    font-size: 19px;
}

.stock-transfer-batch-heading p {
    margin-top: 4px;
    color: #52705c;
    font-size: 13px;
}

.stock-transfer-kicker {
    display: block;
    margin-bottom: 4px;
    color: #15803d;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.stock-transfer-table-wrap {
    overflow-x: auto;
}

.stock-transfer-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.stock-transfer-table th,
.stock-transfer-table td {
    border-bottom: 1px solid #d1e9d7;
    padding: 9px 10px;
    color: var(--text-primary);
    font-size: 13px;
    text-align: left;
    vertical-align: middle;
}

.stock-transfer-table th {
    background: #eaf8ee;
    color: #386446;
    font-size: 11px;
    text-transform: uppercase;
}

.stock-transfer-table input,
.stock-transfer-footer textarea {
    width: 100%;
    border: 1px solid #b9d8c1;
    border-radius: 6px;
    background: #ffffff;
}

.stock-transfer-table input {
    min-width: 120px;
    padding: 8px;
}

.stock-transfer-remove {
    width: 34px;
    height: 34px;
    border: 1px solid #fecaca;
    border-radius: 6px;
    background: #fff1f2;
    color: #b91c1c;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.stock-transfer-footer {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    align-items: end;
    gap: 16px;
    margin-top: 16px;
}

.stock-transfer-footer label span {
    display: block;
    margin-bottom: 6px;
    color: #385441;
    font-size: 12px;
    font-weight: 800;
}

.stock-transfer-footer textarea {
    resize: vertical;
    padding: 9px 10px;
}

.stock-list-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin: 24px 0 12px;
}

.stock-list-header h2 {
    margin: 0 0 3px;
    color: var(--text-primary);
    font-size: 18px;
}

.stock-list {
    display: block;
    max-height: min(58vh, 640px);
    overflow-y: auto;
}

.stock-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
    box-shadow: 0 8px 18px rgba(31, 41, 55, 0.08);
}

.stock-table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
}

.stock-table th,
.stock-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 13px;
    text-align: left;
    vertical-align: top;
}

.stock-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.stock-table tbody tr:last-child td {
    border-bottom: none;
}

.stock-row.sin-cosecha {
    background: #fff7ed;
}

.stock-row.pedido {
    background: #f0fdf4;
}

.stock-row.faltante {
    background: #fffbea;
}

.stock-row.demora {
    background: #f0fdf4;
}

.stock-row.enviado {
    background: #f0f9ff;
}

.stock-row.discontinuado {
    background: #f8fafc;
    opacity: 0.78;
}

.stock-row.historico {
    background: #ffffff;
}

.stock-table-product,
.stock-table-detail,
.stock-row-muted {
    display: block;
}

.stock-request-message,
.stock-transfer-reference,
.stock-commercial-state {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 750;
}

.stock-transfer-reference {
    color: #075985;
}

.stock-commercial-state {
    color: #6b4f00;
}

.stock-table-product {
    font-size: 14px;
}

.stock-table-detail,
.stock-row-muted {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.stock-row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.stock-row-actions .btn {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 12px;
}

.stock-order-conflict-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.58);
}

.stock-order-conflict-dialog {
    position: relative;
    width: min(640px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    border-radius: 8px;
    background: #ffffff;
    padding: 28px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.stock-order-conflict-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #f1f5f9;
    color: #334155;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.stock-order-conflict-kicker {
    display: block;
    margin-bottom: 6px;
    color: #b45309;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.stock-order-conflict-dialog h2 {
    max-width: 520px;
    margin: 0;
    color: #172033;
    font-size: 24px;
    line-height: 1.25;
}

.stock-order-conflict-dialog > p {
    margin: 12px 0 0;
    color: #475569;
    line-height: 1.5;
}

.stock-order-conflict-details {
    margin-top: 18px;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.stock-order-conflict-details table {
    width: 100%;
    border-collapse: collapse;
}

.stock-order-conflict-details th,
.stock-order-conflict-details td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
    font-size: 13px;
    text-align: left;
}

.stock-order-conflict-details th {
    background: #f8fafc;
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
}

.stock-order-conflict-details tr:last-child td {
    border-bottom: 0;
}

.stock-order-conflict-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.stock-order-conflict-actions .btn {
    flex: 1 1 170px;
    margin: 0;
}

@media (min-width: 900px) {
    .stock-shell .form-content {
        padding: 28px 30px 30px;
    }

    .stock-shell #stockFaltanteForm {
        display: grid;
        grid-template-columns: minmax(320px, 1.35fr) 240px 220px;
        gap: 16px;
        align-items: end;
    }

    .stock-shell #stockFaltanteForm .stock-search-wrap {
        grid-column: 1 / -1;
    }

    .stock-shell #stockFaltanteForm .form-grid.two-cols-mobile {
        grid-column: 1 / 2;
    }

    .stock-shell #stockFaltanteForm > .form-group:not(.stock-search-wrap) {
        grid-column: 2 / 3;
    }

    .stock-shell #stockFaltanteForm .button-group {
        grid-column: 3 / 4;
        margin-top: 0;
    }

    .stock-shell .saldo-toolbar {
        grid-template-columns: minmax(280px, 1fr) 220px;
    }
}

.stock-card {
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--warning-color);
    border-radius: 12px;
    background: var(--bg-primary);
    padding: 12px;
    box-shadow: 0 8px 18px rgba(31, 41, 55, 0.08);
}

.stock-card.pedido {
    border-left-color: var(--success-color);
    background: #f0fdf4;
}

.stock-card.demora {
    border-left-color: #facc15;
    background: #fefce8;
}

.stock-card.en-stock {
    border-left-color: #0891b2;
    background: #ecfeff;
}

.stock-card.discontinuado {
    border-left-color: #94a3b8;
    background: #f8fafc;
}

.stock-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.stock-card h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 15px;
}

.stock-card p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.stock-card-product-detail {
    color: var(--text-primary) !important;
    font-weight: 800;
}

.stock-status {
    display: inline-block;
    max-width: 100%;
    border-radius: 999px;
    padding: 4px 8px;
    color: #ffffff;
    font-size: 11px;
    font-weight: 900;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.stock-status.sin-cosecha {
    background: #f97316;
}

.stock-status.pedido {
    background: #16a34a;
}

.stock-status.faltante {
    background: #facc15;
    color: #713f12;
}

.stock-status.demora {
    background: #bbf7d0;
    color: #166534;
}

.stock-status.enviado {
    background: #0ea5e9;
}

.stock-status.discontinuado {
    background: #64748b;
}

.stock-status.historico {
    background: #e2e8f0;
    color: #475569;
}
.stock-card-amount {
    margin-top: 10px;
    color: #0f766e;
    font-size: 20px;
    font-weight: 900;
}

.stock-card-provider,
.stock-card-note {
    margin-top: 7px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.button-group.compact {
    margin-top: 16px;
}

.btn {
    flex: 1;
    min-height: 48px;
    padding: 14px 16px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    box-shadow: var(--shadow);
}

.btn-success:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    color: white;
}

.btn-sm {
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.1;
}

:where(button, a, input, select, textarea):focus-visible {
    outline: 3px solid #ffffff !important;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px #1e40af !important;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 12px;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 18px;
    margin-bottom: 16px;
}

/* Report Card */
.report-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.report-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-primary);
}

.report-row.deduc span:first-child {
    color: var(--danger-color);
}

.report-row.plus span:first-child {
    color: var(--success-color);
}

.report-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

.report-row.total {
    font-weight: 700;
    font-size: 16px;
    margin-top: 4px;
}

.report-row.header {
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 12px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 8px;
}

.balance-box {
    text-align: center;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
}

.balance-box.balanced {
    background: #dcfce7;
    border-color: var(--success-color);
    color: #166534;
}

.balance-box.short {
    background: #fee2e2;
    border-color: var(--danger-color);
    color: #991b1b;
}

.balance-box.over {
    background: #fef3c7;
    border-color: var(--warning-color);
    color: #92400e;
}

.balance-amount {
    display: block;
    font-size: 24px;
    font-weight: 700;
    margin-top: 4px;
}

/* Loading State */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.loading.show {
    display: block;
}

.spinner {
    border: 4px solid var(--bg-secondary);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 16px;
    }

    .header {
        padding: 20px;
    }

    .header h1 {
        font-size: 20px;
    }

    .form-content {
        padding: 20px;
    }

    .cash-denomination {
        min-width: 80px;
        font-size: 15px;
    }

    .cash-input {
        width: 70px;
    }

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

    .saldo-toolbar,
    .saldo-card,
    .form-grid.two-cols-mobile,
    .import-status-row {
        grid-template-columns: 1fr;
    }

    .stock-list-header {
        align-items: stretch;
        flex-direction: column;
    }

    .stock-role-notice,
    .stock-transfer-batch-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .stock-transfer-batch {
        padding: 14px 12px;
    }

    .stock-transfer-footer {
        grid-template-columns: 1fr;
    }

    .stock-transfer-table {
        min-width: 0;
    }

    .stock-transfer-table thead {
        display: none;
    }

    .stock-transfer-table,
    .stock-transfer-table tbody,
    .stock-transfer-table tr,
    .stock-transfer-table td {
        display: block;
        width: 100%;
    }

    .stock-transfer-table tr {
        border-bottom: 1px solid #d1e9d7;
        padding: 8px 0;
    }

    .stock-transfer-table td {
        display: grid;
        grid-template-columns: 104px minmax(0, 1fr);
        gap: 8px;
        border: 0;
        padding: 6px 4px;
    }

    .stock-transfer-table td::before {
        content: attr(data-label);
        color: #52705c;
        font-size: 10px;
        font-weight: 900;
        text-transform: uppercase;
    }

    .session-bar {
        align-items: flex-start;
        flex-direction: column;
    }

    .session-actions {
        width: 100%;
        justify-content: space-between;
    }

    .stock-table {
        min-width: 0;
    }

    .stock-table thead {
        display: none;
    }

    .stock-table,
    .stock-table tbody,
    .stock-table tr,
    .stock-table td {
        display: block;
        width: 100%;
    }

    .stock-table tr {
        border-bottom: 1px solid var(--border-color);
        padding: 10px 0;
    }

    .stock-table td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 10px;
        border-bottom: none;
        padding: 7px 12px;
    }

    .stock-table td::before {
        content: attr(data-label);
        grid-column: 1;
        grid-row: 1;
        color: var(--text-secondary);
        font-size: 11px;
        font-weight: 900;
        text-transform: uppercase;
    }

    .stock-table td > * {
        grid-column: 2;
        min-width: 0;
    }

    .stock-order-conflict-modal {
        align-items: flex-end;
        padding: 12px;
    }

    .stock-order-conflict-dialog {
        max-height: calc(100vh - 24px);
        padding: 24px 18px 18px;
    }

    .stock-order-conflict-dialog h2 {
        padding-right: 28px;
        font-size: 20px;
    }

    .stock-order-conflict-actions .btn {
        flex-basis: 100%;
    }

    .stock-request-message,
    .stock-transfer-reference,
    .stock-commercial-state,
    .stock-row-muted,
    .stock-table-detail,
    .stock-last-sent {
        overflow-wrap: anywhere;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.mb-2 {
    margin-bottom: 16px;
}

.font-bold {
    font-weight: 700;
}

/* La bandeja de pedidos es una superficie de escritorio. Estas reglas quedan
   despues del contenedor historico de 500px para evitar que herede ese limite. */
body .container.pedidos-tienda-shell {
    width: min(1480px, calc(100% - 32px));
    max-width: 1480px;
    margin: 24px auto;
    border-radius: 8px;
}

body .header.pedidos-tienda-header {
    background: #153f35;
    padding: 24px 28px;
    text-align: left;
}

body .header.pedidos-tienda-header h1 {
    margin: 2px 0 4px;
    font-size: 28px;
}

body .pedidos-tienda-modal .pedido-tienda-detail {
    width: min(1040px, calc(100vw - 36px));
    max-width: 1040px;
    padding: 0;
    border-radius: 8px;
}

body .pedidos-tienda-modal .pedido-route-form-card {
    width: min(720px, calc(100vw - 36px));
    max-width: 720px;
    padding: 0;
    border-radius: 8px;
}

body .pedido-route-form-card .pedido-route-form input {
    min-height: 42px;
    margin: 0;
    padding: 10px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font: inherit;
}

.products-screen {
    width: min(1600px, calc(100% - 32px));
    min-height: calc(100vh - 32px);
    margin: 16px auto;
    overflow: hidden;
    border: 1px solid #d9e0dc;
    border-radius: 8px;
    background: #f7f9f8;
    box-shadow: 0 14px 40px rgba(23, 33, 29, 0.14);
}

@media (max-width: 800px) {
    body .container.pedidos-tienda-shell {
        width: 100%;
        margin: 0;
        border-radius: 0;
    }

    .products-screen {
        width: 100%;
        min-height: 100vh;
        margin: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
}
