/* =========================================================
   BI Sage X3 — direction visuelle “finance / pilotage”
   Typo : Source Serif 4 (titres) + IBM Plex Sans (UI / chiffres)
   ========================================================= */

:root {
    --bi-ink: #182430;
    --bi-ink-soft: #2c3d4f;
    --bi-muted: #6a7b8c;
    --bi-line: #d7e0e6;
    --bi-panel: #ffffff;
    --bi-panel-soft: #f7faf8;
    --bi-accent: #0f6b5c;
    --bi-accent-dark: #0a4f44;
    --bi-accent-soft: #e4f3ef;
    --bi-navy: #1a3347;
    --bi-heatmap: #0f6b5c;
    --bi-danger: #a33b2d;
    --bi-shadow: 0 10px 30px rgba(24, 36, 48, 0.06);
    --bi-shadow-sm: 0 1px 2px rgba(24, 36, 48, 0.05), 0 4px 12px rgba(24, 36, 48, 0.04);
    --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
    --font-ui: "IBM Plex Sans", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-ui);
    color: var(--bi-ink);
    background-color: #e8eef1;
    background-image:
        radial-gradient(ellipse 900px 420px at 8% -10%, rgba(15, 107, 92, 0.10), transparent 55%),
        radial-gradient(ellipse 700px 380px at 100% 0%, rgba(26, 51, 71, 0.10), transparent 50%),
        linear-gradient(180deg, #dfe8ec 0%, #e8eef1 180px, #eef2f4 100%);
    background-attachment: fixed;
}

h1, h2, h3, .brand-text, .kpi-value, .pivot-title {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

a {
    color: var(--bi-accent-dark);
}

/* ----- Navbar ----- */
.app-navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: linear-gradient(90deg, #132533 0%, #1a3347 55%, #163a36 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    margin-bottom: 0;
    box-shadow: 0 8px 24px rgba(18, 30, 40, 0.18);
}

main.container,
main.container-fluid {
    padding-top: 1.5rem;
}

.app-navbar .navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: #f3f7f8 !important;
    text-decoration: none;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 0.45rem;
    background: rgba(15, 107, 92, 0.35);
    color: #9ee0d2;
    font-size: 0.95rem;
}

.brand-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: #f5f8f9;
}

.brand-text em {
    font-style: italic;
    font-weight: 500;
    color: #b7d4cc;
}

.app-navbar .nav-link {
    color: rgba(236, 244, 246, 0.78) !important;
    font-weight: 500;
    font-size: 0.92rem;
    padding: 0.45rem 0.85rem !important;
    border-radius: 999px;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link.active {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.08);
}

.app-navbar .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.25);
}

.app-navbar .navbar-toggler-icon {
    filter: invert(1);
}

.navbar-user {
    color: rgba(236, 244, 246, 0.75);
    font-size: 0.88rem;
}

.btn-nav-logout {
    --bs-btn-color: #e8f2ef;
    --bs-btn-border-color: rgba(232, 242, 239, 0.35);
    --bs-btn-hover-bg: rgba(255, 255, 255, 0.08);
    --bs-btn-hover-border-color: rgba(232, 242, 239, 0.55);
    --bs-btn-hover-color: #fff;
    border: 1px solid rgba(232, 242, 239, 0.35);
    color: #e8f2ef;
    background: transparent;
    font-size: 0.82rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
}

.btn-nav-logout:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(232, 242, 239, 0.55);
}

.dropdown-menu {
    border: 1px solid var(--bi-line);
    box-shadow: var(--bi-shadow);
    border-radius: 0.75rem;
    padding: 0.4rem;
}

.dropdown-item {
    border-radius: 0.45rem;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: var(--bi-accent-soft);
    color: var(--bi-accent-dark);
}

/* ----- Cards / panels ----- */
.app-card {
    background: var(--bi-panel);
    border: 1px solid rgba(24, 36, 48, 0.06);
    border-radius: 1rem;
    box-shadow: var(--bi-shadow-sm);
}

.app-card .card-body {
    padding: 1.15rem 1.25rem;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bi-muted);
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border-color: #c9d5dd;
    border-radius: 0.65rem;
    color: var(--bi-ink);
    background-color: #fcfdfe;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--bi-accent);
    box-shadow: 0 0 0 0.2rem rgba(15, 107, 92, 0.15);
}

