#g41k-statistics {
    color: #172b4d;
    font-size: 14px;
}

#g41k-statistics * {
    box-sizing: border-box;
}

.g41k-stat-toolbar,
.g41k-stat-units {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px;
    padding: 12px;
    border: 1px solid #d7dde8;
    border-radius: 8px;
    background: #f7f9fc;
}

.g41k-stat-field {
    display: grid;
    gap: 4px;
}

.g41k-stat-field label,
.g41k-stat-units-title {
    font-weight: 700;
    color: #0b1f44;
}

.g41k-stat-field input,
.g41k-stat-field select,
.g41k-stat-button {
    height: 36px;
    border: 1px solid #9aa7bd;
    border-radius: 4px;
    background: #fff;
    color: #172b4d;
    font: inherit;
}

.g41k-stat-field input,
.g41k-stat-field select {
    min-width: 145px;
    padding: 0 8px;
}

.g41k-stat-button {
    padding: 0 14px;
    cursor: pointer;
    font-weight: 700;
}

.g41k-stat-button:hover {
    border-color: #0052cc;
    background: #edf4ff;
}

.g41k-stat-units {
    align-items: stretch;
}

.g41k-stat-units-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.g41k-stat-unit-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.g41k-stat-unit-action,
.g41k-stat-unit-group {
    height: 34px;
    border: 1px solid #9aa7bd;
    border-radius: 4px;
    background: #fff;
    color: #172b4d;
    font: inherit;
}

.g41k-stat-unit-action {
    padding: 0 12px;
    cursor: pointer;
    font-weight: 700;
}

.g41k-stat-unit-action:hover,
.g41k-stat-unit-group:hover {
    border-color: #0052cc;
    background: #edf4ff;
}

.g41k-stat-unit-group {
    min-width: 220px;
    padding: 0 8px;
}

.g41k-stat-unit-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.g41k-stat-unit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 5px 10px;
    border: 1px solid #9aa7bd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}

.g41k-stat-unit input {
    width: 16px;
    height: 16px;
}

.g41k-stat-message {
    min-height: 20px;
    margin: 0 0 10px;
    color: #067647;
    font-weight: 700;
}

.g41k-stat-message.is-error {
    color: #b42318;
}

.g41k-stat-cost-warning {
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid #f0b429;
    border-radius: 8px;
    background: #fff8e6;
    color: #5f370e;
}

.g41k-stat-cost-warning-title {
    margin: 0 0 4px;
    font-weight: 800;
}

.g41k-stat-cost-warning-text {
    margin: 0 0 8px;
}

.g41k-stat-cost-warning ul {
    margin: 0;
    padding-left: 20px;
}

.g41k-stat-cost-warning li {
    margin: 3px 0;
}

.g41k-stat-muted {
    color: #6b7280;
}

.g41k-stat-cost-link {
    color: #1d4ed8;
    font-weight: 700;
    text-decoration: underline;
}

.g41k-stat-report {
    width: 100%;
    background: #fff;
}

.g41k-stat-print-header {
    margin: 0 0 14px;
}

.g41k-stat-print-header h1 {
    margin: 0 0 6px;
    color: #172b4d;
    font-size: 26px;
}

.g41k-stat-section,
.g41k-stat-chart {
    margin: 0 0 18px;
}

.g41k-stat-section h2,
.g41k-stat-chart h3 {
    margin: 0 0 10px;
    color: #6b7280;
    font-size: 20px;
    font-weight: 700;
}

.g41k-stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

.g41k-stat-cards-small {
    grid-template-columns: repeat(5, minmax(135px, 1fr));
}

.g41k-stat-card {
    display: grid;
    grid-template-rows: minmax(54px, auto) 1fr;
    overflow: hidden;
    border: 1px solid #d7dde8;
    border-radius: 4px;
    text-align: center;
}

.g41k-stat-card-title {
    min-height: 54px;
    padding: 8px;
    background: #f3f5f9;
    color: #111827;
    font-weight: 700;
}

.g41k-stat-card-value {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px;
    background: #b6d7a8;
    color: #000;
    font-size: 16px;
    font-weight: 800;
}

.g41k-stat-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(320px, 1fr));
    gap: 18px 24px;
}

