/* ==========================================================
   ABERTURAS NORTE
   Tema oscuro global
   Compatible con Blazor Web App .NET 10
   ========================================================== */

:root {
    color-scheme: dark;
    /* Fondos */
    --app-bg: #11151b;
    --surface: #1c2430;
    --surface-hover: #242e3c;
    --surface-elevated: #202a37;
    /* Navegación */
    --sidebar-bg: #171d26;
    --sidebar-hover: #263444;
    --sidebar-active: #2c465e;
    /* Colores principales */
    --primary: #4ea1d3;
    --primary-hover: #6ab5e2;
    --primary-soft: rgba(78, 161, 211, .14);
    /* Texto */
    --text-main: #e7edf5;
    --text-secondary: #a6b3c2;
    --text-muted: #8291a3;
    /* Bordes */
    --border: #303b49;
    --border-soft: #283340;
    /* Estados */
    --success: #39b980;
    --success-bg: rgba(57, 185, 128, .12);
    --danger: #f07178;
    --danger-bg: rgba(240, 113, 120, .12);
    --warning: #e8bd67;
    --warning-bg: rgba(232, 189, 103, .12);
    /* Dimensiones */
    --sidebar-width: 250px;
    --header-height: 76px;
    /* Otros */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 5px 18px rgba(0, 0, 0, .12);
}

/* ==========================================================
   RESET Y CONFIGURACIÓN GENERAL
   ========================================================== */

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--app-bg);
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--app-bg);
    color: var(--text-main);
    font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
}

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

a {
    color: var(--primary);
    text-decoration: none;
}

    a:hover {
        color: var(--primary-hover);
    }

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-main);
    font-weight: 650;
    letter-spacing: -.3px;
}

p {
    color: var(--text-secondary);
}

::selection {
    color: #fff;
    background: #326e95;
}

/* ==========================================================
   ESTRUCTURA PRINCIPAL
   ========================================================== */

.app-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

/* ==========================================================
   MENÚ LATERAL
   ========================================================== */

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    color: var(--text-main);
    border-right: 1px solid var(--border-soft);
    z-index: 1000;
    transition: transform .25s ease, width .25s ease;
}

.sidebar-brand {
    min-height: var(--header-height);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-soft);
}

.brand-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4ea1d3, #3476a0);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 11px;
    color: white;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -.5px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.brand-name {
    color: #f0f5fa;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1.3px;
}

.brand-subtitle {
    color: var(--text-muted);
    font-size: 10px;
    letter-spacing: 3px;
}

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

.sidebar-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 10px;
    scrollbar-width: thin;
    scrollbar-color: #364453 transparent;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-title {
    padding: 19px 12px 7px;
    color: #7f90a4;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.15px;
}

.sidebar-link {
    min-height: 42px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 11px;
    color: #b9c5d2;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 450;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

    .sidebar-link:hover {
        color: #fff;
        background: var(--sidebar-hover);
    }

    .sidebar-link.active {
        color: #eaf6ff;
        background: var(--sidebar-active);
        border-color: rgba(78, 161, 211, .18);
        font-weight: 600;
    }

.nav-icon {
    width: 20px;
    flex-shrink: 0;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    color: #90a8bd;
    font-size: 17px;
}

.sidebar-link.active .nav-icon {
    color: var(--primary);
}

.nav-link-disabled {
    opacity: .45;
    cursor: default;
}

    .nav-link-disabled:hover {
        color: #b9c5d2;
        background: transparent;
    }

.nav-coming {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 9px;
    white-space: nowrap;
}

/* ==========================================================
   PIE DEL MENÚ
   ========================================================== */

.sidebar-footer {
    min-height: 53px;
    padding: 15px 18px;
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-soft);
    font-size: 11px;
}

.sidebar-status {
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 9px rgba(57, 185, 128, .3);
}

/* ==========================================================
   ÁREA PRINCIPAL
   ========================================================== */

