.ut-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 16px;
}
.ut-panel h3 {
    margin: 0 0 12px;
    font-size: 1rem;
    color: #1e293b;
}
.ut-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}
.ut-embed-cost-toolbar {
    justify-content: flex-end;
    margin-bottom: 8px;
}
.ut-cost-toggle-btn {
    margin-right: 8px;
}
.ut-total-toggle-btn {
    margin-right: 8px;
}
.chart-toolbar-slot .ut-cost-toggle-btn,
.chart-toolbar-slot .ut-total-toggle-btn {
    margin-right: 6px;
}
.ut-date-range-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}
.ut-date-presets {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}
.ut-date-preset-btn {
    appearance: none;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.ut-date-preset-btn:hover {
    border-color: #94a3b8;
    color: #1e293b;
}
.ut-date-preset-btn.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}
.ut-date-custom {
    display: none;
    align-items: end;
    flex-wrap: wrap;
    gap: 8px;
}
.ut-date-custom.is-open {
    display: inline-flex;
}
.ut-date-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 600;
}
.ut-date-input {
    padding: 5px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #1e293b;
    background: #fff;
    min-height: 30px;
}
.ut-datetime-input {
    min-width: 11.5rem;
}
.ut-date-apply-btn {
    appearance: none;
    border: 1px solid #4f46e5;
    background: #4f46e5;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    min-height: 30px;
}
.ut-date-apply-btn:hover {
    background: #4338ca;
    border-color: #4338ca;
}

/* Calendar modal (replaces native month / datetime-local text inputs) */
.dash-cal-trigger {
    appearance: none;
    cursor: pointer;
    text-align: left;
    min-width: 8.5rem;
    white-space: nowrap;
}
.dash-cal-trigger.ut-datetime-input {
    min-width: 12.5rem;
}
.dash-cal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.dash-cal-panel {
    width: min(300px, 100%);
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28);
    padding: 12px;
    color: #0f172a;
}
.dash-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.dash-cal-title {
    font-size: 0.85rem;
    font-weight: 700;
}
.dash-cal-close {
    appearance: none;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
}
.dash-cal-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}
.dash-cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.dash-cal-nav-label {
    font-size: 0.9rem;
    font-weight: 700;
}
.dash-cal-nav-label.is-clickable {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    user-select: none;
}
.dash-cal-nav-label.is-clickable:hover {
    background: #f1f5f9;
}
.dash-cal-nav-label.is-clickable::after {
    content: ' ▾';
    font-size: 0.7rem;
    opacity: 0.7;
}
.dash-cal-nav-btn {
    appearance: none;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}
