html { min-height: 100%; }
body { min-height: 100vh; }
.app-main { min-height: calc(100vh - 150px); }
.card { border-radius: .85rem; }
code { color: inherit; }
.validation-summary-valid { display: none; }
.table > :not(caption) > * > * { vertical-align: middle; }
.table-responsive { border-radius: inherit; }
.audit-json {
    max-height: 18rem;
    overflow: auto;
    padding: .75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    background: var(--bs-tertiary-bg);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: .78rem;
}
.metric-card .display-6 { font-variant-numeric: tabular-nums; }
.text-break-all { overflow-wrap: anywhere; word-break: break-word; }
button[disabled] { cursor: not-allowed; }
@media (max-width: 767.98px) {
    .app-main { padding-left: .75rem !important; padding-right: .75rem !important; }
}


/* Stage9.2: MRR trend SVG in Bootstrap's theme, no external chart library. */
.mrr-trend-chart { width: 100%; min-width: 0; }
.mrr-trend-svg { display: block; width: 100%; height: auto; max-height: 350px; }
.mrr-trend-grid { stroke: var(--bs-border-color); stroke-width: 1; }
.mrr-trend-zero { stroke: var(--bs-secondary-color); stroke-width: 1.5; stroke-dasharray: 5 4; }
.mrr-trend-axis { fill: var(--bs-secondary-color); font: 12px system-ui, sans-serif; }
.mrr-trend-line { fill: none; stroke: var(--bs-primary); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.mrr-trend-point { fill: var(--bs-primary); stroke: var(--bs-body-bg); stroke-width: 1.5; cursor: crosshair; }
.mrr-trend-point.mrr-trend-active { fill: var(--bs-body-color); stroke: var(--bs-primary); stroke-width: 2; r: 6; }
.mrr-trend-svg:focus-visible { outline: 3px solid var(--bs-primary); outline-offset: 2px; border-radius: .4rem; }
@media (max-width: 576px) { .mrr-trend-svg { min-height: 220px; } }

/* Stage9.3 — Compact client directory. */
.directory-table thead th { font-size: .8rem; vertical-align: middle; }
.directory-table td { padding-top: .9rem; padding-bottom: .9rem; }
.directory-client-name { min-width: 13rem; max-width: 24rem; overflow-wrap: anywhere; }
.directory-number { font-variant-numeric: tabular-nums; white-space: nowrap; }
.directory-advanced > summary { cursor: pointer; width: fit-content; }
.directory-advanced > summary:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 3px; }
.directory-table-card .table-responsive { overscroll-behavior-x: contain; }
@media (max-width: 767.98px) {
  .directory-table { min-width: 850px; }
  .directory-table td { padding-top: .65rem; padding-bottom: .65rem; }
}

/* Stage9.4 — readable advanced filter builder and applied-condition chips. */
.directory-filter-chip { white-space: normal; text-align: left; max-width: min(100%, 36rem); overflow-wrap: anywhere; }
.directory-advanced .condition-row { background: var(--bs-tertiary-bg); }
.directory-advanced .condition-row .form-label { font-weight: 600; }
.directory-advanced .condition-row .invalid-feedback { display: none; }
.directory-advanced .condition-row .is-invalid ~ .condition-error { display: block; }
.directory-advanced #noConditionsMessage[hidden] { display: none; }
@media (max-width: 767.98px) { .directory-filter-chip { max-width: 100%; } }

/* Stage 9.5: modal offcanvas drill-down with wide source-table support */
.analytics-drawer { --bs-offcanvas-width: min(98vw, 1540px); }
.analytics-drawer #facts-grid { width: 100%; min-width: 0; }
.analytics-drawer #facts-grid .tabulator-tableholder { overflow-x: auto; }
.analytics-drawer #facts-grid .tabulator { max-width: 100%; }
.analytics-drawer .table-responsive { max-width: 100%; overflow-x: auto; }
.analytics-drawer td, .analytics-drawer th { min-width: 90px; overflow-wrap: anywhere; }
.analytics-drawer .offcanvas-body { overscroll-behavior: contain; }
@media (max-width: 576px) { .analytics-drawer { --bs-offcanvas-width: 100vw; } }

