:root {
    --azul-principal: #1976d2;
    --azul-secundario: #0d47a1;
    --gris-fondo: #f5f7fa;
    --gris-borde: #dce1e6;
    --gris-texto: #444;
    --verde-ok: #43a047;
    --rojo-error: #e53935;
    --amarillo-alerta: #fbc02d;
}

/* Estilos generales */
body {
    margin: 0;
    font-family: 'Segoe UI', sans-serif;
    background-color: #f6f7f9;
    color: #333;
}

html, body {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
}

body > .footer {
    margin-top: auto;
}

/* Centrado del formulario */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-container form {
    display: flex;
    flex-direction: column;
}

.login-container input[type="text"],
.login-container input[type="email"],
.login-container input[type="password"] {
    padding: 0.8rem;
    margin-bottom: 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.login-container input:focus {
    border-color: #333;
    outline: none;
}

.login-container button {
    padding: 0.9rem;
    background-color: #1a73e8;
    color: #fff;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.login-container button:hover {
    background-color: #0f5bd4;
}
.error-msg {
    background-color: #ffdede;
    color: #b80000;
    border: 1px solid #e08a8a;
    padding: 10px;
    margin-bottom: 1rem;
    border-radius: 5px;
    text-align: center;
}

.forgot-link {
    margin-top: 1rem;
    text-align: center;
}

.forgot-link a {
    color: #1a73e8;
    text-decoration: none;
    font-size: 0.95rem;
}

.forgot-link a:hover {
    text-decoration: underline;
}
.footer {
    text-align: center;
    padding: 1.5rem 1rem;
    background-color: #f1f3f4;
    color: #666;
    font-size: 0.9rem;
    border-top: 1px solid #ddd;
    position: relative;
    bottom: 0;
    width: 100%;
}

/* 🌐 Navbar principal */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--azul-principal);
    padding: 0.9rem 1.8rem;
    color: #fff;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Marca o logo */
.navbar-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    transition: opacity 0.2s ease;
}
.navbar-brand a:hover {
    opacity: 0.85;
}

