*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #080b12;
    --bg-card: #0f1623;
    --border: #1a2236;
    --border-h: #2a3550;
    --text: #f0f4ff;
    --muted: #8b9ab5;
    --dim: #2d3a52;
    --purple: #7c3aed;
    --purple-l: #a78bfa;
    --blue: #2563eb;
    --cyan: #06b6d4;
    --green: #22c55e;
    --red: #ef4444;
    --amber: #f59e0b;
    --pink: #f472b6;
    --indigo: #818cf8;
    --radius: 14px;
}

[data-theme="light"] {
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --border-h: #cbd5e1;
    --text: #0f172a;
    --muted: #475569;
    --dim: #e2e8f0;
}

[data-theme="contrast"] {
    --bg: #000000;
    --bg-card: #000000;
    --border: #ffff00;
    --border-h: #ffffff;
    --text: #ffffff;
    --muted: #dddddd;
    --dim: #333333;
    --purple: #ff00ff;
    --purple-l: #ff00ff;
    --blue: #00ffff;
    --cyan: #00ffff;
    --green: #00ff00;
    --red: #ff0000;
    --amber: #ff9900;
    --pink: #ff00ff;
    --indigo: #00ffff;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* -- SCROLLBAR -- */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--dim);
    border-radius: 99px;
}

/* -- HEADER -- */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
    padding: 0 24px;
    background: rgba(8, 11, 18, .85);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
    transition: background 0.3s, border-color 0.3s;
}

[data-theme="light"] header {
    background: rgba(248, 250, 252, .85);
}

[data-theme="contrast"] header {
    background: rgba(0, 0, 0, .95);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.header-title {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.icon-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.icon-btn:hover {
    border-color: var(--border-h);
    background: var(--dim);
}

/* -- TAB NAV -- */
.tab-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 58px;
    z-index: 90;
    transition: background 0.3s, border-color 0.3s;
}

.tab-btn {
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--dim);
    color: var(--text);
}

.tab-btn.active {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.tabcontent {
    display: none;
}

.tabcontent.active {
    display: block;
}

/* -- MAIN -- */
main {
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px;
}

/* -- PILL -- */
.pill {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    padding: 3px 10px;
    border-radius: 99px;
    background: var(--dim);
    color: var(--muted);
}

/* -- CARD -- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s, background 0.3s;
}

.card:hover {
    border-color: var(--border-h);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: .02em;
}

/* -- KPI GRID (Tab 0) -- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

/* -- TAB GRIDS -- */
.tab1-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    align-items: start;
}

@media (min-width: 1025px) {
    .tab1-grid {
        grid-template-columns: 1fr 280px;
    }
}

.tab2-grid,
.tab3-grid {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 16px;
    align-items: start;
}

.stat-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mt {
    margin-top: 16px;
}

/* -- REPARTITION -- */
.repart-flex {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
}

.repart-item {
    display: flex;
    flex-direction: column;
}

.text-right {
    align-items: flex-end;
    text-align: right;
}