.g41k-stat-chart {
    position: relative;
    min-height: 0;
    padding: 12px;
    border: 1px solid #e1e5ee;
    background:
        linear-gradient(#fff 23px, transparent 24px),
        linear-gradient(90deg, #fff 23px, #e8ebf0 24px);
    background-size: 24px 24px;
}

.g41k-stat-chart-wide {
    grid-column: 1 / -1;
}

.g41k-stat-chart-echarts {
    overflow: hidden;
    padding: 14px 16px 12px;
    border: 1px solid #d9e2ef;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 5px 18px rgb(23 43 77 / 8%);
}

.g41k-stat-chart-echarts:hover {
    border-color: #b8c8dd;
    box-shadow: 0 8px 24px rgb(23 43 77 / 12%);
}

.g41k-stat-chart-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 34px;
    padding: 0 4px 8px;
    border-bottom: 1px solid #edf1f6;
}

.g41k-stat-chart-heading h3,
.g41k-stat-chart-echarts h3 {
    margin: 0;
    color: #172b4d;
    font-size: 17px;
    line-height: 1.3;
}

.g41k-echart-canvas {
    width: 100%;
    height: var(--g41k-echart-height, 430px);
    min-height: 360px;
}

.g41k-race-toggle {
    flex: 0 0 auto;
    padding: 6px 12px;
    border: 1px solid #1f5f99;
    border-radius: 5px;
    background: #fff;
    color: #1f5f99;
    cursor: pointer;
    font: 700 12px/1.2 Arial, sans-serif;
}

.g41k-race-toggle:hover,
.g41k-race-toggle:focus-visible {
    background: #1f5f99;
    color: #fff;
    outline: none;
}

.g41k-stat-chart-horizontal {
    min-height: auto;
}

.g41k-chart-variant {
    display: none;
}

.g41k-stat-chart-bars-vertical .g41k-chart-variant-vertical,
.g41k-stat-chart-bars-horizontal .g41k-chart-variant-horizontal {
    display: block;
}

.g41k-horizontal-bars {
    display: grid;
    gap: 6px;
}

.g41k-hbar-row {
    display: grid;
    grid-template-columns: minmax(170px, clamp(240px, 28vw, 560px)) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.g41k-hbar-label {
    overflow: hidden;
    color: #0b1f44;
    font-size: 12px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.g41k-hbar-track {
    position: relative;
    height: 22px;
    border-radius: 4px;
    background: #dce9f6;
}

.g41k-hbar-fill {
    display: flex;
    align-items: center;
    min-width: 0;
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #4c8bf5, #2f66c4);
    box-shadow: inset -4px 0 0 rgb(0 0 0 / 12%);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.g41k-hbar-value {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.g41k-hbar-value.is-inside {
    color: #fff;
}

.g41k-hbar-value.is-outside {
    left: 8px;
    color: #1a73e8;
}

.g41k-stat-chart-bars-wide {
    min-width: 0;
}

.g41k-bar-svg {
    display: block;
    width: 100%;
    height: auto;
    min-height: 315px;
    overflow: visible;
}

.g41k-bar-axis {
    stroke: #c7d0dd;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.g41k-bar-svg-shadow {
    fill: #d5dbe5;
}

.g41k-bar-svg-bar {
    fill: #4285f4;
}

.g41k-bar-svg-value,
.g41k-bar-svg-value-inside {
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-anchor: middle;
}

.g41k-bar-svg-value {
    fill: #1a73e8;
}

.g41k-bar-svg-value-inside {
    fill: #fff;
}

.g41k-bar-svg-label {
    fill: #0b1f44;
    font-family: Arial, sans-serif;
    font-size: 11px;
    text-anchor: end;
}

.g41k-pie-wrap {
    display: grid;
    grid-template-columns: minmax(220px, 42%) 1fr;
    align-items: center;
    gap: 16px;
}

.g41k-pie {
    width: 100%;
    max-width: 320px;
    border-radius: 50%;
    box-shadow: 0 10px 0 rgb(0 0 0 / 12%);
}

.g41k-pie-value {
    fill: #0b1f44;
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 400;
    stroke: none;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

.g41k-chart-legend {
    display: grid;
    gap: 5px;
    font-size: 12px;
}

.g41k-chart-legend-row {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) max-content;
    align-items: center;
    gap: 6px;
}

.g41k-chart-legend-color {
    display: inline-block;
    width: 12px;
    height: 12px;
}

.g41k-chart-legend-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.g41k-chart-legend-name b {
    color: #0b1f44;
    font-weight: 800;
}

.g41k-chart-legend-percent {
    color: #6b7280;
    font-style: normal;
    text-align: right;
}

.g41k-bars {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--bar-count), minmax(30px, 1fr));
    align-items: stretch;
    gap: clamp(5px, .9vw, 12px);
    min-height: 330px;
    overflow: visible;
    padding: 20px 12px 112px;
    background: none;
}

.g41k-bars::before {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    top: 208px;
    border-top: 1px solid #c7d0dd;
}

.g41k-bar-item {
    display: grid;
    grid-template-rows: 18px 170px;
    justify-items: center;
    align-items: stretch;
    min-width: 0;
    position: relative;
}

.g41k-bar-value {
    color: #1a73e8;
    font-size: 11px;
    font-weight: 700;
}

.g41k-bar {
    width: min(22px, 72%);
    min-height: 6px;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(90deg, #4c8bf5, #2f66c4);
    box-shadow:
        inset -3px 0 0 rgb(0 0 0 / 12%),
        0 1px 2px rgb(9 30 66 / 18%);
}

.g41k-bar-slot {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 100%;
}

.g41k-bar-label {
    position: absolute;
    top: 214px;
    left: 50%;
    width: 120px;
    transform: rotate(-58deg);
    transform-origin: top right;
    margin-left: -120px;
    font-size: 11px;
    line-height: 1.1;
    text-align: right;
    white-space: nowrap;
}

.g41k-bars-dense {
    grid-template-columns: repeat(var(--bar-count), minmax(24px, 1fr));
    gap: clamp(4px, .55vw, 8px);
    padding-left: 10px;
    padding-right: 10px;
}

.g41k-bars-dense .g41k-bar {
    width: min(18px, 74%);
}

.g41k-bars-dense .g41k-bar-value,
.g41k-bars-dense .g41k-bar-label {
    font-size: 10px;
}

.g41k-bars-dense .g41k-bar-label {
    width: 112px;
    margin-left: -112px;
    transform: rotate(-60deg);
}

.g41k-bars-ultra {
    grid-template-columns: repeat(var(--bar-count), minmax(18px, 1fr));
    gap: 4px;
    min-height: 330px;
    padding-bottom: 112px;
}

.g41k-bars-ultra::before {
    top: 208px;
}

.g41k-bars-ultra .g41k-bar-item {
    grid-template-rows: 18px 170px;
}

.g41k-bars-ultra .g41k-bar {
    width: min(14px, 78%);
    border-radius: 3px 3px 0 0;
}

.g41k-bars-ultra .g41k-bar-value {
    font-size: 10px;
}

.g41k-bars-ultra .g41k-bar-label {
    top: 214px;
    width: 104px;
    margin-left: -104px;
    font-size: 10px;
    transform: rotate(-62deg);
}

.g41k-efficiency,
.g41k-stacked {
    display: grid;
    gap: 8px;
}

.g41k-eff-row,
.g41k-stack-row {
    display: grid;
    grid-template-columns: minmax(120px, 160px) minmax(0, 1fr) minmax(56px, 105px);
    align-items: center;
    gap: 10px;
}

.g41k-eff-track,
.g41k-stack-track {
    display: flex;
    position: relative;
    height: 24px;
    overflow: hidden;
    border-radius: 4px;
    background: #dce9f6;
}

.g41k-eff-fill,
.g41k-stack-positive {
    background: #4285f4;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    overflow: visible;
    padding: 0;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    text-align: center;
    font-weight: 700;
}

.g41k-stack-negative {
    background: #cfe2f3;
    display: block;
    min-width: 0;
}

.g41k-eff-fill span,
.g41k-stack-positive span {
    position: relative;
    z-index: 2;
    margin-left: 8px;
    white-space: nowrap;
}

.g41k-zero-label {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0b1f44;
    font-weight: 700;
    pointer-events: none;
}

.g41k-stat-empty {
    padding: 30px;
    color: #6b7280;
    text-align: center;
}

@media (max-width: 900px) {
    .g41k-stat-chart-grid {
        grid-template-columns: 1fr;
    }

    .g41k-stat-cards {
        grid-template-columns: repeat(2, minmax(130px, 1fr));
    }

    .g41k-stat-cards-small {
        grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
    }

    .g41k-pie-wrap {
        grid-template-columns: 1fr;
    }

    .g41k-stat-chart {
        min-height: auto;
    }

    .g41k-bars {
        min-height: 330px;
    }

    .g41k-hbar-row {
        grid-template-columns: minmax(130px, 32vw) minmax(0, 1fr);
        gap: 6px;
    }

    .g41k-hbar-label {
        font-size: 12px;
    }
}

@media (max-width: 767.98px) {
    .g41k-stat-chart-echarts {
        padding: 12px 8px 10px;
    }

    .g41k-stat-chart-heading {
        padding-inline: 6px;
    }

    .g41k-stat-chart-heading h3,
    .g41k-stat-chart-echarts h3 {
        font-size: 16px;
    }

    .g41k-echart-canvas {
        height: var(--g41k-echart-mobile-height, var(--g41k-echart-height, 430px));
    }
}

@media (max-width: 520px) {
    .g41k-stat-toolbar,
    .g41k-stat-units {
        display: grid;
        grid-template-columns: 1fr;
    }

    .g41k-stat-units-head,
    .g41k-stat-unit-tools,
    .g41k-stat-unit-list {
        display: grid;
        grid-template-columns: 1fr;
    }

    .g41k-stat-field input,
    .g41k-stat-field select,
    .g41k-stat-button,
    .g41k-stat-unit-action,
    .g41k-stat-unit-group {
        width: 100%;
    }

    .g41k-stat-cards,
    .g41k-stat-cards-small {
        grid-template-columns: 1fr;
    }

    .g41k-pie {
        max-width: 220px;
    }

    .g41k-bars {
        min-height: 320px;
        padding-bottom: 92px;
    }

    .g41k-bars .g41k-bar-label {
        width: 70px;
        margin-left: -70px;
        font-size: 8px;
    }

    .g41k-bars .g41k-bar-value {
        font-size: 8px;
    }

    .g41k-hbar-row {
        grid-template-columns: 1fr;
        gap: 3px;
    }

    .g41k-hbar-value {
        font-size: 11px;
    }
}

@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    body * {
        visibility: hidden !important;
    }

    #g41k-statistics,
    #g41k-statistics * {
        visibility: visible !important;
    }

    #g41k-statistics {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        font-size: 10px;
    }

    .g41k-stat-toolbar,
    .g41k-stat-units,
    .g41k-stat-message,
    .g41k-stat-cost-warning {
        display: none !important;
    }

    .g41k-stat-print-header h1 {
        display: none !important;
    }

    .g41k-stat-chart-grid {
        grid-template-columns: 1fr;
        gap: 7mm;
    }

    .g41k-stat-chart {
        grid-column: 1 / -1;
        break-inside: avoid;
        page-break-inside: avoid;
        width: 100%;
        min-height: 0;
        padding: 4mm;
    }

    .g41k-stat-chart-bars-wide {
        grid-column: 1 / -1;
    }

    .g41k-stat-chart-bars .g41k-chart-variant-vertical {
        display: none !important;
    }

    .g41k-stat-chart-bars .g41k-chart-variant-horizontal {
        display: block !important;
    }

    .g41k-horizontal-bars {
        gap: 1.6mm;
    }

    .g41k-hbar-row {
        grid-template-columns: 46mm minmax(0, 1fr);
        gap: 2mm;
    }

    .g41k-hbar-label,
    .g41k-hbar-value {
        font-size: 8px;
    }

    .g41k-hbar-track {
        height: 5mm;
    }

    .g41k-hbar-fill {
        font-size: 8px;
    }

    .g41k-bar-svg {
        min-height: 72mm;
    }

    .g41k-bars {
        grid-template-columns: repeat(var(--bar-count), minmax(3.3mm, 1fr));
        gap: .8mm;
        min-height: 70mm;
        padding: 4mm 1mm 23mm;
    }

    .g41k-bars::before {
        left: 1mm;
        right: 1mm;
        top: 47mm;
    }

    .g41k-bar-item {
        grid-template-rows: 4mm 40mm;
    }

    .g41k-bar {
        width: min(4mm, 78%);
    }

    .g41k-bar-value {
        font-size: 7px;
    }

    .g41k-bar-label,
    .g41k-bars-dense .g41k-bar-label,
    .g41k-bars-ultra .g41k-bar-label {
        top: 48mm;
        width: 20mm;
        margin-left: -20mm;
        font-size: 7px;
        transform: rotate(-62deg);
    }

    .g41k-pie-wrap {
        grid-template-columns: minmax(62mm, 34%) 1fr;
        gap: 4mm;
    }

    .g41k-chart-legend-row {
        grid-template-columns: 3mm minmax(0, 1fr) max-content;
        gap: 1.4mm;
    }

    .g41k-pie {
        max-width: 78mm;
    }

    .g41k-stat-cards {
        grid-template-columns: repeat(5, 1fr);
    }

    .g41k-stat-card {
        grid-template-rows: minmax(13mm, auto) 1fr;
    }

    .g41k-stat-card-value {
        min-height: 10mm;
    }
}
.g41k-stat-unit.is-disabled {
    opacity: .45;
    background: #eef0f3;
    cursor: not-allowed;
}