/* Contenedor de enlaces */
.navbar-links {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

/* Enlaces del navbar */
.navbar a {
    color: #fff;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s ease;
}
.navbar a:hover {
    opacity: 0.85;
}

/* Usuario / sesión info */
.navbar-user {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}


@media (max-height: 600px) {
    .footer {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .navbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .navbar-links {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    .navbar-links a {
        margin: 0.3rem 0;
    }

    .navbar-links span {
        margin-bottom: 0.3rem;
    }
}

.info-msg {
    background-color: #e7f3fe;
    color: #155a9c;
    border: 1px solid #a3d0f9;
    padding: 10px;
    margin-bottom: 1rem;
    border-radius: 5px;
    text-align: center;
}

/* 🧾 Tabla general */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.95rem;
    background-color: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
    margin-top: 1.5rem;
    border-radius: 12px;
    overflow: hidden;
}


/* Encabezado */
table thead {
    background-color: var(--azul-principal) !important;
    color: #fff !important;
}
table thead th {
    padding: 14px 18px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid #e0e0e0;
}

/* Cuerpo */
table tbody td {
    padding: 12px 18px;
    border-bottom: 1px solid #f0f0f0;
    color: var(--gris-texto);
    vertical-align: middle;
    font-size: 0.92rem;
}

/* Alternancia */
table tbody tr:nth-child(even) {
    background-color: #fbfcfe;
}

/* Hover */
table tbody tr:hover {
    background-color: #f1f7ff;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

/* Última fila sin borde */
table tbody tr:last-child td {
    border-bottom: none;
}

/* Acciones (por ejemplo botones en tabla) */
td .btn {
    margin-right: 4px;
}

.main-content > *:not(.navbar) {
    padding: 2rem;
    flex-grow: 1;
}

/* Contenedor general del datatable */
.dataTables_wrapper {
    margin-top: 1.5rem;
}

/* Input de búsqueda */
.dataTables_filter {
    position: relative;
}

.dataTables_filter input {
    padding: 8px 12px 8px 36px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: white;
    background-size: 18px;
}

/* Select de paginación */
.dataTables_length label {
    font-size: 0.95rem;
    color: #333;
    font-weight: 500;
}

.dataTables_length select {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    background-color: #fff;
    margin-left: 6px;
}

.dataTables_wrapper {
    margin-top: 1rem;
    padding: 0 1rem;
}

.dataTables_filter {
    float: right;
    margin-bottom: 1rem;
}

/* Información de la tabla */
.dataTables_info {
    padding-top: 1rem;
    font-size: 0.85rem;
    color: #666;
}

/* Controles de paginación */
.dataTables_paginate {
    margin-top: 1rem;
    text-align: right;
}

.dataTables_paginate a {
    padding: 6px 10px;
    margin: 0 2px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f8f8f8;
    text-decoration: none;
    color: #333;
    font-size: 0.9rem;
}

.dataTables_paginate a:hover {
    background-color: #e6f0ff;
    border-color: #7aa6e8;
}

.dataTables_paginate .current {
    background-color: #1a73e8;
    color: white !important;
    border-color: #1a73e8;
}
h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #1a73e8;
    text-shadow: 1px 1px 1px rgba(26, 115, 232, 0.1);
    letter-spacing: -0.5px;
    border-left: 5px solid #1a73e8;
    padding-left: 12px;
}
.btn {
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s ease-in-out;
    border: none;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--azul-principal);
    color: white;
}

.btn-primary:hover {
    background-color: var(--azul-secundario);
}

.btn-small {
    padding: 4px 8px;
    font-size: 0.85rem;
    margin-right: 4px;
}

.btn-edit {
    background-color: #ffc107;
    color: #333;
}

.btn-verifactu {
    background-color: #88d69a;
    color: white;
}

.btn-delete {
    background-color: #dc3545;
    color: white;
}

.btn-edit:hover {
    background-color: #e0a800;
}

.btn-verifactu:hover {
    background-color: #218838;
}

.btn-delete:hover {
    background-color: #c82333;
}
.btn-delete-factura{
    background-color: var(--gris-fondo);
}
.btn-delete-factura:hover {
    background-color: var(--gris-borde) !important;
}
.factura-acciones .btn-delete-factura{
    background-color: var(--gris-fondo);
    color: #333;
    font-weight: 100;
}
form {
    max-width: 600px;
    margin: 2rem auto;
    background-color: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

form#editar-factura {
    max-width: 700px;
}

form label {
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #333;
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form input[type="date"],
form select {
    padding: 0.7rem 1rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    transition: border 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

form input:focus,
form select:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
    outline: none;
}

form button[type="submit"] {
    background-color: #4a90e2;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease-in-out;
}

form button[type="submit"]:hover {
    background-color: #3a78c2;
}

.forgot-link {
    margin-top: 1rem;
    text-align: center;
}

.forgot-link a {
    color: #4a90e2;
    text-decoration: none;
    font-weight: 500;
}

.forgot-link a:hover {
    text-decoration: underline;
}

.error-msg, .info-msg {
    max-width: 600px;
    margin: 1rem auto;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
}

.error-msg {
    background-color: #ffe5e5;
    color: #c00;
    border: 1px solid #f5b5b5;
}

.info-msg {
    background-color: #e5f6ff;
    color: #0077b6;
    border: 1px solid #b5e3f5;
}

.card-panel {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.04);
    padding: 1.5rem;
    text-align: center;
    transition: box-shadow 0.2s ease-in-out;
}

.card-panel:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.card-panel .card-title {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--azul-secundario);
    margin-bottom: 0.4rem;
}

.card-panel .card-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--gris-texto);
}
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    cursor: pointer;
    color: white;
    font-weight: 500;
    text-decoration: none;
    margin-left: 1rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    z-index: 1;
}

.dropdown-menu a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    border-bottom: 1px solid #eee;
}

.dropdown-menu a:hover {
    background-color: #f1f1f1;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.navbar .dropdown {
    position: relative;
    display: inline-block;
}

.navbar .dropdown-toggle {
    cursor: pointer;
    font-weight: 500;
    color: #fff;
    margin-left: 1rem;
    text-decoration: none;
}

.navbar .dropdown-menu {
    display: none;
    position: absolute;
    right: 0; /* para alinear a la derecha */
    background-color: white;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    z-index: 1;
    border-radius: 4px;
    overflow: hidden;
}

.navbar .dropdown-menu a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    border-bottom: 1px solid #eee;
}

.navbar .dropdown-menu a:hover {
    background-color: #f1f1f1;
}

.navbar .dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-right {
    right: 0;
    left: auto;
}