.btn-outline-primary {
    --bs-btn-color: var(--bi-accent-dark);
    --bs-btn-border-color: rgba(15, 107, 92, 0.45);
    --bs-btn-hover-bg: var(--bi-accent-soft);
    --bs-btn-hover-border-color: var(--bi-accent);
    --bs-btn-hover-color: var(--bi-accent-dark);
    border-radius: 0.65rem;
    font-weight: 550;
}

.btn-outline-secondary {
    --bs-btn-color: var(--bi-ink-soft);
    --bs-btn-border-color: #c5d0d8;
    --bs-btn-hover-bg: #eef3f5;
    --bs-btn-hover-border-color: #b5c2cc;
    --bs-btn-hover-color: var(--bi-ink);
    border-radius: 999px;
    font-weight: 500;
}

.btn-dark,
.preset-btn.active {
    background: var(--bi-navy);
    border-color: var(--bi-navy);
    color: #fff;
    border-radius: 999px;
    font-weight: 550;
}

.preset-btn {
    border-radius: 999px;
    font-size: 0.82rem;
    padding: 0.4rem 0.85rem;
    border: 1px solid #c5d0d8;
    background: rgba(255, 255, 255, 0.72);
    color: var(--bi-ink-soft);
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.preset-btn:hover {
    background: #fff;
    border-color: var(--bi-accent);
    color: var(--bi-accent-dark);
}

.preset-btn.active {
    background: var(--bi-navy);
    border-color: var(--bi-navy);
    color: #fff;
}

.source-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.35rem;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid #d5e0e6;
    border-radius: 999px;
    width: fit-content;
    max-width: 100%;
}

.source-tab {
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 550;
    padding: 0.45rem 1.1rem;
    color: var(--bi-ink-soft);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.source-tab:hover {
    background: #fff;
    color: var(--bi-accent-dark);
}

.source-tab.active {
    background: var(--bi-accent);
    color: #fff;
}

.doc-chain {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.75rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid #cfe0e4;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    max-width: 42rem;
}

.doc-chain-title {
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--bi-ink-soft);
}

.doc-chain-nums {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1rem;
    font-size: 0.88rem;
    color: var(--bi-ink);
}

.doc-chain-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.doc-chain-link {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid var(--bi-accent);
    color: var(--bi-accent-dark);
    background: #fff;
    padding: 0.28rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 550;
    text-decoration: none;
}

.doc-chain-link:hover {
    background: var(--bi-accent);
    color: #fff;
}

.pivot-row-label-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
}

.row-cross-links {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.row-cross-link {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid #b7c9d0;
    color: var(--bi-ink-soft);
    background: rgba(255, 255, 255, 0.9);
    padding: 0.08rem 0.42rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    line-height: 1.2;
}

.row-cross-link:hover {
    border-color: var(--bi-accent);
    color: var(--bi-accent-dark);
    background: #fff;
}

.pivot-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-top: 1px solid #d7e2e7;
    background: rgba(255, 255, 255, 0.65);
}

.pivot-pagination-info {
    font-size: 0.85rem;
    color: var(--bi-ink-soft);
}

.pivot-pagination-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.pivot-page-btn {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid #c5d0d8;
    background: #fff;
    color: var(--bi-ink-soft);
    padding: 0.28rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 550;
    text-decoration: none;
}

.pivot-page-btn:hover {
    border-color: var(--bi-accent);
    color: var(--bi-accent-dark);
}

.pivot-page-btn.is-disabled {
    opacity: 0.45;
    cursor: default;
}

.pivot-page-current {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--bi-ink);
    padding: 0 0.35rem;
}

.btn-preset-config {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    border: 1px dashed #9aafb8;
    background: rgba(255, 255, 255, 0.65);
    color: var(--bi-muted);
    font-size: 0.8rem;
    font-weight: 550;
    padding: 0.38rem 0.75rem;
}

.btn-preset-config:hover,
.btn-preset-config:focus {
    background: #fff;
    color: var(--bi-accent-dark);
    border-color: var(--bi-accent);
}

.preset-quick-menu {
    min-width: 280px;
    max-width: 360px;
    border-radius: 0.85rem;
    border: 1px solid var(--bi-line);
    overflow: hidden;
}

.preset-quick-head {
    padding: 0.7rem 0.9rem 0.45rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bi-muted);
    font-weight: 650;
}

