/* ==========================================================================
   Fuente principal cargada desde Google Fonts
   ========================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap");

/* ==========================================================================
   Variables globales y paleta base
   ========================================================================== */
:root {
    --bg: #f7f7f8;
    --bg-panel: #ffffff;
    --border: #b7babd;
    --text: #1f2933;
    --text-muted: #6b7280;
    --accent: #6366f1;
    --accent-strong: #7c3aed;
    --danger: #ef4444;
    --danger_palid: #ff7070;
    --danger-dark: #9b2226;
    --success: #10b981;
    --sidebar-bg: #1f2937;
    --sidebar-border: #111827;
    --sidebar-text: #e5e7eb;
    --sidebar-hover: #4c5a70;
    --color-black: #000000;
    --row-hover: #dbdbdb;
}

/* ==========================================================================
   Reset minimo y tipografia base
   ========================================================================== */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--bg);
    color: var(--text);
    height: 100%;
    overflow: hidden;
}

/* ==========================================================================
   Elementos generales (links, botones, accesibilidad)
   ========================================================================== */
a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    border: none;
    background: transparent;
    cursor: pointer;
}

.sr-only {
    /* Texto solo visible para lectores de pantalla */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Disposicion general de la aplicacion
   ========================================================================== */
.app-shell {
    /* Envoltura general que organiza topbar + contenido */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: 100vh;
    background-color: var(--bg);
}

.workspace {
    /* Zona flexible donde conviven sidebar y contenido */
    flex: 1;
    display: flex;
    min-height: 0;
    height: calc(100vh - 64px);
}

/* Columna fija con navegacion lateral */
.sidebar {
    /* Columna fija que aloja el menu principal */
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem 1rem;
    transition: width 0.3s ease, padding 0.3s ease, transform 0.3s ease;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
}

.sidebar-toggle,
.topbar-toggle {
    /* Botones reutilizados para abrir/cerrar la barra lateral */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 1px solid var(--sidebar-border);
    border-radius: 0.5rem;
    padding: 0.35rem 0.65rem;
    background: #111827;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.sidebar-toggle {
    margin-left: auto;
}

.sidebar-toggle:hover,
.topbar-toggle:hover {
    background: #0b1220;
    border-color: #0b1220;
}

.sidebar-toggle .toggle-icon,
.topbar-toggle .toggle-icon {
    /* Icono basado en texto que rotamos via JS */
    font-size: 2rem;
    font-weight: 700;
    transition: transform 0.25s ease;
    display: inline-block;
}

.is-collapsed .toggle-icon {
    transform: rotate(180deg);
}

/* Lista vertical con todos los enlaces principales */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0;
    list-style: none;
}