.dash-cal-nav-btn:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}
.dash-cal-months {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.dash-cal-years {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.dash-cal-year-btn.is-current:not(.is-selected) {
    border-color: #a5b4fc;
}
.dash-cal-month-btn,
.dash-cal-day {
    appearance: none;
    border: 1px solid transparent;
    background: #f8fafc;
    color: #0f172a;
    border-radius: 8px;
    min-height: 36px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}
.dash-cal-month-btn:hover,
.dash-cal-day:hover {
    border-color: #a5b4fc;
    background: #eef2ff;
}
.dash-cal-month-btn.is-selected,
.dash-cal-day.is-selected {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}
.dash-cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.dash-cal-dow {
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #64748b;
    padding: 2px 0 4px;
}
.dash-cal-day.is-empty {
    visibility: hidden;
    pointer-events: none;
}
.dash-cal-time {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
}
.dash-cal-time-select {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #0f172a;
    font-size: 0.8rem;
    padding: 4px 6px;
    min-height: 30px;
}
.dash-cal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}
.dash-cal-btn {
    appearance: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 7px 12px;
    cursor: pointer;
    min-height: 30px;
}
.dash-cal-btn-ghost {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
}
.dash-cal-btn-ghost:hover {
    background: #f8fafc;
}
.dash-cal-btn-primary {
    border: 1px solid #4f46e5;
    background: #4f46e5;
    color: #fff;
}
.dash-cal-btn-primary:hover {
    background: #4338ca;
    border-color: #4338ca;
}

.ut-date-summary {
    font-size: 0.75rem;
    color: #64748b;
    margin-left: auto;
}
.ut-range-loading {
    padding: 18px !important;
}
.ut-profile-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.ut-profile-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}
.ut-profile-item.active {
    border-color: #4f46e5;
    background: #eef2ff;
}
.ut-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.ut-form-grid label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 4px;
}
.ut-form-grid input,
.ut-form-grid select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.875rem;
}
.ut-bucket-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.ut-bucket-row {
    display: grid;
    grid-template-columns: 1fr 100px 90px 90px 1fr auto;
    gap: 8px;
    align-items: end;
}
.ut-time-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0 12px;
}
.ut-time-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr 1.2fr auto;
    gap: 8px;
    align-items: end;
}
.ut-time-row label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 4px;
}
.ut-time-row input,
.ut-time-row select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.875rem;
}
.ut-bucket-row select.ut-b-mode {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.875rem;
    background: #fff;
}
.ut-b-tol-wrap.is-hidden {
    display: none;
}
.ut-bucket-row label {
    font-size: 0.7rem;
    color: #64748b;
}
.ut-btn {
    border: 0;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.8rem;
    cursor: pointer;
}
.ut-btn-primary { background: #4f46e5; color: #fff; }
.ut-btn-secondary { background: #e2e8f0; color: #334155; }
.ut-btn-danger { background: #fee2e2; color: #b91c1c; }
.ut-btn-sm { padding: 4px 8px; font-size: 0.75rem; }
.ut-chart-wrap {
    min-height: 280px;
    margin-top: 8px;
}

/* Main chart flex layout — chart fills space after compact chrome */
#mainChart.ut-chart-container {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
    /* visible so Apex tooltips are not clipped by the chart host */
    overflow: visible;
    padding-bottom: clamp(8px, 1.5vh, 16px);
    box-sizing: border-box;
}
.ut-chart-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: visible;
}
.ut-chart-meta {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 8px;
    margin: 0 6px 4px;
    font-size: clamp(0.68rem, 1.6vw, 0.76rem);
    color: #475569;
    line-height: 1.25;
}
.ut-meta-part {
    white-space: nowrap;
}
.ut-meta-k {
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    margin-right: 3px;
}
.ut-meta-sep {
    color: #cbd5e1;
    font-weight: 600;
}
.ut-meta-rate {
    padding: 1px 6px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
}
.ut-apex-inner {
    flex: 1 1 0;
    min-height: 160px;
    min-width: 0;
    position: relative;
    overflow: visible;
}
.ut-apex-inner .apexcharts-tooltip {
    z-index: 40 !important;
    max-width: min(360px, 70vw);
    white-space: normal !important;
    pointer-events: none;
}
.ut-apex-inner .apexcharts-tooltip .apexcharts-tooltip-text-y-value,
.ut-apex-inner .apexcharts-tooltip .apexcharts-tooltip-y-group {
    white-space: normal !important;
}

/* Dashboard panels clip by default — lift that for UT slides so fixed tips stay readable */
body.utility-dashboard .panel.chart-container:has(#mainChart.ut-chart-container),
body.utility-dashboard .panel.chart-container:has(.ut-apex-inner) {
    overflow: visible;
}

/* Compact single-row bucket comparison strip */
.ut-bucket-diff {
    flex: 0 0 auto;
    margin: 0 4px 4px;
    padding: clamp(4px, 0.6vh, 6px) clamp(6px, 1vw, 8px);
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.ut-bucket-diff-strip {
    flex-shrink: 0;
}
.ut-bucket-diff-unreliable {
    border-color: #fcd34d;
    background: #fffbeb;
    border-left: 3px solid #f59e0b;
}
.ut-bucket-diff-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(4px, 1vw, 8px);
    min-height: 0;
}
.ut-bucket-diff-multi .ut-bucket-diff-row + .ut-bucket-diff-row {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed #e2e8f0;
}
.ut-bucket-diff-window-label {
    flex: 0 0 auto;
    min-width: 4.5rem;
    max-width: 28%;
    font-size: clamp(0.6rem, 1.35vw, 0.68rem);
    font-weight: 700;
    color: #64748b;
    text-transform: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ut-bucket-diff-row-window .ut-bucket-strip-label {
    max-width: 42%;
}
.ut-bucket-diff-warn-chip {
    flex: 0 0 auto;
    font-size: 0.75rem;
    line-height: 1;
    color: #b45309;
    cursor: help;
}
.ut-bucket-strip-side {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 4px;
    font-size: clamp(0.68rem, 1.6vw, 0.76rem);
    line-height: 1.25;
}
.ut-bucket-strip-a {
    justify-content: flex-start;
    text-align: left;
}
.ut-bucket-strip-b {
    justify-content: flex-end;
    text-align: right;
}
.ut-bucket-strip-thin {
    color: #92400e;
}
.ut-bucket-strip-label {
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.ut-bucket-strip-value {
    font-weight: 700;
    color: #4f46e5;
    white-space: nowrap;
}
.ut-bucket-strip-hours {
    color: #94a3b8;
    white-space: nowrap;
    font-size: clamp(0.62rem, 1.4vw, 0.7rem);
}
.ut-bucket-strip-hours-warn {
    color: #b45309;
    font-weight: 600;
}
.ut-bucket-diff-mid {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2px;
    max-width: 34%;
}
.ut-bucket-diff-delta {
    font-size: clamp(0.68rem, 1.6vw, 0.76rem);
    font-weight: 700;
    color: #0f172a;
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
}
.ut-bucket-diff-delta-muted {
    color: #94a3b8;
}

/* 7-day forecast panel */
.ut-forecast-panel {
    flex: 0 0 auto;
    margin: 0 4px 6px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #fff;
    max-height: 42%;
    overflow: auto;
}
.ut-forecast-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 8px;
    margin-bottom: 4px;
}
.ut-forecast-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}
.ut-forecast-sub {
    font-size: 0.68rem;
    color: #94a3b8;
}
.ut-forecast-table-wrap {
    overflow-x: auto;
}
.ut-forecast-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
}
.ut-forecast-table th,
.ut-forecast-table td {
    padding: 3px 6px;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
}
.ut-forecast-table th {
    font-weight: 600;
    color: #94a3b8;
    font-size: 0.65rem;
    text-transform: uppercase;
}
.ut-rec-pill {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
}
.ut-rec-off .ut-rec-pill { background: #dcfce7; color: #166534; }
.ut-rec-minimal .ut-rec-pill { background: #ecfdf5; color: #047857; }
.ut-rec-less .ut-rec-pill { background: #dbeafe; color: #1d4ed8; }
.ut-rec-normal .ut-rec-pill { background: #f1f5f9; color: #475569; }
.ut-rec-more .ut-rec-pill { background: #fee2e2; color: #b91c1c; }
.ut-forecast-note {
    margin-top: 4px;
    font-size: 0.65rem;
    color: #94a3b8;
    line-height: 1.3;
}
.ut-forecast-loading,
.ut-forecast-error {
    font-size: 0.72rem;
    color: #64748b;
    padding: 4px 0;
}
.ut-forecast-error { color: #b45309; }

@media (max-width: 520px) {
    .ut-bucket-diff-row {
        flex-wrap: wrap;
        justify-content: center;
    }
    .ut-bucket-diff-window-label {
        flex: 1 1 100%;
        max-width: none;
        text-align: center;
    }
    .ut-bucket-strip-a,
    .ut-bucket-strip-b {
        flex: 1 1 100%;
        justify-content: center;
        text-align: center;
    }
    .ut-bucket-diff-mid {
        flex: 1 1 100%;
        max-width: none;
        order: -1;
    }
}

.ut-embed-strip {
    margin-top: 12px;
    padding: 12px;
    border-top: 1px solid #e2e8f0;
}
.ut-empty {
    color: #64748b;
    font-size: 0.875rem;
    padding: 8px 0;
}
.ut-status {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 6px;
}

/* Dark mode — match dashboard Apex chrome (navy + muted cyan text) */
html[data-bs-theme="dark"] .ut-panel {
    background: var(--ms-card, #002447);
    border-color: var(--ms-border, #1a4d7a);
}
html[data-bs-theme="dark"] .ut-panel h3 {
    color: var(--ms-text, #e8f2fa);
}
html[data-bs-theme="dark"] .ut-profile-item {
    background: var(--ms-card-raised, #003060);
    border-color: var(--ms-border, #1a4d7a);
    color: var(--ms-text, #e8f2fa);
}
html[data-bs-theme="dark"] .ut-profile-item.active {
    border-color: #4d9fe8;
    background: rgba(77, 159, 232, 0.12);
}
html[data-bs-theme="dark"] .ut-form-grid label,
html[data-bs-theme="dark"] .ut-bucket-row label {
    color: var(--ms-text-muted, #8eb0cc);
}
html[data-bs-theme="dark"] .ut-form-grid input,
html[data-bs-theme="dark"] .ut-form-grid select,
html[data-bs-theme="dark"] .ut-bucket-row select.ut-b-mode,
html[data-bs-theme="dark"] .ut-bucket-row input {
    background: var(--ms-card-raised, #003060);
    color: var(--ms-text, #e8f2fa);
    border-color: var(--ms-border, #1a4d7a);
}
html[data-bs-theme="dark"] .ut-btn-secondary {
    background: var(--ms-card-raised, #003060);
    color: var(--ms-text, #e8f2fa);
}
html[data-bs-theme="dark"] .ut-btn-danger {
    background: rgba(185, 28, 28, 0.25);
    color: #fca5a5;
}
html[data-bs-theme="dark"] .ut-chart-meta {
    color: var(--ms-text-muted, #8eb0cc);
}
html[data-bs-theme="dark"] .ut-meta-k {
    color: #6b8fad;
}
html[data-bs-theme="dark"] .ut-meta-sep {
    color: var(--ms-border, #1a4d7a);
}
html[data-bs-theme="dark"] .ut-meta-rate {
    background: rgba(77, 159, 232, 0.15);
    color: #7ec4f5;
}
html[data-bs-theme="dark"] .ut-bucket-diff {
    background: var(--ms-card-raised, #003060);
    border-color: var(--ms-border, #1a4d7a);
}
html[data-bs-theme="dark"] .ut-bucket-diff-unreliable {
    border-color: #b45309;
    background: rgba(245, 158, 11, 0.12);
    border-left-color: #f59e0b;
}
html[data-bs-theme="dark"] .ut-bucket-diff-warn-chip {
    color: #fbbf24;
}
html[data-bs-theme="dark"] .ut-bucket-diff-multi .ut-bucket-diff-row + .ut-bucket-diff-row {
    border-top-color: var(--ms-border, #1a4d7a);
}
html[data-bs-theme="dark"] .ut-bucket-diff-window-label {
    color: #6b8fad;
}
html[data-bs-theme="dark"] .ut-bucket-strip-thin {
    color: #fbbf24;
}
html[data-bs-theme="dark"] .ut-bucket-strip-label {
    color: var(--ms-text-muted, #8eb0cc);
}
html[data-bs-theme="dark"] .ut-bucket-strip-value {
    color: #7ec4f5;
}
html[data-bs-theme="dark"] .ut-bucket-strip-hours {
    color: #6b8fad;
}
html[data-bs-theme="dark"] .ut-bucket-strip-hours-warn {
    color: #fbbf24;
}
html[data-bs-theme="dark"] .ut-bucket-diff-delta {
    color: var(--ms-text, #e8f2fa);
}
html[data-bs-theme="dark"] .ut-bucket-diff-delta-muted {
    color: #6b8fad;
}
html[data-bs-theme="dark"] .ut-forecast-panel {
    background: var(--ms-card-raised, #003060);
    border-color: var(--ms-border, #1a4d7a);
}
html[data-bs-theme="dark"] .ut-forecast-title {
    color: var(--ms-text-muted, #8eb0cc);
}
html[data-bs-theme="dark"] .ut-forecast-sub,
html[data-bs-theme="dark"] .ut-forecast-note,
html[data-bs-theme="dark"] .ut-forecast-loading {
    color: #6b8fad;
}
html[data-bs-theme="dark"] .ut-forecast-table th,
html[data-bs-theme="dark"] .ut-forecast-table td {
    border-bottom-color: var(--ms-border, #1a4d7a);
    color: var(--ms-text, #e8f2fa);
}
html[data-bs-theme="dark"] .ut-forecast-table th {
    color: #6b8fad;
}
html[data-bs-theme="dark"] .ut-rec-off .ut-rec-pill { background: rgba(22, 101, 52, 0.35); color: #86efac; }
html[data-bs-theme="dark"] .ut-rec-minimal .ut-rec-pill { background: rgba(4, 120, 87, 0.3); color: #6ee7b7; }
html[data-bs-theme="dark"] .ut-rec-less .ut-rec-pill { background: rgba(29, 78, 216, 0.3); color: #93c5fd; }
html[data-bs-theme="dark"] .ut-rec-normal .ut-rec-pill { background: rgba(142, 176, 204, 0.12); color: #8eb0cc; }
html[data-bs-theme="dark"] .ut-rec-more .ut-rec-pill { background: rgba(185, 28, 28, 0.3); color: #fca5a5; }
html[data-bs-theme="dark"] .ut-embed-strip {
    border-top-color: var(--ms-border, #1a4d7a);
}
html[data-bs-theme="dark"] .ut-embed-strip > h4 {
    color: var(--ms-text, #e8f2fa) !important;
}
html[data-bs-theme="dark"] .ut-empty,
html[data-bs-theme="dark"] .ut-status {
    color: var(--ms-text-muted, #8eb0cc);
}
html[data-bs-theme="dark"] .ut-date-range-bar {
    background: var(--ms-card-raised, #003060);
    border-color: var(--ms-border, #1a4d7a);
}
html[data-bs-theme="dark"] .ut-date-preset-btn {
    background: var(--ms-card, #002447);
    border-color: var(--ms-border, #1a4d7a);
    color: var(--ms-text-muted, #8eb0cc);
}
html[data-bs-theme="dark"] .ut-date-preset-btn:hover {
    color: var(--ms-text, #e8f2fa);
    border-color: #4d9fe8;
}
html[data-bs-theme="dark"] .ut-date-preset-btn.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}
html[data-bs-theme="dark"] .ut-date-field {
    color: var(--ms-text-muted, #8eb0cc);
}
html[data-bs-theme="dark"] .ut-date-input {
    background: var(--ms-card, #002447);
    border-color: var(--ms-border, #1a4d7a);
    color: var(--ms-text, #e8f2fa);
    color-scheme: dark;
}
html[data-bs-theme="dark"] .dash-cal-overlay {
    background: rgba(2, 8, 23, 0.62);
}
html[data-bs-theme="dark"] .dash-cal-panel {
    background: var(--ms-card-raised, #003060);
    border-color: var(--ms-border, #1a4d7a);
    color: var(--ms-text, #e8f2fa);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
html[data-bs-theme="dark"] .dash-cal-close {
    color: var(--ms-text-muted, #8eb0cc);
}
html[data-bs-theme="dark"] .dash-cal-close:hover {
    background: var(--ms-card, #002447);
    color: var(--ms-text, #e8f2fa);
}
html[data-bs-theme="dark"] .dash-cal-nav-btn {
    background: var(--ms-card, #002447);
    border-color: var(--ms-border, #1a4d7a);
    color: var(--ms-text, #e8f2fa);
}
html[data-bs-theme="dark"] .dash-cal-nav-btn:hover {
    background: #0a3a66;
    border-color: #4d9fe8;
}
html[data-bs-theme="dark"] .dash-cal-nav-label.is-clickable:hover {
    background: var(--ms-card, #002447);
}
html[data-bs-theme="dark"] .dash-cal-year-btn.is-current:not(.is-selected) {
    border-color: #6366f1;
}
html[data-bs-theme="dark"] .dash-cal-month-btn,
html[data-bs-theme="dark"] .dash-cal-day {
    background: var(--ms-card, #002447);
    color: var(--ms-text, #e8f2fa);
}
html[data-bs-theme="dark"] .dash-cal-month-btn:hover,
html[data-bs-theme="dark"] .dash-cal-day:hover {
    background: #0a3a66;
    border-color: #6366f1;
}
html[data-bs-theme="dark"] .dash-cal-month-btn.is-selected,
html[data-bs-theme="dark"] .dash-cal-day.is-selected {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
}
html[data-bs-theme="dark"] .dash-cal-dow,
html[data-bs-theme="dark"] .dash-cal-time {
    color: var(--ms-text-muted, #8eb0cc);
}
html[data-bs-theme="dark"] .dash-cal-time-select {
    background: var(--ms-card, #002447);
    border-color: var(--ms-border, #1a4d7a);
    color: var(--ms-text, #e8f2fa);
}
html[data-bs-theme="dark"] .dash-cal-btn-ghost {
    background: var(--ms-card, #002447);
    border-color: var(--ms-border, #1a4d7a);
    color: var(--ms-text, #e8f2fa);
}
html[data-bs-theme="dark"] .dash-cal-btn-ghost:hover {
    background: #0a3a66;
}
html[data-bs-theme="dark"] .ut-time-row label {
    color: var(--ms-text-muted, #8eb0cc);
}
html[data-bs-theme="dark"] .ut-time-row input,
html[data-bs-theme="dark"] .ut-time-row select {
    background: var(--ms-card, #002447);
    border-color: var(--ms-border, #1a4d7a);
    color: var(--ms-text, #e8f2fa);
}
html[data-bs-theme="dark"] .ut-apex-inner .apexcharts-xaxis-label,
html[data-bs-theme="dark"] .ut-apex-inner .apexcharts-yaxis-label,
html[data-bs-theme="dark"] .ut-apex-inner .apexcharts-yaxis-title-text,
html[data-bs-theme="dark"] .ut-apex-inner .apexcharts-title-text {
    fill: #8eb0cc !important;
}
html[data-bs-theme="dark"] .ut-apex-inner .apexcharts-gridline {
    stroke: rgba(142, 176, 204, 0.2) !important;
}
html[data-bs-theme="dark"] #mainChart.ut-chart-container .apexcharts-xaxis-label,
html[data-bs-theme="dark"] #mainChart.ut-chart-container .apexcharts-yaxis-label,
html[data-bs-theme="dark"] #mainChart.ut-chart-container .apexcharts-yaxis-title-text {
    fill: #8eb0cc !important;
}
html[data-bs-theme="dark"] #mainChart.ut-chart-container .apexcharts-gridline {
    stroke: rgba(142, 176, 204, 0.2) !important;
}

/* Freeform custom charts — keep date chrome + plot usable on phones */
#mainChart.ff-chart-host {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}
#mainChart.ff-chart-host .ff-date-bar-host,
#mainChart.ff-chart-host .ff-date-range-bar {
    flex: 0 0 auto;
    min-width: 0;
    max-width: 100%;
}
#mainChart.ff-chart-host .ff-apex-inner {
    flex: 1 1 auto;
    min-height: 200px;
    min-width: 0;
}
#mainChart.ff-chart-host .ff-apex-inner .apexcharts-legend {
    max-width: 100%;
    padding: 0 4px;
}
#mainChart.ff-chart-host .ff-apex-inner .apexcharts-tooltip {
    max-width: min(280px, 86vw);
    white-space: normal !important;
}

@media (max-width: 640px) {
    .ff-date-range-bar.ut-date-range-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px;
    }
    .ff-date-range-bar .ut-date-presets {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    .ff-date-range-bar .ut-date-preset-btn {
        flex: 1 1 auto;
        text-align: center;
        padding: 7px 8px;
        font-size: 0.7rem;
    }
    .ff-date-range-bar .ut-date-custom.is-open {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 8px;
    }
    .ff-date-range-bar .ut-date-field {
        width: 100%;
    }
    .ff-date-range-bar .dash-cal-trigger,
    .ff-date-range-bar .dash-cal-trigger.ut-datetime-input,
    .ff-date-range-bar .ut-datetime-input {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    .ff-date-range-bar .ut-date-apply-btn {
        width: 100%;
    }
    .ff-date-range-bar .ut-date-summary {
        margin-left: 0;
        width: 100%;
        font-size: 0.7rem;
        line-height: 1.35;
        white-space: normal;
    }
    .dash-cal-overlay {
        align-items: flex-start;
        padding: 12px;
        padding-top: max(12px, env(safe-area-inset-top, 0px));
        overflow-y: auto;
    }
    .dash-cal-panel {
        width: min(320px, 100%);
        margin: 0 auto;
    }
}

@media (max-width: 1024px) {
    body.utility-dashboard .panel.chart-container:has(#mainChart.ff-chart-host),
    body.utility-dashboard .panel.chart-container:has(#mainChart.ut-chart-container) {
        min-height: 70vh;
    }
    body.utility-dashboard .panel.chart-container:has(#mainChart.ff-chart-host) .chart-wrapper,
    body.utility-dashboard .panel.chart-container:has(#mainChart.ut-chart-container) .chart-wrapper {
        height: auto;
        min-height: 58vh;
    }
}
