@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── RESET ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 0.75rem;
    background: #f4f6f9;
    color: #1a1a2e;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ── LAYOUT ── */
.contab-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.contab-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.contab-main {
    flex: 1;
    overflow-y: auto;
    min-width: 0;
}

.contab-content {
    padding: 1.25rem;
}

/* ── NAVBAR ── */
.contab-navbar {
    height: 52px;
    background: #198754;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
    z-index: 100;
    flex-shrink: 0;
}

.contab-system-name {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: .02em;
}

.contab-navbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.contab-user-name {
    color: rgba(255,255,255,.85);
    font-size: .75rem;
}

.contab-btn-salir {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.35);
    padding: .28rem .8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: .75rem;
}

    .contab-btn-salir:hover {
        background: rgba(255,255,255,.28);
    }

/* ── SIDEBAR ── */
.contab-sidebar {
    width: 210px;
    min-width: 210px;
    max-width: 210px;
    background: #fff;
    border-right: 1px solid #d8dde6;
    overflow-y: auto;
    padding: .75rem 0;
    flex-shrink: 0;
}

.contab-sidenav {
    display: flex;
    flex-direction: column;
}

.contab-nav-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1.1rem;
    font-size: .82rem;
    color: #374151;
    border-left: 3px solid transparent;
    transition: background .15s, border-color .15s;
}

    .contab-nav-item:hover {
        background: #f0faf5;
    }

    .contab-nav-item.active {
        background: #ecfdf5;
        border-left-color: #198754;
        color: #198754;
        font-weight: 600;
    }

/* ── LOGIN ── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f6f9;
}

.login-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,.1);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

    .login-logo h2 {
        color: #198754;
        font-size: 1.8rem;
        font-weight: 700;
    }

    .login-logo p {
        color: #6c757d;
        font-size: .88rem;
        margin-top: .3rem;
    }

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

    .login-field label {
        font-size: .8rem;
        font-weight: 600;
        color: #374151;
    }

    .login-field input {
        padding: .55rem .85rem;
        border: 1px solid #d1d5db;
        border-radius: 4px;
        font-size: .9rem;
    }

        .login-field input:focus {
            outline: none;
            border-color: #198754;
        }

.login-btn {
    background: #198754;
    color: white;
    border: none;
    padding: .65rem;
    border-radius: 4px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: .4rem;
}

    .login-btn:hover {
        background: #157347;
    }

    .login-btn:disabled {
        background: #6c757d;
        cursor: not-allowed;
    }

.login-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    padding: .55rem .85rem;
    font-size: .82rem;
    margin-bottom: .8rem;
}

.login-info {
    color: #6c757d;
    font-size: .85rem;
    text-align: center;
}

/* ── PAGE HEADER ── */
.contab-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

    .contab-page-header h4 {
        font-size: 1.05rem;
        font-weight: 700;
        color: #1a1a2e;
    }

/* ── CARD ── */
.contab-card {
    background: white;
    border-radius: 5px;
    border: 1px solid #d8dde6;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    overflow: visible;
}

/* ── TOOLBAR ── */
.contab-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .7rem .9rem;
    border-bottom: 1px solid #d8dde6;
}

.contab-search {
    padding: .35rem .7rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: .82rem;
    width: 240px;
}

    .contab-search:focus {
        outline: none;
        border-color: #198754;
    }

.contab-count {
    font-size: .78rem;
    color: #6b7280;
}
/* ── TABLE ESTILO EXCEL ── */
.contab-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .78rem;
    table-layout: auto;
}

    .contab-table thead tr {
        background: #198754;
    }

    .contab-table th {
        padding: .45rem .7rem;
        text-align: left;
        font-weight: 600;
        color: #fff;
        font-size: .72rem;
        text-transform: uppercase;
        letter-spacing: .03em;
        white-space: nowrap;
        border: 1px solid #157347;
    }

    .contab-table td {
        padding: .38rem .7rem;
        border: 1px solid #e5e7eb;
        white-space: nowrap;
    }

    .contab-table tbody tr:nth-child(even) {
        background: #f9fafb;
    }

    .contab-table tbody tr:hover {
        background: #f0fdf4;
    }

.contab-empty {
    text-align: center;
    color: #9ca3af;
    padding: 2rem !important;
    font-style: italic;
    white-space: normal !important;
}

/* ── FILA GRUPO ── */
.usuario-grupo-row td {
    background: #e8f5e9 !important;
    border: 1px solid #c8e6c9 !important;
    border-left: 4px solid #198754 !important;
    padding: .38rem .7rem !important;
    font-size: .75rem;
    color: #1b5e20;
    white-space: nowrap;
}