/* Stage9.9 — minimal shared visual vocabulary and accessible focus states */
:root { --analytics-card-radius: .75rem; --analytics-focus: #174ea6; }
.app-main .card { border-radius: var(--analytics-card-radius); }
.app-main :is(a, button, input, select, summary, [tabindex]):focus-visible { outline: 3px solid var(--analytics-focus); outline-offset: 2px; }
.app-main .table-responsive { overscroll-behavior-inline: contain; }
.app-main .table td, .app-main .table th { vertical-align: middle; }
.saved-view-name { min-width: 180px; max-width: 230px; }
.saved-view-choice { min-width: 170px; max-width: 260px; }
@media (max-width: 480px) { .saved-view-name, .saved-view-choice { width: 100%; max-width: none; } }
@media (prefers-reduced-motion: reduce) { .app-main * { scroll-behavior: auto !important; transition-duration: 0s !important; animation-duration: 0s !important; } }

/* UID: inline form; Virtual Select popup is portaled outside the clipped table viewport. */
.uid-client-link-form { min-width: 360px; }
.uid-client-link-form .client-picker,
#unlinked-groups-fallback .client-picker,
#linked-identities-fallback .client-picker { flex: 1 1 250px; min-width: 230px; max-width: 100%; }
.uid-picker-portal .vscomp-dropbox-wrapper,
.uid-picker-portal .vscomp-dropbox-container { z-index: 1200 !important; }
.uid-picker-portal .vscomp-dropbox-container { min-width: min(360px, calc(100vw - 24px)); }

/* Fix 3: the UID workbench uses every available pixel inside the sidebar shell. */
.executive-app .app-main:has(#unlinked-groups-grid) { max-width:none; width:100%; padding-inline:clamp(10px,1.5vw,26px); }
#unlinked-groups-grid, #linked-identities-grid { width:100%; max-width:none; }
#unlinked-groups-grid .tabulator-tableholder, #linked-identities-grid .tabulator-tableholder { overflow-x:auto; }
.uid-client-link-form { min-width:0; width:100%; }
.uid-client-link-form .client-picker { min-width:175px; flex:1 1 175px; }
.uid-icon-button { padding:.38rem .5rem; min-width:31px; font-size:17px; line-height:1; }

/* Stage 21 Fix 1: stable chart controls across line / stacked area / pie and dimensions.
   The title/caption occupy their own row so even changing caption text cannot move the controls. */
#trend-section { container-type: inline-size; }
#trend-section .trend-chart-header { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
#trend-section .trend-chart-heading { min-width: 0; }
#trend-section #trend-caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#trend-section .trend-chart-controls {
  display: grid;
  grid-template-columns: 160px 205px 155px 190px;
  gap: 10px;
  align-items: end;
  justify-content: start;
  max-width: 100%;
}
#trend-section .trend-chart-control { min-width: 0; }
#trend-section .trend-chart-control select { width: 100%; min-width: 0; }
#trend-section .trend-chart-control-inactive { opacity: .55; }
#trend-section .trend-chart-period .btn-group { display: flex; width: 100%; }
#trend-section .trend-chart-period .btn { flex: 1 1 0; white-space: nowrap; }
@media (max-width: 900px) {
  #trend-section .trend-chart-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 480px) {
  #trend-section .trend-chart-controls { grid-template-columns: minmax(0, 1fr); }
}

/* Container-based breakpoints handle the fixed sidebar and narrow card widths. */
@container (max-width: 760px) {
  .trend-chart-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; }
}
@container (max-width: 420px) {
  .trend-chart-controls { grid-template-columns: minmax(0, 1fr) !important; }
}
