.analytics-module {
    position: relative;
    /* Keep visuals clipped horizontally but allow full vertical access to long analytics sections. */
    overflow-x: hidden;
    overflow-y: auto;
    /* Fill the workspace and provide its own scroll container when content exceeds viewport height. */
    min-height: 100%;
    max-height: 100%;
    border: 1px solid var(--border2-color);
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(5, 150, 105, 0.05) 45%, rgba(15, 23, 42, 0.03)),
        #ffffff;
}

.analytics-module::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(circle at 18% -8%, rgba(37, 99, 235, 0.2), transparent 40%),
        radial-gradient(circle at 86% 108%, rgba(5, 150, 105, 0.16), transparent 42%);
    opacity: 0.35;
}

.analytics-module > * {
    position: relative;
    z-index: 1;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.analytics-range-badge {
    padding: 7px 10px;
    border: 1px solid rgba(37, 99, 235, 0.25);
    background: rgba(37, 99, 235, 0.09);
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.analytics-filters {
    margin-bottom: 14px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.analytics-filters > div {
    min-width: 0;
}

.analytics-filters select,
.analytics-filters input[type="date"] {
    width: 100%;
    padding: 8px 9px;
    border: 1px solid var(--border2-color);
    background: #fff;
    color: #0f172a;
    font-size: 12px;
    min-height: 36px;
}

.analytics-filters select:focus,
.analytics-filters input[type="date"]:focus {
    outline: none;
    border-color: var(--primary-border);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

.analytics-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.analytics-kpi {
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(248, 250, 252, 0.95));
    padding: 10px;
    display: grid;
    gap: 6px;
    transition: transform 0.16s ease, box-shadow 0.18s ease, border-color 0.16s ease;
    animation: analytics-rise 420ms ease both;
}

.analytics-kpi:hover {
    transform: translateY(-2px);
    border-color: rgba(37, 99, 235, 0.32);
    box-shadow: 0 14px 24px rgba(15, 23, 42, 0.08);
}

.analytics-kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #475467;
    font-weight: 700;
}

.analytics-kpi-value {
    font-size: clamp(20px, 2.1vw, 27px);
    color: #0f172a;
    font-weight: 800;
    line-height: 1.1;
}

.analytics-kpi-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: #667085;
    align-items: baseline;
    flex-wrap: wrap;
}

.analytics-kpi-delta {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.analytics-kpi-delta.up {
    color: #027a48;
}

.analytics-kpi-delta.down {
    color: #b42318;
}

.analytics-kpi-delta.neutral {
    color: #475467;
}

.analytics-layout {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analytics-card {
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.92);
    padding: 10px;
    display: grid;
    gap: 10px;
    min-height: 250px;
    animation: analytics-rise 460ms ease both;
}

.analytics-card-wide {
    grid-column: span 2;
}

.analytics-card-head {
    display: grid;
    gap: 2px;
}

.analytics-card-title {
    font-size: 14px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: 0.01em;
}

.analytics-card-sub {
    font-size: 12px;
    color: #64748b;
}

.analytics-trend {
    width: 100%;
    height: 290px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.8), rgba(255, 255, 255, 0.8));
}

.analytics-trend .axis-line {
    stroke: rgba(15, 23, 42, 0.16);
    stroke-width: 1;
}

.analytics-trend .grid-line {
    stroke: rgba(15, 23, 42, 0.08);
    stroke-width: 1;
    stroke-dasharray: 3 4;
}

.analytics-trend .tick-label {
    font-size: 11px;
    fill: #475467;
}

.analytics-trend .series-area {
    opacity: 0;
    animation: analytics-fade 600ms ease forwards;
}

.analytics-trend .series-line {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.analytics-trend .series-line.total {
    stroke: #2563eb;
}

.analytics-trend .series-line.cancel {
    stroke: #dc2626;
}

.analytics-trend .series-dot {
    fill: #fff;
    stroke-width: 2;
}

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

.analytics-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    color: #334155;
}

.analytics-legend-item .swatch {
    width: 10px;
    height: 10px;
}

.analytics-donut-wrap {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 200px;
}

.analytics-donut {
    width: min(220px, 100%);
    height: 220px;
}

.analytics-donut .track {
    fill: none;
    stroke: rgba(15, 23, 42, 0.12);
    stroke-width: 18;
}

.analytics-donut .segment {
    fill: none;
    stroke-width: 18;
    stroke-linecap: butt;
    transition: stroke-dasharray 420ms ease, stroke-dashoffset 420ms ease;
}

