/* ============================================
   MEDSEEK — ANALÍTICAS PRO
   analiticas.css
   ============================================ */

.an-main {
    box-sizing: border-box;
}

/* ── Variables ── */
:root {
    --an-navy:      #043259;
    --an-teal:      #036A6F;
    --an-teal-lt:   #E1F5EE;
    --an-teal-dark: #085041;
    --an-amber:     #E7964F;
    --an-amber-lt:  #FAEEDA;
    --an-red:       #E24B4A;
    --an-red-lt:    #FCEBEB;
    --an-blue:      #185FA5;
    --an-blue-lt:   #E6F1FB;
    --an-gray:      #4d6F8C;
    --an-border:    rgba(4, 50, 89, 0.1);
    --an-bg:        #F0F6FA;
    --an-white:     #FFFFFF;
    --an-radius:    12px;
    --an-radius-sm: 8px;
    --an-shadow:    0 2px 12px rgba(4, 50, 89, 0.07);
    --an-font:      'Nunito Sans', sans-serif;
}

/* ── Layout ── */
.an-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 60px;
    font-family: var(--an-font);
}

/* ── Page header ── */
.an-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.an-breadcrumb {
    font-size: 12px;
    color: var(--an-gray);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.an-breadcrumb a {
    color: var(--an-teal);
    text-decoration: none;
}

.an-breadcrumb a:hover {
    text-decoration: underline;
}

.an-page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--an-navy);
    margin: 0 0 4px;
}

.an-page-subtitle {
    font-size: 12px;
    color: var(--an-gray);
    margin: 0;
}

.an-page-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.an-period-selector {
    display: flex;
    gap: 4px;
    background: var(--an-white);
    border: 0.5px solid var(--an-border);
    border-radius: 20px;
    padding: 4px;
}

.an-period-btn {
    font-family: var(--an-font);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 16px;
    border: none;
    background: transparent;
    color: var(--an-gray);
    cursor: pointer;
    transition: all 0.15s;
}

.an-period-btn:hover {
    background: var(--an-teal-lt);
    color: var(--an-teal-dark);
}

.an-period-active {
    background: var(--an-navy);
    color: var(--an-white);
}

.an-period-active:hover {
    background: var(--an-navy);
    color: var(--an-white);
}

.an-export-btn {
    font-family: var(--an-font);
    font-size: 12px;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: var(--an-radius-sm);
    border: 0.5px solid var(--an-border);
    background: var(--an-white);
    color: var(--an-gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}

.an-export-btn:hover {
    border-color: var(--an-navy);
    color: var(--an-navy);
}

/* ── Loading / error states ── */
.an-loading {
    text-align: center;
    padding: 80px 20px;
    color: var(--an-gray);
    font-size: 14px;
}

.an-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--an-teal-lt);
    border-top-color: var(--an-teal);
    border-radius: 50%;
    animation: an-spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

.an-error {
    text-align: center;
    padding: 80px 20px;
    color: var(--an-gray);
}

.an-error p {
    font-size: 15px;
    font-weight: 500;
    color: var(--an-navy);
    margin: 12px 0 4px;
}

.an-error span {
    font-size: 13px;
}

/* ── KPI cards ── */
.an-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.an-kpi-card {
    background: var(--an-white);
    border: 0.5px solid var(--an-border);
    border-radius: var(--an-radius);
    padding: 16px 18px;
    box-shadow: var(--an-shadow);
}

.an-kpi-card--alert {
    border-color: var(--an-red);
    background: var(--an-red-lt);
}

.an-kpi-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--an-gray);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.an-kpi-icon {
    width: 14px;
    height: 14px;
    opacity: 0.6;
}

.an-kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--an-navy);
    line-height: 1;
}

.an-kpi-delta {
    font-size: 11px;
    margin-top: 5px;
    color: var(--an-teal-dark);
}

.an-kpi-delta.down {
    color: var(--an-red);
}

.an-kpi-sub {
    font-size: 11px;
    color: var(--an-gray);
    margin-top: 4px;
}

