.page-grid {
    display: grid;
    gap: 18px;
    min-width: 0;
    max-width: 100%;
}

.page-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.widget-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    max-width: 100%;
}

.widget-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.widget-card {
    min-width: 0;
    max-width: 100%;
    background: var(--infradac-card);
    border: 1px solid var(--infradac-border);
    border-radius: 22px;
    padding: 22px;
    box-shadow: 0 12px 30px rgba(36, 51, 43, 0.06);
}

.widget-card h3,
.widget-card h4,
.widget-card h5 {
    margin-top: 0;
}

.stat-board-wrapper,
.table-wrapper,
.pie-chart-wrapper,
.donut-chart-wrapper,
.area-graph-wrapper,
.bar-graph-wrapper {
    display: grid;
    gap: 16px;
    min-width: 0;
    max-width: 100%;
}

.page-grid > *,
.widget-grid > * {
    min-width: 0;
    max-width: 100%;
}

.statboard-title h3,
.table-title h5,
.pie-chart-title,
.donut-chart-title,
.bar-graph-title {
    margin: 0;
    color: var(--infradac-green-dark);
}

body.dark-mode .statboard-title h3,
body.dark-mode .table-title h5,
body.dark-mode .pie-chart-title,
body.dark-mode .donut-chart-title,
body.dark-mode .bar-graph-title {
    color: var(--infradac-gold);
}

.stat-board-container {
    display: grid;
}

.stat-carousel {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stat-panel-wrapper,
.stat-item {
    border-radius: 18px;
    border: 1px solid var(--infradac-border);
    background: var(--infradac-surface);
    padding: 18px;
}

.stat-panel-wrapper.highlighted {
    border-color: rgba(226, 180, 71, 0.42);
    box-shadow: inset 0 0 0 1px rgba(226, 180, 71, 0.2);
}

.stat-panel-header,
.stat-label-row,
.stat-value-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stat-panel-header {
    margin-bottom: 14px;
}

.panel-title,
.stat-label {
    font-weight: 700;
    color: var(--infradac-green-dark);
}

.stat-panel-value,
.stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--infradac-green-dark);
}

.stat-panel-description,
.small-muted,
.chart-subtitle,
.table-empty {
    color: var(--infradac-muted);
    line-height: 1.5;
}

.stat-panel-change,
.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
}

.stat-panel-change.positive,
.stat-change.positive {
    color: #1f7c45;
}

.stat-panel-change.negative,
.stat-change.negative {
    color: #b94141;
}

.stat-panel-change.neutral,
.stat-change.neutral {
    color: var(--infradac-muted);
}

.chart-container,
.bar-graph-canvas-container {
    position: relative;
    min-width: 0;
    max-width: 100%;
    min-height: 280px;
}

.chart-container canvas,
.bar-graph-canvas-container canvas {
    max-width: 100% !important;
}

.pie-chart-content,
.donut-chart-content {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) 220px;
    align-items: center;
}

.pie-chart-content.no-legend,
.donut-chart-content.no-legend {
    grid-template-columns: minmax(0, 1fr);
}

.chart-legend,
.graph-legend {
    display: grid;
    gap: 10px;
}

.graph-legend-horizontal {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.graph-section-header {
    align-items: center;
}

.graph-header-actions {
    display: flex;
    justify-content: flex-end;
    min-width: fit-content;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--infradac-muted);
    font-size: 0.95rem;
}

button.legend-item {
    width: fit-content;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

button.legend-item:hover,
button.legend-item:focus-visible {
    border-color: var(--infradac-border);
    background: color-mix(in srgb, var(--infradac-green) 7%, transparent);
    outline: none;
}

button.legend-item[aria-pressed="false"] {
    opacity: 0.48;
}

button.legend-item[aria-pressed="false"] .legend-label {
    text-decoration: line-through;
}

.legend-color {
    width: 12px;
    height: 12px;
    border: 1px solid color-mix(in srgb, var(--infradac-border) 82%, transparent);
    border-radius: 999px;
    display: inline-block;
}

.legend-label {
    line-height: 1.2;
}

.legend-total {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: 2px 7px;
    border: 1px solid color-mix(in srgb, var(--infradac-border) 72%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--infradac-surface) 78%, var(--infradac-card));
    color: var(--infradac-heading);
    font-size: 0.82rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    text-decoration: none;
}

