.cfb-spatial,
.cfb-spatial-mode {
    --cfb-spatial-cyan: var(--chart-series-secondary, #12a5b4);
    --cfb-spatial-green: var(--done, #17864f);
    --cfb-spatial-coral: var(--overdue, #c93535);
    box-sizing: border-box;
    color: var(--text, #17233b);
    font-family: var(--font-sans, "Segoe UI", Arial, sans-serif);
    letter-spacing: 0;
}

.cfb-spatial *,
.cfb-spatial-mode * {
    box-sizing: border-box;
    letter-spacing: 0;
}

.cfb-spatial[hidden],
.cfb-spatial [hidden] {
    display: none !important;
}

.cfb-spatial {
    width: 100%;
    max-width: 1440px;
    min-width: 0;
    margin: 0 auto 18px;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--panel-border, #dde3ec);
    background: transparent;
}

.cfb-spatial-mode {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 2px;
    max-width: 100%;
    padding: 3px;
    border: 1px solid var(--meta-border, #dde3ec);
    border-radius: 6px;
    background: var(--meta-bg, #f4f6fa);
}

.cfb-spatial-mode-button,
.cfb-spatial-arrow,
.cfb-spatial-panel {
    appearance: none;
    margin: 0;
    color: inherit;
    font: inherit;
    text-transform: none;
    cursor: pointer;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
}

.cfb-spatial-mode-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 36px;
    min-width: 46px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--muted, #5c6b82);
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
}

.cfb-spatial-mode-button[aria-pressed="true"] {
    border-color: var(--panel-border, #dde3ec);
    background: var(--panel, #ffffff);
    color: var(--text, #17233b);
}

.cfb-spatial-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.cfb-spatial-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    min-width: 0;
}

.cfb-spatial .cfb-spatial-title {
    margin: 0;
    color: var(--text, #17233b);
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
}

.cfb-spatial-scope {
    min-width: 0;
    color: var(--muted, #5c6b82);
    font-size: 11px;
    line-height: 16px;
    overflow-wrap: anywhere;
}

.cfb-spatial-navigation {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 4px;
}

.cfb-spatial-position {
    width: 44px;
    color: var(--muted, #5c6b82);
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.cfb-spatial-arrow {
    display: inline-flex;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--ghost-border, #ccd5e1);
    border-radius: 6px;
    background: var(--ghost-bg, #ffffff);
}

.cfb-spatial-icon {
    display: inline-flex;
    flex: 0 0 22px;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 18px;
    line-height: 1;
}

.cfb-spatial-icon svg {
    display: block;
    width: 20px;
    height: 20px;
    stroke-width: 1.75;
}

.cfb-spatial-stage {
    position: relative;
    isolation: isolate;
    width: 100%;
    min-width: 0;
    height: 218px;
    overflow: hidden;
    perspective: 1000px;
    perspective-origin: 50% 50%;
    touch-action: pan-y pinch-zoom;
}

.cfb-spatial-panel {
    --cfb-spatial-tone: var(--cfb-spatial-cyan);
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    grid-template-rows: 24px 40px minmax(0, 1fr);
    gap: 8px;
    align-content: start;
    width: min(280px, calc(100% - 24px));
    height: 176px;
    padding: 16px;
    border: 1px solid var(--panel-border, #dde3ec);
    border-top: 3px solid var(--cfb-spatial-tone);
    border-radius: 8px;
    background: var(--panel, #ffffff);
    text-align: left;
    transform: translate(-50%, -50%);
    transform-origin: center;
    backface-visibility: hidden;
}

.cfb-spatial-panel[data-tone="green"] {
    --cfb-spatial-tone: var(--cfb-spatial-green);
}

.cfb-spatial-panel[data-tone="coral"] {
    --cfb-spatial-tone: var(--cfb-spatial-coral);
}

.cfb-spatial-panel[data-centered="true"] {
    border-color: var(--border-strong, #c9d2df);
    border-top-color: var(--cfb-spatial-tone);
    box-shadow: var(--shadow, 0 2px 8px rgba(23, 35, 59, 0.08));
}

.cfb-spatial-panel-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--cfb-spatial-tone);
}

.cfb-spatial-panel-title {
    min-width: 0;
    color: var(--text, #17233b);
    font-size: 16px;
    font-weight: 600;
    line-height: 20px;
    overflow-wrap: anywhere;
}

.cfb-spatial-metric {
    display: grid;
    grid-template-rows: minmax(24px, auto) auto;
    gap: 2px;
    min-width: 0;
    align-content: end;
}

.cfb-spatial-value {
    min-width: 0;
    color: var(--text, #17233b);
    font-size: 22px;
    font-weight: 600;
    line-height: 24px;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.cfb-spatial-metric-label {
    color: var(--muted, #5c6b82);
    font-size: 11px;
    line-height: 16px;
    overflow-wrap: anywhere;
}

.cfb-spatial-panel:disabled {
    cursor: default;
}

.cfb-spatial-arrow:hover,
.cfb-spatial-mode-button:hover {
    background: var(--ghost-hover-bg, #f3f6fb);
}

.cfb-spatial-panel[data-centered="true"]:hover {
    background: var(--panel-2, #f7f9fc);
}

.cfb-spatial :is(button):focus-visible,
.cfb-spatial-mode button:focus-visible {
    outline: 2px solid var(--focus-border, #2457d6);
    outline-offset: 3px;
}

.cfb-spatial-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 560px) {
    .cfb-spatial-header {
        align-items: flex-start;
        gap: 8px;
    }

    .cfb-spatial-heading {
        display: grid;
        align-content: center;
        min-height: 40px;
    }

    .cfb-spatial-mode {
        margin-bottom: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cfb-spatial *,
    .cfb-spatial-mode * {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

@media (forced-colors: active) {
    .cfb-spatial-panel[data-centered="true"],
    .cfb-spatial-mode-button[aria-pressed="true"] {
        outline: 2px solid Highlight;
        outline-offset: -4px;
    }
}

@media print {
    .cfb-spatial,
    .cfb-spatial-mode {
        display: none !important;
    }
}