.anulada {
    background-color: #ffe6e6 !important;
    color: #999 !important;
    text-decoration: line-through;
    position: relative;
}

.anulada::after {
    content: '⚠️ Anulada';
    position: absolute;
    top: 8px;
    right: 40px;
    font-size: 0.8em;
    color: #d33;
}

.hash-verifactu {
    margin-top: 10px;
    font-size: 0.9em;
    word-break: break-all;
}

tr.procesada {
    background-color: #e3f8e3 !important;
}
.linea-item,
.descuento-item,
.repercutido-item,
.retenido-item {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
    background-color: #fafafa;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 8px;
}

#lineas-container,
#descuentos-container,
#repercutidos-container,
#retenidos-container {
    margin-bottom: 1.5rem;
}

form h3 {
    font-size: 1.3rem;
    margin: 2rem 0 1rem;
    color: #1a73e8;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0.3rem;
}

form fieldset {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    background-color: #fdfdfd;
}

form fieldset legend {
    font-weight: bold;
    font-size: 1rem;
    color: #333;
    padding: 0 6px;
}

form fieldset label {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    gap: 0.6rem;
    font-weight: 600;
    flex-wrap: wrap;
}

form fieldset label input,
form fieldset label select {
    flex: 1;
    min-width: 160px;
    padding: 0.6rem;
}
.factura-detalle {
    background-color: #fff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
    max-width: 800px;
    margin: 0 auto;
}

.factura-cabecera ul,
.factura-resumen ul,
.factura-descuentos ul,
.factura-impuestos ul,
.factura-retenciones ul {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.factura-cabecera ul li,
.factura-resumen ul li,
.factura-descuentos ul li,
.factura-impuestos ul li,
.factura-retenciones ul li {
    padding: 0.3rem 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.factura-cabecera ul li:last-child,
.factura-resumen ul li:last-child,
.factura-descuentos ul li:last-child,
.factura-impuestos ul li:last-child,
.factura-retenciones ul li:last-child {
    border-bottom: none;
}

.factura-cabecera ul li strong,
.factura-resumen ul li strong,
.factura-descuentos ul li strong,
.factura-impuestos ul li strong,
.factura-retenciones ul li strong {
    color: #444;
    font-weight: 600;
    min-width: 240px;
    display: inline-block;
}

.factura-qr,
.factura-verifactu {
    text-align: center;
    margin-bottom: 2rem;
}

.factura-verifactu img.qr-img {
    max-height: 120px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.factura-acciones {
    text-align: center;
    margin-top: 2rem;
}

.factura-acciones .btn {
    margin: 0.5rem;
}

/* Tabla de líneas */
.factura-lineas table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.95rem;
}

.factura-lineas th,
.factura-lineas td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid #eee;
    text-align: left;
}

.factura-lineas th {
    background-color: var(--azul-principal);
    color: white;
    font-weight: 600;
}

.factura-lineas tr:nth-child(even) {
    background-color: #fafafa;
}

.log-verifactu {
    background-color: #e0ffe0 !important;
}
.log-anulada {
    background-color: #ffe6e6 !important;
}

.filter-form {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    max-width: 100%;
}

.filter-form .filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}

.filter-form label {
    font-weight: bold;
    margin-right: 0.5rem;
}

