.afiliados-body {
    margin: 0;
    background: #f4f7fe;
    color: #334155;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.afiliados-body * {
    box-sizing: border-box;
}

.afiliados-body a {
    text-decoration: none;
}

.aff-app {
    min-height: 100vh;
    display: flex;
    background: #f4f7fe;
}

.aff-sidebar {
    width: 260px;
    min-width: 260px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
    position: relative;
    z-index: 30;
}

.aff-sidebar-header {
    height: 76px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid #e2e8f0;
}

.aff-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aff-logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #4356b6;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    box-shadow: 0 8px 20px rgba(67, 86, 182, 0.18);
}

.aff-logo-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.aff-logo-text strong {
    font-size: 15px;
    line-height: 1.1;
    color: #0f172a;
}

.aff-logo-text span {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

.aff-menu {
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aff-menu-item {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 14px;
    color: #64748b;
    font-size: 14px;
    font-weight: 700;
    transition: 0.2s ease;
}

.aff-menu-item:hover {
    background: #f8fafc;
    color: #0f172a;
}

.aff-menu-item.active {
    background: #4356b6;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(67, 86, 182, 0.22);
}

.aff-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.aff-topbar {
    min-height: 76px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 18px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.01);
    position: sticky;
    top: 0;
    z-index: 20;
}

.aff-topbar-left {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.aff-topbar-heading h1 {
    margin: 0 0 4px;
    font-size: 24px;
    line-height: 1.2;
    color: #0f172a;
    font-weight: 800;
}

.aff-topbar-heading p {
    margin: 0;
    color: #64748b;
    font-size: 14px;
}

.aff-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aff-topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aff-topbar-user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4356b6, #6c7fe0);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
}

.aff-topbar-user-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.aff-topbar-user-info strong {
    color: #0f172a;
    font-size: 14px;
    line-height: 1.1;
}

.aff-topbar-user-info span {
    color: #64748b;
    font-size: 12px;
}

.aff-sidebar-toggle {
    width: 42px;
    height: 42px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    padding: 0;
}

.aff-sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #334155;
}

.aff-content {
    padding: 24px;
}

.aff-alert {
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
}

.aff-alert-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
}

.aff-alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.aff-alert-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aff-dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.aff-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.aff-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    box-shadow: 0 2px 10px -3px rgba(0, 0, 0, 0.02);
}

.aff-metric-card {
    padding: 20px;
    min-height: 136px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.aff-metric-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.aff-metric-label {
    display: inline-block;
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

.aff-metric-value {
    margin: 0;
    color: #0f172a;
    font-size: 28px;
    line-height: 1.1;
    font-weight: 800;
}

.aff-metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #4356b6;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    box-shadow: 0 8px 16px rgba(67, 86, 182, 0.18);
}

.aff-metric-icon.warning {
    background: #f59e0b;
}

.aff-metric-foot {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
}

.aff-metric-foot.positive {
    color: #059669;
}

.aff-metric-foot.warning {
    color: #d97706;
}

.aff-main-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    gap: 24px;
}

.aff-chart-card,
.aff-ranking-card,
.aff-alerts-card,
.aff-table-card {
    padding: 24px;
}

.aff-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.aff-card-header h2 {
    margin: 0 0 6px;
    color: #0f172a;
    font-size: 18px;
    line-height: 1.2;
    font-weight: 800;
}

.aff-card-header p {
    margin: 0;
    color: #64748b;
    font-size: 13px;
}

.aff-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.aff-btn {
    height: 38px;
    padding: 0 16px;
    border-radius: 10px;
    border: none;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
}

.aff-btn-primary {
    background: #4356b6;
    color: #ffffff;
}

.aff-btn-primary:hover {
    background: #384aa3;
}

.aff-btn-light {
    background: #ffffff;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.aff-btn-light:hover {
    background: #f8fafc;
}

.aff-chart-legend {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
    font-size: 12px;
    color: #64748b;
    font-weight: 700;
}

.legend-box {
    width: 10px;
    height: 10px;
    display: inline-block;
    border-radius: 3px;
    margin-right: 6px;
}

.legend-primary {
    background: #4356b6;
}

.legend-secondary {
    background: #a2b2ee;
}

.aff-chart-bars {
    height: 320px;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
    padding-top: 18px;
    border-bottom: 1px solid #cbd5e1;
}

.aff-bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    height: 100%;
}

.aff-bar-item span {
    font-size: 11px;
    color: #64748b;
    font-weight: 700;
}

.aff-bar-stack {
    height: 100%;
    width: 100%;
    max-width: 30px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
}

.aff-bar {
    width: 11px;
    border-radius: 10px 10px 0 0;
    transition: 0.2s ease;
}

.aff-bar-primary {
    background: #4356b6;
}

.aff-bar-secondary {
    background: #a2b2ee;
}

.aff-side-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.aff-ranking-list,
.aff-alert-request-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aff-ranking-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border-radius: 14px;
    background: #f8fafc;
}