/* ── Insight cards ── */
.an-insights {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.an-insight {
    border-radius: var(--an-radius-sm);
    padding: 12px 14px;
    border: 0.5px solid;
}

.an-insight--amber {
    background: var(--an-amber-lt);
    border-color: #EF9F27;
}

.an-insight--teal {
    background: var(--an-teal-lt);
    border-color: var(--an-teal);
}

.an-insight--blue {
    background: var(--an-blue-lt);
    border-color: var(--an-blue);
}

.an-insight--red {
    background: var(--an-red-lt);
    border-color: var(--an-red);
}

.an-insight-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.an-insight--amber .an-insight-label { color: #854F0B; }
.an-insight--teal  .an-insight-label { color: var(--an-teal-dark); }
.an-insight--blue  .an-insight-label { color: #0C447C; }
.an-insight--red   .an-insight-label { color: #791F1F; }

.an-insight-text {
    font-size: 12px;
    line-height: 1.5;
}

.an-insight--amber .an-insight-text { color: #633806; }
.an-insight--teal  .an-insight-text { color: var(--an-teal-dark); }
.an-insight--blue  .an-insight-text { color: #0C447C; }
.an-insight--red   .an-insight-text { color: #791F1F; }

/* ── Cards ── */
.an-card {
    background: var(--an-white);
    border: 0.5px solid var(--an-border);
    border-radius: var(--an-radius);
    padding: 16px 18px;
    box-shadow: var(--an-shadow);
}

.an-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 8px;
    flex-wrap: wrap;
}

.an-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--an-navy);
}

.an-card-sub {
    font-size: 11px;
    color: var(--an-gray);
    margin-top: 2px;
}

/* ── Legend ── */
.an-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.an-leg-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--an-gray);
}

.an-leg-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Chart layouts ── */
.an-charts-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.an-charts-row--retention {
    grid-template-columns: 1fr;
}


.an-chart-wrap {
    position: relative;
    width: 100%;
    height: 220px;
}

.an-chart-wrap--sm {
    height: 150px;
}

/* ── Middle row ── */
.an-mid-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

/* ── Bar list ── */
.an-bar-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.an-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.an-bar-name {
    font-size: 11px;
    color: var(--an-gray);
    width: 90px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.an-bar-track {
    flex: 1;
    height: 6px;
    background: #EEF3F7;
    border-radius: 3px;
    overflow: hidden;
}

.an-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.an-bar-num {
    font-size: 11px;
    color: var(--an-gray);
    width: 32px;
    text-align: right;
    flex-shrink: 0;
}

/* ── Status list ── */
.an-status-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.an-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 0.5px solid #EEF3F7;
    font-size: 12px;
}

.an-stat-row:last-child {
    border-bottom: none;
}

.an-stat-label {
    color: var(--an-gray);
    display: flex;
    align-items: center;
    gap: 7px;
}

.an-stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.an-stat-val {
    font-weight: 600;
    color: var(--an-navy);
    font-size: 13px;
    padding-left: 20px;
}

/* ── Badges ── */
.an-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.an-badge--teal  { background: var(--an-teal-lt);  color: var(--an-teal-dark); }
.an-badge--amber { background: var(--an-amber-lt);  color: #633806; }
.an-badge--navy  { background: #E6EEF4; color: var(--an-navy); }
.an-badge--red   { background: var(--an-red-lt);   color: #791F1F; }

/* ── Bottom row ── */
.an-bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

/* ── Ranking card ── */
.an-ranking-big {
    text-align: center;
    padding: 16px 0 10px;
}

.an-ranking-num {
    font-size: 52px;
    font-weight: 700;
    color: var(--an-navy);
    line-height: 1;
}

.an-ranking-of {
    font-size: 13px;
    color: var(--an-gray);
    margin-top: 4px;
}

.an-ranking-bar-wrap {
    margin: 12px 0;
}

.an-ranking-track {
    width: 100%;
    height: 8px;
    background: #EEF3F7;
    border-radius: 4px;
    overflow: hidden;
}

.an-ranking-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--an-navy);
    transition: width 0.8s ease;
}

.an-ranking-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--an-gray);
    margin-top: 4px;
}

/* ── Insight pill ── */
.an-insight-pill {
    font-size: 11px;
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 10px;
    line-height: 1.5;
}

.an-insight-pill--teal {
    background: var(--an-teal-lt);
    color: var(--an-teal-dark);
}

.an-insight-pill--amber {
    background: var(--an-amber-lt);
    color: #633806;
}

/* ── Profile score ── */
.an-score-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 4px 0 14px;
}

.an-score-ring-wrap {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.an-score-ring {
    width: 100%;
    height: 100%;
}

.an-score-pct {
    font-size: 24px;
    font-weight: 700;
    color: var(--an-navy);
}

.an-score-lbl {
    font-size: 11px;
    color: var(--an-gray);
    margin-top: 3px;
    line-height: 1.4;
}

.an-beta-bonus {
    font-size: 11px;
    font-weight: 600;
    color: var(--an-teal-dark);
    margin-top: 5px;
}

/* ── Action items ── */
.an-action-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.an-action-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 0.5px solid #EEF3F7;
    text-decoration: none;
}

.an-action-item:last-child {
    border-bottom: none;
}

