:root {
    --app-bg: #f4f6f8;
    --app-surface: #ffffff;
    --app-surface-2: #eef2f6;
    --app-text: #1d2733;
    --app-muted: #657386;
    --app-border: #d9e1ea;
    --app-primary: #0f766e;
    --app-primary-dark: #115e59;
    --app-accent: #2563eb;
    --app-warn: #b7791f;
    --app-danger: #b42318;
    --app-shadow: 0 14px 40px rgba(31, 41, 55, 0.10);
    --app-radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-padding-top: 92px;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(37, 99, 235, 0.04) 280px, transparent 520px),
        var(--app-bg);
    color: var(--app-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

.navbar {
    min-height: 64px;
    background: rgba(18, 28, 38, 0.94) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.20);
    backdrop-filter: blur(14px);
}

.navbar .container-fluid {
    gap: 12px;
}

.navbar-brand {
    font-weight: 800;
    letter-spacing: 0;
}

.navbar img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    padding: 4px;
}

.navbar .btn {
    min-height: 36px;
    border-radius: 8px;
}

.container {
    max-width: 1180px;
}

h2 {
    font-size: clamp(1.25rem, 2vw, 1.75rem);
    font-weight: 800;
    letter-spacing: 0;
    margin-bottom: 14px;
}

.container.mt-4:first-of-type {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    padding: 18px;
}

.container.mt-4:first-of-type > .d-flex {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start !important;
    margin-bottom: 16px !important;
}

.btn {
    border-radius: 8px;
    font-weight: 700;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: var(--app-accent);
    border-color: var(--app-accent);
}

.btn-success {
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-success:hover {
    background: var(--app-primary-dark);
    border-color: var(--app-primary-dark);
}

.btn-outline-warning {
    color: #7a4a00;
    border-color: #d7a034;
    background: #fff8e6;
}

.btn-outline-secondary {
    color: #334155;
    border-color: #cbd5e1;
    background: #f8fafc;
}

.form-control,
.form-select,
select.form-control {
    min-height: 44px;
    border-radius: 8px;
    border-color: var(--app-border);
    color: var(--app-text);
}

.form-control:focus,
select.form-control:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.form-label,
label {
    color: #364456;
    font-size: 0.86rem;
    font-weight: 700;
    margin-bottom: 5px;
}

#formRegistroBloque {
    background: var(--app-surface-2) !important;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius) !important;
    box-shadow: none !important;
    margin-top: 10px !important;
}

.almacen-wrapper {
    aspect-ratio: 16 / 9 !important;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background-color: #d4d8dd;
    box-shadow: var(--app-shadow), inset 0 0 0 9999px rgba(255, 255, 255, 0.18) !important;
}

.almacen-grid {
    gap: 5px;
    padding: 10px;
}

.square {
    margin: 0 !important;
    border: 1px solid rgba(15, 23, 42, 0.20) !important;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.72) !important;
    color: #1f2937 !important;
    font-size: clamp(9px, 1.1vw, 12px) !important;
    font-weight: 800 !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
    min-width: 0;
    min-height: 0;
}

.square:hover {
    transform: translateY(-1px);
    background: #ffffff !important;
    border-color: var(--app-primary) !important;
}

.square.ocupada {
    background: #0f766e !important;
    border-color: #0f766e !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.18), 0 8px 18px rgba(15, 118, 110, 0.22) !important;
}

.square.ocupada:hover {
    background: #115e59 !important;
    border-color: #115e59 !important;
}

.container.mt-4.mb-4 {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    padding: 18px;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.modal-content {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.modal-header {
    border-bottom-color: var(--app-border);
    background: #f8fafc;
}

.modal-title {
    font-weight: 800;
}

.card {
    border-color: var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: none;
}

.table {
    --bs-table-bg: transparent;
    vertical-align: middle;
}

.table thead th {
    background: #eef2f6;
    color: #334155;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0;
}

.table-bordered > :not(caption) > * {
    border-color: var(--app-border);
}

.load-group-card {
    border: 1px solid var(--app-border) !important;
    border-radius: var(--app-radius) !important;
    background: #f8fafc !important;
}

.alert {
    border-radius: var(--app-radius);
}

.bundle-container {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 12px;
    margin: 0 0 14px;
    background: #fff;
}

.bg-dark {
    background: #17202b !important;
    border-radius: var(--app-radius) !important;
}

body.bg-light {
    background:
        linear-gradient(180deg, rgba(15, 118, 110, 0.12), rgba(37, 99, 235, 0.06)),
        var(--app-bg) !important;
}

body.bg-light .card {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
}

@media (max-width: 768px) {
    .navbar.fixed-top {
        position: sticky !important;
        min-height: auto;
        padding: 8px 0;
    }

    .navbar .container-fluid {
        align-items: flex-start;
    }

    .navbar-brand {
        font-size: 1rem;
        max-width: 150px;
        white-space: normal;
        line-height: 1.1;
    }

    .navbar .ms-auto {
        order: 3;
        width: 100%;
        justify-content: space-between;
        font-size: 0.82rem;
        gap: 8px !important;
    }

    .navbar img {
        width: 36px;
        height: 36px;
    }

    body > div[style*="height"] {
        display: none;
    }

    .container {
        width: 100%;
        padding-left: 10px;
        padding-right: 10px;
    }

    .container.mt-4:first-of-type,
    .container.mt-4.mb-4 {
        padding: 12px;
        margin-top: 12px !important;
    }

    .container.mt-4:first-of-type > .d-flex .btn {
        flex: 1 1 calc(50% - 8px);
        margin: 0 !important;
        min-width: 138px;
    }

    #formRegistroBloque {
        padding: 12px !important;
    }

    #formRegistroBloque .col-md-5,
    #formRegistroBloque .col-md-2 {
        width: 100%;
    }

    .almacen-wrapper {
        aspect-ratio: auto !important;
        min-height: 430px;
        overflow-x: auto !important;
    }

    .almacen-grid {
        min-width: 760px;
        min-height: 410px;
    }

    .square {
        font-size: 11px !important;
        min-height: 54px;
    }

    .modal-dialog {
        margin: 8px;
    }

    .modal-dialog.modal-xl {
        max-width: calc(100% - 16px);
    }

.modal-body {
        padding: 12px;
        overflow-x: auto;
    }

    .table-responsive {
        border: 1px solid var(--app-border);
        border-radius: var(--app-radius);
    }

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