.aff-ranking-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.aff-ranking-left strong {
    width: 24px;
    color: #64748b;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}

.aff-ranking-left h4 {
    margin: 0 0 4px;
    color: #0f172a;
    font-size: 14px;
    font-weight: 800;
}

.aff-ranking-left span {
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
}

.aff-ranking-right {
    color: #0f172a;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.aff-alert-request {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border-radius: 14px;
    background: #fffbeb;
    border: 1px solid #fde68a;
}

.aff-alert-request strong {
    display: block;
    margin-bottom: 4px;
    color: #92400e;
    font-size: 14px;
}

.aff-alert-request span {
    color: #b45309;
    font-size: 12px;
    font-weight: 600;
}

.aff-table-wrap {
    overflow-x: auto;
}

.aff-table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
}

.aff-table thead th {
    text-align: left;
    padding: 0 12px 14px;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 700;
    border-bottom: 1px solid #e2e8f0;
}

.aff-table tbody td {
    padding: 16px 12px;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    border-top: 1px solid #f1f5f9;
}

.aff-table tbody tr:hover {
    background: #f8fafc;
}

.text-right {
    text-align: right !important;
}

.aff-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.aff-badge.success {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.aff-badge.warning {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.aff-badge.danger {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.aff-badge.neutral {
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.aff-link {
    color: #4356b6;
    font-weight: 800;
}

.aff-link:hover {
    color: #384aa3;
}

.aff-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: 0.2s ease;
    z-index: 25;
}

.afiliados-body.aff-sidebar-open .aff-overlay {
    opacity: 1;
    visibility: visible;
}

.aff-auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background:
        radial-gradient(circle at top left, rgba(67, 86, 182, 0.08), transparent 28%),
        radial-gradient(circle at bottom right, rgba(108, 127, 224, 0.08), transparent 30%),
        #f4f7fe;
}

.aff-auth-wrapper {
    width: 100%;
    max-width: 760px;
}

.aff-auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-bottom: 24px;
}

.aff-auth-brand-logo {
    width: 190px;
    height: auto;
    display: block;
    object-fit: contain;
}

.aff-auth-brand-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.aff-auth-brand-text strong {
    display: block;
    color: #0f172a;
    font-size: 20px;
    line-height: 1.1;
    font-weight: 800;
}

.aff-auth-brand-text span {
    display: block;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
}

.aff-auth-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.06);
}

.aff-auth-card-header {
    margin-bottom: 24px;
}

.aff-auth-card-header h1 {
    margin: 0 0 10px;
    color: #0f172a;
    font-size: 34px;
    line-height: 1.1;
    font-weight: 800;
}

.aff-auth-card-header p {
    margin: 0;
    color: #64748b;
    font-size: 15px;
    line-height: 1.6;
}

.aff-auth-form {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.aff-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.aff-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aff-form-group-full {
    grid-column: span 2;
}

.aff-form-group label {
    color: #334155;
    font-size: 14px;
    font-weight: 700;
}

.aff-form-group input,
.aff-form-group select {
    width: 100%;
    height: 50px;
    border: 1px solid #dbe3f0;
    border-radius: 14px;
    padding: 0 16px;
    background: #f8fafc;
    color: #0f172a;
    font-size: 15px;
    transition: 0.2s ease;
    outline: none;
}

.aff-form-group input::placeholder {
    color: #94a3b8;
}

.aff-form-group input:focus,
.aff-form-group select:focus {
    background: #ffffff;
    border-color: #4356b6;
    box-shadow: 0 0 0 4px rgba(67, 86, 182, 0.10);
}

.aff-form-group small {
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
    margin-top: -2px;
}

.aff-auth-submit {
    width: 100%;
    height: 52px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 800;
    box-shadow: 0 12px 24px rgba(67, 86, 182, 0.18);
}

@media (max-width: 1200px) {
    .aff-cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .aff-main-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 992px) {
    .aff-sidebar-toggle {
        display: inline-flex;
    }

    .aff-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .afiliados-body.aff-sidebar-open .aff-sidebar {
        transform: translateX(0);
    }

    .aff-topbar {
        padding: 16px 18px;
    }

    .aff-content {
        padding: 18px;
    }
}

@media (max-width: 768px) {
    .aff-cards-grid {
        grid-template-columns: 1fr;
    }

    .aff-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .aff-topbar-right {
        width: 100%;
        justify-content: flex-start;
    }

    .aff-topbar-user-info span {
        max-width: 220px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .aff-chart-card,
    .aff-ranking-card,
    .aff-alerts-card,
    .aff-table-card,
    .aff-metric-card {
        padding: 18px;
    }

    .aff-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .aff-chart-bars {
        gap: 8px;
        height: 260px;
    }

    .aff-bar-stack {
        max-width: 22px;
    }

    .aff-bar {
        width: 9px;
    }

    .aff-auth-card {
        padding: 22px 18px;
        border-radius: 20px;
    }

    .aff-auth-card-header h1 {
        font-size: 28px;
    }

    .aff-form-grid {
        grid-template-columns: 1fr;
    }

    .aff-form-group-full {
        grid-column: span 1;
    }

    .aff-auth-brand {
        flex-direction: column;
        text-align: center;
    }

    .aff-auth-brand-logo {
        width: 170px;
    }
}

.aff-auth-brand {
    flex-direction: column;
    text-align: center;
}

.aff-auth-brand-text.centered strong {
    font-size: 22px;
}

.aff-auth-brand-text.centered span {
    font-size: 13px;
    color: #64748b;
}