/* ── ACCIONES ── */
.contab-actions {
    display: flex;
    gap: .25rem;
    white-space: nowrap;
}


/* ── BADGES ── */
.contab-badge {
    display: inline-block;
    padding: .18rem .55rem;
    border-radius: 9999px;
    font-size: .73rem;
    font-weight: 600;
}

.badge-activo {
    background: #d1fae5;
    color: #065f46;
}

.badge-inactivo {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-secondary {
    background: #f3f4f6;
    color: #374151;
}

.badge-juridica {
    background: #dbeafe;
    color: #1e40af;
}

.badge-natural {
    background: #ede9fe;
    color: #5b21b6;
}

/* ── BUTTONS ── */
.contab-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .38rem .85rem;
    border: none;
    border-radius: 4px;
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity .15s;
}

    .contab-btn:disabled {
        opacity: .5;
        cursor: not-allowed;
    }

    .contab-btn:hover {
        opacity: .88;
    }

.contab-btn-primary {
    background: #198754;
    color: #fff;
}

.contab-btn-warning {
    background: #f59e0b;
    color: #fff;
}

.contab-btn-danger {
    background: #dc3545;
    color: #fff;
}

.contab-btn-ghost {
    background: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

    .contab-btn-ghost:hover {
        background: #f9fafb;
        opacity: 1;
    }

.contab-btn-sm {
    padding: .22rem .55rem;
    font-size: .75rem;
}

.contab-actions {
    display: flex;
    gap: .3rem;
}

/* ── MODAL ── */
.contab-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.contab-modal {
    background: white;
    border-radius: 7px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 30px rgba(0,0,0,.2);
}

.contab-modal-sm {
    max-width: 360px;
}

.contab-modal-lg {
    max-width: 760px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

    .contab-modal-lg .contab-modal-body {
        overflow-y: auto;
        flex: 1;
    }

.contab-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .9rem 1.1rem;
    border-bottom: 1px solid #e5e7eb;
}

    .contab-modal-header h5 {
        font-size: .95rem;
        font-weight: 700;
        margin: 0;
        color: #198754;
    }

.contab-modal-close {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: #9ca3af;
}

.contab-modal-body {
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.contab-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .9rem 1.1rem;
    border-top: 1px solid #e5e7eb;
}

/* ── FORM ── */
.contab-field {
    display: flex;
    flex-direction: column;
    gap: .28rem;
}

    .contab-field label {
        font-size: .78rem;
        font-weight: 600;
        color: #6b7280;
    }

.contab-input {
    padding: .4rem .7rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: .82rem;
}

    .contab-input:focus {
        outline: none;
        border-color: #198754;
    }

.contab-alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    padding: .45rem .7rem;
    font-size: .8rem;
}

/* ── LOADING ── */
.contab-loading {
    padding: 2rem;
    text-align: center;
    color: #9ca3af;
    font-style: italic;
}

/* ── STATS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: .7rem;
    margin-bottom: .9rem;
}

.stat-card {
    background: white;
    border-radius: 5px;
    padding: .75rem .9rem;
    border: 1px solid #d8dde6;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    display: flex;
    flex-direction: column;
    border-left: 3px solid #d8dde6;
}

    .stat-card.stat-green {
        border-left-color: #198754;
    }

    .stat-card.stat-red {
        border-left-color: #dc3545;
    }

    .stat-card.stat-orange {
        border-left-color: #f59e0b;
    }

    .stat-card.stat-blue {
        border-left-color: #3b82f6;
    }

.stat-label {
    font-size: .7rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-top: .1rem;
}

/* ── TOAST ── */
.signer-toast {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    background: #198754;
    color: white;
    padding: .6rem 1.1rem;
    border-radius: 5px;
    font-size: .82rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    z-index: 2000;
}

/* ── FIRMADORES ── */
.signer-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px,1fr));
    gap: .9rem;
}

.signer-card {
    background: white;
    border-radius: 5px;
    padding: 1.1rem;
    cursor: pointer;
    border: 1px solid #d8dde6;
    border-left: 3px solid #198754;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    transition: box-shadow .2s;
}

    .signer-card:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,.1);
    }

.signer-card-inactivo {
    border-left-color: #9ca3af;
    opacity: .7;
}

.signer-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .9rem;
}

.signer-card-name {
    font-weight: 700;
    font-size: .9rem;
}

.signer-card-stats {
    display: grid;
    grid-template-columns: repeat(2,1fr);
    gap: .45rem;
    margin-bottom: .9rem;
}

.signer-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #f9fafb;
    border-radius: 4px;
    padding: .4rem;
    text-align: center;
}