.graph-mode-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
}

.graph-mode-tab {
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--infradac-border);
    border-radius: 8px;
    background: var(--infradac-surface);
    color: var(--infradac-muted);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
}

.graph-mode-tab:hover,
.graph-mode-tab:focus-visible,
.graph-mode-tab.is-active {
    border-color: var(--infradac-green);
    background: color-mix(in srgb, var(--infradac-green) 10%, var(--infradac-surface));
    color: var(--infradac-green-dark);
    outline: none;
}

body.dark-mode .graph-mode-tab.is-active {
    border-color: var(--infradac-gold);
    color: var(--infradac-gold);
}

.graph-external-tooltip {
    position: fixed;
    z-index: 3200;
    min-width: 220px;
    max-width: min(320px, calc(100vw - 20px));
    display: grid;
    gap: 9px;
    padding: 12px 14px;
    border: 1px solid var(--infradac-border);
    border-radius: 10px;
    background: var(--infradac-card);
    color: var(--infradac-ink);
    box-shadow: 0 18px 45px rgba(20, 31, 25, 0.22);
    font-size: 0.82rem;
    line-height: 1.35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 80ms linear;
}

.graph-external-tooltip[hidden] {
    display: none;
}

.graph-tooltip-title {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
}

.graph-tooltip-title strong {
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--infradac-heading);
    font-size: 0.88rem;
}

.graph-tooltip-color {
    width: 12px;
    height: 12px;
    border: 1px solid color-mix(in srgb, var(--infradac-border) 78%, transparent);
    border-radius: 3px;
}

.graph-tooltip-window {
    color: var(--infradac-muted);
    font-weight: 800;
}

.graph-tooltip-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: baseline;
}

.graph-tooltip-row span {
    color: var(--infradac-muted);
    font-weight: 800;
}

.graph-tooltip-row strong {
    color: var(--infradac-heading);
    font-weight: 950;
}

.graph-tooltip-row.is-error strong {
    color: #dc2626;
}

.area-graph-filters,
.bar-graph-filters,
.language-editor-toolbar,
.language-tab-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.language-editor-toolbar {
    justify-content: space-between;
    padding: 14px 16px;
    border: 1px solid var(--infradac-border);
    border-radius: 18px;
    background: color-mix(in srgb, var(--infradac-surface) 88%, var(--infradac-card));
}

.language-editor-toolbar label {
    font-size: 0.92rem;
    color: var(--infradac-ink);
}

.language-editor-toolbar select,
.field select,
.filter-item select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    min-height: 46px;
    padding-right: 44px;
    border: 1px solid color-mix(in srgb, var(--infradac-green-dark) 16%, var(--infradac-border));
    background-color: color-mix(in srgb, var(--infradac-card) 92%, white);
    background-image: none;
    background-repeat: no-repeat !important;
    background-position: right 14px center;
    background-size: 10px 10px;
    background-origin: border-box;
    background-clip: padding-box;
    color: var(--infradac-ink);
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
    cursor: pointer;
    line-height: 1.35;
    text-overflow: ellipsis;
}

.language-editor-toolbar .infradac-select-shell,
.filter-item .infradac-select-shell {
    width: min(320px, 100%);
}

.language-editor-toolbar .infradac-select-shell select,
.filter-item .infradac-select-shell select,
.field .infradac-select-shell select {
    min-height: 46px;
    padding-left: 46px !important;
    padding-right: 16px !important;
    background-image: none !important;
}

.language-editor-toolbar select::-ms-expand,
.field select::-ms-expand,
.filter-item select::-ms-expand {
    display: none;
}