.filter-form select,
.filter-form input[type="date"] {
    padding: 0.4rem 0.6rem;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.filter-form .btn {
    height: 2.2rem;
    padding: 0 1rem;
    font-size: 0.95rem;
}

.navbar-logo {
    height: 55px;
    width: auto;
}

.dashboard-overview {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: flex-start;
    margin-top: 2rem;
}

.cards-container {
    flex: 1 1 300px;
}

.chart-distribucion {
    flex: 1 1 360px;
    background: #fff;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.dashboard-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.dashboard-buttons {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.dashboard-buttons > div {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

.dashboard-cards .card {
    background: #f8f9fa;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    width: 230px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    text-align: center;
}

.dashboard-cards .card h2 {
    font-size: 2rem;
    margin: 0.2rem 0;
}

.dashboard-cards .card p {
    margin: 0.2rem 0 1rem;
    color: #555;
}

@media (max-width: 768px) {
    .dashboard-overview {
        flex-direction: column;
    }
    .chart-distribucion {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .main-content > *:not(.navbar) {
        padding: 1rem;
    }
}

/* Navegación */
.navbar {
    position: relative;
}
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: white;
    cursor: pointer;
}

@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
    }

    .navbar-toggle {
        display: block;
        position: absolute;
        top: 1rem;
        right: 1rem;
        background: var(--azul-principal);
        border: none;
        color: #fff;
        padding: 0.4rem 0.8rem;
        border-radius: 4px;
        font-size: 1.8rem;
        cursor: pointer;
        box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    }

    .navbar-links {
        margin-top: 3rem;
    }

    .navbar-links {
        display: none;
        flex-direction: column;
        width: 100%;
        background-color: var(--azul-principal);
        padding: 1rem 0;
        border-top: 1px solid rgba(255,255,255,0.2);
    }

    .navbar-links a,
    .navbar .dropdown {
        padding: 0.5rem 1.5rem;
        width: 100%;
    }

    .navbar-links.show {
        display: flex;
    }

    .navbar .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        background-color: rgba(255,255,255,0.1);
        border-radius: 0;
    }

    .navbar .dropdown:hover .dropdown-menu {
        display: none;
    }

    .navbar .dropdown.open .dropdown-menu {
        display: block;
    }

    .navbar a.dropdown-toggle {
        padding-left: 0px;
        margin-left: 0px;
    }
    .navbar .dropdown-toggle.navbar-user {
        padding-left: 1.5rem;
    }
}


/* Dashboard */
@media (max-width: 768px) {
    .dashboard-overview {
        flex-direction: column;
        gap: 2rem;
    }

    .cards-container {
        width: 100%;
    }

    .dashboard-cards {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .dashboard-cards .card {
        width: 90%;
        padding: 5%;
        margin: 0;
    }

    .dashboard-buttons {
        justify-content: center;
        flex-direction: column;
        align-items: center;
    }

    .dashboard-buttons > div {
        margin-top: 1.5rem;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }

    .chart-distribucion {
        width: 90%;
        max-width: 90%;
        padding: 5%;
        margin: 0 auto;
    }

    .chart-distribucion canvas {
        width: 100% !important;
        height: auto !important;
    }

    .filter-form.filter-form-dashboard .filters {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Ajuste responsive de las tablas */
@media (max-width: 768px) {
    .dataTables_wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        padding: 0px;
    }

    table.admin-table thead {
        display: none;
    }

    table.admin-table tbody tr {
        display: block;
        margin-bottom: 10px;
        border-radius: 8px;
        padding: 10px;
        background-color: #fff;
        box-shadow: 0 3px 6px rgba(0,0,0,0.1);
        border: 1px solid #dce1e6;
    }

    table.admin-table tbody tr:hover {
        background-color: #eef6ff;
        border-left: 4px solid var(--azul-principal);
    }

    table.admin-table tbody td {
        display: flex;
        justify-content: space-between;
        padding: 10px;
        border-bottom: 1px solid #ddd;
        font-size: 0.9rem;
    }

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

    table.admin-table tbody td::before {
        content: attr(data-label);
        font-weight: bold;
        text-transform: uppercase;
        color: #333;
        margin-right: 1rem;
        flex: 1 1 auto;
    }

    table.admin-table tbody td a.btn {
        display: inline-block;
        padding: 6px 10px;
        border-radius: 5px;
        text-decoration: none;
        font-size: 0.85rem;
        font-weight: 500;
        margin: 2px 2px;
        text-transform: uppercase;
        transition: background 0.3s, color 0.3s;
    }

    table.admin-table tbody td a.btn:hover {
        opacity: 0.9;
    }
}

/* Facturas - Listar */
@media (min-width: 930px) {
    #tabla-facturas th:last-child,
    #tabla-facturas td:last-child {
        min-width: 110px;
    }
      #tabla-facturas td[data-label="Acciones"] {
        text-align: center;
    }
}