.repart-pct {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.repart-lbl {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.repart-vol {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-top: 2px;
}

.progress-bar-dual {
    display: flex;
    height: 6px;
    border-radius: 99px;
    overflow: hidden;
    background: var(--dim);
}

.progress-cyan {
    background: var(--cyan);
    transition: width 1s ease;
}

.progress-green {
    background: var(--green);
    transition: width 1s ease;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* -- RANK TABLE -- */
.rank-table {
    width: 100%;
    border-collapse: collapse;
}

.rank-table thead th {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: .09em;
    padding: 0 0 12px;
    text-align: left;
    border-bottom: 2px solid rgba(129, 140, 248, 0.4);
}

[data-theme="light"] .rank-table thead th {
    border-bottom-color: rgba(100, 116, 139, 0.3);
}

.rank-row {
    border-bottom: 1px solid rgba(129, 140, 248, 0.25);
    transition: background 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] .rank-row {
    border-bottom-color: rgba(100, 116, 139, 0.2);
}

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

.rank-row:hover {
    background: rgba(45, 58, 82, 0.5);
    transform: translateX(4px);
    border-radius: 6px;
}

[data-theme="light"] .rank-row:hover {
    background: rgba(226, 232, 240, 0.7);
}

.rank-row td {
    padding: 13px 8px;
    vertical-align: middle;
}

.rank-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    min-width: 36px;
    text-align: center;
}

.app-name {
    font-size: 13.5px;
    font-weight: 500;
    display: block;
    margin-bottom: 5px;
}

.mini-bar-wrap {
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 99px;
}

[data-theme="light"] .mini-bar-wrap {
    background: rgba(0, 0, 0, 0.08);
}

.mini-bar {
    height: 6px;
    border-radius: 99px;
    transition: width .8s ease;
}

.app-vol {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

/* -- DONUT -- */
.donut-wrap {
    position: relative;
    width: 100%;
    height: 260px;
    margin: 12px 0;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    color: var(--muted);
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* -- STAT CARDS -- */
.stat-card {
    padding: 22px;
}

.stat-label {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    margin-bottom: 10px;
}

.stat-big {
    font-size: 42px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 14px;
    color: var(--text);
}

/* -- BADGES -- */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-green {
    background: rgba(34, 197, 94, .12);
    color: var(--green);
    border: 1px solid rgba(34, 197, 94, .25);
}

.badge-red {
    background: rgba(239, 68, 68, .12);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, .25);
}

.badge-cyan {
    background: rgba(6, 182, 212, .12);
    color: var(--cyan);
    border: 1px solid rgba(6, 182, 212, .25);
}

.badge-purple {
    background: rgba(124, 58, 237, .12);
    color: var(--purple-l);
    border: 1px solid rgba(124, 58, 237, .25);
}

.badge-amber {
    background: rgba(245, 158, 11, .12);
    color: var(--amber);
    border: 1px solid rgba(245, 158, 11, .25);
}

.badge-pink {
    background: rgba(244, 114, 182, .12);
    color: var(--pink);
    border: 1px solid rgba(244, 114, 182, .25);
}

.stat-app-name {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 10px;
    color: var(--text);
}

.stat-app-vol {
    font-size: 15px;
    font-weight: 600;
    color: var(--cyan);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cyan {
    color: var(--cyan) !important;
    -webkit-text-fill-color: var(--cyan) !important;
}

/* -- GLOW ORBS -- */
.glow-orb {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.08;
    pointer-events: none;
    animation: pulseGlow 4s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
    0% {
        opacity: 0.05;
        transform: scale(1);
    }

    100% {
        opacity: 0.12;
        transform: scale(1.1);
    }
}

.glow-orb.purple {
    background: var(--purple);
    top: -40px;
    right: -40px;
}

.glow-orb.green {
    background: var(--green);
    bottom: -40px;
    left: -40px;
}

.glow-orb.amber {
    background: var(--amber);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.glow-orb.red {
    background: var(--red);
    left: 50%;
    transform: translateX(-50%);
}

.glow-orb.cyan {
    background: var(--cyan);
    left: 50%;
    transform: translateX(-50%);
}

[data-theme="light"] .glow-orb {
    display: none;
}

/* -- CHART BOX -- */
.chart-box {
    height: 260px;
    position: relative;
}

/* -- RATIO CARD -- */
.ratio-card {
    min-height: 220px;
    display: flex;
    flex-direction: column;
}

.ratio-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ratio-val {
    font-size: 54px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.ratio-sub {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: .12em;
}

/* -- DATA TABLE -- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: .09em;
    padding: 0 16px 12px;
    text-align: left;
    border-bottom: 2px solid rgba(129, 140, 248, 0.4);
}

[data-theme="light"] .data-table thead th {
    border-bottom-color: rgba(100, 116, 139, 0.3);
}

.data-table tbody tr {
    border-bottom: 1px solid rgba(129, 140, 248, 0.25);
    transition: background 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] .data-table tbody tr {
    border-bottom-color: rgba(100, 116, 139, 0.15);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: rgba(45, 58, 82, 0.5);
    transform: translateX(4px);
}

[data-theme="light"] .data-table tbody tr:hover {
    background: rgba(226, 232, 240, 0.7);
}

.data-table tbody td {
    padding: 13px 16px;
    font-size: 13.5px;
    color: var(--muted);
}

.td-bold {
    font-weight: 600;
    color: var(--text);
}

.delta {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 12.5px;
    font-weight: 700;
}

.delta-pos {
    background: rgba(34, 197, 94, .1);
    color: var(--green);
}

.delta-neg {
    background: rgba(239, 68, 68, .1);
    color: var(--red);
}

/* -- STAGGER ANIMATION -- */
@keyframes cardSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tabcontent.active .card {
    animation: cardSlideUp 0.4s ease-out both;
}

.tabcontent.active .card:nth-child(1) {
    animation-delay: 0s;
}

.tabcontent.active .card:nth-child(2) {
    animation-delay: 0.06s;
}

.tabcontent.active .card:nth-child(3) {
    animation-delay: 0.12s;
}

.tabcontent.active .card:nth-child(4) {
    animation-delay: 0.18s;
}

.tabcontent.active .card:nth-child(5) {
    animation-delay: 0.24s;
}

/* -- PREMIUM HOVER GLOW -- */
.card {
    transition: border-color 0.3s, background 0.3s, box-shadow 0.4s ease, transform 0.3s ease;
}

.card:hover {
    border-color: var(--border-h);
    box-shadow: 0 4px 24px rgba(124, 58, 237, 0.12), 0 0 0 1px rgba(129, 140, 248, 0.08);
    transform: translateY(-2px);
}

[data-theme="light"] .card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

/* -- SMOOTH TAB FADE -- */
.tabcontent.active {
    animation: tabFadeIn 0.35s ease-out;
}

@keyframes tabFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* -- PROGRESS BAR SHINE -- */
@keyframes barShine {
    0% {
        background-position: -200% center;
    }

    100% {
        background-position: 200% center;
    }
}

.mini-bar {
    background-size: 200% 100%;
    background-image: linear-gradient(90deg, transparent 30%, rgba(255, 255, 255, 0.15) 50%, transparent 70%);
    animation: barShine 2.5s ease-in-out infinite;
}

/* -- COUNTER GLOW -- */
.stat-big,
.ratio-val {
    transition: text-shadow 0.3s ease;
}

.card:hover .stat-big {
    text-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

.card:hover .ratio-val {
    text-shadow: 0 0 20px rgba(129, 140, 248, 0.3);
}

/* -- BADGE PULSE ON HOVER -- */
.badge {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover .badge {
    transform: scale(1.05);
}

/* ===========================================================
   RESPONSIVENESS
   =========================================================== */
@media (max-width: 1200px) {
    .tab1-grid {
        grid-template-columns: 1fr 280px;
    }

    .tab1-grid .stat-col {
        grid-column: span 2;
        flex-direction: row;
    }

    .stat-card {
        flex: 1;
    }
}

@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .tab1-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .stat-col {
        grid-column: 1;
        flex-direction: row;
    }

    .stat-card {
        flex: 1;
    }

    .tab2-grid,
    .tab3-grid {
        grid-template-columns: 1fr;
    }

    .ratio-card {
        min-height: 160px;
    }
}

@media (max-width: 768px) {
    main {
        padding: 14px;
    }

    header {
        padding: 0 14px;
        height: 52px;
    }

    .header-title {
        font-size: 13px;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .tab1-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px;
    }

    .tab1-grid>.card,
    .tab1-grid>.stat-col {
        width: 100% !important;
        min-width: 0;
    }

    .stat-col {
        grid-column: 1;
        flex-direction: column;
    }

    .donut-wrap {
        height: 250px;
        margin: 16px 0;
    }

    .tab-nav {
        flex-wrap: wrap;
        padding: 10px 14px;
        gap: 4px;
    }

    .tab-btn {
        font-size: 11.5px;
        padding: 6px 10px;
    }

    .rank-table th,
    .rank-table td,
    .data-table th,
    .data-table td {
        font-size: 11px;
        padding: 8px 4px;
    }

    .rank-table,
    .rank-table tbody {
        display: block;
        width: 100%;
    }

    .rank-table td {
        display: block;
        width: auto;
        box-sizing: border-box;
        padding: 0;
    }

    .rank-row {
        display: grid;
        grid-template-columns: 40px 1fr auto;
        align-items: center;
        gap: 12px;
        padding: 12px 0;
        border-bottom: 1px solid rgba(129, 140, 248, 0.25);
    }

    .rank-row td {
        display: block;
        padding: 0;
    }

    .rank-row td:nth-child(1) {
        text-align: center;
    }

    .app-name {
        margin: 0 0 6px 0;
        font-size: 13.5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mini-bar-wrap {
        margin-bottom: 0;
        width: 100%;
    }

    .rank-row td:nth-child(3) {
        text-align: right;
        font-size: 12px;
        font-weight: 600;
    }

    .rank-table thead {
        display: none;
    }

    .stat-big {
        font-size: 28px;
    }

    .stat-app-name {
        font-size: 20px;
    }

    .repart-pct {
        font-size: 22px;
    }

    .chart-box {
        height: 200px;
    }

    .donut-wrap {
        height: 220px;
    }

    .card {
        padding: 16px;
    }

    .data-table tbody td {
        padding: 10px 8px;
        font-size: 12px;
    }

    .data-table thead th {
        padding: 0 8px 10px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .tab-btn svg {
        display: none;
    }

    .stat-big {
        font-size: 24px;
    }

    .donut-wrap {
        height: 200px;
    }

    .ratio-val {
        font-size: 40px;
    }
}

/* -- ERROR -- */
.error-banner {
    background: rgba(239, 68, 68, .08);
    border: 1px solid rgba(239, 68, 68, .3);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
    color: var(--red);
    font-size: 13.5px;
}