.language-editor-toolbar select option,
.field select option,
.filter-item select option {
    background: var(--infradac-card);
    color: var(--infradac-ink);
}

.field input[type="date"],
.field input[type="datetime-local"],
.field input[type="time"],
.filter-item input[type="date"],
.filter-item input[type="datetime-local"],
.filter-item input[type="time"] {
    min-height: 46px;
    color-scheme: light;
}

.field input[type="date"]::-webkit-calendar-picker-indicator,
.field input[type="datetime-local"]::-webkit-calendar-picker-indicator,
.field input[type="time"]::-webkit-calendar-picker-indicator,
.filter-item input[type="date"]::-webkit-calendar-picker-indicator,
.filter-item input[type="datetime-local"]::-webkit-calendar-picker-indicator,
.filter-item input[type="time"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.82;
}

.field input[type="date"]::-webkit-calendar-picker-indicator:hover,
.field input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
.field input[type="time"]::-webkit-calendar-picker-indicator:hover,
.filter-item input[type="date"]::-webkit-calendar-picker-indicator:hover,
.filter-item input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
.filter-item input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

body.dark-mode .language-editor-toolbar,
[data-bs-theme="dark"] .language-editor-toolbar {
    background: color-mix(in srgb, var(--infradac-card) 92%, var(--infradac-surface));
}

body.dark-mode .language-editor-toolbar select,
body.dark-mode .field select,
body.dark-mode .filter-item select,
[data-bs-theme="dark"] .language-editor-toolbar select,
[data-bs-theme="dark"] .field select,
[data-bs-theme="dark"] .filter-item select {
    background-color: color-mix(in srgb, var(--infradac-card) 88%, black);
    background-image: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

body.dark-mode .language-editor-toolbar select option,
body.dark-mode .field select option,
body.dark-mode .filter-item select option,
[data-bs-theme="dark"] .language-editor-toolbar select option,
[data-bs-theme="dark"] .field select option,
[data-bs-theme="dark"] .filter-item select option {
    background: var(--infradac-card);
    color: var(--infradac-ink);
}

body.dark-mode .field input[type="date"],
body.dark-mode .field input[type="datetime-local"],
body.dark-mode .field input[type="time"],
body.dark-mode .filter-item input[type="date"],
body.dark-mode .filter-item input[type="datetime-local"],
body.dark-mode .filter-item input[type="time"],
[data-bs-theme="dark"] .field input[type="date"],
[data-bs-theme="dark"] .field input[type="datetime-local"],
[data-bs-theme="dark"] .field input[type="time"],
[data-bs-theme="dark"] .filter-item input[type="date"],
[data-bs-theme="dark"] .filter-item input[type="datetime-local"],
[data-bs-theme="dark"] .filter-item input[type="time"] {
    color-scheme: dark;
}

body.dark-mode .field input[type="date"]::-webkit-calendar-picker-indicator,
body.dark-mode .field input[type="datetime-local"]::-webkit-calendar-picker-indicator,
body.dark-mode .field input[type="time"]::-webkit-calendar-picker-indicator,
body.dark-mode .filter-item input[type="date"]::-webkit-calendar-picker-indicator,
body.dark-mode .filter-item input[type="datetime-local"]::-webkit-calendar-picker-indicator,
body.dark-mode .filter-item input[type="time"]::-webkit-calendar-picker-indicator,
[data-bs-theme="dark"] .field input[type="date"]::-webkit-calendar-picker-indicator,
[data-bs-theme="dark"] .field input[type="datetime-local"]::-webkit-calendar-picker-indicator,
[data-bs-theme="dark"] .field input[type="time"]::-webkit-calendar-picker-indicator,
[data-bs-theme="dark"] .filter-item input[type="date"]::-webkit-calendar-picker-indicator,
[data-bs-theme="dark"] .filter-item input[type="datetime-local"]::-webkit-calendar-picker-indicator,
[data-bs-theme="dark"] .filter-item input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1) grayscale(100%);
}

