.black-border {
    border: 2px solid #000000 !important;
}

.black-border-sm {
    border: 1px solid #000000 !important;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.reading-rule {
    position: absolute;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(234, 179, 8, 0.3);
    border-top: 2px solid #ca8a04;
    border-bottom: 2px solid #ca8a04;
    pointer-events: none;
    z-index: 20;
}

#invoiceModal.side-mode {
    justify-content: flex-start;
    gap: 0.75rem;
}

#invoiceModal.side-mode>div:first-child {
    flex: 0 0 42rem;
    width: 42rem;
}

@media (max-width: 639px) {
    .tax-edit-only {
        display: none !important;
    }

    /* En tablas de ancho fijo, una celda con display: none sigue reservando su ancho:
       se deja la columna con ancho cero para que las demás ocupen todo el espacio. */
    th.tax-edit-only,
    td.tax-edit-only {
        display: table-cell !important;
        width: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: hidden;
        visibility: hidden;
    }
}

#invoiceForm input:disabled,
#invoiceForm select:disabled {
    opacity: 1;
    background-color: #fff;
}

#desktopTableBody tr {
    cursor: pointer;
    scroll-margin-top: 3rem;
    scroll-margin-bottom: 0.5rem;
}

tr.admin-row {
    cursor: pointer;
    scroll-margin-top: 2.5rem;
}

#desktopTableBody tr.selected-row,
tr.admin-row.selected-row {
    background-color: #dbeafe;
}

#desktopTableBody tr.selected-row td:first-child,
tr.admin-row.selected-row td:first-child {
    box-shadow: inset 4px 0 0 #000;
}

.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
    cursor: pointer;
}

/* Encabezado de hasta 2 líneas (centrado verticalmente si es una sola). */
.th-2-lineas {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: normal;
    text-align: inherit;
    line-height: 1.15rem;
}

.sort-btn:hover {
    text-decoration: underline;
}

.sort-ind {
    font-size: 0.7em;
    opacity: 0.5;
}

.sort-ind.active {
    opacity: 1;
}

.clear-btn {
    display: none;
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.3rem;
    height: 1.3rem;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    color: #475569;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.clear-btn:hover {
    background: #e2e8f0;
    color: #000;
}

/* Buscadores para elegir o agregar elementos (clase Buscador): se ven como un select, con un
   triángulo hacia abajo, hasta que se hace clic; con el foco el triángulo apunta hacia arriba. */
input.buscador-select {
    cursor: pointer;
    padding-right: 1.6rem !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23334155'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 0.6rem 0.36rem;
}

input.buscador-select:has(+ .clear-btn) {
    padding-right: 3.2rem !important;
}

input.buscador-select + .clear-btn {
    right: 1.6rem;
}

input.buscador-select::placeholder {
    color: #000;
    opacity: 1;
}

input.buscador-select:focus::placeholder {
    color: transparent;
}

input.buscador-select:focus {
    cursor: text;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 6h10L5 0z' fill='%23334155'/%3E%3C/svg%3E");
}

input.buscador-select:disabled {
    cursor: not-allowed;
}

input:not(:placeholder-shown)+.clear-btn {
    display: flex;
}

@media (max-width: 639px) {
    input:not(:placeholder-shown)+.clear-btn {
        display: none;
    }
}

#desktopTableBody td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 640px) {
    #appContainer {
        height: 100vh;
        height: 100dvh;
        min-height: 0 !important;
    }

    #appContainer>main {
        min-height: 0;
        overflow-y: auto;
    }

    #recordsContainer {
        min-height: 14rem;
    }

    #recordsContainer>div.overflow-x-auto {
        overflow-y: auto;
        min-height: 0;
    }

    #recordsContainer thead th {
        position: sticky;
        top: 0;
        z-index: 1;
        background: #000;
        color: #fff;
        box-shadow: none;
    }
}

@media (max-width: 639px) {
    #appContainer {
        height: 100vh;
        height: 100dvh;
        min-height: 0 !important;
    }

    #appContainer>main {
        min-height: 0;
        overflow: hidden;
    }

    #recordsContainer {
        min-height: 0;
    }

    #mobileCardContainer {
        overflow-y: auto;
        min-height: 0;
    }
}

