/* =============================================
   TK Stats — styles
   ============================================= */

#tk-stats-app {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
    font-family: inherit;
    position: relative;
}

/* ── Period selector ────────────────────────── */
.tk-st-periods {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    margin-bottom: 12px;
}
.tk-st-periods::-webkit-scrollbar { display: none; }

.tk-st-p {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    color: #374151;
    font-size: .82rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.tk-st-p:hover  { border-color: #0d1b2a; color: #0d1b2a; }
.tk-st-p.active { background: #0d1b2a; border-color: #0d1b2a; color: #fff; }

.tk-st-period-label {
    font-size: .75rem;
    color: #9ca3af;
    margin-bottom: 16px;
}

/* ── KPI cards ──────────────────────────────── */
.tk-st-kpis {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
@media (min-width: 640px) {
    .tk-st-kpis { grid-template-columns: repeat(4, 1fr); }
}

.tk-st-kpi {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
}

.tk-st-kpi-label {
    font-size: .72rem;
    color: #6b7280;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.tk-st-kpi-val {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0d1b2a;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
@media (max-width: 400px) { .tk-st-kpi-val { font-size: 1rem; } }

.tk-st-kpi-sub       { font-size: .72rem; color: #9ca3af; }
.tk-st-kpi-sub.up    { color: #15803d; }
.tk-st-kpi-sub.down  { color: #b91c1c; }

/* ── Cards ──────────────────────────────────── */
.tk-st-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px 16px;
    margin-bottom: 14px;
}

.tk-st-card-title {
    font-size: .9rem;
    font-weight: 600;
    color: #0d1b2a;
    margin: 0 0 14px;
}

/* ── Revenue chart ──────────────────────────── */
.tk-st-chart-card { }

.tk-st-chart-wrap {
    position: relative;
    height: 220px;
}

/* ── Bottom row ─────────────────────────────── */
.tk-st-row2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media (min-width: 700px) {
    .tk-st-row2 { grid-template-columns: 1.6fr 1fr; }
}

.tk-st-col2 { display: flex; flex-direction: column; gap: 14px; }

/* ── Products table ─────────────────────────── */
.tk-st-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

.tk-st-table th {
    text-align: left;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
    padding: 0 6px 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.tk-st-table td {
    padding: 7px 6px 7px 0;
    color: #374151;
    vertical-align: middle;
    border-bottom: 1px solid #f9fafb;
}

.tk-st-table tr:last-child td { border-bottom: none; }

.tk-st-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #f3f4f6;
    border-radius: 50%;
    font-size: .68rem;
    color: #6b7280;
    margin-right: 6px;
    flex-shrink: 0;
}

.tk-st-pname {
    max-width: 180px;
    white-space: normal;
    line-height: 1.3;
}

.tk-st-bar {
    height: 3px;
    background: #f3f4f6;
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}
.tk-st-bar > div {
    height: 100%;
    background: linear-gradient(to right, #3b82f6, #60a5fa);
    border-radius: 2px;
    transition: width .4s;
}

.mono { font-variant-numeric: tabular-nums; white-space: nowrap; }

.tk-st-pct {
    display: inline-block;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: .72rem;
    font-weight: 600;
}

/* ── Donut ──────────────────────────────────── */
.tk-st-donut-wrap {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.tk-st-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: .78rem;
    color: #374151;
}
.tk-st-legend span { display: inline-flex; align-items: center; gap: 5px; }
.tk-st-legend strong { margin-left: auto; color: #0d1b2a; }
.tk-st-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Cities ─────────────────────────────────── */
.tk-st-city-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 4px 10px;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #f9fafb;
    font-size: .82rem;
}
.tk-st-city-row:last-child { border-bottom: none; }

.tk-st-city-name  { font-weight: 500; color: #0d1b2a; }
.tk-st-city-count { color: #9ca3af; font-size: .75rem; }
.tk-st-city-rev   { color: #374151; white-space: nowrap; font-variant-numeric: tabular-nums; }

.tk-st-city-bar {
    grid-column: 1 / -1;
    height: 3px;
    background: #f3f4f6;
    border-radius: 2px;
    overflow: hidden;
}
.tk-st-city-bar > div {
    height: 100%;
    background: linear-gradient(to right, #8b5cf6, #a78bfa);
    border-radius: 2px;
    transition: width .4s;
}

/* ── Loading / empty ────────────────────────── */
.tk-st-loading, .tk-st-empty {
    text-align: center;
    padding: 24px 0;
    color: #9ca3af;
    font-size: .875rem;
}

.tk-st-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 12px;
}

.tk-st-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: tk-spin .7s linear infinite;
}
@keyframes tk-spin { to { transform: rotate(360deg); } }