.analytics-donut-center {
    position: absolute;
    display: grid;
    place-items: center;
    gap: 2px;
    pointer-events: none;
}

.analytics-donut-center strong {
    font-size: 28px;
    color: #0f172a;
    line-height: 1;
}

.analytics-donut-center span {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.analytics-stacked {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(10px, 1fr);
    gap: 4px;
    align-items: end;
    min-height: 220px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: rgba(248, 250, 252, 0.85);
    padding: 8px;
}

.analytics-stack-col {
    display: grid;
    gap: 5px;
    justify-items: center;
}

.analytics-stack-bar {
    width: 100%;
    height: 176px;
    display: grid;
    align-items: end;
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.6);
}

.analytics-stack-segments {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
}

.analytics-stack-segment {
    width: 100%;
    transform-origin: bottom;
    transform: scaleY(0);
    animation: analytics-grow 560ms cubic-bezier(.2, .8, .2, 1) forwards;
}

.analytics-stack-label {
    font-size: 10px;
    color: #475467;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    letter-spacing: 0.03em;
}

.analytics-heatmap {
    display: grid;
    grid-template-columns: 56px repeat(24, minmax(14px, 1fr));
    gap: 3px;
    align-items: center;
    overflow-x: auto;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: rgba(248, 250, 252, 0.8);
    padding: 7px;
    min-height: 238px;
}

.analytics-heatmap .row-label,
.analytics-heatmap .hour-label {
    font-size: 10px;
    color: #475467;
    text-align: center;
    user-select: none;
}

.analytics-heatmap .row-label {
    text-align: left;
    padding-left: 2px;
    font-weight: 700;
}

.analytics-heatmap .heat-cell {
    height: 14px;
    min-width: 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    transform: scale(0.75);
    opacity: 0;
    animation: analytics-pop 500ms ease forwards;
}

.analytics-heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    color: #475467;
    font-size: 11px;
}

.heat-scale {
    display: inline-flex;
    gap: 3px;
}

.heat-scale i {
    width: 16px;
    height: 10px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: rgba(37, 99, 235, calc(var(--s) * 0.75));
}

.analytics-bars {
    display: grid;
    gap: 8px;
}

.analytics-bar-row {
    display: grid;
    gap: 4px;
}

.analytics-bar-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: baseline;
    font-size: 12px;
}

.analytics-bar-meta strong {
    color: #0f172a;
}

.analytics-bar-track {
    height: 11px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(248, 250, 252, 0.9);
    overflow: hidden;
}

.analytics-bar-fill {
    height: 100%;
    width: 0;
    transition: width 620ms cubic-bezier(.2, .9, .2, 1);
    background: linear-gradient(90deg, #1d4ed8, #0ea5e9);
}

.analytics-bar-sub {
    display: flex;
    justify-content: space-between;
    color: #667085;
    font-size: 11px;
}

.analytics-provider-list {
    display: grid;
    gap: 8px;
}

.analytics-provider-row {
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.8);
    padding: 8px;
    display: grid;
    gap: 5px;
}

.analytics-provider-row .top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
}

.analytics-provider-row .top strong {
    color: #0f172a;
}

.analytics-provider-row .meter {
    height: 10px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: #eef2f7;
    overflow: hidden;
}

.analytics-provider-row .fill.complete {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #059669, #10b981);
}

.analytics-provider-row .meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 11px;
    color: #64748b;
}

.analytics-insights {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
}

.analytics-insights li {
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.82);
    padding: 9px 10px;
    font-size: 13px;
    color: #0f172a;
    line-height: 1.35;
}

.analytics-empty-inline {
    color: #667085;
    font-size: 12px;
    padding: 6px 0;
}

@keyframes analytics-rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes analytics-grow {
    from {
        transform: scaleY(0);
    }
    to {
        transform: scaleY(1);
    }
}

@keyframes analytics-pop {
    from {
        opacity: 0;
        transform: scale(0.65);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes analytics-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 0.24;
    }
}

@media (max-width: 1100px) {
    .analytics-layout {
        grid-template-columns: 1fr;
    }
    .analytics-card-wide {
        grid-column: auto;
    }
    .analytics-header {
        flex-direction: column;
    }
}

@media (max-width: 720px) {
    .analytics-filters {
        grid-template-columns: 1fr 1fr;
    }
    .analytics-kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
    .analytics-stacked {
        min-height: 180px;
    }
}