.overlay {
    position: fixed;
    inset: 0;
    cursor: wait;
}

.overlay.hidden {
    display: none !important;
}

.solidgray {
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: spinner-fade 0.2s ease 0.12s both;
}

/* Spinner de la carga de la página: fondo blanco sólido para que no se vea la página vacía. */
#spinner-over.spinner-inicial {
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    animation: none;
}

#spinner-over.spinner-inicial .spinner-text {
    color: #0f172a;
    text-shadow: none;
}

#spinner-over {
    z-index: 2147483000;
}

.spinner-text {
    position: fixed;
    top: calc(50% + 50px);
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
}

.spinner-wrapper {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(0, 0, 0, 0.35);
    border-radius: 50%;
    z-index: 9999;
}

.spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #3498db;
    border-radius: 50%;
    width: 100%;
    height: 100%;
    animation: spin 1s linear infinite;
}

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

@keyframes spinner-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#formTaxSearch:disabled {
    border-color: #d1d5db !important;
}

#formTaxSearch:disabled::placeholder {
    color: #4b5563;
    opacity: 1;
}

#toast {
    z-index: 2147483647 !important;
}

@media (min-width: 640px) {
    .menu-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.sugerencia:hover {
    background-color: #f1f5f9;
}

.sugerencia.sugerencia-activa {
    background-color: #dbeafe;
    box-shadow: inset 4px 0 0 #000;
}

.lineas-2,
.lineas-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    overflow-wrap: anywhere;
}

