.crm-cuentas-wrap,
.crm-cuenta-detalle-wrap {
    padding: 24px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.05);
    box-sizing: border-box;
}

.crm-cuentas-header h2,
.crm-cuenta-detalle-header h2 {
    margin: 0 0 6px;
    font-size: 28px;
    line-height: 1.2;
    color: #0f172a;
}

.crm-cuentas-header p,
.crm-cuenta-detalle-header p {
    margin: 0 0 18px;
    color: #64748b;
    font-size: 14px;
}

/* =========================
   LISTADO GENERAL
========================= */

.crm-cuentas-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.crm-kpi-card {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 16px 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
}

.crm-kpi-label {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 6px;
}

.crm-kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
}

.crm-cuentas-filtros {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 12px;
    margin-bottom: 18px;
    align-items: end;
}

.crm-cuentas-filtros input,
.crm-cuentas-filtros select,
.crm-cuentas-filtros button,
.crm-campo input,
.crm-campo select,
.crm-campo textarea {
    padding: 11px 13px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    transition: all 0.2s ease;
    background: #fff;
    box-sizing: border-box;
}

.crm-cuentas-filtros input:focus,
.crm-cuentas-filtros select:focus,
.crm-campo input:focus,
.crm-campo select:focus,
.crm-campo textarea:focus {
    outline: none;
    border-color: #1d4ed8;
    box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.08);
}

.crm-cuentas-filtros button,
.crm-cuenta-detalle-actions button {
    cursor: pointer;
    background: linear-gradient(135deg, #111827 0%, #1e293b 100%);
    color: #fff;
    border: none;
    font-weight: 600;
}

.crm-cuentas-filtros button:hover,
.crm-cuenta-detalle-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

/* =========================
   TABLA CUENTAS
========================= */

.crm-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.04);
    box-sizing: border-box;
    min-width: 0;
    overflow: visible;
}

.crm-cuentas-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    box-sizing: border-box;
    display: block;
}

.crm-cuentas-table {
    width: max-content;
    min-width: 1500px;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: auto;
}

.crm-cuentas-table th,
.crm-cuentas-table td {
    border: 1px solid #e5e7eb;
    padding: 7px 8px;
    text-align: left;
    vertical-align: middle;
    font-size: 12px;
    line-height: 1.25;
    white-space: nowrap;
}

.crm-cuentas-table thead th {
    background: #f8fafc;
    font-weight: 700;
    color: #0f172a;
    position: sticky;
    top: 0;
    z-index: 1;
}

.crm-cuentas-table tbody tr:nth-child(even) {
    background: #fcfcfd;
}

.crm-cuentas-table tbody tr:hover {
    background: #f8fafc;
}

.crm-cuentas-table th:first-child,
.crm-cuentas-table td:first-child {
    min-width: 260px;
    max-width: 260px;
}

.crm-cuentas-table td:first-child a {
    display: inline-block;
    max-width: 260px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
}

.crm-link-detalle {
    color: #1d4ed8;
    text-decoration: none;
    font-weight: 600;
}

.crm-link-detalle:hover {
    text-decoration: underline;
}

/* =========================
   HERO CUENTAS / DETALLE
========================= */

.crm-cuenta-hero {
    display: grid;
    grid-template-columns: 2fr 1.4fr;
    gap: 20px;
    margin-bottom: 22px;
    padding: 22px;
    border-radius: 18px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
}

.crm-cuenta-eyebrow {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.75;
    margin-bottom: 8px;
}

.crm-cuenta-hero-main h2 {
    margin: 0 0 8px;
    font-size: 32px;
    line-height: 1.1;
    color: #fff;
}

.crm-cuenta-hero-main p {
    margin: 0 0 16px;
    color: rgba(255, 255, 255, 0.82);
}

.crm-cuenta-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.crm-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 13px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.crm-cuenta-hero-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(90px, 1fr));
    gap: 12px;
}

.crm-mini-kpi {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 16px;
    min-width: 0;
}

.crm-mini-kpi-label {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.78);
    margin-bottom: 8px;
}

.crm-mini-kpi strong {
    font-size: 24px;
    color: #fff;
}

.crm-cuenta-layout {
    display: grid;
    gap: 20px;
    min-width: 0;
}

.crm-card-header {
    margin-bottom: 18px;
}