.filter-item {
    display: grid;
    gap: 6px;
}

.filter-item label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--infradac-muted);
}

.filter-item input,
.filter-item select {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--infradac-border);
    background: #fffdf8;
}

.graph-range-extents {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--infradac-muted);
    font-size: 0.92rem;
}

.table-responsive {
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
}

.custom-table th,
.custom-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(36, 51, 43, 0.08);
    text-align: left;
    vertical-align: top;
}

.custom-table th {
    color: var(--infradac-green-dark);
    font-size: 0.92rem;
}

.custom-table td {
    color: var(--infradac-muted);
}

body.compact-tables .custom-table th,
body.compact-tables .custom-table td {
    padding: 10px 12px;
}

.editor-shell {
    display: grid;
    gap: 18px;
}

.editor-language-panel {
    display: none;
}

.editor-language-panel.active {
    display: grid;
    gap: 14px;
}

.editor-meta-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.editor-note {
    color: var(--infradac-muted);
    font-size: 0.94rem;
    line-height: 1.5;
}

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

.section-header h2,
.section-header h3 {
    margin: 0;
}

.section-header p {
    margin: 6px 0 0;
    color: var(--infradac-muted);
}

@media (max-width: 1100px) {
    .widget-grid,
    .widget-grid.three,
    .page-grid.two,
    .pie-chart-content,
    .donut-chart-content,
    .editor-meta-grid {
        grid-template-columns: 1fr;
    }

    .language-editor-toolbar {
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .page-grid,
    .widget-grid,
    .widget-grid.three {
        gap: 14px;
        grid-template-columns: 1fr;
    }

    .widget-card {
        padding: 16px;
        border-radius: 16px;
    }

    .stat-board-wrapper,
    .table-wrapper,
    .pie-chart-wrapper,
    .donut-chart-wrapper,
    .area-graph-wrapper,
    .bar-graph-wrapper {
        gap: 12px;
    }

    .stat-carousel {
        gap: 10px;
        grid-template-columns: 1fr;
        padding: 12px;
        border-radius: 14px;
    }

    .stat-panel-wrapper,
    .stat-item {
        padding: 14px;
        border-radius: 14px;
    }

    .stat-panel-header,
    .stat-label-row,
    .stat-value-row,
    .section-header {
        align-items: flex-start;
    }

    .section-header,
    .stat-panel-header {
        display: grid;
    }

    .section-header p {
        font-size: 0.93rem;
    }

    .stat-panel-value,
    .stat-value {
        font-size: 1.42rem;
        overflow-wrap: anywhere;
        white-space: normal;
    }

    .pie-chart-content,
    .donut-chart-content,
    .editor-meta-grid {
        grid-template-columns: 1fr;
    }

    .chart-container,
    .bar-graph-canvas-container {
        min-height: 220px;
    }

    .graph-range-extents {
        display: grid;
        gap: 4px;
        font-size: 0.84rem;
    }

    .chart-legend,
    .graph-legend {
        gap: 8px;
    }

    .legend-item {
        align-items: flex-start;
        font-size: 0.9rem;
        overflow-wrap: anywhere;
    }

    .graph-section-header {
        align-items: stretch;
        flex-direction: column;
    }

    .graph-header-actions {
        justify-content: flex-start;
        min-width: 0;
    }

    .area-graph-filters,
    .bar-graph-filters,
    .language-editor-toolbar,
    .language-tab-toolbar {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .language-editor-toolbar .infradac-select-shell,
    .filter-item .infradac-select-shell {
        width: 100%;
    }

    .table-responsive {
        margin-inline: -2px;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
    }

    .custom-table {
        min-width: 560px;
    }

    .custom-table th,
    .custom-table td,
    body.compact-tables .custom-table th,
    body.compact-tables .custom-table td {
        padding: 10px 11px;
        font-size: 0.88rem;
    }
}