.lineas-2 {
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.lineas-3 {
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.texto-verde {
    color: #15803d;
}

.btn-presupuestar {
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (max-width: 639px) {
    .btn-presupuestar {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

.btn-libre {
    background-color: #6F42C1;
}

.btn-libre:hover {
    background-color: #59339D;
}

.pres-tag-libre {
    display: inline-block;
    padding: 0 0.35rem;
    border-radius: 0.375rem;
    background-color: #6F42C1;
    color: #fff;
    font-size: 0.75rem;
    line-height: 1.25rem;
    vertical-align: 0.1rem;
}

.pres-tabla {
    height: 225px;
    overflow-y: auto;
    background-color: #e2e8f0;
}

.pres-fila {
    background-color: #fff;
}

.pres-mitad {
    flex: 1 1 0;
    min-width: 0;
}

.pres-num {
    font-size: 1rem;
    line-height: 1.4rem;
}

.pres-btn-icono {
    width: 1.75rem;
}

.pres-totales {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0.5rem;
}

.pres-totales-label {
    font-weight: 700;
    color: #000;
    text-transform: uppercase;
    white-space: nowrap;
}

@media (max-width: 639px) {
    .pres-tabla {
        height: max(300px, 45vh);
    }

    .pres-totales {
        column-gap: 0.5rem;
    }

    .pres-totales-label {
        font-size: 0.875rem;
    }

    .pres-total-input {
        font-size: 1.1rem;
    }
}

#presupuestoSugerencias .sugerencia {
    height: 4rem;
}

/* Opciones de hasta 2 líneas, con alto mínimo de 2 líneas (una sola línea queda centrada). */
#servicioServSugerencias .sugerencia {
    min-height: 3.5rem;
}

.sugerencia-2-lineas {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.serv-costo {
    width: 11rem;
}

@media (max-width: 639px) {
    .serv-costo {
        width: 8.5rem;
    }
}

.car-th {
    cursor: pointer;
    user-select: none;
}

.car-th:hover {
    background-color: #1e293b;
}

.car-th.car-th-activa {
    background-color: #1d4ed8;
}

.campos-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.col-th {
    position: relative;
}

.col-menu-btn {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 0.25rem;
    line-height: 1;
    font-size: 0.8rem;
    color: #e2e8f0;
}

.col-menu-btn:hover,
.col-menu-btn:focus {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.25);
}

.col-resize {
    position: absolute;
    top: 0;
    right: -3px;
    width: 7px;
    height: 100%;
    cursor: col-resize;
    z-index: 2;
}

.col-resize:hover {
    background-color: rgba(59, 130, 246, 0.8);
}

body.col-arrastrando,
body.col-arrastrando * {
    cursor: col-resize !important;
    user-select: none !important;
}

.col-menu {
    position: fixed;
    z-index: 3000;
    min-width: 15rem;
    background: #fff;
    border: 2px solid #000;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    padding: 0.25rem 0;
}

.col-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #000;
}

.col-menu-item:hover:not(:disabled) {
    background-color: #f1f5f9;
}

.col-menu-item:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.col-menu-ico {
    width: 1rem;
    text-align: center;
    color: #475569;
}

.col-menu-sep {
    height: 1px;
    margin: 0.25rem 0;
    background-color: #e2e8f0;
}

/* Modales propios (no app-modal): con scroll y centrados con márgenes automáticos, así si son más
   altos que la pantalla se pueden recorrer desde arriba en cualquier navegador. */
.modal-overlay {
    overflow-y: auto;
    align-items: flex-start !important;
}

.modal-overlay > * {
    margin-top: auto !important;
    margin-bottom: auto !important;
}

.pl-tag {
    display: inline-block;
    margin-right: 0.35rem;
    padding: 0 0.35rem;
    border-radius: 0.375rem;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    line-height: 1.15rem;
    vertical-align: 0.1rem;
}

.pl-tag-fija {
    background-color: #EA9415;
}

.pl-tag-union {
    background-color: #6F42C1;
}

tr.admin-row.pl-fila-fija:not(.selected-row) {
    background-color: #fff7ed;
}

.pl-btn-accion {
    width: 6.5rem;
}

/* Tablas con selección múltiple (Shift/Alt/Ctrl + clic): sin seleccionar texto al hacer clic. */
#plantillaTbody tr,
#plantillaUnionTbody tr,
#servPlantillaFilasTbody tr {
    user-select: none;
}

/* Inputs solo de dinero: símbolo de moneda a la izquierda. */
.con-moneda {
    position: relative;
}

.con-moneda::before {
    content: '$';
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    color: #475569;
    pointer-events: none;
}

.con-moneda > input {
    padding-left: 1.5rem !important;
}

/* En celular, los inputs dentro de tablas se ven como texto: sin borde ni fondo. */
@media (max-width: 639px) {
    table input[class] {
        border-color: transparent !important;
        background: transparent !important;
    }
}

/* Tablas de vista previa: alto fijo con scroll propio (el panel no se desplaza), encabezado fijo
   y fila de totales fija al pie. */
.scroll-vista {
    overflow: auto;
    max-height: calc(100vh - 15rem);
}

.tabla-vista-pie td {
    position: sticky;
    bottom: 0;
    z-index: 1;
    background: #f1f5f9;
    border-top: 1px solid #000;
}

/* Al moverse con las flechas, la fila seleccionada deja ver media fila más en esa dirección
   (arriba, además, la altura del encabezado fijo), para indicar que hay más filas. */
#desktopTableBody tr {
    scroll-margin-top: 5rem;
    scroll-margin-bottom: 1.85rem;
}

[id$="AdminBody"] tr {
    scroll-margin-top: 1.25rem;
    scroll-margin-bottom: 1.25rem;
}

/* Flechas del desplazamiento libre (sobre los bordes del modal de un registro). */
.desplazamiento-flecha {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: #000;
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.desplazamiento-flecha.hidden {
    display: none;
}

.desplazamiento-flecha:hover:not(:disabled) {
    background: #1e293b;
}

.desplazamiento-flecha:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#toast.toast-exito {
    background: #15803d;
}

#toast.toast-exito svg {
    color: #fff;
}

@media (max-width: 639px) {
    /* Servicios incluidos en celular: sin ID, el costo con ancho fijo y la descripción ocupa el resto. */
    #servicioIncSeccion th.inc-desc {
        width: auto;
    }

    #servicioIncSeccion th.inc-costo {
        width: 8.5rem;
    }
}

/* Mientras no corre el script de los componentes, la página no se muestra: así no se ven por un
   instante los modales sin armar ni la página sin el spinner de carga. */
body:has(app-comunes:not(:defined)) > :not(app-comunes) {
    visibility: hidden;
}

app-modal:not(:defined),
form-modal:not(:defined) {
    display: none !important;
}

