/* Stack the chart and table sections */
#tenant-dashboard-div {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    padding-top: 20px;
    padding-bottom: 24px;
}

/* Space each graph heading from its chart */
#tenant-dashboard-div .tenant-dashboard-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    isolation: isolate;
    width: 100%;
    min-width: 0;
    margin: 0;
}

/* Graph headings */
#tenant-dashboard-div .tenant-dashboard-heading {
    display: block;
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 0;
    color: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 20px;
    text-align: left;
}

/* Chart and table content */
#tenant-dashboard-div .tenant-dashboard-section-content {
    display: flow-root;
    position: relative;
    z-index: 0;
    width: 100%;
    min-width: 0;
    margin: 0;
}

/* Outer graph containers */
#tenant-dashboard-div .tenant-dashboard-section-content>.summary-div {
    position: relative;
    inset: auto;
    float: none;
    width: 100%;
    margin: 0;
}

/* Recharges heading and toolbar container */
#tenant-dashboard-recharges-table {
    position: relative;
}

/* Keep the heading in the layout so the table cannot overlap it */
#tenant-dashboard-recharges-table>.table-header {
    display: flex;
    align-items: flex-end;
    position: static;
    float: none;
    box-sizing: border-box;
    width: 100%;
    min-height: 36px;
    margin: 0 0 12px;
    padding: 0 110px 0 0;
    transform: none;
    color: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 20px;
    text-align: left;
    justify-content: flex-start;
}

/* Prevent the generated table wrapper becoming the toolbar anchor */
#tenant-dashboard-recharges-table>.bootstrap-table {
    position: static;
    margin-top: 0;
    padding-top: 0;
}

/* Place the controls beside the heading without adding another row */
#tenant-dashboard-recharges-table .fixed-table-toolbar {
    position: absolute;
    top: 0;
    right: 0;
    left: auto;
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    z-index: 2;
}

#tenant-dashboard-recharges-table .fixed-table-toolbar .columns {
    margin-top: 0;
    margin-bottom: 0;
}

#tenant-dashboard-filter-form-div {
    margin-top: 10px;
}

/* Align the filter panel and charts */
#tenant-dashboard-filter-form-div,
#tenant-dashboard-div {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-left: 0;
    margin-right: 0;
}

/* Allow enough height for wrapped filter rows */
#tenant-dashboard-filter-form-div .accordion-item,
#tenant-dashboard-filter-panel.show {
    height: auto;
    max-height: none;
}

#tenant-dashboard-filter-panel .accordion-body {
    display: block;
    box-sizing: border-box;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 22px 12px 28px !important;
}

#tenant-dashboard-filter-form {
    display: block;
    position: static;
    float: none;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0;
}

/* Five equal filter sections plus the Filter button */
#tenant-dashboard-filter-form .tenant-dashboard-filter-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
}

/* Keep the button aligned at the far right */
#tenant-dashboard-filter-form .tenant-dashboard-filter-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    margin: 0;
    padding: 0;
}

#tenant-dashboard-filter-button {
    width: auto;
    min-height: 34px;
    margin: 0;
    padding: 6px 12px;
    white-space: nowrap;
}

/* Compact label/control pairs */
#tenant-dashboard-filter-form .tenant-dashboard-filter-field {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: center;
    justify-content: stretch;
    column-gap: 8px;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
}

/* Right-align labels so every label ends 8px from its control */
#tenant-dashboard-filter-form .tenant-dashboard-filter-field>.fw-bold {
    display: block;
    width: auto;
    margin: 0;
    padding: 0;
    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
    text-align: right;
    white-space: nowrap;
}

/* Control wrapper */
#tenant-dashboard-filter-form .tenant-dashboard-filter-field>div:last-child {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0 !important;
    padding: 0;
    text-align: left;
}

/* Remove differing widths from widget wrappers */
#tenant-dashboard-filter-form .tenant-dashboard-filter-field>div:last-child>*,
#tenant-dashboard-filter-form .tenant-dashboard-filter-field .multiselect-dropdown,
#tenant-dashboard-filter-form .tenant-dashboard-filter-field .btn-group,
#tenant-dashboard-filter-form .tenant-dashboard-filter-field .bootstrap-select,
#tenant-dashboard-filter-form .tenant-dashboard-filter-field .select2-container,
#tenant-dashboard-filter-form .tenant-dashboard-filter-field .input-group {
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    float: none;
    font-size: 12px;
}

/* Consistent visible control sizing */
/* Size visible controls only — exclude bootstrap-select's hidden select */
#tenant-dashboard-filter-form .tenant-dashboard-filter-field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
#tenant-dashboard-filter-form .tenant-dashboard-filter-field select:not(.selectpicker):not(.bs-select-hidden):not(.bootstrap-select > select),
#tenant-dashboard-filter-form .tenant-dashboard-filter-field .dropdown-toggle,
#tenant-dashboard-filter-form .tenant-dashboard-filter-field button.multiselect,
#tenant-dashboard-filter-form .tenant-dashboard-filter-field .multiselect-dropdown,
#tenant-dashboard-filter-form .tenant-dashboard-filter-field .select2-selection--single {
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 34px;
    margin: 0 !important;
    font-size: 12px;
    text-align: left;
}