@media (max-width: 930px) {
        #tabla-facturas_wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    #tabla-facturas thead {
        display: none;
    }

    #tabla-facturas tbody tr {
        display: block;
        margin-bottom: 10px;
        border-radius: 8px;
        padding: 10px;
        background-color: #fff;
        box-shadow: 0 3px 6px rgba(0,0,0,0.1);
        border: 1px solid #dce1e6;
    }

    #tabla-facturas tbody tr:nth-child(odd) {
        background-color: #f7f7f7;
    }

    #tabla-facturas tbody tr:nth-child(even) {
        background-color: #ffffff;
    }

    #tabla-facturas tbody tr:hover {
        background-color: #eef6ff;
        border-left: 4px solid var(--azul-principal);
    }

    #tabla-facturas tbody td {
        display: flex;
        justify-content: space-between;
        padding: 10px;
        border-bottom: 1px solid #ddd;
        font-size: 0.9rem;
    }

    #tabla-facturas tbody td:last-child {
        border-bottom: none;
    }

    #tabla-facturas tbody td::before {
        content: attr(data-label);
        font-weight: bold;
        text-transform: uppercase;
        color: #333;
        margin-right: 1rem;
        flex: 1 1 auto;
    }

    #tabla-facturas tbody td a.btn {
        display: inline-block;
        padding: 6px 10px;
        border-radius: 5px;
        text-decoration: none;
        font-size: 0.85rem;
        font-weight: 500;
        margin: 2px 2px;
        text-transform: uppercase;
        transition: background 0.3s, color 0.3s;
    }

    #tabla-facturas tbody td a.btn:hover {
        opacity: 0.9;
    }

    .anulada::after {
        bottom: 15px;
        right: 15px;
        top: unset;
    }
}

/* Facturas - Ficha */
@media (max-width: 768px) {
    .factura-acciones {
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
        align-items: stretch;
    }
    .factura-lineas table.admin-table td {
        flex-direction: column;
    }

    .factura-detalle {
        padding: 1rem;
    }
    
    .factura-detalle ul {
        padding: 0;
    }

    .factura-detalle ul li {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
        padding: 0.5rem 0;
    }

    .factura-detalle ul li strong {
        min-width: auto;
    }

    form#form-subida {
        padding: 1rem;
    }
}

/* Usuarios y empresas */
@media (max-width: 768px) {
    .usuarios-registrados, .listar-empresas {
        flex-direction: column;
        margin-bottom: 30px;
        gap: 10px;
    }
}

/* === Pagarés (scoped) =================================================== */
.pagares-ui .pagare-editar-layout{
  display:grid;
  grid-template-columns: 3fr 2fr;     /* ≈60/40: PDF más ancho */
  gap: 2rem;
  align-items: start;
}
@media (max-width: 1400px){
  .pagares-ui .pagare-editar-layout{ grid-template-columns: 1.7fr 1fr; }
}
@media (max-width: 1024px){
  .pagares-ui .pagare-editar-layout{ grid-template-columns: 1fr; }
}

/* Cols bounds */
.pagares-ui .pagare-pdf{ min-width: 460px; max-width: 100%; }
.pagares-ui .pagare-form{ min-width: 360px; max-width: 860px; }