/* Aparición suave de los modales: el fondo se funde y la ventana sube apenas mientras aparece. */
@keyframes modal-fondo {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-caja {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

[id$="Modal"]:not(.hidden) {
    animation: modal-fondo 0.16s ease-out;
}

[id$="Modal"]:not(.hidden) > .rounded-2xl {
    animation: modal-caja 0.2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    [id$="Modal"]:not(.hidden),
    [id$="Modal"]:not(.hidden) > .rounded-2xl {
        animation: none;
    }
}

/* Buscadores: las opciones en letra normal y, al escribir, las coincidencias en negrita. */
.sugerencia [data-resaltar] b {
    font-weight: 800;
}

/* Presupuesto: cantidad de cada ítem (texto), lo más angosta posible, a la izquierda de la descripción. */
.pres-cantidad {
    min-width: 1.75rem;
    padding: 0.05rem 0.35rem;
    border-radius: 0.5rem;
    background-color: #FFE570;
    color: #000;
    text-align: center;
}

/* Modal de ítem: el importe resultante, 2px más grande que la operación. */
.pres-item-resultado {
    font-size: calc(1rem + 2px);
}

/* Descripción del ítem: plegada, en 1 línea con "Ver más" al final; desplegada, el texto completo y
   "Ver menos" a continuación, separado por un pequeño espacio. */
#presItemDescCaja.desc-plegada {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

#presItemDescCaja.desc-plegada #presItemDescTexto {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#presItemDescCaja.desc-plegada #presItemVerMas {
    flex-shrink: 0;
}

#presItemDescCaja:not(.desc-plegada) #presItemDescTexto {
    overflow-wrap: anywhere;
}

#presItemDescCaja:not(.desc-plegada) #presItemVerMas {
    margin-left: 0.4rem;
}

/* Inicio en celular: ícono a la izquierda y, a su derecha, el título y la descripción (hasta 2 líneas). */
@media (max-width: 639px) {
    .menu-tarjeta {
        display: grid !important;
        grid-template-columns: auto 1fr;
        column-gap: 1rem;
        row-gap: 0.15rem;
        align-items: center;
        padding: 1rem !important;
    }

    .menu-icono {
        grid-row: span 2;
    }

    .menu-titulo {
        font-size: 1.35rem;
        line-height: 1.75rem;
    }

    .menu-desc {
        text-align: left !important;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        line-height: 1.3rem;
    }
}

@media (max-width: 639px) {
    .pres-fila {
        cursor: pointer;
    }
}

/* Dato de solo lectura con aspecto de campo (borde negro redondeado y fondo celeste). */
.campo-lectura {
    padding: 0.5rem 0.75rem;
    border: 1px solid #000;
    border-radius: 0.75rem;
    background-color: #eff6ff;
}

/* Texto que se escribe sin mostrarse (token de GitHub), sin ser un campo de contraseña. */
.texto-oculto {
    -webkit-text-security: disc;
}

/* Buscador del presupuesto en celular: lugar para 4 opciones y el resto con scroll. */
@media (max-width: 639px) {
    #presupuestoSugerencias {
        max-height: calc(16rem + 2px) !important;
    }
}

/* Login en celular: con el encabezado en horizontal:
   el ícono a la izquierda y, a su derecha, el título y el subtítulo. */
@media (max-width: 639px) {
    .login-caja {
        padding: 1rem !important;
    }

    .login-cabecera {
        display: grid;
        grid-template-columns: auto 1fr;
        column-gap: 0.75rem;
        align-items: center;
        text-align: left !important;
        margin-bottom: 1rem !important;
    }

    .login-icono {
        grid-row: span 2;
        width: 3rem !important;
        height: 3rem !important;
        margin-bottom: 0 !important;
    }

    .login-titulo {
        font-size: 1.35rem;
        line-height: 1.6rem;
    }

    .login-subtitulo {
        margin-top: 0 !important;
        font-size: 0.9rem;
    }
}

/* Pies de tabla en celular: sin el texto de registros ("1-10 de 36"); los botones de acción a la
   izquierda y el paginador a la derecha. */
@media (max-width: 639px) {
    .info-registros {
        display: none !important;
    }

    .info-registros + *,
    #paginationControls {
        margin-left: auto;
    }

    .pie-acciones {
        flex: 1;
        justify-content: space-between;
    }
}