/* Keep the plugin's invisible select within its own control */
#tenant-dashboard-filter-form .bootstrap-select>select:not(.mobile-device) {
    position: absolute !important;
    left: 50%;
    bottom: 0;
    width: 0.5px !important;
    min-width: 0 !important;
    max-width: 0.5px !important;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}
/* Selected-value text */
#tenant-dashboard-filter-form .select2-selection,
#tenant-dashboard-filter-form .multiselect-selected-text,
#tenant-dashboard-filter-form .filter-option {
    font-size: 12px;
}

#tenant-dashboard-filter-form .multiselect-selected-text {
    display: inline-block;
    max-width: calc(100% - 20px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

/* Wrap complete label/control pairs on smaller screens */
@media (max-width: 1100px) {
    #tenant-dashboard-filter-form .tenant-dashboard-filter-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        row-gap: 16px;
    }
}

@media (max-width: 800px) {
    #tenant-dashboard-filter-form .tenant-dashboard-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 540px) {
    #tenant-dashboard-filter-form .tenant-dashboard-filter-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Keep these selectors global: the tooltip renders outside the dashboard. */
.tenant-chart-tooltip {
    width: min(420px, calc(100vw - 56px));
    color: inherit;
    font-size: 12px;
    line-height: 1.45;
    white-space: normal;
}

.tenant-chart-tooltip__heading {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid currentColor;
    font-size: 13px;
    font-weight: 600;
}

.tenant-chart-tooltip__scroll {
    max-height: min(300px, 45vh);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-right: 8px;
    pointer-events: auto;
}

.tenant-chart-tooltip__row {
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr) max-content;
    align-items: start;
    gap: 8px;
    padding: 6px 0;
}

.tenant-chart-tooltip__dot {
    width: 8px;
    height: 8px;
    margin-top: 5px;
    border-radius: 50%;
}

.tenant-chart-tooltip__name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.tenant-chart-tooltip__value {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.tenant-chart-tooltip__hint {
    margin-top: 8px;
    font-size: 11px;
    opacity: 0.7;
}

/* Theme-aware legend pagination text */
#tenant-dashboard-cost-graph-container text.highcharts-legend-navigation,
#tenant-dashboard-consumption-graph-container text.highcharts-legend-navigation {
    fill: var(--font-color) !important;
}

.tenant-month-change {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    color: var(--k_color_text);
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

.tenant-month-change__arrow,
.tenant-month-change__neutral {
    display: block;
    font-family: Arial, sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 18px;
}

.tenant-month-change__arrow--up {
    color: #ff3344;
}

.tenant-month-change__arrow--down {
    color: #35d04f;
}

.tenant-month-change__neutral {
    color: var(--k_color_text);
}

/* Tenant dashboard summary cards only */
#tenant-dashboard-summary {
    --tenant-card-header-bg: #b8e0bb;
    --tenant-card-header-text: #243c2a;

    color: var(--k_color_text, var(--bs-body-color, inherit));
}

/* Card outline and subtle Trace green shadow */
#tenant-dashboard-summary .dashboard-card {
    color: inherit;
    border: 1px solid rgba(113, 165, 118, 0.45);
    border-radius: 6px !important;
    box-shadow:
        0 2px 5px rgba(0, 0, 0, 0.12),
        0 0 5px rgba(184, 224, 187, 0.12);
}

/* Override the existing inline header background */
#tenant-dashboard-summary .dashboard-card-header {
    background-color: var(--tenant-card-header-bg) !important;
    color: var(--tenant-card-header-text);
    border-radius: 5px 5px 0 0;
    padding: 11px 12px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}

/* Body follows the surrounding dashboard background */
#tenant-dashboard-summary .dashboard-card-body {
    background-color: transparent;
    color: inherit;
    border-radius: 0 0 5px 5px;
    padding: 16px 12px;
}

/* Theme-aware values */
#tenant-dashboard-summary .dashboard-card-text,
#tenant-dashboard-summary .dashboard-card-value {
    color: inherit;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

/* Loading text */
#tenant-dashboard-summary .dashboard-card-loading {
    color: inherit;
    font-size: 14px;
    font-weight: 400;
    opacity: 0.75;
}

/* Theme-aware tenant dashboard values */
#tenant-dashboard-summary .dashboard-card-body,
#tenant-dashboard-summary .dashboard-card-text,
#tenant-dashboard-summary .dashboard-card-value,
#tenant-dashboard-summary .dashboard-card-loading {
    color: var(--font-color) !important;
}

/* Smaller values on narrower screens */
@media (max-width: 1000px) {

    #tenant-dashboard-summary .dashboard-card-text,
    #tenant-dashboard-summary .dashboard-card-value {
        font-size: 18px;
    }
}