/* Bloques con cabecera + subenlaces */
.sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Boton que permite desplegar cada grupo */
.sidebar-group-header {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.6rem;
    color: var(--sidebar-text);
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-group-header:hover {
    background-color: var(--sidebar-hover);
}

.sidebar-group .chevron {
    /* Indicador visual de apertura/cierre */
    margin-left: auto;
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.sidebar-group.open .chevron {
    transform: rotate(90deg);
}

/* Lista de enlaces hijos (oculta por defecto) */
.sidebar-subnav {
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    padding-left: 1.5rem;
}

.sidebar-group.open .sidebar-subnav {
    display: flex;
}

/* Estilo por defecto de los enlaces secundarios */
.sidebar-sublink {
    padding: 0.65rem 0.9rem;
    border-radius: 0.5rem;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-sublink:hover {
    background-color: var(--sidebar-hover);
}

.sidebar-sublink.active {
    background-color: var(--sidebar-hover);
    color: #ffffff;
}

/* Enlaces principales de la navegacion */
.sidebar-link {
    padding: 0.75rem 1rem;
    border-radius: 0.6rem;
    color: var(--sidebar-text);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-link span.icon {
    /* Icono vectorial que acompana a cada etiqueta */
    font-size: 1.1rem;
    color: var(--sidebar-text);
}

.sidebar-link span.label {
    /* Aseguramos que el texto no rompa el layout */
    white-space: nowrap;
}

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

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

/* Contenedor donde se renderiza cada vista */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

/* Barra superior fija con titulo y acciones */
.topbar {
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

.topbar {
    gap: 0.75rem;
}

.topbar-left {
    /* Agrupa boton de menu + logotipo */
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-logo {
    /* Texto de marca que aparece siempre en la cabecera */
    font-weight: 700;
    color: var(--text);
}

.topbar-toggle {
    /* Solo se muestra cuando necesitamos abrir/cerrar la barra lateral */
    display: inline-flex;
}

.topbar-title {
    /* Titulo contextual de cada vista */
    font-size: 1.05rem;
    font-weight: 600;
}

.topbar-user {
    /* Contenedor de acciones del usuario (avatar, logout, etc.) */
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

/* Boton destacado para cerrar sesion */
.logout-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 0.5rem;
    background: var(--danger-dark);
    color: #ffffff;
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.7rem 0.9rem;
    display: inline-flex;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Estado visual cuando los VIPs estan ocultos manualmente (solo para quien puede verlos) */
body[data-allow-vips="true"][data-hide-vips="true"] .logout-button:not(.logout-button--ghost) {
    background: #0b2240;
    box-shadow: 0 8px 18px rgba(11, 34, 64, 0.5);
}

/* Estado visual cuando el usuario no tiene permiso para ver VIPs */
body[data-allow-vips="false"] .logout-button:not(.logout-button--ghost) {
    background: #0b2240;
    box-shadow: 0 8px 18px rgba(11, 34, 64, 0.5);
}

.logout-button:hover {
    /* Aplica microanimacion para reforzar el click */
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(238, 46, 46, 0.4);
}

/* Variante neutra del boton de logout para acciones secundarias */
.logout-button.logout-button--ghost {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: none;
    text-decoration: none;
}

.logout-button.logout-button--ghost:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
}

/* Area desplazable del contenido principal */
.main-content {
    padding: 0.8rem 1.5rem 1.5rem;
    overflow-y: auto;
    height: 100%;
}

/* Rejilla adaptativa para las tarjetas del dashboard */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

/* Tarjeta individual con datos resumidos */
.card {
    background-color: var(--bg-panel);
    border-radius: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.card h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

.card strong {
    /* Cifra secundaria (ej. tendencia) */
    font-size: 1.6rem;
    font-weight: 600;
}

/* Valor principal dentro de cada tarjeta */
.card-value {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text);
}

/* Texto secundario o de apoyo */
.muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Mosaico responsive usado en /config */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

/* Tarjeta que contiene cada bloque de ajustes */
.config-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

/* Estado comprimido pero visible para pantallas medianas */
.sidebar-collapsed .sidebar {
    width: 76px;
    padding: 1rem 0.5rem;
}

/* Estado completamente contraido (usado al ocultar) */
.sidebar-collapsed .sidebar {
    width: 0;
    padding: 0;
    border: none;
    transform: translateX(-100%);
}

/* ==========================================================================
   Ajustes responsive para mobile/tablet
   ========================================================================== */
@media (max-width: 960px) {
    .sidebar {
        /* En mobile pasa a modo drawer */
        position: fixed;
        z-index: 20;
        inset: 64px auto 0 0;
        max-width: 240px;
        height: calc(100% - 64px);
        overflow-y: auto;
        width: 240px;
        transform: translateX(-100%);
    }

    .sidebar.open {
        /* Clase usada por JS para mostrar el menu */
        transform: translateX(0);
    }
}

/* ==========================================================================
   Layout alternativo para pantallas de autenticacion
   ========================================================================== */
.auth-shell {
    /* Fondo mas suave para pantallas especiales */
    background: radial-gradient(circle at top, #eef2ff, #f8fafc);
}

.auth-shell .workspace {
    /* Centramos el contenido cuando no hay sidebar */
    justify-content: center;
    align-items: center;
    height: calc(100vh - 64px);
    padding: 2rem;
}

.auth-shell .content-area.full {
    /* Ancho maximo comodo para formularios */
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
}

.auth-shell .topbar {
    /* La cabecera se vuelve transparente para no distraer */
    border-bottom: none;
    background: transparent;
    justify-content: center;
}

/* ==========================================================================
   Componentes del formulario de acceso
   ========================================================================== */
.login-wrapper {
    /* Asegura que el formulario ocupa todo el ancho disponible */
    width: 100%;
}

/* Tarjeta que contiene el formulario y copia principal */
.login-card {
    background: #ffffff;
    border-radius: 1.25rem;
    padding: 2rem;
    box-shadow: 0 15px 45px rgba(15, 23, 42, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Encabezado del login con titulo + texto auxiliar */
.login-hero {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Logo improvisado para reforzar marca */
.login-logo {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    margin: 0 auto;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 600;
    font-size: 1.25rem;
}

.login-hero h1 {
    /* Mensaje directo que da la bienvenida */
    margin: 0;
    font-size: 1.4rem;
}

.login-hero p {
    /* Subtitulo con informacion adicional */
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-form {
    /* Contenedor del formulario con distribucion vertical */
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-field {
    /* Agrupa label + input para mantener coherencia vertical */
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-field label {
    /* Etiqueta textual encima del input */
    font-weight: 600;
    font-size: 0.9rem;
}

.form-field input[type="text"],
.form-field input[type="password"] {
    /* Campos del login con radios suaves */
    border: 1px solid #d3d8e0;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

.form-field input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ==========================================================================
   Controles de formulario reutilizables
   ========================================================================== */
.form-control {
    width: 100%;
    border: 1px solid rgba(15, 23, 42, 0.18);
    border-radius: 0.85rem;
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    background-color: #fff;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-readonly {
    width: 100%;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0.85rem;
    padding: 0.7rem 1rem;
    background: #f8fafc;
    color: var(--text);
}

.cobro-form__cliente .form-readonly {
    font-size: 1.05rem;
    font-weight: 600;
}

.form-control:focus {
    border-color: rgba(99, 102, 241, 0.65);
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control[disabled] {
    background-color: rgba(15, 23, 42, 0.04);
    color: var(--text-muted);
    border-color: rgba(15, 23, 42, 0.1);
    cursor: not-allowed;
}

.form-error {
    color: var(--danger);
    font-size: 0.78rem;
    margin-top: 0.2rem;
}

.form-control.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.70);
}

.form-textarea {
    width: 100%;
    border: 1px solid rgba(15, 23, 42, 0.18);
    border-radius: 0.85rem;
    padding: 0.8rem 1rem;
    resize: vertical;
    min-height: 110px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-textarea:focus {
    border-color: rgba(99, 102, 241, 0.65);
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-select {
    appearance: none;
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
    padding-right: 2.4rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23666' stroke-width='2' viewBox='0 0 18 18'%3E%3Cpath d='M4 6l5 5 5-5'/%3E%3C/svg%3E");
}

.form-select:focus {
    background-color: #fff;
}

.form-number {
    font-variant-numeric: tabular-nums;
}

.form-number::-webkit-inner-spin-button,
.form-number::-webkit-outer-spin-button {
    margin: 0;
}

.form-currency {
    text-align: right;
    font-feature-settings: "tnum";
}

.form-currency.is-negative {
    color: var(--danger);
}

.is-negative {
    color: var(--danger);
}

.is-negative-strong {
    font-weight: 700;
}

.cobro-form__saldo-value {
    text-align: left;
}

.form-currency::placeholder {
    color: var(--text-muted);
}

.login-options {
    /* Linea que muestra enlaces como "?Olvidaste tu contrasena?" */
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.login-options a {
    /* Enlace de accion secundaria */
    color: var(--accent);
    font-weight: 600;
}

.login-actions {
    /* Agrupa botones de accion/CTA */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn {
    /* Boton generico que se reutiliza en distintas vistas */
    border: none;
    border-radius: 0.9rem;
    padding: 0.85rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn.primary {
    /* Boton principal que resalta sobre el fondo */
    color: #ffffff;
    background: var(--sidebar-bg);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.35);
}

.btn.primary:hover {
    /* Pequeno efecto al pasar el puntero */
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.45);
}

.btn.secondary {
    color: var(--sidebar-bg);
    background: rgba(99, 102, 241, 0.08);
    box-shadow: none;
}

.btn.secondary:hover {
    background: rgba(99, 102, 241, 0.15);
}

.btn.ghost {
    color: var(--text);
    background: transparent;
    border: 1px solid var(--border);
    box-shadow: none;
}

.btn.ghost:hover {
    background: rgba(31, 45, 84, 0.05);
}

.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn[disabled]:hover {
    background: inherit;
}

.btn.ghost.danger {
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--danger);
}

.btn.ghost.danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

.btn-icon {
    display: inline-flex;
    margin-right: 0.35rem;
}

.btn-label {
    font-weight: 600;
}

.login-errors {
    /* Caja de alerta para mensajes de error */
    background-color: rgba(239, 68, 68, 0.07);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 0.75rem;
    padding: 0.75rem;
}

.login-error-list {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--danger);
    font-size: 0.9rem;
}

.login-remember {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.login-remember input[type="checkbox"] {
    /* Tamaño uniforme del checkbox para que no se deforme */
    width: 16px;
    height: 16px;
}

.cobro-info-banner {
    background: #fff4cc;
    border: 1px solid #f1c76b;
    border-radius: 0.6rem;
    color: #7a4b00;
    font-weight: 700;
    padding: 0.6rem 0.75rem;
}

.cobro-info-banner.is-hidden {
    display: none;
}

/* ==========================================================================
   Componentes reutilizables en barra superior y formularios
   ========================================================================== */
.logout-icon {
    /* Alineamos el icono de salida con el texto */
    display: inline-flex;
    align-items: center;
}

.logout-name {
    /* El nombre visible del usuario conectado */
    font-weight: 600;
}

/* ==========================================================================
   Modal de inactividad y estados relacionados
   ========================================================================== */
.idle-modal {
    position: fixed;
    inset: 0;
    background: rgba(12, 19, 34, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 1.5rem;
}

.idle-modal.open {
    /* Clase que activa la visualizacion del overlay */
    display: flex;
}

.idle-modal__content {
    /* Caja centrada dentro del overlay oscuro */
    background: #ffffff;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.4);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.idle-modal__icon {
    /* Icono circular que refuerza el mensaje */
    font-size: 2rem;
    color: var(--danger);
}

/* ==========================================================================
   Listados tabulares (BaseView)
   ========================================================================== */
.view-shell {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 0;
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0;
    margin: -0.2rem 0 -0.15rem;
}

.view-title-block {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
}

.view-title {
    font-size: 1.28rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.05;
}

.view-subtitle {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin: 0;
    line-height: 1.05;
}

.view-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.view-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

.view-panel--filters {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.7rem 0.85rem;
}

.view-filters-toolbar {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem;
    align-items: flex-start;
}

.view-filters-left {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
    flex: 1 1 auto;
    min-width: 0;
}

.view-quick-filters {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
}

.view-quick-filter {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    align-items: flex-start;
}

.view-filter-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1;
    display: inline-block;
}

.quick-filter-btn-group {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    overflow: hidden;
}

.quick-filter-btn {
    border: none;
    background: transparent;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.quick-filter-btn:last-child {
    border-right: none;
}

.quick-filter-btn.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text);
    font-weight: 600;
}

.view-quick-filter .view-select.compact {
    min-width: 140px;
    padding: 0.4rem 0.75rem;
}

.view-advanced-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 1 auto;
    flex-wrap: wrap;
}

.filter-chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    min-height: 30px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.5rem;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
    font-size: 0.78rem;
}

.filter-chip .chip-remove {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    line-height: 1;
}

.filter-chip.negated {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
}

.filter-chip.negated .chip-label {
    color: #b91c1c;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 400;
    line-height: 1.2;
    text-transform: capitalize;
}

.status-chip--bloqueado {
    background-color: #8f6ad6;
    color: #fff;
}

.status-chip--activa {
    background-color: #34a853;
    color: #fff;
}

.status-chip--baja {
    background-color: #f07a7a;
    color: #fff;
}

.status-chip--efectivo {
    background-color: #0f9d58;
    color: #fff;
}

.status-chip--transferencia {
    background-color: #1d4ed8;
    color: #fff;
}

.status-chip--recibo {
    background-color: #f59e0b;
    color: #000;
}

.status-chip--otro {
    background-color: #6b7280;
    color: #fff;
}

.status-chip--borrador {
    background-color: #6b7280;
    color: #fff;
}

.status-chip--confirmado {
    background-color: #0f9d58;
    color: #fff;
}

.status-chip--exportado {
    background-color: #1d4ed8;
    color: #fff;
}

.status-chip--cerrado {
    background-color: #0f766e;
    color: #fff;
}

.status-chip--papelera {
    background-color: var(--danger);
    color: #ffffff;
}

.obra-capitulos__embed {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.obra-capitulos__list-actions {
    display: flex;
    justify-content: flex-end;
}

.obra-capitulos__empty,
.obra-capitulos__empty-text {
    padding: 0.75rem;
    border-radius: 0.5rem;
    background-color: var(--panel);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.obra-capitulos__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.obra-capitulos__item {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #fff;
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.obra-capitulos__content {
    flex: 1;
}

.obra-capitulos__row-head {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.obra-capitulos__order {
    font-weight: 700;
    font-size: 1rem;
    min-width: 2rem;
    text-align: center;
    background: var(--panel);
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
}

.obra-capitulos__title {
    font-weight: 600;
    color: var(--text);
}

.obra-capitulos__main {
    flex: 1;
}

.obra-capitulos__notes {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.obra-capitulos__metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.35rem;
    font-size: 0.85rem;
}

.obra-capitulos__metric {
    background: var(--panel);
    border-radius: 0.375rem;
    padding: 0.2rem 0.5rem;
}

.obra-capitulos__item.record-row--updated {
    background-color: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.45);
}

.obra-capitulos__item.record-row--deleted {
    background-color: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.45);
}

.obra-capitulos__item.record-row--focus {
    background-color: #0f172a;
    border-color: #0f172a;
    color: #fff;
}

.obra-capitulos__item.record-row--focus .obra-capitulos__title,
.obra-capitulos__item.record-row--focus .obra-capitulos__order {
    color: #fff;
}

.obra-capitulos__item.record-row--focus .obra-capitulos__order {
    background-color: rgba(255, 255, 255, 0.15);
}

.obra-capitulos__item.record-row--focus .obra-capitulos__metric,
.obra-capitulos__item.record-row--focus .obra-capitulos__notes {
    color: rgba(255, 255, 255, 0.85);
    background-color: rgba(255, 255, 255, 0.12);
}

.obra-pagos-previstos__embed {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.obra-pagos-previstos__list-actions {
    display: flex;
    justify-content: flex-end;
}

.obra-pagos-previstos__empty,
.obra-pagos-previstos__empty-text {
    padding: 0.75rem;
    border-radius: 0.5rem;
    background-color: var(--panel);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.obra-pagos-previstos__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.obra-pagos-previstos__item {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #fff;
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.obra-pagos-previstos__row-head {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.obra-pagos-previstos__order {
    font-weight: 700;
    font-size: 1rem;
    min-width: 2rem;
    text-align: center;
    background: var(--panel);
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
}

.obra-pagos-previstos__body {
    flex: 1;
    display: flex;
    align-items: center;
}

.obra-pagos-previstos__title {
    font-weight: 600;
    color: var(--text);
}

.obra-pagos-previstos__row-head {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    width: 100%;
}

.obra-pagos-previstos__state-chip {
    font-size: 0.85rem;
    padding: 0.15rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    white-space: nowrap;
    margin-left: auto;
}

.obra-pagos-previstos__item {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1.5rem;
}

.status-chip--pendiente {
    /* background-color: #fceecf;
    border-color: #f8d39b;
    color: #a05d08; */
    background-color: #ff4049;
    color: #ffffff;
}

.status-chip--en-curso {
    background-color: #3d60ff;
    color: #ffffff;
}

.status-chip--acabado {
    /* background-color: #e9f6ed;
    border-color: #9fe2b1;
    color: #2c6e3b; */
    background-color: #636363;
    color: #fff;
}

.status-chip--pro-forma {
    /* background-color: #f4e5ff;
    border-color: #d3aef9;
    color: #5b2abf; */
    background-color: #5b2abf;
    color: #ffffff;
}

.status-chip--facturado {
    /* background-color: #fff0d0;
    border-color: #ffd29f;
    color: #a65c01; */
    background-color: #ffba3b;
    color: #000000;
}

.status-chip--cobrado {
    /* background-color: #def2d9;
    border-color: #9fd8a3;
    color: #34793a; */
    background-color: #34a853;
    color: #fff;

}

.obra-pagos-previstos__state {
    display: inline-flex;
    margin-top: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-left: auto;
}

.obra-pagos-previstos__item.record-row--updated {
    background-color: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.45);
}

.obra-pagos-previstos__item.record-row--deleted {
    background-color: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.45);
}

.obra-pagos-previstos__item.record-row--focus {
    background-color: #0f172a;
    border-color: #0f172a;
    color: #fff;
}

.obra-pagos-previstos__item.record-row--focus .obra-pagos-previstos__title,
.obra-pagos-previstos__item.record-row--focus .obra-pagos-previstos__order {
    color: #fff;
}

.obra-pagos-previstos__item.record-row--focus .obra-pagos-previstos__order {
    background-color: rgba(255, 255, 255, 0.15);
}


.status-chip--cerrada {
    background-color: #636363;
    color: #fff;
}

.filter-add {
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
}

.view-search-field.compact {
    min-width: 220px;
}

.view-search-field.compact .view-search-input {
    height: 34px;
    padding: 0.45rem 0.7rem;
    border-radius: 0.6rem;
}

.filter-modal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
    padding: 1.5rem;
}

[x-cloak] {
    display: none !important;
}

.filter-modal__panel {
    width: 100%;
    max-width: 420px;
}

.filter-modal {
    background: #fff;
    border-radius: 1rem;
    padding: 1.25rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.filter-modal .modal-close {
    align-self: flex-end;
    border: none;
    background: transparent;
    font-size: 1.4rem;
    cursor: pointer;
}

.filter-modal .modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.filter-modal .modal-field--checkbox {
    padding-top: 0.15rem;
}

.modal-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.modal-checkbox-input {
    width: 16px;
    height: 16px;
}

.modal-checkbox-text {
    color: var(--text-muted);
}

.modal-between-fields {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.modal-between-fields .view-search-input {
    flex: 1;
}

.modal-between-separator {
    color: var(--text-muted);
    font-weight: 600;
}

.filter-modal input[type="text"],
.filter-modal input[type="search"],
.filter-modal input[type="number"] {
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    background: var(--bg-panel);
}

.filter-modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.view-filters-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.view-filter-field {
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-left: auto;
    min-width: 220px;
    align-self: flex-end;
}

.view-search-field {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.65rem;
    border: 1px solid var(--border);
    border-radius: 0.55rem;
    background: var(--bg-panel);
    min-width: 75px;
    height: 32px;
}

.view-search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0;
    font-size: 0.9rem;
    min-width: 0;
    line-height: 1.2;
    transition: color 0.2s ease;
}

.view-search-input:focus {
    outline: none;
}

.view-search-icon {
    display: inline-flex;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.view-search-input::placeholder {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.view-data {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
    position: relative;
}

.view-table-wrapper {
    overflow-x: auto;
}

.view-panel--table {
    padding: 0.6rem 0.8rem;
}

.view-panel--pagination {
    padding: 0.55rem 0.85rem;
}

.view-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.view-table thead th {
    text-align: left;
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    color: var(--color-black);
    font-weight: 800;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.view-table thead th.align-right {
    text-align: right;
    padding-right: 0.15rem;
}

.view-table tbody td {
    padding: 0.25rem 0.15rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

.view-table thead th.sorted {
    background-color: rgba(156, 156, 158, 0.12);
    color: var(--text);
    border-bottom-color: var(--accent);
}

.view-table tbody td.sorted {
    background-color: rgba(156, 156, 158, 0.05);
}

.view-table tbody tr:hover {
    background-color: var(--row-hover);
}

.view-cell {
    padding-right: 1rem;
    white-space: nowrap;
}

.view-cell--select {
    width: 38px;
    padding-right: 0.4rem;
}

.bulk-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #0f172a;
}

.align-right {
    text-align: right;
}

.align-center {
    text-align: center;
}

.view-cell-actions {
    width: 1%;
    text-align: right;
}

.view-row-actions {
    display: inline-flex;
    justify-content: flex-end;
    gap: 0.35rem;
}

.view-row-actions .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    border-radius: 0.6rem;
}

.view-table tbody tr.row-selected td {
    background-color: rgba(15, 23, 42, 0.06);
}

.view-table tbody tr.row-selected td.sorted {
    background-color: rgba(15, 23, 42, 0.08);
}

.albaran-id--aot {
    display: block;
    width: 100%;
    margin: -0.25rem -0.15rem;
    padding: 0.15rem 0.35rem 0 0.15rem;
    background-color: #b8b8b8;
    text-align: center;
    color: #000000;
    border-radius: 4px;
}

#clientes-shell .view-table thead th {
    padding-bottom: 0.2rem;
}

#clientes-shell .view-table tbody td {
    padding: 0.15rem 0.15rem;
}

#clientes-shell .status-chip {
    padding: 0.05rem 0.45rem;
    font-size: 0.8rem;
}

#albaranes-shell .view-table thead th {
    padding-bottom: 0.2rem;
}

#albaranes-shell .view-table tbody td {
    padding: 0.15rem 0.15rem;
}

#albaranes-shell .status-chip {
    padding: 0.05rem 0.45rem;
    font-size: 0.8rem;
}

.albaran-preview-toggle {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn.ghost.cliente-albaran-preview-toggle {
    background-color: #000;
    color: #fff;
    border-color: #000;
}

.btn.ghost.cliente-albaran-preview-toggle:hover,
.btn.ghost.cliente-albaran-preview-toggle:focus-visible {
    background-color: #111;
    color: #fff;
    border-color: #111;
}

.cliente-albaran-preview-toggle .btn-icon {
    color: currentColor;
}

.albaran-preview-toggle .btn-icon {
    transition: transform 0.2s ease;
    transform: rotate(180deg);
}

.albaran-preview-toggle.is-open .btn-icon {
    transform: rotate(0deg);
}

.albaran-row--expanded td {
    background-color: rgba(15, 23, 42, 0.03);
}

.albaran-preview-row {
    display: none;
    background-color: #f8fafc;
}

.albaran-preview-row.is-open {
    display: table-row;
}

.albaran-preview-row td {
    padding: 0.8rem 0.9rem;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.albaran-preview {
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 0.9rem;
    padding: 0.9rem;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.albaran-preview__loading,
.albaran-preview__error {
    font-size: 0.85rem;
    color: #64748b;
}

.albaran-preview__content {
    display: grid;
    gap: 0.9rem;
}

.albaran-preview__header {
    display: grid;
    gap: 0.6rem 1rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.albaran-preview__item .label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.albaran-preview__item .value {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: #0f172a;
}

.albaran-preview__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.albaran-preview__table th,
.albaran-preview__table td {
    padding: 0.4rem 0.45rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.albaran-preview__table th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    text-align: left;
}

.albaran-preview__empty {
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
    padding: 0.8rem 0.4rem;
}

.albaran-preview__cell-article {
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
}

.albaran-preview__cell-desc {
    color: #1f2937;
}

.albaran-preview__totals .albaran-lines__totals-grid {
    margin-top: 0.6rem;
}

.albaran-preview__notes {
    padding: 0.7rem 0.8rem;
    border-radius: 0.7rem;
    background: rgba(15, 23, 42, 0.04);
}

.albaran-preview__notes .label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.albaran-preview__notes .value {
    display: block;
    font-size: 0.9rem;
    color: #0f172a;
}

.bulk-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.bulk-menu__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.75rem;
}

.bulk-menu__dots {
    font-size: 1.35rem;
    line-height: 1;
}

.bulk-menu__count {
    background: #0f172a;
    color: #fff;
    font-size: 0.7rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
}

.bulk-menu__dropdown {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    min-width: 190px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0.75rem;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    z-index: 25;
}

.bulk-menu__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    padding: 0.45rem 0.6rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}

.bulk-menu__item:hover {
    background: rgba(15, 23, 42, 0.06);
}

.bulk-menu__item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: transparent;
}

.bulk-menu__item--danger {
    color: var(--danger);
}

.bulk-menu__item--danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

.bulk-menu__icon {
    display: inline-flex;
    color: var(--text-muted);
}

.bulk-menu__item--danger .bulk-menu__icon {
    color: var(--danger);
}

.bulk-confirm {
    position: fixed;
    inset: 0;
    z-index: 120;
}

.bulk-confirm__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.bulk-confirm__panel {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 1rem;
    padding: 1.4rem;
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bulk-confirm__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bulk-confirm__title {
    font-size: 1.05rem;
    font-weight: 700;
}

.bulk-confirm__close {
    border: none;
    background: transparent;
    font-size: 1.2rem;
    cursor: pointer;
}

.bulk-confirm__row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.bulk-confirm__label {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.bulk-confirm__value {
    font-weight: 600;
}

.bulk-confirm__text {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.bulk-confirm__selector {
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0.9rem;
    background: rgba(15, 23, 42, 0.03);
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.bulk-confirm__select {
    padding: 0.55rem 0.75rem;
    border-radius: 0.75rem;
    background-color: #fff;
}

.bulk-confirm__slug {
    font-family: "Courier New", monospace;
    font-size: 0.9rem;
    background: rgba(15, 23, 42, 0.08);
    padding: 0.1rem 0.45rem;
    border-radius: 0.45rem;
    font-weight: 600;
    color: var(--text);
}

.bulk-confirm__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.bulk-confirm__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.bulk-confirm__confirm {
    min-width: 160px;
}

.bulk-loading {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 130;
}

.bulk-loading.htmx-request {
    display: flex;
}

.bulk-loading__panel {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: #fff;
    padding: 0.85rem 1.1rem;
    border-radius: 0.9rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
    font-weight: 600;
}

.bulk-loading__spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--accent);
    animation: view-spin 1s linear infinite;
}

.bulk-loading__text {
    font-size: 0.9rem;
    color: var(--text);
}

.bulk-result {
    position: fixed;
    inset: 0;
    z-index: 120;
}

.bulk-result__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.bulk-result__panel {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border: 1px solid rgba(15, 23, 42, 0.1);
}

.bulk-result[data-status="error"] .bulk-result__panel {
    border-color: rgba(239, 68, 68, 0.4);
}

.bulk-result[data-status="error"] .bulk-result__title {
    color: var(--danger);
}

.bulk-result__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bulk-result__title {
    font-size: 1.05rem;
    font-weight: 700;
}

.bulk-result__close {
    border: none;
    background: transparent;
    font-size: 1.2rem;
    cursor: pointer;
}

.bulk-result__text {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.bulk-result__actions {
    display: flex;
    justify-content: flex-end;
}

.sortable-button {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: none;
    background: transparent;
    font: inherit;
    color: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.sortable-button .sort-icon {
    display: inline-flex;
    opacity: 0.4;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.sortable-button .sort-icon svg {
    stroke: var(--text-muted);
}

.sortable-button.active .sort-icon {
    opacity: 1;
}

.sortable-button.desc .sort-icon svg {
    transform: rotate(180deg);
}

.view-table-empty {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.view-empty {
    border: 4px dashed var(--border);
    border-radius: 0.85rem;
    padding: 1rem;
    background: rgba(247, 247, 248, 0.6);
}

.view-empty-title {
    font-weight: 600;
}

.view-empty-hint {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.view-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.view-pagination-info {
    flex: 1 1 240px;
}

.view-pagination-summary {
    font-weight: 500;
    font-size: 0.82rem;
}

.view-pagination-size {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
}

.view-select {
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    padding: 0.45rem 0.6rem;
    background: var(--bg-panel);
}

.pagination-buttons {
    display: inline-flex;
    gap: 0.5rem;
}

.pager-btn {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.5rem 1rem;
    font-weight: 600;
    background: #ffffff;
    color: var(--text);
}

.pager-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.view-loading-indicator {
    position: absolute;
    inset: auto 1.25rem 1.25rem auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--accent);
    animation: view-spin 1s linear infinite;
    display: none;
}

.view-loading-indicator.htmx-request {
    display: inline-flex;
}

@keyframes view-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 960px) {
    .view-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .view-actions {
        width: 100%;
    }
}

@media (max-width: 720px) {
    .view-filters-grid {
        flex-direction: column;
    }

    .view-filter-field {
        width: 100%;
    }
}

.col-hide-lg {
    /* Se oculta en pantallas menores a 1280px */
    display: table-cell;
}

.col-hide-md,
.col-hide-sm {
    display: table-cell;
}

@media (max-width: 1200px) {
    .col-hide-lg {
        display: none;
    }
}

@media (max-width: 960px) {
    .col-hide-md {
        display: none;
    }
}

@media (max-width: 720px) {
    .col-hide-sm {
        display: none;
    }
}

/* ==========================================================================
   Formularios modales para ediciones
   ========================================================================== */
.record-modal-host {
    position: fixed;
    inset: 0;
    z-index: 90;
    pointer-events: none;
}

.record-modal-host--overlay {
    z-index: 120;
}

.record-modal-host.is-visible {
    pointer-events: auto;
}

.record-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    outline: none;
}

.record-modal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.record-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
}

.record-modal__window {
    position: relative;
    z-index: 2;
    width: min(960px, 95vw);
    max-height: 92vh;
    min-height: 0;
    background: var(--bg-panel);
    border-radius: 1.2rem;
    box-shadow: 0 35px 80px rgba(15, 23, 42, 0.45);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.record-modal__form {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.record-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.85rem 1.5rem 0.65rem;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.record-modal__title-block {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: baseline;
}

.record-modal__title {
    font-size: 1.25rem;
    font-weight: 700;
}

.record-modal__subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.record-modal__close {
    border: none;
    border-radius: 0.75rem;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: transparent;
    transition: background 0.2s ease;
    outline: none;
}

.record-modal__close:hover {
    background: rgba(15, 23, 42, 0.08);
}

.record-modal__body {
    padding: 0.85rem 1.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.record-modal__body-extra {
    padding: 0 1.75rem 1.1rem;
}

.record-modal__tabs {
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: flex-start;
}

.record-modal__tabs .uk-tab {
    border-bottom: none !important;
    display: flex;
    gap: 0.35rem;
    margin: 0;
    padding-left: 0;
    position: relative;
}

.record-modal__tabs .uk-tab::before {
    display: none !important;
    content: "";
}

.record-modal--no-tabs .record-modal__tabs {
    display: none;
}

.record-modal__tabs .uk-tab>li {
    margin-bottom: 0;
    margin-left: 0;
    padding-left: 0;
}

.record-modal__tabs .uk-tab>li+li {
    margin-left: 0;
}

.record-modal__tabs .uk-tab>li>a {
    border: 1px solid rgba(15, 23, 42, 0.18);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-weight: 600;
    font-size: 0.92rem;
    background: rgba(15, 23, 42, 0.03);
    color: var(--text);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.record-modal__tabs .uk-tab>li.uk-active>a {
    background: rgba(15, 23, 42, 0.22);
    border-color: rgba(15, 23, 42, 0.55);
    color: var(--text);
}

.record-modal__tabs .uk-tab>li:not(.uk-active)>a {
    color: var(--text-muted);
}

.record-modal__tab-badge {
    background: #000;
    color: #fff;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    margin-left: 0.5rem;
    font-size: 0.85rem;
}

.record-modal__tabs-content {
    background: rgba(15, 23, 42, 0.02);
    border-radius: 1rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    padding: 0.85rem 1.1rem;
    min-height: 320px;
    max-height: 440px;
    overflow: auto;
    margin: 0;
}

.record-modal--xl .record-modal__window {
    width: min(1400px, 98vw);
    max-height: 95vh;
    height: 95vh;
}

.record-modal--xl .record-modal__tabs-content {
    max-height: none;
    min-height: 0;
    height: 100%;
}

.record-modal--xl .record-modal__panel,
.record-modal--xl .record-modal__panel-content {
    min-height: 0;
}

.record-modal--xl .record-modal__panel-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.record-modal--compact .record-modal__window {
    width: min(520px, 92vw);
    max-height: 70vh;
    height: auto;
}

.record-modal--mensualidades .record-modal__window {
    width: min(640px, 88vw) !important;
    max-width: 640px;
    max-height: 75vh;
}

.record-modal--mensualidad .record-modal__window {
    width: min(560px, 88vw);
    max-width: 560px;
    max-height: 75vh;
}

.record-modal--contrato .record-modal__window {
    width: min(1200px, 96vw);
}

.record-modal--contrato .record-modal__notes-textarea {
    min-height: 5.2rem;
    height: auto;
}

.record-modal--contrato .record-modal__list {
    gap: 0.15rem;
}

.record-modal--contrato .record-modal__list-item {
    padding: 0.15rem 0.6rem;
}

.record-modal--contrato .record-modal__item-sku {
    font-family: inherit;
    font-size: 1rem;
    letter-spacing: normal;
    margin-left: 0.5rem;
}

.record-modal--contrato .record-modal__item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.record-modal--contrato .record-modal__item-row {
    line-height: 1.2;
}

.record-modal--contrato .record-modal__item-meta .status-chip {
    margin-left: 0.35rem;
}

.record-modal--contrato .contrato-mensualidades__toolbar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0.5rem;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(6px);
}

.record-modal--contrato .contrato-mensualidades__left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.record-modal--contrato .contrato-mensualidades__right {
    display: flex;
    align-items: center;
}

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

.albaran-form__span-2 {
    grid-column: span 2;
}

.albaran-form__header .form-field--full {
    grid-column: 1 / -1;
}

.albaran-form__row-3 {
    grid-column: 1 / -1;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1024px) {
    .albaran-form__row-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .albaran-form__row-3 {
        grid-template-columns: minmax(0, 1fr);
    }
}

.albaran-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.albaran-lines__content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    height: 100%;
    flex: 1;
    min-height: 0;
}

.albaran-lines__table-wrap {
    overflow: auto;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 0.9rem;
    background: #fff;
    flex: 1;
    min-height: 0;
}

.albaran-lines__table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.albaran-lines__table th,
.albaran-lines__table td {
    padding: 0.2rem 0.35rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    vertical-align: middle;
    line-height: 1.15;
}

.albaran-lines__table th:nth-child(1),
.albaran-lines__table td:nth-child(1) {
    width: 18%;
}

.albaran-lines__table th:nth-child(2),
.albaran-lines__table td:nth-child(2) {
    width: 36%;
}

.albaran-lines__table th:nth-child(3),
.albaran-lines__table td:nth-child(3),
.albaran-lines__table th:nth-child(4),
.albaran-lines__table td:nth-child(4),
.albaran-lines__table th:nth-child(5),
.albaran-lines__table td:nth-child(5),
.albaran-lines__table th:nth-child(6),
.albaran-lines__table td:nth-child(6),
.albaran-lines__table th:nth-child(7),
.albaran-lines__table td:nth-child(7) {
    width: 8%;
}

.albaran-lines__table th:nth-child(8),
.albaran-lines__table td:nth-child(8) {
    width: 4%;
}

.albaran-lines__cell-article {
    width: 220px;
}

.albaran-lines__cell-article .dynamic-select {
    width: 100%;
}

.albaran-lines__article-wrap {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 0.4rem;
    align-items: center;
}

.albaran-lines__order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    font-size: 0.8rem;
    font-weight: 0.9rem;
    color: var(--color-black);
}

.albaran-lines__cell-desc {
    width: 36%;
}

.albaran-lines__desc {
    width: 100%;
}

.albaran-lines__table th {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.albaran-lines__table .form-compact {
    font-size: 0.82rem;
    padding: 0.35rem 0.5rem;
}

.albaran-lines__table [data-line-remove] {
    width: 36px;
    height: 36px;
    border-radius: 0.8rem;
    line-height: 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.albaran-lines__actions {
    margin-top: 0.5rem;
    margin-top: auto;
}

.albaran-lines__totals-grid {
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 1rem;
    padding: 0.65rem 0.85rem;
    background: rgba(15, 23, 42, 0.03);
    display: grid;
    grid-template-columns: 1.4fr 10px 0.9fr;
    gap: 0.75rem;
    align-items: start;
}

.albaran-lines__totals-separator {
    width: 6px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.12);
    align-self: stretch;
    margin: 0 0.35rem;
}

.albaran-lines__tax-box {
    overflow-x: auto;
}

.albaran-lines__tax-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.87rem;
}

.albaran-lines__tax-table th,
.albaran-lines__tax-table td {
    padding: 0.3rem 0.35rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.albaran-lines__tax-table th {
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.albaran-lines__tax-table td.align-right,
.albaran-lines__tax-table th.align-right {
    text-align: right;
}

.albaran-lines__tax-table td.align-left,
.albaran-lines__tax-table th.align-left {
    text-align: left;
}

.albaran-lines__summary {
    display: flex;
    flex-direction: row;
    gap: 1.25rem;
    align-items: flex-start;
    justify-content: flex-end;
}

.albaran-lines__summary .label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.albaran-lines__summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    align-items: flex-start;
}

.albaran-lines__summary-item .label {
    font-size: 0.8rem;
}

.albaran-lines__summary .amount {
    display: block;
    font-weight: 700;
    font-size: 1rem;
}

.albaran-lines__summary .amount.total {
    font-size: 1.08rem;
    font-weight: 800;
}

.albaran-lines__totals-item .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.albaran-lines__totals-item .amount {
    display: block;
    font-weight: 700;
    margin-top: 0.2rem;
}

.albaran-lines__totals-item.total .amount {
    font-size: 1.05rem;
}

.albaran-lines__tax-list {
    list-style: none;
    margin: 0;
    padding: 0.4rem 0 0;
    border-top: 1px dashed rgba(15, 23, 42, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    grid-column: 1 / -1;
}

.albaran-lines__tax-item .muted {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.albaran-lines__tax-sep {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.albaran-lines__tax-item {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.35rem 0;
    font-size: 0.85rem;
    color: var(--text);
}

.albaran-lines__tax-item .label {
    font-size: 0.82rem;
    font-weight: 600;
}

.albaran-lines__tax-item .amount {
    font-weight: 600;
    color: var(--text);
    font-size: 0.9rem;
}

.albaran-lines__tax-item .muted {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.albaran-lines__tax-sep {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.albaran-lines__tax-item .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    display: block;
}

.albaran-lines__tax-item .amount {
    display: block;
    font-weight: 600;
    color: var(--text);
}

.albaran-docs__table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.albaran-docs__table th,
.albaran-docs__table td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.albaran-docs__name a {
    color: var(--text);
    text-decoration: none;
}

.albaran-docs__name a:hover {
    text-decoration: underline;
}

.albaran-docs__thumb-cell {
    width: 90px;
}

.albaran-docs__thumb {
    width: 72px;
    height: 48px;
    border-radius: 0.5rem;
    border: 1px solid rgba(15, 23, 42, 0.15);
    object-fit: cover;
    background: rgba(15, 23, 42, 0.04);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

img.albaran-docs__thumb {
    display: block;
    padding: 0;
}

.albaran-docs__thumb-label {
    padding: 0 0.4rem;
}

.albaran-docs__check .record-modal__checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.doc-menu {
    position: relative;
    display: inline-flex;
}

.doc-menu__btn {
    width: 30px;
    height: 30px;
    border-radius: 0.6rem;
    border: 1px solid rgba(15, 23, 42, 0.2);
    background: #fff;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.doc-menu__dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.35rem);
    min-width: 140px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0.75rem;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
    display: none;
    flex-direction: column;
    padding: 0.35rem;
    z-index: 10;
}

.albaran-docs__toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

.btn.doc-gallery__trigger {
    background: rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(15, 23, 42, 0.55);
    color: var(--text);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-weight: 600;
    font-size: 0.92rem;
    box-shadow: none;
}

.doc-gallery {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.76);
    z-index: 1400;
}

.doc-gallery.is-open {
    display: flex;
}

.doc-gallery__panel {
    position: relative;
    width: min(1200px, 94vw);
    min-height: 72vh;
    max-height: 94vh;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 1rem;
    padding: 2.5rem 1.75rem 1.25rem;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 1fr auto;
    gap: 1rem;
}

.doc-gallery__stage {
    grid-column: 2 / span 1;
    grid-row: 1 / span 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 55vh;
    max-height: 74vh;
}

.doc-gallery__stage img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 0.6rem;
    background: rgba(248, 250, 252, 0.08);
}

.doc-gallery__placeholder {
    width: min(520px, 70vw);
    min-height: 240px;
    border-radius: 0.75rem;
    border: 1px dashed rgba(248, 250, 252, 0.35);
    background: rgba(248, 250, 252, 0.06);
    padding: 1.5rem;
    text-align: center;
    display: none;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    justify-content: center;
}

.doc-gallery__filetype {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(248, 250, 252, 0.7);
}

.doc-gallery__download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.1rem;
    border-radius: 999px;
    background: #f8fafc;
    color: #0f172a;
    text-decoration: none;
    font-weight: 600;
}

.doc-gallery__meta {
    grid-column: 1 / span 3;
    grid-row: 2 / span 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.doc-gallery__counter {
    font-variant-numeric: tabular-nums;
    color: rgba(248, 250, 252, 0.7);
}

.doc-gallery__caption {
    flex: 1;
    text-align: center;
    color: rgba(248, 250, 252, 0.95);
}

.doc-gallery__notes {
    flex: 1;
    text-align: right;
    color: rgba(248, 250, 252, 0.7);
    font-size: 0.85rem;
}

.doc-gallery__nav,
.doc-gallery__close {
    border: none;
    background: rgba(248, 250, 252, 0.1);
    color: #f8fafc;
    border-radius: 999px;
    width: 42px;
    height: 42px;
    font-size: 1.3rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.doc-gallery__nav:hover,
.doc-gallery__close:hover {
    background: rgba(248, 250, 252, 0.2);
}

.doc-gallery__nav:disabled {
    opacity: 0.4;
    cursor: default;
}

.doc-gallery__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 2;
}

.doc-gallery__nav--prev {
    grid-column: 1 / span 1;
    grid-row: 1 / span 1;
    align-self: center;
    justify-self: start;
    margin-left: 0.25rem;
}

.doc-gallery__nav--next {
    grid-column: 3 / span 1;
    grid-row: 1 / span 1;
    align-self: center;
    justify-self: end;
    margin-right: 0.25rem;
}

body.doc-gallery-open {
    overflow: hidden;
}

.doc-menu__item {
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-start;
}

.doc-menu__item:hover {
    background: rgba(15, 23, 42, 0.06);
}

.doc-menu__icon {
    display: inline-flex;
    color: var(--text-muted);
}

.doc-menu__text {
    flex: 1;
    text-align: left;
}

.doc-menu.is-open .doc-menu__dropdown {
    display: flex;
}

.file-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.file-input__label {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.file-input__label input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.9rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(15, 23, 42, 0.2);
    background: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.file-input__label:hover .file-input__button {
    background: rgba(15, 23, 42, 0.05);
    border-color: rgba(15, 23, 42, 0.35);
}

.file-input__text {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.file-dropzone {
    border: 1px dashed rgba(15, 23, 42, 0.2);
    border-radius: 0.9rem;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.02);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.file-dropzone.is-dragover {
    border-color: rgba(15, 23, 42, 0.45);
    background: rgba(15, 23, 42, 0.06);
}

.file-dropzone__hint {
    font-size: 0.9rem;
    color: var(--text-muted);
}

@media (max-width: 1024px) {
    .albaran-form__header {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .albaran-form__span-2 {
        grid-column: span 2;
    }

    .albaran-lines__totals-footer {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 720px) {
    .albaran-form__header {
        grid-template-columns: minmax(0, 1fr);
    }

    .albaran-form__span-2 {
        grid-column: span 1;
    }
}

.record-modal__tabs-content>li {
    list-style: none;
}

.record-modal__panel {
    width: 100%;
}

.record-modal__panel-desc {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.record-modal__fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.record-modal__fields.albaran-form__header {
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

@media (max-width: 1024px) {
    .record-modal__fields.albaran-form__header {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .record-modal__fields.albaran-form__header {
        grid-template-columns: minmax(0, 1fr);
    }
}

.record-modal__fields--single {
    grid-template-columns: 1fr;
}

.record-modal__fields--notes {
    width: 100%;
}

.record-modal__notes-field {
    height: 100%;
}

.record-modal__notes-textarea {
    min-height: 18rem;
}

.record-modal__checkbox input[type="checkbox"] {
    accent-color: #000;
}

.record-modal__checkbox input[type="checkbox"]:checked {
    background-color: #000;
    border-color: #000;
}

.record-modal__panel-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.35rem 0.35rem 0.75rem;
}

.record-modal__section-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
}

.record-modal__section-lead {
    margin-bottom: 0;
}

.record-modal__section-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.record-modal__section--compact .record-modal__section-title {
    margin: 0.45rem 0 0.15rem 0;
}

.cliente-extracto-table {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    display: table;
    margin-right: 0;
}

.cliente-extracto-table .extracto-balance-row td {
    background: #000;
    color: #fff;
    font-weight: 700;
}

.cliente-extracto__saldo-final {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.85rem;
    border: 1px solid rgba(15, 23, 42, 0.2);
    border-radius: 0.9rem;
    background: #fff;
    font-weight: 600;
    align-self: flex-start;
    margin-top: 1.4rem;
    min-height: 42px;
    height: 42px;
    font-size: 1rem;
    line-height: 1;
}

.cliente-extracto__saldo-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.cliente-extracto__saldo-value {
    font-weight: 700;
}

.cliente-extracto__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.35rem;
}

.cliente-extracto__filters {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.cliente-extracto__filter-toggle {
    gap: 0.35rem;
    align-self: flex-start;
    margin-top: 1.1rem;
}

.cliente-extracto__filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 140px;
}

.cliente-extracto__filter-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.extracto-balance-row td {
    font-weight: 600;
}
.cliente-extracto__filter-refresh {
    align-self: flex-start;
    margin-top: 1.4rem;
    min-height: 42px;
    height: 42px;
    width: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cobro-aplicaciones__importe {
    width: 180px;
}

.cobro-aplicaciones__spacer {
    width: 20%;
}

.cobro-aplicaciones__summary {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.cobro-aplicaciones__total {
    min-width: 160px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.cobro-aplicaciones__summary .muted {
    font-weight: 600;
}

.record-modal__hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.record-modal__error {
    border: 1px solid rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
    border-radius: 0.9rem;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.82rem;
}

.record-modal__error-title {
    font-weight: 600;
    color: var(--danger);
    font-size: 0.80rem;
}

.record-modal__error-list {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--danger);
    font-size: 0.75rem;
}

.record-modal__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.record-modal__list-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
}

.record-modal__list-item {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 0.8rem;
    padding: 0.65rem 0.85rem;
    background: #fff;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.record-modal__list-item.is-open {
    background: #f8fafc;
    border-color: rgba(15, 23, 42, 0.18);
}

.albaran-embed-preview {
    display: none;
    margin-top: 0.65rem;
}

.record-modal__list-item.is-open .albaran-embed-preview {
    display: block;
}

.record-modal__list-item:hover {
    background-color: var(--row-hover);
}

.record-modal__list-item.record-row--updated {
    background-color: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.45);
}

.record-modal__list-item.record-row--deleted {
    background-color: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.45);
}

.record-modal__list-item.record-row--focus {
    background-color: #0f172a;
    border-color: #0f172a;
    color: #fff;
}

.record-modal--contrato .record-modal__list {
    gap: 0.2rem;
}

.record-modal--contrato .record-modal__list-item {
    padding: 0.22rem 0.6rem;
}

.record-modal--contrato .record-modal__item-row {
    line-height: 1.25;
}

.record-modal--contrato .mensualidades-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.05rem;
}

.record-modal--contrato .mensualidades-table__row td {
    background: #fff;
    border: none;
    padding: 0.18rem 0.5rem;
    vertical-align: middle;
}

.record-modal--contrato .mensualidades-table__row td:first-child {
    border-top-left-radius: 0.65rem;
    border-bottom-left-radius: 0.65rem;
}

.record-modal--contrato .mensualidades-table__row td:last-child {
    border-top-right-radius: 0.65rem;
    border-bottom-right-radius: 0.65rem;
}

.record-modal--contrato .mensualidades-table__row.record-row--focus td {
    background-color: #0f172a;
    border-color: #0f172a;
    color: #fff;
}

.record-modal--contrato .mensualidades-table__row:hover td {
    background-color: #e5e7eb;
}

.record-modal--contrato .mensualidades-table__period {
    width: 90px;
}

.record-modal--contrato .mensualidades-table__precio {
    width: 120px;
}

.record-modal--contrato .mensualidades-table__estado {
    width: 120px;
}

.record-modal--contrato .mensualidades-table__albaran {
    width: 90px;
}

.record-modal--contrato .mensualidades-table__acciones {
    width: 96px;
}

.record-modal--contrato .mensualidades-table__acciones-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.record-modal--contrato .mensualidades-table__concepto .record-modal__item-sku {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-modal--contrato .mensualidades-table__acciones .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.6rem;
}

.record-modal--contrato .mensualidades-table__acciones .btn .btn-icon {
    display: inline-flex;
    align-items: center;
}

.record-modal--contrato .record-modal__item-row>div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.record-modal--contrato .record-modal__item-meta {
    width: 190px;
    justify-content: flex-start;
}

.record-modal--mensualidad-albaran .record-modal__window {
    width: min(760px, 92vw);
    max-width: 760px;
}

.record-modal--contrato .record-modal__item-actions {
    width: 64px;
    justify-content: flex-end;
}

.record-modal--contrato .record-modal__item-sku {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-modal--contrato .record-modal__item-actions .btn {
    padding: 0.3rem 0.55rem;
}

.record-modal--contrato .status-chip {
    padding: 0.2rem 0.55rem;
    font-size: 0.8rem;
}

.record-modal__item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.record-modal__item-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.record-modal__item-name {
    font-weight: 600;
}

.record-modal__item-sku {
    font-family: "Courier New", monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.record-modal__empty {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0;
}

.record-modal__footer {
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    padding: 1.25rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.record-modal__footer-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

@media (max-width: 720px) {
    .record-modal {
        padding: 1rem;
    }

    .record-modal__body,
    .record-modal__footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .record-modal__tabs-content {
        padding: 0.6rem 0.85rem;
        max-height: 320px;
    }

    .record-modal__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .record-modal__footer-right,
    .record-modal__footer-left {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }

    .record-modal__footer-right {
        justify-content: flex-end;
    }
}

tr[data-record-row-id] {
    cursor: pointer;
}

tr[data-record-row-id] td {
    transition: background-color 0.3s ease;
}

tr.record-row--updated td {
    background-color: rgba(16, 185, 129, 0.18);
}

tr.record-row--deleted td {
    background-color: rgba(239, 68, 68, 0.28);
}

tr.record-row--focus td {
    background-color: #000;
    color: #fff;
}

.view-table tbody tr.record-row--updated td.sorted {
    background-color: rgba(16, 185, 129, 0.18);
}

.view-table tbody tr.record-row--deleted td.sorted {
    background-color: rgba(239, 68, 68, 0.28);
}

.view-table tbody tr.record-row--focus td.sorted {
    background-color: #000;
    color: #fff;
}

/* Dynamic select */
.dynamic-select {
    position: relative;
    width: 100%;
}

.dynamic-select .dynamic-select__display,
.dynamic-select .dynamic-select__input {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px 12px;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.95rem;
    line-height: 1.4;
    cursor: text;
}

.dynamic-select .dynamic-select__display {
    display: flex;
    align-items: center;
    min-height: 44px;
}

.dynamic-select .dynamic-select__display.is-placeholder {
    color: #6b7280;
}

.dynamic-select.is-disabled .dynamic-select__display {
    background: #f5f5f5;
    color: #9ca3af;
    cursor: not-allowed;
}

.dynamic-select .dynamic-select__input {
    box-shadow: none;
}

.dynamic-select .dynamic-select__input:focus {
    border-color: #0f172a;
    outline: none;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
}

/* Compacto solo en lineas de albaran */
.albaran-lines__table .dynamic-select .dynamic-select__display,
.albaran-lines__table .dynamic-select .dynamic-select__input {
    padding: 8px 10px;
    line-height: 1.25;
}

.albaran-lines__table .dynamic-select .dynamic-select__display {
    min-height: 36px;
}

.dynamic-select .dynamic-select__input-wrapper {
    display: none;
}

.dynamic-select.is-editing .dynamic-select__input-wrapper {
    display: block;
}

.dynamic-select.is-editing .dynamic-select__display {
    display: none;
}

.dynamic-select .dynamic-select__dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    padding: 6px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 30;
    display: none;
}

.dynamic-select.is-open .dynamic-select__dropdown {
    display: block;
}

.dynamic-select__options {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dynamic-select__item+.dynamic-select__item {
    margin-top: 4px;
}

.dynamic-select__option {
    width: 100%;
    text-align: left;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    color: #0f172a;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.dynamic-select__option:hover,
.dynamic-select__option:focus {
    background: #f1f5f9;
    border-color: #cbd5e1;
    outline: none;
}

.dynamic-select__option.is-empty {
    font-weight: 600;
    border-style: dashed;
    background: #f9fafb;
}

.dynamic-select__empty {
    padding: 8px 10px;
    color: #6b7280;
    font-size: 13px;
}

.dynamic-select.is-invalid .dynamic-select__display,
.dynamic-select.is-invalid .dynamic-select__input {
    border-color: #ef4444;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.1);
}