.app-main {
    width: calc(100% - var(--sidebar-width));
    height: 100vh;
    height: 100dvh;
    min-width: 0;
    min-height: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==========================================================
   ENCABEZADO
   ========================================================== */

.app-header {
    flex: 0 0 auto;
    min-height: var(--header-height);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.header-eyebrow {
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.2px;
}

.header-title {
    margin-top: 2px;
    color: var(--text-main);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.4px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-environment {
    padding: 6px 9px;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid rgba(78, 161, 211, .18);
    border-radius: 5px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .5px;
}

/* ==========================================================
   BOTÓN DE MENÚ MÓVIL
   ========================================================== */

.mobile-menu-button {
    display: none;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    background: var(--surface-hover);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

    .mobile-menu-button:hover {
        background: var(--sidebar-active);
    }

    .mobile-menu-button svg {
        width: 21px;
        height: 21px;
    }

/* Fondo que aparece detrás del menú móvil */

.mobile-menu-backdrop {
    display: none;
}

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

.app-content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    padding: 28px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.app-footer {
    flex: 0 0 auto;
    padding: 15px 28px;
    color: var(--text-muted);
    background: var(--surface);
    border-top: 1px solid var(--border-soft);
    font-size: 11px;
}

/* ==========================================================
   TARJETAS
   ========================================================== */

.card {
    color: var(--text-main);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.card-header {
    color: var(--text-main);
    background: var(--surface-elevated);
    border-bottom: 1px solid var(--border);
}

.card-footer {
    color: var(--text-muted);
    background: var(--surface-elevated);
    border-top: 1px solid var(--border);
}

.card-body {
    color: var(--text-main);
}

/* ==========================================================
   FORMULARIOS
   ========================================================== */

.form-label {
    display: block;
    margin-bottom: 7px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 650;
}

.form-control,
.form-select {
    width: 100%;
    min-height: 41px;
    color: var(--text-main);
    background-color: #151c25;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

    .form-control::placeholder {
        color: #738296;
        opacity: 1;
    }

    .form-control:focus,
    .form-select:focus {
        color: var(--text-main);
        background-color: #18212c;
        border-color: var(--primary);
        box-shadow: 0 0 0 .2rem rgba(78, 161, 211, .13);
        outline: none;
    }

    .form-select option {
        color: var(--text-main);
        background: var(--surface);
    }

    .form-control:disabled,
    .form-select:disabled {
        color: var(--text-muted);
        background: var(--surface-elevated);
        opacity: .7;
    }

.form-check-input {
    background-color: #151c25;
    border-color: #536174;
}

    .form-check-input:checked {
        background-color: var(--primary);
        border-color: var(--primary);
    }

.form-check-label {
    color: var(--text-secondary);
}

.form-text {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 11px;
}

.validation-message {
    margin-top: 5px;
    color: var(--danger);
    font-size: 12px;
}

.validation-summary-errors {
    color: var(--danger);
}

.input-validation-error {
    border-color: var(--danger) !important;
}

/* ==========================================================
   BOTONES
   ========================================================== */

.btn {
    min-height: 37px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 650;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.btn-primary {
    color: #fff;
    background: #347fae;
    border-color: #347fae;
}

    .btn-primary:hover,
    .btn-primary:focus {
        color: #fff;
        background: #286b96;
        border-color: #286b96;
    }

.btn-secondary {
    color: var(--text-main);
    background: #354354;
    border-color: #354354;
}

    .btn-secondary:hover {
        color: #fff;
        background: #435469;
        border-color: #435469;
    }

.btn-light {
    color: var(--text-main);
    background: #2a3543;
    border-color: var(--border);
}

    .btn-light:hover {
        color: #fff;
        background: #354253;
        border-color: #46576b;
    }

.btn-outline-primary {
    color: var(--primary);
    background: transparent;
    border-color: #3c779d;
}

    .btn-outline-primary:hover {
        color: #fff;
        background: #286b96;
        border-color: #286b96;
    }

.btn-outline-secondary {
    color: #b4c1ce;
    background: transparent;
    border-color: #536174;
}

    .btn-outline-secondary:hover {
        color: #fff;
        background: #354354;
        border-color: #536174;
    }

.btn-outline-danger {
    color: var(--danger);
    border-color: rgba(240, 113, 120, .5);
}

    .btn-outline-danger:hover {
        color: #fff;
        background: #a93d48;
        border-color: #a93d48;
    }

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* ==========================================================
   TABLAS
   ========================================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    margin-bottom: 0;
    color: var(--text-secondary);
    border-color: var(--border);
    vertical-align: middle;
}

    .table > :not(caption) > * > * {
        padding: 13px 15px;
        color: inherit;
        background-color: transparent;
        border-bottom-color: var(--border);
        box-shadow: none;
    }

    .table thead th {
        color: #a5b5c6;
        background: #202936;
        font-size: 10px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: .55px;
        white-space: nowrap;
    }

    .table tbody td {
        color: var(--text-secondary);
        font-size: 12px;
    }

    .table tbody strong {
        color: var(--text-main);
    }

.table-hover > tbody > tr:hover > * {
    color: var(--text-main);
    background-color: var(--surface-hover);
}

.table-light,
.table-light > th,
.table-light > td {
    color: var(--text-main);
    background: #202936;
}

/* ==========================================================
   BADGES
   ========================================================== */

.badge {
    padding: 6px 9px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 750;
}

.text-bg-success {
    color: #69ddb0 !important;
    background: var(--success-bg) !important;
}

.text-bg-secondary {
    color: #b0bdca !important;
    background: #303b49 !important;
}

.text-bg-danger {
    color: #ff9ba1 !important;
    background: var(--danger-bg) !important;
}

.text-bg-warning {
    color: #f3d28e !important;
    background: var(--warning-bg) !important;
}

/* ==========================================================
   ALERTAS
   ========================================================== */

.alert {
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.alert-success {
    color: #79ddb5;
    background: var(--success-bg);
    border-color: rgba(57, 185, 128, .25);
}

.alert-danger {
    color: #ff9ba1;
    background: var(--danger-bg);
    border-color: rgba(240, 113, 120, .25);
}

.alert-warning {
    color: #f3d28e;
    background: var(--warning-bg);
    border-color: rgba(232, 189, 103, .25);
}

.alert-info {
    color: #94d4f7;
    background: var(--primary-soft);
    border-color: rgba(78, 161, 211, .25);
}

.alert .btn-close {
    filter: invert(1) grayscale(100%);
}

/* ==========================================================
   MODALES
   ========================================================== */

.modal {
    padding: 16px;
    overflow-y: auto;
}

.modal-dialog {
    width: 100%;
    max-width: 560px;
    margin: 24px auto;
}

    .modal-dialog.modal-lg {
        max-width: 800px;
    }

.modal-content {
    color: var(--text-main);
    background: var(--surface);
    border: 1px solid #3b4858;
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 60px rgba(0, 0, 0, .45);
    overflow: hidden;
}

.modal-header,
.modal-footer {
    padding: 16px 20px;
    background: var(--surface);
    border-color: var(--border);
}

.modal-title {
    color: var(--text-main);
    font-size: 16px;
    font-weight: 700;
}

.modal-body {
    padding: 22px;
}

.modal-header .btn-close {
    filter: invert(1) grayscale(100%);
    opacity: .75;
}

    .modal-header .btn-close:hover {
        opacity: 1;
    }

/* ==========================================================
   UTILIDADES
   ========================================================== */

.text-muted {
    color: var(--text-muted) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.bg-white {
    background-color: var(--surface) !important;
}

.border,
.border-top,
.border-bottom {
    border-color: var(--border) !important;
}

.shadow-sm {
    box-shadow: var(--shadow-card) !important;
}

hr {
    border-color: var(--border);
    opacity: 1;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ==========================================================
   TABLETAS
   ========================================================== */

@media (max-width: 1000px) {
    :root {
        --sidebar-width: 220px;
    }

    .app-content {
        padding: 22px;
    }

    .app-header {
        padding: 14px 22px;
    }

    .app-footer {
        padding: 14px 22px;
    }
}

/* ==========================================================
   MÓVILES
   ========================================================== */

@media (max-width: 700px) {
    .app-sidebar {
        width: min(290px, 86vw);
        transform: translateX(-105%);
        box-shadow: none;
    }

        .app-sidebar.mobile-open {
            transform: translateX(0);
            box-shadow: 12px 0 35px rgba(0, 0, 0, .4);
        }

    .app-main {
        width: 100%;
        margin-left: 0;
    }

    .app-header {
        min-height: 66px;
        padding: 11px 14px;
        gap: 10px;
    }

    .header-left {
        gap: 10px;
    }

    .mobile-menu-button {
        display: inline-flex;
    }

    .header-eyebrow {
        font-size: 8px;
    }

    .header-title {
        font-size: 15px;
    }

    .header-environment {
        padding: 5px 7px;
        font-size: 8px;
    }

    .app-content {
        padding: 18px 12px;
    }

    .app-footer {
        padding: 13px 14px;
        font-size: 10px;
    }

    .card {
        border-radius: 8px;
    }

    .card-body {
        padding: 14px;
    }

    .table > :not(caption) > * > * {
        padding: 11px 12px;
    }

    .modal {
        padding: 8px;
    }

    .modal-dialog,
    .modal-dialog.modal-lg {
        max-width: none;
        margin: 8px auto;
    }

    .modal-content {
        border-radius: 10px;
    }

    .modal-header,
    .modal-footer {
        padding: 13px 15px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

        .modal-footer .btn {
            flex: 1;
        }
}

/* Fondo detrás del menú */

.mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .62);
    z-index: 900;
}

/* ==========================================================
   ACCESIBILIDAD
   ========================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}
/* =====================================================
   LOGIN - ABERTURAS NORTE
   ===================================================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top right, rgba(78,161,211,.12), transparent 35%), var(--app-bg);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 38px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-card);
}

.login-brand {
    text-align: center;
    margin-bottom: 25px;
}

.login-icon {
    width: 65px;
    height: 65px;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 16px;
    font-size: 30px;
}

.login-brand h1 {
    font-size: 23px;
    margin: 0;
}

.login-brand p,
.login-description {
    color: var(--text-secondary);
    margin-top: 5px;
}

.login-divider {
    height: 1px;
    background: var(--border);
    margin-bottom: 25px;
}

.login-card h2 {
    font-size: 21px;
}

.login-card .form-control {
    min-height: 46px;
    background: var(--app-bg);
    color: var(--text-main);
    border: 1px solid var(--border);
}

    .login-card .form-control:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-soft);
    }

.login-card .btn-primary {
    min-height: 46px;
    margin-top: 10px;
}

.login-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 28px;
}

@media(max-width: 480px) {
    .login-card {
        padding: 25px;
    }
}
/* ==========================================================
   PRESUPUESTOS - AJUSTES VISUALES GLOBALES
   Dock móvil oscuro y panel de materiales integrado al tema
   ========================================================== */

/* Barra fija inferior en móviles */
@media (max-width: 1199.98px) {
    .presupuesto-mobile-dock {
        background: var(--surface) !important;
        color: var(--text-main) !important;
        border-top: 1px solid var(--border) !important;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, .38) !important;
        padding-bottom: calc(.65rem + env(safe-area-inset-bottom));
        -webkit-backdrop-filter: blur(14px);
        backdrop-filter: blur(14px);
    }

        .presupuesto-mobile-dock .presupuesto-mobile-summary-button {
            color: var(--text-main) !important;
            background: var(--surface-elevated) !important;
            border-color: var(--border) !important;
        }

            .presupuesto-mobile-dock .presupuesto-mobile-summary-button:hover,
            .presupuesto-mobile-dock .presupuesto-mobile-summary-button:focus {
                color: #fff !important;
                background: var(--surface-hover) !important;
                border-color: var(--primary) !important;
            }

    .presupuesto-mobile-total span {
        color: var(--text-secondary) !important;
    }

    .presupuesto-mobile-total strong {
        color: var(--text-main) !important;
    }

    .presupuesto-mobile-dock .presupuesto-mobile-save-button {
        color: #fff !important;
        background: #347fae !important;
        border-color: #347fae !important;
    }

        .presupuesto-mobile-dock .presupuesto-mobile-save-button:disabled {
            color: #d4dce5 !important;
            opacity: .65;
        }

    /* Resumen desplegable: evitar fondos blancos de Bootstrap */
    .presupuesto-mobile-sheet {
        color: var(--text-main) !important;
        background: var(--surface) !important;
        border-color: var(--border) !important;
    }

        .presupuesto-mobile-sheet .border {
            border-color: var(--border) !important;
        }
}

/* Materiales y terminaciones: eliminar el gris predeterminado de bg-dark */
.presupuesto-page [data-bs-theme="dark"] {
    color: var(--text-main) !important;
    background-color: var(--surface) !important;
    border-color: var(--border) !important;
}

    .presupuesto-page [data-bs-theme="dark"] .text-light,
    .presupuesto-page [data-bs-theme="dark"] .form-label {
        color: var(--text-main) !important;
    }

    .presupuesto-page [data-bs-theme="dark"] .form-control,
    .presupuesto-page [data-bs-theme="dark"] .form-select,
    .presupuesto-page [data-bs-theme="dark"] .bg-dark {
        color: var(--text-main) !important;
        background-color: #151c25 !important;
        border-color: var(--border) !important;
    }

        .presupuesto-page [data-bs-theme="dark"] .form-control:focus,
        .presupuesto-page [data-bs-theme="dark"] .form-select:focus {
            color: var(--text-main) !important;
            background-color: #18212c !important;
            border-color: var(--primary) !important;
            box-shadow: 0 0 0 .2rem rgba(78, 161, 211, .13) !important;
        }

        .presupuesto-page [data-bs-theme="dark"] .form-select option {
            color: var(--text-main) !important;
            background-color: var(--surface) !important;
        }

    .presupuesto-page [data-bs-theme="dark"] .border-secondary {
        border-color: var(--border) !important;
    }


/* ==========================================================
   VISTA FRONTAL DE ABERTURAS - SVG RESPONSIVE
   Evita que el plano sobresalga del ancho disponible en móvil.
   ========================================================== */

.card-body.bg-white.p-2 > .w-100[style*="max-width: 650px"] {
    width: 100%;
    max-width: 100% !important;
    min-width: 0;
    overflow: hidden;
}

    .card-body.bg-white.p-2 > .w-100[style*="max-width: 650px"] > svg {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        margin-inline: auto;
    }

@media (max-width: 700px) {
    .card-body.bg-white.p-2 {
        min-width: 0;
        overflow: hidden;
    }

        .card-body.bg-white.p-2 > .w-100[style*="max-width: 650px"] {
            max-width: 100% !important;
        }
}

/* ==========================================================
   PROVEEDORES - MODAL DE REGISTRO DE ENTRADAS
   Mantiene el encabezado y los botones visibles; los materiales
   se desplazan dentro del cuerpo del formulario.
   ========================================================== */

.proveedor-entrada-modal .modal-dialog {
    height: min(88vh, 860px);
    max-height: calc(100vh - 1.5rem);
    min-height: 0;
    margin-top: .75rem;
    margin-bottom: .75rem;
}

    .proveedor-entrada-modal .modal-dialog .modal-content {
        display: flex;
        flex-direction: column;
        height: 100%;
        max-height: 100%;
        min-height: 0;
        overflow: hidden;
    }

.proveedor-entrada-modal .modal-content .proveedor-entrada-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.proveedor-entrada-modal .proveedor-entrada-form .proveedor-entrada-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.proveedor-entrada-modal .proveedor-entrada-form .proveedor-entrada-footer {
    position: relative;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: .5rem;
    background: var(--surface, #1c2430);
    border-top: 1px solid var(--border, #303b49);
    z-index: 2;
}

@supports (height: 100dvh) {
    .proveedor-entrada-modal .modal-dialog {
        max-height: calc(100dvh - 1.5rem);
        height: min(88dvh, 860px);
    }
}

@media (max-width: 700px) {
    .proveedor-entrada-modal .modal-dialog {
        width: calc(100% - 1rem);
        height: calc(100vh - 1rem);
        max-height: calc(100vh - 1rem);
        margin: .5rem auto;
    }

        .proveedor-entrada-modal .modal-dialog .modal-content {
            height: 100%;
        }

    .proveedor-entrada-modal .proveedor-entrada-form .proveedor-entrada-footer {
        padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
    }
}

@supports (height: 100dvh) {
    @media (max-width: 700px) {
        .proveedor-entrada-modal .modal-dialog {
            height: calc(100dvh - 1rem);
            max-height: calc(100dvh - 1rem);
        }
    }
}

/* Mayor especificidad para prevalecer sobre reglas locales del componente. */
.proveedor-entrada-modal.proveedor-entrada-modal .modal-dialog {
    height: min(88vh, 860px);
    max-height: calc(100vh - 1.5rem);
    min-height: 0;
}

@supports (height: 100dvh) {
    .proveedor-entrada-modal.proveedor-entrada-modal .modal-dialog {
        height: min(88dvh, 860px);
        max-height: calc(100dvh - 1.5rem);
    }
}

@media (max-width: 700px) {
    .proveedor-entrada-modal.proveedor-entrada-modal .modal-dialog {
        height: calc(100vh - 1rem);
        max-height: calc(100vh - 1rem);
        margin: .5rem auto;
    }
}

@supports (height: 100dvh) {
    @media (max-width: 700px) {
        .proveedor-entrada-modal.proveedor-entrada-modal .modal-dialog {
            height: calc(100dvh - 1rem);
            max-height: calc(100dvh - 1rem);
        }
    }
}

/* ==========================================================
   GESTIÓN DE PRESUPUESTOS - LISTADO CON SCROLL INTERNO
   La tabla conserva una altura constante y desplaza sus filas
   sin empujar el pie global de la aplicación.
   ========================================================== */

.gestion-presupuestos-page .presupuestos-listado-scroll {
    height: clamp(280px, 56vh, 580px);
    max-height: clamp(280px, 56vh, 580px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    position: relative;
}

    .gestion-presupuestos-page .presupuestos-listado-scroll table {
        margin-bottom: 0;
    }

    .gestion-presupuestos-page .presupuestos-listado-scroll thead th {
        position: sticky;
        top: 0;
        z-index: 3;
        color: #a5b5c6;
        background: var(--surface-elevated, #202936);
        box-shadow: inset 0 -1px var(--border, #303b49);
    }

@media (max-width: 700px) {
    .gestion-presupuestos-page .presupuestos-listado-scroll {
        height: clamp(240px, 48vh, 420px);
        max-height: clamp(240px, 48vh, 420px);
    }
}


/* ==========================================================
   PROVEEDORES - DETALLE VISUAL DE MATERIALES RECIBIDOS
   Estilos centralizados desde Proveedores.razor.
   ========================================================== */

.proveedor-entrada-observaciones {
    min-height: 2.5rem;
    resize: vertical;
}

.proveedor-entrada-ayuda {
    max-width: 760px;
    color: var(--text-muted, #9eacbd);
    font-size: .76rem;
    line-height: 1.35;
}

/* Cada material queda contenido en una tarjeta independiente. */
.proveedor-entrada-item {
    padding: .95rem;
    margin-bottom: .85rem;
    border: 1px solid var(--border, #303b49);
    border-radius: .7rem;
    background: var(--surface-elevated, #202a37);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025),
                0 3px 12px rgba(0, 0, 0, .10);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.proveedor-entrada-item:hover,
.proveedor-entrada-item:focus-within {
    border-color: rgba(78, 161, 211, .5);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035),
                0 5px 16px rgba(0, 0, 0, .16);
}

.proveedor-entrada-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding-bottom: .65rem;
    margin-bottom: .75rem;
    border-bottom: 1px solid var(--border-soft, #283340);
}

.proveedor-entrada-item-header > span {
    color: var(--text-main, #e7edf5);
    font-size: .9rem;
    font-weight: 700;
}

.proveedor-entrada-material .form-label,
.proveedor-entrada-field .form-label {
    margin-bottom: .35rem;
}

.proveedor-entrada-material .input-group {
    min-width: 0;
}

.proveedor-entrada-material-seleccionado {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    width: fit-content;
    max-width: 100%;
    margin-top: .5rem;
    padding: .3rem .55rem;
    color: var(--success, #35c995);
    background: var(--success-bg, rgba(57, 185, 128, .12));
    border: 1px solid rgba(57, 185, 128, .22);
    border-radius: .45rem;
    font-size: .76rem;
    line-height: 1.3;
}

.proveedor-entrada-fields {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr) minmax(0, 1.25fr);
    gap: .75rem;
    align-items: end;
    margin-top: .85rem;
}

.proveedor-entrada-field {
    min-width: 0;
}

.proveedor-entrada-field .form-control,
.proveedor-entrada-field .form-select {
    min-width: 0;
}

.proveedor-entrada-unidad-precio {
    margin-top: .3rem;
    color: var(--text-muted, #9eacbd);
    font-size: .75rem;
    line-height: 1.25;
}

/* Coincidencias del buscador de materiales. */
.proveedor-material-sugerencias {
    position: relative;
    z-index: 5;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border, #303b49);
    border-radius: 6px;
    background: var(--surface, #1c2430);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .24);
}

.proveedor-material-sugerencia {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 9px 11px;
    color: var(--text-main, #e7edf5);
    text-align: left;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border-soft, #283340);
}

.proveedor-material-sugerencia:last-child {
    border-bottom: 0;
}

.proveedor-material-sugerencia:hover,
.proveedor-material-sugerencia:focus-visible {
    background: var(--surface-hover, #242e3c);
    outline: none;
}

/* Catálogo completo: tabla con scroll y encabezado visible. */
.proveedor-catalogo-tabla {
    max-height: min(55vh, 520px);
    overflow: auto;
    border: 1px solid var(--border, #303b49);
    border-radius: 7px;
}

.proveedor-catalogo-tabla thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.proveedor-catalogo-tabla thead th {
    background: var(--surface-elevated, #202a37);
}

@media (max-width: 700px) {
    .proveedor-entrada-body {
        padding: .85rem;
    }

    .proveedor-entrada-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .65rem;
    }

    .proveedor-entrada-precio {
        grid-column: 1 / -1;
    }

    .proveedor-entrada-item {
        padding: .8rem;
        margin-bottom: .7rem;
    }
}

@media (max-width: 420px) {
    .proveedor-entrada-fields {
        grid-template-columns: minmax(0, 1fr);
    }

    .proveedor-entrada-precio {
        grid-column: auto;
    }
}