.signer-stat-label {
    font-size: .68rem;
    color: #6b7280;
    white-space: nowrap;
}

.signer-stat-value {
    font-size: .88rem;
    font-weight: 700;
}

.signer-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #e5e7eb;
    padding-top: .6rem;
}

.signer-url {
    font-size: .7rem;
    color: #9ca3af;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── DETALLE FIRMADOR ── */
.signer-detalle-section {
    margin-bottom: 1rem;
}

    .signer-detalle-section h6 {
        font-size: .72rem;
        font-weight: 700;
        color: #198754;
        text-transform: uppercase;
        letter-spacing: .04em;
        margin-bottom: .5rem;
    }

.signer-detalle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px,1fr));
    gap: .5rem;
}

.signer-detalle-item {
    background: #f9fafb;
    border-radius: 4px;
    padding: .45rem .7rem;
    display: flex;
    flex-direction: column;
}

    .signer-detalle-item span {
        font-size: .7rem;
        color: #6b7280;
    }

    .signer-detalle-item strong {
        font-size: .88rem;
    }

/* ── COLORES UTIL ── */
.text-danger {
    color: #dc3545 !important;
}

.text-warning {
    color: #f59e0b !important;
}

.text-success {
    color: #198754 !important;
}

/* ── USUARIOS ── */
.usuario-grupo {
    margin-bottom: .25rem;
}

.usuario-grupo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem .9rem;
    background: #f0fdf4;
    border-left: 3px solid #198754;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    font-size: .78rem;
    color: #166534;
    user-select: none;
}

    .usuario-grupo-header:hover {
        background: #dcfce7;
    }

.usuario-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #dcfce7;
    color: #198754;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .68rem;
    flex-shrink: 0;
}

/* ── CLIENTE DROPDOWN ── */
.cliente-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    max-height: 210px;
    overflow-y: auto;
    z-index: 9999;
}

.cliente-drop-item {
    padding: .45rem .75rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: .78rem;
}

    .cliente-drop-item:hover {
        background: #f0fdf4;
    }

    .cliente-drop-item.selected {
        background: #dcfce7;
        color: #198754;
        font-weight: 600;
    }

/* ── CLIENTES ── */
.contab-btn-dte-on {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
    font-size: .72rem;
}

.contab-btn-dte-off {
    background: #f9fafb;
    color: #6b7280;
    border: 1px solid #d1d5db;
    font-size: .72rem;
}

.contab-btn-dte-on:hover {
    background: #a7f3d0;
    opacity: 1;
}

.contab-btn-dte-off:hover {
    background: #f3f4f6;
    opacity: 1;
}

/* ── PAGINACIÓN ── */
.contab-pagination {
    display: flex;
    gap: .25rem;
    align-items: center;
    padding: .7rem .9rem;
    justify-content: center;
    border-top: 1px solid #e5e7eb;
}

/* ── TABS ── */
.contab-tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 0;
}

.contab-tab {
    padding: .45rem 1.1rem;
    border: none;
    background: transparent;
    font-size: .82rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .15s;
}

    .contab-tab:hover {
        color: #198754;
    }

    .contab-tab.active {
        color: #198754;
        border-bottom-color: #198754;
    }

/* ── ÁRBOL DE PERMISOS ── */
.perm-modulo-block {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.perm-modulo-label {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem 1rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    font-size: .85rem;
    user-select: none;
}

    .perm-modulo-label:hover {
        background: #f0fdf4;
    }

    .perm-modulo-label input[type=checkbox] {
        width: 16px;
        height: 16px;
        accent-color: #198754;
        cursor: pointer;
        flex-shrink: 0;
    }

.perm-acciones-list {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    padding: .9rem 1rem;
    background: white;
}

.perm-accion-label {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .8rem;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: .78rem;
    cursor: pointer;
    user-select: none;
    transition: all .12s;
    white-space: nowrap;
}

    .perm-accion-label:hover {
        background: #dcfce7;
        border-color: #86efac;
    }

    .perm-accion-label input[type=checkbox] {
        width: 13px;
        height: 13px;
        accent-color: #198754;
        cursor: pointer;
        flex-shrink: 0;
    }

    .perm-accion-label:has(input:checked) {
        background: #dcfce7;
        border-color: #198754;
        color: #166534;
        font-weight: 600;
    }

/* ── SECTION TITLE ── */
.contab-section-title {
    font-size: .78rem;
    font-weight: 700;
    color: #198754;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .8rem;
}


.contab-alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
    border-radius: 4px;
    padding: .45rem .7rem;
    font-size: .8rem;
}