.an-action-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
}

.an-action-icon--amber { background: var(--an-amber-lt); }
.an-action-icon--blue  { background: var(--an-blue-lt); }
.an-action-icon--teal  { background: var(--an-teal-lt); }

.an-action-text {
    flex: 1;
    font-size: 12px;
    color: var(--an-gray);
    line-height: 1.4;
}

.an-action-pts {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 8px;
    background: var(--an-teal-lt);
    color: var(--an-teal-dark);
    flex-shrink: 0;
    white-space: nowrap;
}

/* ── Retention ── */
.an-retention-wrap {
    display: flex;
    align-items: center;
    gap: 24px;
}

.an-retention-wrap .an-stat-list {
    flex: 1;
}

/* ── Sources legend ── */
.an-sources-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

/* ── Billing card ── */
.an-billing-card {
    margin-top: 12px;
}

.an-billing-header {
    flex-wrap: wrap;
    gap: 12px;
}

.an-billing-filters {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.an-date-input,
.an-select {
    font-family: var(--an-font);
    font-size: 11px;
    padding: 6px 10px;
    border-radius: var(--an-radius-sm);
    border: 0.5px solid var(--an-border);
    background: #F0F6FA;
    color: var(--an-gray);
    cursor: pointer;
}

.an-export-primary {
    font-family: var(--an-font);
    font-size: 12px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: var(--an-radius-sm);
    border: none;
    background: var(--an-navy);
    color: var(--an-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}

.an-export-primary:hover {
    background: #032244;
}

.an-billing-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.an-billing-stat {
    background: #F0F6FA;
    border-radius: var(--an-radius-sm);
    padding: 10px 12px;
}

.an-billing-stat-lbl {
    font-size: 10px;
    color: var(--an-gray);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.an-billing-stat-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--an-navy);
}

.an-billing-note {
    font-size: 11px;
    color: var(--an-gray);
    padding-top: 12px;
    border-top: 0.5px solid #EEF3F7;
    line-height: 1.5;
}

/* ============================================
   RESPONSIVE — TABLET (≤ 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .an-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .an-insights {
        grid-template-columns: repeat(2, 1fr);
    }

    .an-charts-row {
        grid-template-columns: 1fr;
    }

    .an-mid-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .an-bottom-row {
        grid-template-columns: 1fr;
    }

    .an-billing-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   RESPONSIVE — MOBILE (≤ 768px)
   ============================================ */
@media (max-width: 768px) {

    .an-kpi-grid,
    .an-insights,
    .an-charts-row,
    .an-mid-row,
    .an-bottom-row {
        width: 100%;
        box-sizing: border-box;
    }

    .an-main {
        padding: 16px 12px 48px;
    }

    .an-page-header {
        flex-direction: column;
        gap: 12px;
    }

    .an-page-header-right {
        width: 100%;
        justify-content: space-between;
    }

    .an-page-title {
        font-size: 18px;
    }

    .an-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .an-kpi-value {
        font-size: 22px;
    }

    .an-insights {
        grid-template-columns: 1fr;
    }

    .an-charts-row {
        grid-template-columns: 1fr;
    }

    .an-mid-row {
        grid-template-columns: 1fr;
    }

    .an-bottom-row {
        grid-template-columns: 1fr;
    }

    .an-chart-wrap {
        height: 200px;
        width: 100%;
    }

    .an-chart-wrap--sm {
        height: 160px;
        width: 100%;
    }

    .an-card {
        padding: 12px 14px;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }

    .an-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .an-legend {
        flex-wrap: wrap;
        gap: 8px;
    }

    .an-ranking-num {
        font-size: 40px;
    }

    .an-ranking-bar-wrap {
        margin: 8px 0;
    }

    .an-score-wrap {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .an-score-ring-wrap {
        width: 100px;
        height: 100px;
    }

    .an-retention-wrap {
        flex-direction: column;
    }

    .an-billing-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .an-billing-filters {
        width: 100%;
        flex-direction: column;
    }

    .an-date-input,
    .an-select {
        width: 100%;
    }

    .an-export-primary {
        width: 100%;
        justify-content: center;
    }

    .an-billing-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .an-sources-legend {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .an-kpi-card {
        width: 100%;
        box-sizing: border-box;
    }

}

/* ============================================
   RESPONSIVE — MOBILE SMALL (≤ 480px)
   ============================================ */
@media (max-width: 480px) {
    .an-kpi-grid {
        grid-template-columns: 1fr;
    }

    .an-billing-summary {
        grid-template-columns: 1fr;
    }

    .an-period-selector {
        width: 100%;
        justify-content: center;
    }
}