.preset-quick-list {
    max-height: 320px;
    overflow: auto;
    padding: 0.15rem 0.35rem 0.35rem;
}

.preset-quick-group-label {
    margin: 0.55rem 0.55rem 0.2rem;
    padding-bottom: 0.2rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--bi-accent-dark);
    border-bottom: 1px solid #d7e4e8;
}

.preset-quick-group-label:first-child {
    margin-top: 0.15rem;
}

.preset-quick-item {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.45rem 0.55rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--bi-ink-soft);
}

.preset-quick-item:hover {
    background: var(--bi-accent-soft);
}

.preset-quick-item input {
    margin-top: 0.15rem;
}

.preset-quick-actions {
    border-top: 1px solid var(--bi-line);
    padding: 0.65rem 0.75rem 0.75rem;
    background: #f7faf8;
}

/* ----- Panneau de sélection repliable (Analyse) ----- */
.selection-panel-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.7rem 1rem;
    background: linear-gradient(180deg, #f7faf8 0%, #f2f7f5 100%);
}

.selection-panel-bar-main {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
    min-width: 0;
    flex: 1;
}

.btn-selection-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid #c5d0d8;
    background: #fff;
    color: var(--bi-ink-soft);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.8rem;
}

.btn-selection-toggle:hover {
    border-color: var(--bi-accent);
    color: var(--bi-accent-dark);
}

.selection-toggle-icon {
    display: inline-block;
    transition: transform 0.18s ease;
    font-size: 0.85rem;
}

.selection-panel.is-collapsed .selection-toggle-icon {
    transform: rotate(-90deg);
}

.selection-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 1rem;
    font-size: 0.82rem;
    color: var(--bi-muted);
    min-width: 0;
}

.selection-summary span {
    white-space: nowrap;
}

.selection-summary strong {
    color: var(--bi-ink-soft);
    font-weight: 600;
    margin-right: 0.2rem;
}

.selection-panel-refresh {
    flex-shrink: 0;
}

/* ----- Login ----- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(circle at 15% 20%, rgba(15, 107, 92, 0.16), transparent 42%),
        radial-gradient(circle at 85% 80%, rgba(26, 51, 71, 0.18), transparent 40%),
        linear-gradient(160deg, #d5e2e4 0%, #e8eef1 45%, #edf1f0 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 1.15rem;
    overflow: hidden;
}

.login-card .card-body {
    padding: 1.75rem !important;
}

.login-card h1 {
    font-family: var(--font-display);
    font-weight: 600;
}

/* ----- Pivot header / KPIs ----- */
.pivot-header {
    padding-top: 0.35rem;
}

.pivot-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.7rem;
    color: var(--bi-accent-dark);
    font-weight: 650;
    font-family: var(--font-ui);
}

.pivot-title {
    font-size: clamp(1.55rem, 2.2vw, 2rem);
    font-weight: 650;
    color: var(--bi-ink);
    margin: 0;
}

.pivot-subtitle {
    color: var(--bi-muted);
    font-size: 0.95rem;
}

.kpi-card {
    position: relative;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfa 100%);
    border-radius: 1rem;
    padding: 1.05rem 1.15rem 1rem;
    box-shadow: var(--bi-shadow-sm);
    border: 1px solid rgba(24, 36, 48, 0.06);
    height: 100%;
    overflow: hidden;
}

.kpi-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.85rem;
    bottom: 0.85rem;
    width: 3px;
    border-radius: 999px;
    background: var(--bi-accent);
}

