/* ══════════════════════════════════════════════════════════
   STATISTICS SHEET — Camada 40
   ══════════════════════════════════════════════════════════ */

.stats-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 39;
    background: rgba(0,0,0,0.4);
}
.stats-overlay.active { display: block; }

.stats-sheet {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 40;
    background: #f5f6f8;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.stats-sheet.active { display: flex; }

/* ── Header ──────────────────────────────────────── */
.stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px clamp(14px,3vw,20px) 16px;
    background: var(--white);
    border-bottom: 1px solid var(--grey-light);
    flex-shrink: 0;
}

.stats-title {
    font-size: clamp(18px,4vw,20px);
    font-weight: 700;
    color: var(--dark);
}

.stats-close {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--grey-bg);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
}
.stats-close:hover { background: var(--grey-light); }
.stats-close svg { width: 16px; height: 16px; color: var(--grey); }

/* ── Body ────────────────────────────────────────── */
.stats-body {
    overflow-y: auto;
    padding: 16px clamp(14px,3vw,20px) 100px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.stats-loading {
    display: flex; align-items: center; justify-content: center;
    padding: 60px 0;
    color: var(--grey); font-size: 14px;
}

/* ── KPI row ─────────────────────────────────────── */
.stats-kpi-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stats-kpi-card {
    background: var(--white);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stats-kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stats-kpi-icon {
    width: 34px; height: 34px;
    border-radius: 8px;
    background: #f1f3f5;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stats-kpi-icon svg {
    width: 16px; height: 16px;
    color: #475569;
}

.stats-kpi-badge {
    font-size: 10px; font-weight: 600;
    color: #64748b;
    background: #f1f3f5;
    border-radius: 20px;
    padding: 2px 8px;
}

.stats-kpi-value {
    font-size: clamp(26px,7vw,32px);
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
    letter-spacing: -0.5px;
}

.stats-kpi-label {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: -4px;
}

/* ── Section card ────────────────────────────────── */
.stats-card {
    background: var(--white);
    border-radius: 14px;
    padding: 18px 16px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

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

.stats-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.3;
}

.stats-card-sub {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}

.stats-card-icon {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: #f1f3f5;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stats-card-icon svg { width: 14px; height: 14px; color: #64748b; }

/* ── City breakdown ──────────────────────────────── */
.stats-city-list {
    display: flex; flex-direction: column; gap: 10px;
}

.stats-city-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    background: #f8f9fb;
    border-radius: 10px;
    border: 1px solid #eef0f3;
}

.stats-city-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stats-city-item-name {
    font-size: 13px; font-weight: 600; color: var(--dark);
}

.stats-city-item-total {
    font-size: 11px; color: #94a3b8;
}

.stats-city-item-stats {
    display: flex; gap: 12px;
}

.stats-city-stat {
    display: flex; align-items: center; gap: 4px;
}

.stats-city-stat-dot {
    width: 6px; height: 6px; border-radius: 50%;
    flex-shrink: 0;
}

.stats-city-stat-val {
    font-size: 12px; font-weight: 700; color: var(--dark);
}

.stats-city-stat-lbl {
    font-size: 11px; color: #94a3b8;
}

/* ── Bar chart (weekday) ─────────────────────────── */
.stats-barchart-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 120px;
}

.stats-bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    height: 100%;
}

.stats-bar-track {
    width: 100%;
    background: #f1f3f5;
    border-radius: 6px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    position: relative;
}

.stats-bar-track.is-today {
    background: #e8edf2;
}

.stats-bar-fill-v2 {
    width: 100%;
    background: #1e293b;
    border-radius: 6px;
    transition: height .5s cubic-bezier(.4,0,.2,1);
    min-height: 2px;
}

.stats-bar-track.is-today .stats-bar-fill-v2 {
    background: var(--primary, #4A7FD4);
}

.stats-bar-lbl {
    font-size: 10px;
    color: #94a3b8;
    font-weight: 500;
    flex-shrink: 0;
}

.stats-bar-lbl.is-today {
    color: var(--primary, #4A7FD4);
    font-weight: 700;
}

/* ── Legend (weekday chart) ──────────────────────── */
.stats-weekday-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f3f5;
}

.stats-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

.stats-legend-bar {
    width: 12px;
    height: 12px;
    background: #1e293b;
    border-radius: 2px;
    flex-shrink: 0;
}

.stats-legend-line {
    width: 12px;
    height: 2px;
    background: #4A7FD4;
    border-radius: 1px;
    flex-shrink: 0;
}

/* ── Bar + line overlay ──────────────────────────── */
.stats-bar-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: #4A7FD4;
    border-radius: 1px;
    left: 0;
    box-shadow: 0 0 4px rgba(74, 127, 212, 0.3);
    transition: bottom .5s cubic-bezier(.4,0,.2,1);
}

/* ── Line chart (open per hour) ──────────────────── */
.stats-linechart-wrap {
    position: relative;
    width: 100%;
}

.stats-linechart-wrap canvas {
    display: block;
    width: 100% !important;
    height: 160px !important;
    cursor: crosshair;
}

.stats-linechart-xlabels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
}

.stats-linechart-xlabel {
    font-size: 10px;
    color: #94a3b8;
    text-align: center;
    flex: 1;
}

/* ── Tooltip ─────────────────────────────────────── */
.stats-tooltip {
    position: absolute;
    background: #1e293b;
    border-radius: 8px;
    padding: 8px 12px;
    pointer-events: none;
    z-index: 10;
    min-width: 90px;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

.stt-hour {
    font-size: 10px; font-weight: 700;
    color: rgba(255,255,255,.5);
    text-transform: uppercase; letter-spacing: .5px;
    margin-bottom: 4px;
}

.stt-val {
    font-size: 18px; font-weight: 700;
    color: #fff; line-height: 1;
}

.stt-sub {
    font-size: 10px; color: rgba(255,255,255,.5);
    margin-top: 1px;
}

/* ── Table ───────────────────────────────────────── */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.stats-table thead tr {
    border-bottom: 1px solid #eef0f3;
}

.stats-table thead th {
    padding: 0 8px 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #94a3b8;
    text-align: right;
}

.stats-table thead th:first-child {
    text-align: left;
    padding-left: 0;
}

.stats-table tbody tr {
    border-bottom: 1px solid #f5f6f8;
}

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

.stats-table tbody td {
    padding: 11px 8px;
}

.st-city {
    font-weight: 600;
    color: var(--dark);
    padding-left: 0 !important;
}

.st-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #475569;
}

.st-aberto  { color: #4A7FD4; }
.st-abrindo { color: #F59E0B; }
.st-fechado { color: #EF4444; font-weight: 600; }

/* ── Pie chart ───────────────────────────────────── */
.stats-piechart-wrap {
    position: relative;
    width: 100%;
    margin-bottom: 12px;
}

.stats-piechart-wrap canvas {
    display: block;
    width: 100% !important;
    height: 240px !important;
}

.stats-pie-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 0 0;
    border-top: 1px solid #f1f3f5;
}

.stats-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.stats-legend-square {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.stats-legend-text {
    flex: 1;
    color: #475569;
    font-weight: 500;
}

.stats-legend-pct {
    color: #94a3b8;
    font-size: 11px;
    font-weight: 600;
}

/* ── Footer ──────────────────────────────────────── */
.stats-footer {
    text-align: center;
    font-size: 11px; color: #94a3b8;
    padding: 4px 0 8px;
    letter-spacing: .3px;
}