.crm-card-header h3 {
    margin: 0 0 6px;
    font-size: 20px;
    color: #0f172a;
}

.crm-card-header p {
    margin: 0;
    color: #64748b;
    font-size: 14px;
}

.crm-subsection-header {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid #e5e7eb;
}

/* =========================
   MENSAJES
========================= */

.crm-cuenta-detalle-mensaje {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
}

.crm-cuenta-detalle-mensaje.ok {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.crm-cuenta-detalle-mensaje.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* =========================
   DETALLE CUENTA
========================= */

.crm-cuenta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 16px;
}

.crm-campo {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.crm-campo-full {
    grid-column: 1 / -1;
}

.crm-campo label {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.crm-info-box {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #dbe4f0;
    background: #f8fafc;
    color: #334155;
    font-size: 14px;
}

.crm-cuenta-detalle-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

.crm-cuenta-detalle-actions button {
    border-radius: 12px;
    padding: 12px 18px;
}

/* =========================
   TABLAS LITE
========================= */

.crm-table-lite-wrap {
    overflow-x: auto;
}

.crm-table-lite {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
    font-size: 14px;
}

.crm-table-lite th,
.crm-table-lite td {
    padding: 12px 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}

.crm-table-lite thead th {
    background: #f8fafc;
    color: #0f172a;
    font-weight: 700;
    border-bottom: 1px solid #dbe4f0;
}

.crm-table-lite tbody tr:hover {
    background: #fafcff;
}

/* =========================
   TOOLBAR Y PAGINACIÓN
========================= */

.crm-cuentas-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 10px;
}

.crm-cuentas-per-page {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #64748b;
}

.crm-cuentas-per-page label,
.crm-cuentas-per-page span {
    white-space: nowrap;
}

.crm-cuentas-per-page select {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
    padding: 4px 6px;
    font-size: 12px;
    line-height: 1.1;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #fff;
    box-sizing: border-box;
}

.crm-cuentas-paginacion {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.crm-cuentas-paginacion button {
    padding: 8px 16px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.crm-cuentas-paginacion button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.crm-cuentas-paginacion button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

#crm-paginacion-info {
    font-size: 13px;
    color: #475569;
}

/* =========================
   DASHBOARD
========================= */

.crm-dashboard-wrap {
    min-width: 0;
}

.crm-dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(6, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.crm-dashboard-kpi {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.03);
}

.crm-dashboard-kpi-label {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 8px;
}

.crm-dashboard-kpi strong {
    font-size: 18px;
    color: #0f172a;
}

.crm-dashboard-charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 16px;
}

.crm-dashboard-chart {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px;
    min-height: 260px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.03);
}

.crm-dashboard-chart h4 {
    margin: 0 0 12px;
    font-size: 16px;
    color: #0f172a;
}

.crm-dashboard-chart-full {
    grid-column: 1 / -1;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1400px) {
    .crm-cuenta-hero-kpis {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .crm-dashboard-kpis {
        grid-template-columns: repeat(3, minmax(160px, 1fr));
    }
}

@media (max-width: 1100px) {
    .crm-cuentas-kpis {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .crm-cuentas-filtros {
        grid-template-columns: 1fr 1fr;
    }

    .crm-cuenta-hero {
        grid-template-columns: 1fr;
    }

    .crm-cuenta-hero-kpis {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .crm-dashboard-kpis {
        grid-template-columns: repeat(2, minmax(160px, 1fr));
    }

    .crm-dashboard-charts {
        grid-template-columns: 1fr;
    }

    .crm-dashboard-chart-full {
        grid-column: auto;
    }
}

@media (max-width: 900px) {
    .crm-cuenta-grid {
        grid-template-columns: 1fr;
    }

    .crm-cuenta-hero-kpis {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
}

@media (max-width: 640px) {
    .crm-cuentas-kpis {
        grid-template-columns: 1fr;
    }

    .crm-cuentas-filtros {
        grid-template-columns: 1fr;
    }

    .crm-cuenta-hero-main h2 {
        font-size: 26px;
    }

    .crm-cuenta-hero-kpis {
        grid-template-columns: 1fr 1fr;
    }

    .crm-dashboard-kpis {
        grid-template-columns: 1fr;
    }

    .crm-cuentas-paginacion {
        flex-direction: column;
        align-items: flex-start;
    }
}