/* PDF sticky + viewport height */
.pagares-ui .pagare-pdf--sticky{ position: sticky; top: 1rem; }
.pagares-ui .pdf-wrap{
  border:1px solid #e5e5e5; border-radius:8px; overflow:hidden;
  max-height: calc(100vh - 2rem);
}
.pagares-ui .pdf-wrap object,
.pagares-ui .pdf-wrap iframe{
  width:100%;
  height: calc(100vh - 2rem);
  display:block;
}
.pagares-ui .pdf-tip{ margin-top:.5rem; color:#666; }
@media (max-width: 1024px){
  .pagares-ui .pagare-pdf--sticky{ position: static; }
  .pagares-ui .pdf-wrap{ max-height: 520px; }
  .pagares-ui .pdf-wrap object,
  .pagares-ui .pdf-wrap iframe{ height: 520px; }
}

/* Grids del formulario */
.pagares-ui .grid-ident{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.pagares-ui .grid-2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 900px){
  .pagares-ui .grid-2{ grid-template-columns: 1fr; }
}
.pagares-ui .full{ grid-column: 1 / -1; }

.pagares-ui .grid-ident label,
.pagares-ui .grid-2 label{ display:flex; flex-direction:column; min-width:0; }
.pagares-ui .grid-ident input,
.pagares-ui .grid-ident select,
.pagares-ui .grid-2 input,
.pagares-ui .grid-2 select{ width:100%; min-width:0; }

/* Hints compactos */
.pagares-ui .hint{
  margin-top:.25rem; color:#666; font-size:.85rem; line-height:1.2;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

/* Select2 a 100% solo aquí */
.pagares-ui .select2-container{ width:100% !important; }

/* Feedback validación (clases que ya usas) */
.pagares-ui .input-ok    { border-color:#28a745 !important; box-shadow:0 0 0 2px rgba(40,167,69,.15); }
.pagares-ui .input-error { border-color:#dc3545 !important; box-shadow:0 0 0 2px rgba(220,53,69,.15); }

/* Botonera del formulario */
.pagares-ui .form-actions{
  display:flex; gap:.5rem; flex-wrap:wrap; margin-top:1rem;
}

.pagare-form select {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.selector-entidad {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Arreglo de solapes en formularios de Pagarés --- */
.pagares-ui fieldset { min-width: 0; }

.pagares-ui .grid-ident,
.pagares-ui .grid-2 {
  align-items: start;
  grid-auto-flow: row;
}

.pagares-ui .grid-ident > label,
.pagares-ui .grid-2 > label {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  min-width: 0;           /* permite que el contenido encoja dentro de la celda */
}

/* ¡Caja correcta para TODOS los controles dentro de pagarés! */
.pagares-ui input,
.pagares-ui select,
.pagares-ui textarea,
.pagares-ui .select2-container,
.pagares-ui .select2-selection--single {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: block;
}

/* Inputs de fecha y texto: dimensiones coherentes */
.pagares-ui input[type="text"],
.pagares-ui input[type="number"],
.pagares-ui input[type="date"] {
  padding: .5rem .75rem;
}

/* Hints compactos: no empujan a los vecinos */
.pagares-ui .hint {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Select2: asegura altura y que no se desborde */
.pagares-ui .select2-container--default .select2-selection--single {
  height: 38px;
}
.pagares-ui .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 38px;
}
.pagares-ui .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 38px;
}

/* ===== Vista ver pagaré ===== */
.pagares-ui .view-header{
  display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap;
  margin-bottom: 1rem;
}
.pagares-ui .view-header h1{ margin:0; font-weight:700; font-size:1.8rem; }
.pagares-ui .view-header .strong{ font-weight:800; }
.pagares-ui .view-header .muted, .pagares-ui .meta-grid .muted{ color:#6b7280; font-weight:400; margin-left:.25rem; }
.pagares-ui .chip{
  display:inline-block; margin-left:.5rem; padding:.15rem .5rem;
  font-size:.85rem; border-radius:999px; background:#eef2ff; color:#3730a3;
}
.chip {
  display:inline-flex; align-items:center; gap:.35rem;
  padding:.2rem .6rem; border-radius:999px;
  font-size:.85rem; font-weight:600; line-height:1;
  border:1px solid transparent;
}
.chip.chip-warning { background:#fff3cd; color:#856404; border-color:#ffe8a1; }
.chip-estado .dot { width:8px; height:8px; border-radius:50%; display:inline-block; }
.btn .btn-spinner {
  width:14px; height:14px; border-radius:50%;
  border:2px solid rgba(255,255,255,.35);
  border-top-color:#fff;
  display:inline-block; vertical-align:middle; margin-left:.5rem;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chip-estado { margin-left:.4rem; }

/* Estados */
.state-procesando { background:#fff3cd; color:#856404; border-color:#ffe8a1; }
.state-procesando .dot { background:#ffc107; animation:pulse 1s infinite; }

.state-parseado-ok  { background:#e7f5ff; color:#0b7285; border-color:#cfe8fb; }
.state-parseado-ok .dot { background:#74c0fc; }

.state-procesado-ok { background:#e6ffed; color:#0f5132; border-color:#b7f3c7; }
.state-procesado-ok .dot { background:#2f9e44; }

.state-error        { background:#fde2e2; color:#842029; border-color:#f8c8c8; }
.state-error .dot   { background:#e03131; }

.state-recibido     { background:#eceff1; color:#495057; border-color:#dfe4e7; }
.state-recibido .dot{ background:#868e96; }

/* Animación para “procesando” */
@keyframes pulse { 0%{opacity:.35} 50%{opacity:1} 100%{opacity:.35} }
.pagares-ui .actions{ display:flex; gap:.5rem; }

.pagares-ui .pagare-detalle{
  display:grid; gap:2rem;
  grid-template-columns: 1.2fr 1.8fr; /* datos / PDF (PDF más ancho) */
}
@media (max-width: 1200px){
  .pagares-ui .pagare-detalle{ grid-template-columns: 1fr; }
}

/* Tarjetas */
.pagares-ui .card-panel{ max-width:100%; box-sizing:border-box; }

/* Meta grid: filas clave-valor limpias */
.pagares-ui .meta-grid{
  display:grid; grid-template-columns: 1fr 2fr; gap:.35rem 1rem;
  margin: .5rem 0 1.25rem 0;
}
.pagares-ui .meta-grid dt{
  font-weight:600; color:#374151; text-align:right;
}
.pagares-ui .meta-grid dd{
  margin:0; color:#111827; word-break:break-word;
  text-align: left;
}
@media (max-width: 640px){
  .pagares-ui .meta-grid{ grid-template-columns: 1fr; }
  .pagares-ui .meta-grid dt{ text-align:left; }
}

/* Monospace para códigos */
.pagares-ui .mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }

/* PDF sticky y alto adaptado a viewport */
.pagares-ui .pagare-pdf--sticky{ position: sticky; top: 1rem; }
.pagares-ui .pdf-wrap{
  border:1px solid #e5e5e5; border-radius:8px; overflow:hidden;
  max-height: calc(100vh - 2rem);
}
.pagares-ui .pdf-wrap object,
.pagares-ui .pdf-wrap iframe{
  width:100%; height: calc(100vh - 2rem); display:block;
}
.pagares-ui .pdf-tip{ margin-top:.5rem; color:#6b7280; }
@media (max-width: 1200px){
  .pagares-ui .pagare-pdf--sticky{ position: static; }
  .pagares-ui .pdf-wrap{ max-height: 70vh; }
  .pagares-ui .pdf-wrap object,
  .pagares-ui .pdf-wrap iframe{ height: 70vh; }
}

/* === Estados de procesado === */
table tbody tr.estado-procesando {
    background-color: #fff6e0; /* Amarillo claro */
}

table tbody tr.estado-parseado-ok {
    background-color: #e8f5e9; /* Verde claro */
}
table tbody tr.estado-parseado-ok:hover {
    background-color: #c8e6c9; /* Verde más intenso al pasar el mouse */
}

table tbody tr.estado-procesado-ok {
    background-color: #e0f7fa; /* Azul claro */
}
table tbody tr.estado-procesado-ok:hover {
    background-color: #b2ebf2; /* Azul más intenso al pasar el mouse */
}

table tbody tr.estado-error {
    background-color: #ffebee; /* Rojo claro */
}
table tbody tr.estado-error:hover {
    background-color: #ffcdd2; /* Rojo más intenso al pasar el mouse */
}

table tbody tr.estado-findango-error {
    background-color: #f3e5f5; /* Morado claro */
}
table tbody tr.estado-findango-error:hover {
    background-color: #e1bee7; /* Morado más intenso al pasar el mouse */
}

/* Fila en procesamiento: fondo animado tipo shimmer amarillo */
tr.estado-procesando {
  position: relative;
  background: linear-gradient(
      110deg,
      rgba(255, 249, 217, 0.9) 8%,   /* amarillo claro */
      rgba(255, 239, 170, 0.65) 18%, /* amarillo medio */
      rgba(255, 249, 217, 0.9) 33%
  );
  background-size: 200% 100%;
  animation: shimmer-row 1.2s linear infinite;
  cursor: progress;
}

/* Spinner cálido en la esquina derecha */
tr.estado-procesando::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 12px;
  width: 16px;
  height: 16px;
  margin-top: -8px;           
  border: 2px solid rgba(255, 193, 7, 0.3);   /* amarillo suave */
  border-top-color: rgba(255, 193, 7, 0.9);   /* amarillo fuerte */
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  pointer-events: none;        
  opacity: 0.9;
}

/* Borde sutil si hay varias filas procesando seguidas */
tr.estado-procesando + tr.estado-procesando {
  box-shadow: inset 0 1px 0 rgba(0,0,0,0.04);
}

/* Hover acentúa ligeramente el brillo */
tr.estado-procesando:hover {
  filter: brightness(1.02);
}

/* Animaciones */
@keyframes shimmer-row {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Respeta usuarios con reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
  tr.estado-procesando {
    animation: none;
    background: rgba(255, 249, 217, 0.9);
  }
  tr.estado-procesando::after {
    animation: none;
  }
}

/* Si algo se pasa de ancho, que la tabla pueda hacer scroll horizontal */
.pagares-ui .pagare-logs { overflow-x: auto; }

/* Alineación superior */
.admin-table td, .admin-table th { vertical-align: top; }

/* La columna Detalle no debe crecer infinito */
.admin-table td[data-label="Detalle"] { max-width: 560px; }

/* Texto de detalle: cortar a 3 líneas por defecto + permitir saltos en tokens largos (URLs, JSON) */
.log-detail{
  white-space: pre-wrap;               /* respeta saltos de línea */
  overflow-wrap: anywhere;             /* rompe palabras largas donde haga falta */
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;               /* CLAMP: 3 líneas */
  line-clamp: 3;                       /* para navegadores que lo soporten */
  max-height: 4.5em;                   /* fallback aproximado */
  overflow: hidden;
}

/* Estado expandido */
.log-detail.expanded{
  -webkit-line-clamp: unset;
  line-clamp: unset;
  max-height: none;
}

/* Botón toggle */
.log-toggle{
  display: inline-block;
  margin-top: .35rem;
  font-size: .85rem;
  text-decoration: underline;
  cursor: pointer;
  color: #0d6efd;
}
.log-toggle:focus { outline: 2px dashed #0d6efd; outline-offset: 2px; }

@media (min-width: 769px){
    #tabla-proveedores td[data-label="Nombre"] {
        max-width: 200px;       /* ancho máximo deseado */
        white-space: normal;    /* permite saltos de línea */
        word-break: break-word; /* fuerza corte si hay palabras largas */
    }
}

/* ===== Ficha Proveedor ===== */
.provider-meta { padding: 1rem 1.25rem; }
.provider-head { display:flex; flex-direction:column; gap:.5rem; margin-bottom: .75rem; }
.provider-title { display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; }
.provider-name { margin:0; font-size:1.25rem; font-weight:700; line-height:1.2; }

.provider-ids { display:flex; flex-wrap:wrap; gap:.5rem; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; padding-top: 4px; }

/* Chips genéricos (ya usas algo parecido en pagarés) */

.chip .dot { width:.5rem; height:.5rem; border-radius:50%; display:inline-block; }
.chip-success { background:#eaf8f0; border-color:#cfeedd; color:#176a3a; }
.chip-danger  { background:#fdecec; border-color:#f8d2d2; color:#9b1c1c; }
.chip-muted   { background:#f5f7fa; border-color:#e7ebf2; color:#556270; }
.chip-id      { background:#eef3ff; border-color:#d8e4ff; color:#1b3f8b; }

/* Grid de metadatos */
.meta-grid {
  display:grid;
  grid-template-columns: 160px 1fr;
  gap:.4rem 1rem;
  margin: .75rem 0 0;
}
.meta-grid dt {
  font-weight:600; color:#4b5563; white-space:nowrap;
}
.meta-grid dd {
  margin:0; color:#111827;
}
.meta-grid .muted { color:#6b7280; }

/* Responsive */
@media (max-width: 720px) {
  .meta-grid { grid-template-columns: 1fr; }
  .meta-grid dt { color:#6b7280; }
}

/* Contenedor responsive */
.factura-logs .table-wrapper{
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}

/* La tabla no se desborda y calcula por columnas */
.factura-logs table {
  width: 100%;
  table-layout: fixed;
}

/* Fija anchos pequeños para las “no críticas” */
.factura-logs .col-fecha      { width: 140px !important; }
.factura-logs .col-evento     { width: 160px !important; }
.factura-logs .col-usuario    { width: 220px !important; }
.factura-logs .col-ip         { width: 140px !important; }
/* La descripción no lleva width: se queda con TODO el espacio restante 
.factura-logs .col-descripcion {}*/

/* Que el texto largo no haga columnas finísimas */
.factura-logs th, .factura-logs td {
  white-space: normal; 
  vertical-align: top;
  font-size: 14px;
}

/* Wrap agresivo para hashes, códigos y mensajes largos */
.factura-logs td[data-label="Descripción"],
.factura-logs td:nth-child(3) {
  word-break: break-word;
}

/* El <code> suele impedir el wrap; lo forzamos */
.factura-logs code {
  white-space: normal;
  word-break: break-all;
}

/* Responsive: en pantallas pequeñas reduce un poco y oculta IP si hace falta */
@media (max-width: 900px) {
  .factura-logs .col-usuario { width: 180px !important; }
}
@media (max-width: 700px) {
  /* Si aprieta mucho, escondemos IP en móvil para dar aire a Descripción */
  .factura-logs thead th:nth-child(5),
  .factura-logs tbody td:nth-child(5) { display: none; }
}