.kpi-label {
    font-size: 0.72rem;
    color: var(--bi-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 0.4rem;
    font-weight: 600;
    padding-left: 0.55rem;
}

.kpi-value {
    font-size: clamp(1.2rem, 1.8vw, 1.55rem);
    font-weight: 650;
    letter-spacing: -0.025em;
    color: var(--bi-ink);
    font-variant-numeric: tabular-nums;
    padding-left: 0.55rem;
    line-height: 1.15;
}

.kpi-sub {
    margin-top: 0.35rem;
    padding-left: 0.55rem;
    font-size: 0.78rem;
    color: var(--bi-muted);
    font-variant-numeric: tabular-nums;
}

.var-up {
    color: #0f6b5c;
    font-weight: 600;
}

.var-down {
    color: var(--bi-danger);
    font-weight: 600;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.55rem;
    border-radius: 0.45rem;
    background: #e8f3ef;
    border: 1px solid #c5ddd4;
    font-size: 0.82rem;
    color: var(--bi-ink);
}

.filter-chip-remove {
    color: var(--bi-muted);
    text-decoration: none;
    font-weight: 700;
    line-height: 1;
    padding: 0 0.15rem;
}

.filter-chip-remove:hover {
    color: var(--bi-danger);
}

.filter-chip-clear {
    font-size: 0.8rem;
    color: var(--bi-muted);
}

.pivot-drill-link {
    color: var(--bi-accent);
    text-decoration: none;
    border-bottom: 1px dotted rgba(15, 107, 92, 0.45);
}

.pivot-drill-link:hover {
    color: var(--bi-ink);
    border-bottom-color: var(--bi-ink);
}

/* ----- Schema catalog admin (navigateur type X3) ----- */
.btn-help-q {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    border: 1px solid #c5ddd4;
    background: #fff;
    color: var(--bi-accent);
    font-weight: 700;
    font-family: var(--font-ui);
    line-height: 1;
    cursor: pointer;
}

.btn-help-q:hover,
.btn-help-q[aria-expanded="true"] {
    background: #e8f3ef;
    border-color: var(--bi-accent);
}

.schema-help {
    margin-bottom: 0.85rem;
}

.schema-help-inner {
    background: #f7fbf9;
    border: 1px solid #c5ddd4;
    border-radius: 0.75rem;
    padding: 1rem 1.15rem;
    max-width: 52rem;
}

.schema-browser-layout {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    min-height: 62vh;
    overflow: hidden;
}

.schema-nav {
    border-right: 1px solid var(--bi-line);
    background: linear-gradient(180deg, #f4f8f6 0%, #eef4f1 100%);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.schema-nav-title {
    padding: 0.85rem 1rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bi-muted);
    border-bottom: 1px solid #d7e2dd;
}

.schema-nav-list {
    list-style: none;
    margin: 0;
    padding: 0.4rem 0;
    overflow: auto;
    flex: 1;
}

.schema-nav-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 0.7rem 1rem;
    border-left: 3px solid transparent;
    cursor: pointer;
    font-family: var(--font-ui);
}

.schema-nav-item:hover {
    background: rgba(15, 107, 92, 0.06);
}

.schema-nav-item.is-active {
    background: #fff;
    border-left-color: var(--bi-accent);
}

.schema-nav-label {
    display: block;
    font-weight: 600;
    color: var(--bi-ink);
    font-size: 0.92rem;
    margin-bottom: 0.15rem;
}

.schema-nav-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.schema-nav-meta code {
    font-size: 0.72rem;
    color: var(--bi-muted);
}

.schema-nav-x3 {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.7rem;
    color: #8a6a2b;
    font-family: ui-monospace, monospace;
}

.schema-alias-pill {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 0.3rem;
    background: #dceee8;
    color: var(--bi-accent);
    font-family: ui-monospace, monospace;
}

.schema-alias-pill.is-off {
    background: #eee;
    color: #888;
}

.schema-detail {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.schema-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.schema-panel[hidden] {
    display: none !important;
}

.schema-detail-head {
    padding: 1rem 1.25rem 1.05rem;
    border-bottom: 1px solid var(--bi-line);
    background: #fff;
}

.schema-detail-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.35rem;
}

.schema-detail-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 650;
    margin: 0;
    color: var(--bi-ink);
}

.bi-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.55rem;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    font-weight: 650;
    font-family: var(--font-ui);
    line-height: 1.2;
    border: 1px solid transparent;
    white-space: nowrap;
}

.bi-badge-ok {
    background: #e4f3ee;
    border-color: #b7d9ce;
    color: #0b4f44;
}

.bi-badge-warn {
    background: #fff6e5;
    border-color: #efd7a3;
    color: #7a4e00;
}

.schema-detail-hint {
    color: var(--bi-muted);
    font-size: 0.9rem;
    max-width: 48rem;
}

.schema-alias-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(160px, 1fr));
    gap: 0.65rem;
    padding: 0.7rem 0.85rem;
    background: #f4f8f6;
    border: 1px solid #d7e2dd;
    border-radius: 0.55rem;
}

.schema-alias-label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bi-muted);
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.schema-alias-cell code {
    font-weight: 600;
    color: var(--bi-accent);
}

.schema-x3 {
    color: #8a5a12 !important;
    font-weight: 650;
}

.schema-fields-wrap {
    overflow: auto;
    flex: 1;
    max-height: calc(62vh - 9rem);
}

.schema-columns thead th {
    position: sticky;
    top: 0;
    background: #eef5f2;
    z-index: 1;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bi-muted);
}

.schema-columns code.schema-expr {
    color: var(--bi-accent);
    font-weight: 600;
}

.schema-col-muted td {
    opacity: 0.55;
}

.schema-alias-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.schema-alias-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.3rem 0.55rem;
    background: #f4f8f6;
    border: 1px solid #d7e2dd;
    border-radius: 0.4rem;
    font-size: 0.82rem;
}

.schema-alias-chip code {
    color: var(--bi-accent);
    font-weight: 700;
}

@media (max-width: 900px) {
    .schema-browser-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .schema-nav {
        border-right: 0;
        border-bottom: 1px solid var(--bi-line);
        max-height: 220px;
    }

    .schema-alias-bar {
        grid-template-columns: 1fr;
    }

    .schema-fields-wrap {
        max-height: none;
    }
}

/* ----- Matrix ----- */
.pivot-matrix-card {
    overflow: hidden;
    border-radius: 1rem;
}

.pivot-matrix-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.95rem 1.2rem;
    border-bottom: 1px solid var(--bi-line);
    background:
        linear-gradient(180deg, #f4f8f6 0%, #eef4f1 100%);
}

.pivot-matrix-toolbar strong {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
}

.pivot-scroll {
    max-height: 70vh;
    overflow: auto;
    background: #fff;
}

.pivot-table {
    font-size: 0.86rem;
    font-variant-numeric: tabular-nums;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
}

.pivot-table > :not(caption) > * > * {
    border-bottom-color: #e4ebef;
    padding: 0.55rem 0.7rem;
}

.pivot-head {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #eef5f2 !important;
    color: var(--bi-muted);
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid #cfdcd6 !important;
    vertical-align: bottom;
}

.pivot-col-main {
    color: var(--bi-ink);
    font-weight: 600;
    font-family: var(--font-ui);
}

.pivot-col-sub {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--bi-muted);
}

.pivot-sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    min-width: 170px;
    max-width: 280px;
    border-right: 1px solid #d7e2dd;
}

thead .pivot-sticky-col {
    z-index: 4;
    background: #eef5f2 !important;
}

.pivot-row-label {
    font-weight: 550;
    color: var(--bi-ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pivot-cell {
    white-space: nowrap;
    min-width: 100px;
}

.pivot-total-col {
    background: #f3f8f5 !important;
    border-left: 1px solid #d0ddd6;
    min-width: 114px;
}

.pivot-footer th,
.pivot-footer td {
    position: sticky;
    bottom: 0;
    background: #e4efe9 !important;
    border-top: 2px solid #b9cfc4 !important;
    z-index: 2;
    color: var(--bi-ink);
}

.pivot-footer .pivot-sticky-col {
    z-index: 5;
}

.text-danger {
    color: var(--bi-danger) !important;
}

/* ----- Home polish ----- */
.home-hero-title {
    font-family: var(--font-display);
    font-weight: 650;
}

.home-quick-groups {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.home-quick-group {
    padding: 0.85rem 0.95rem;
    border: 1px solid #d7e2e7;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
}

.home-quick-group-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem 0.75rem;
    margin-bottom: 0.65rem;
}

.home-quick-group-title {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--bi-accent-dark);
}

.home-quick-group-open {
    font-size: 0.78rem;
    font-weight: 550;
    color: var(--bi-ink-soft);
    text-decoration: none;
}

.home-quick-group-open:hover {
    color: var(--bi-accent-dark);
    text-decoration: underline;
}

.home-quick-group-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.preset-source-row td {
    background: #f3f7f8;
    padding-top: 0.65rem !important;
    padding-bottom: 0.65rem !important;
    border-bottom-color: #d7e2e7;
}

.preset-source-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--bi-accent-dark);
}

@media (max-width: 768px) {
    .kpi-value {
        font-size: 1.12rem;
    }

    .pivot-scroll {
        max-height: 60vh;
    }

    main.container,
    main.container-fluid {
        padding-top: 1rem;
    }
}
