/* Business Analysis Manager: navy and gold dashboard theme */
:root {
    --navy: #13306a;
    --navy-dark: #0c2150;
    --navy-soft: #4a6fa5;
    --gold: #f5b700;
    --gold-dark: #d99e00;
    --gold-light: #fff3c4;
    --ink: #1d2742;
    --muted: #6b7489;
    --line: #dde2ec;
    --bg: #eef1f6;
    --gain: #1e8e3e;
    --loss: #d93025;
    --rail: 64px;
    --bs-primary: #13306a;
    --bs-primary-rgb: 19, 48, 106;
    --bs-link-color: #13306a;
    --bs-link-color-rgb: 19, 48, 106;
    --bs-link-hover-color: #0c2150;
    --bs-link-hover-color-rgb: 12, 33, 80;
}

html { font-size: 14px; }
body { background: var(--bg); color: var(--ink); }
a { color: var(--navy); }
a:hover { color: var(--navy-dark); }

/* ------------------------------------------------------------------ side rail */
.rail {
    position: fixed; inset: 0 auto 0 0; width: var(--rail); z-index: 1040;
    background: var(--navy); display: flex; flex-direction: column; align-items: stretch;
    padding: 10px 0; overflow: hidden; transition: width .18s ease; box-shadow: 2px 0 8px rgba(12, 33, 80, .18);
}
.rail:hover, .rail:focus-within { width: 200px; }
.rail-item {
    display: flex; align-items: center; gap: 16px; height: 44px; padding: 0 20px; color: #fff;
    text-decoration: none; white-space: nowrap; border: 0; background: none; width: 100%;
    border-left: 4px solid transparent; font-size: .95rem; opacity: .92;
}
.rail-item svg { width: 22px; height: 22px; flex: 0 0 22px; margin-left: -4px; }
.rail-item span { opacity: 0; transition: opacity .12s; }
.rail:hover .rail-item span, .rail:focus-within .rail-item span { opacity: 1; }
.rail-item:hover, .rail-item:focus-visible { background: rgba(255, 255, 255, .08); color: var(--gold); opacity: 1; outline: none; }
.rail-item.active { color: var(--gold); border-left-color: var(--gold); background: rgba(255, 255, 255, .06); opacity: 1; }
.rail-sep { height: 1px; background: rgba(255, 255, 255, .15); margin: 6px 12px; }
.rail-fill { flex: 1; }
.with-rail .shell { margin-left: var(--rail); }

.topbar {
    display: flex; align-items: center; gap: 12px; padding: 8px 24px; background: #fff;
    border-bottom: 3px solid var(--gold);
}
.topbar .brand { font-weight: 700; color: var(--navy); font-size: 1.05rem; letter-spacing: .2px; }
.user-chip {
    background: var(--navy); color: #fff; border-radius: 14px; padding: 2px 12px; font-size: .82rem; text-decoration: none;
}
.user-chip:hover { background: var(--gold); color: var(--navy); }

@media (max-width: 767.98px) {
    .rail { inset: auto 0 0 0; width: 100% !important; height: 56px; flex-direction: row; padding: 0; overflow-x: auto; }
    .rail-item { width: auto; height: 56px; padding: 0 14px; border-left: 0; border-top: 3px solid transparent; }
    .rail-item.active { border-top-color: var(--gold); }
    .rail-item span, .rail-sep, .rail-fill, .rail-tool { display: none; }
    .rail form { flex: 0 0 auto; }
    .with-rail .shell { margin-left: 0; padding-bottom: 60px; }
    .topbar { padding: 8px 16px; }
}

/* ------------------------------------------------------------------ general */
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; color: var(--navy); }
.card { border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 1px 3px rgba(19, 48, 106, .06); }
.card-header {
    background: #fff; font-weight: 700; color: var(--ink); border-bottom: 1px solid #edf0f5; font-size: .98rem;
}
.card-header:first-child { border-radius: 6px 6px 0 0; }
.card-title-c { text-align: center; font-weight: 700; font-size: 1.02rem; color: var(--ink); padding: .6rem .75rem 0; }

.btn-primary { background-color: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active { background-color: var(--navy-dark) !important; border-color: var(--navy-dark) !important; color: #fff; }
.btn-primary:disabled { background-color: var(--navy-soft); border-color: var(--navy-soft); }
.btn-outline-primary { color: var(--navy); border-color: var(--navy); }
.btn-outline-primary:hover, .btn-outline-primary:active, .btn-outline-primary.active, .btn-check:checked + .btn-outline-primary { background-color: var(--navy) !important; border-color: var(--navy) !important; color: #fff !important; }
.btn-warning, .btn-gold { background-color: var(--gold); border-color: var(--gold); color: var(--navy); font-weight: 600; }
.btn-warning:hover, .btn-gold:hover, .btn-gold:focus { background-color: var(--gold-dark); border-color: var(--gold-dark); color: var(--navy); }
.btn:focus { box-shadow: 0 0 0 .2rem rgba(245, 183, 0, .35); }
.bg-primary { background-color: var(--navy) !important; }
.text-primary { color: var(--navy) !important; }
.form-control:focus, .form-select:focus { border-color: var(--gold); box-shadow: 0 0 0 .2rem rgba(245, 183, 0, .25); }
.form-check-input:checked { background-color: var(--navy); border-color: var(--navy); }

.nav-tabs { border-bottom: 2px solid var(--line); }
.nav-tabs .nav-link { font-size: .9rem; color: var(--muted); border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.nav-tabs .nav-link:hover { color: var(--navy); border-bottom-color: var(--gold-light); }
.nav-tabs .nav-link.active { color: var(--navy); font-weight: 600; background: none; border-bottom-color: var(--gold); }
.nav-pills .nav-link.active { background: var(--navy); }
.page-link { color: var(--navy); }
.page-item.active .page-link { background-color: var(--navy); border-color: var(--navy); color: #fff; }

/* ------------------------------------------------------------------ KPI tiles (gold value over navy strip) */
.tile { border-radius: 6px; overflow: hidden; box-shadow: 0 2px 6px rgba(19, 48, 106, .15); height: 100%; display: flex; flex-direction: column; }
.tile-top { background: var(--gold); color: var(--navy-dark); padding: .7rem .9rem .55rem; text-align: center; }
.tile-val { font-size: 1.55rem; font-weight: 800; line-height: 1.15; letter-spacing: -.3px; white-space: nowrap; }
.tile-lbl { font-size: .86rem; font-weight: 600; }
.tile-bot { background: var(--navy); color: #fff; padding: .45rem .9rem; font-size: .8rem; flex: 1; text-align: center; line-height: 1.35; }
.tile-bot b { font-weight: 700; color: #fff; white-space: nowrap; }
.tile-bot .up { color: #8ee6a4; }
.tile-bot .down { color: #ffb3ab; }

/* Older KPI cards on other pages: same palette */
.card.kpi { padding: 0; overflow: hidden; border: 0; box-shadow: 0 2px 6px rgba(19, 48, 106, .15); display: flex; flex-direction: column; height: 100%; }
.kpi .lbl { background: var(--gold); color: var(--navy-dark); padding: .55rem .9rem 0; font-size: .76rem; text-transform: uppercase; letter-spacing: .4px; font-weight: 700; }
.kpi .val { background: var(--gold); color: var(--navy-dark); padding: .1rem .9rem .5rem; font-size: 1.35rem; font-weight: 800; line-height: 1.3; }
.kpi .sub { background: var(--navy); color: #e6ebf5; padding: .4rem .9rem; font-size: .8rem; flex: 1; }
.kpi .sub a { color: var(--gold); }
.kpi .sub .text-success, .kpi .sub .text-gain { color: #8ee6a4 !important; }
.kpi .sub .text-danger, .kpi .sub .text-loss { color: #ffb3ab !important; }
.kpi .val.text-loss, .kpi .val .text-loss { color: #b3261e !important; }
.kpi > :last-child:not(.sub) { padding-bottom: .7rem; }

/* ------------------------------------------------------------------ month-over-month cards */
.mom { border: 1px solid var(--line); border-radius: 6px; background: #fff; text-align: center; overflow: hidden; height: 100%; display: flex; flex-direction: column; }
.mom-title { font-weight: 600; font-size: .9rem; padding: .55rem .5rem 0; color: var(--ink); }
.mom-val { font-size: 1.6rem; font-weight: 800; line-height: 1.2; margin-top: .2rem; }
.mom-prev { font-size: .78rem; color: var(--muted); }
.mom-spark { height: 46px; margin-top: auto; }
.mom.up .mom-val { color: var(--gain); }
.mom.down .mom-val { color: var(--loss); }
.mom.flat .mom-val { color: var(--navy); }
.mom-group { border: 2px solid var(--navy); border-radius: 8px; padding: 8px; background: #fff; }

/* ------------------------------------------------------------------ tables */
.table-num td.n, .table-num th.n, td.n, th.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table thead th {
    font-size: .76rem; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap;
    color: #fff; background: var(--navy); border-color: var(--navy); font-weight: 600;
}
.table thead th a { color: #fff; }
.table-hover > tbody > tr:hover { --bs-table-accent-bg: var(--gold-light); background-color: var(--gold-light); }
.table-sm td, .table-sm th { padding: .32rem .5rem; }
.pnl td { padding: .25rem .5rem; }
.pnl tr.total td { font-weight: 700; border-top: 2px solid var(--navy); color: var(--navy); }
.pnl tr.sub td:first-child { padding-left: 1.5rem; color: #555; }

/* ------------------------------------------------------------------ misc */
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 360px; }
.chart-box.short { height: 220px; }
.filter-bar .form-select, .filter-bar .form-control { min-width: 130px; }
.badge-status { font-weight: 500; }
.small-muted { font-size: .8rem; color: var(--muted); }
.scroll-x { overflow-x: auto; }
.sticky-head thead th { position: sticky; top: 0; z-index: 1; }
.max-h-500 { max-height: 500px; overflow-y: auto; }
.text-loss { color: var(--loss); }
.text-gain { color: var(--gain); }
footer { font-size: .8rem; color: #8a92a6; }

/* Login page (no rail) */
.no-rail { background: linear-gradient(160deg, var(--navy) 0 45%, var(--bg) 45% 100%); min-height: 100vh; }
.no-rail footer { color: #8a92a6; }

/* KPI cards that still use the .kpi markup (exhibition detail): value first, centred, like the tiles */
.card.kpi { text-align: center; }
.kpi .val { order: 1; padding-top: .6rem; }
.kpi .lbl { order: 2; padding: 0 .9rem .5rem; text-transform: none; letter-spacing: 0; font-size: .86rem; font-weight: 600; }
.kpi .sub { order: 3; }

/* Chart cards: centred bold title like the dashboard */
.chart-card .card-body { padding-top: .5rem; }
.tab-pane > .row > [class*="col"] > .card, .tab-pane > .card { margin-bottom: 0; }

/* ------------------------------------------------------------------ export buttons */
.btn-export { display: inline-flex; align-items: center; gap: 6px; }
.btn-export svg { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ PDF export (server-side print) */
.pdf { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 12px; }
.pdf .pdf-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 0 6px; margin: 0 16px; border-bottom: 3px solid var(--gold); font-size: .78rem; color: var(--muted); }
.pdf .pdf-head .brand { font-weight: 700; color: var(--navy); font-size: .95rem; }
.pdf .container-fluid { padding-left: 16px !important; padding-right: 16px !important; }
.pdf form, .pdf .btn, .pdf .nav-tabs, .pdf .no-pdf, .pdf .alert-dismissible .btn-close { display: none !important; }
.pdf .tab-content > .tab-pane { display: block !important; opacity: 1 !important; break-before: page; }
.pdf .tab-content > .tab-pane:first-child { break-before: auto; margin-top: 12px; }
.pdf .tab-pane::before { content: attr(data-title); display: block; font-size: 1.1rem; font-weight: 700; color: var(--navy); border-bottom: 2px solid var(--navy); padding-bottom: 3px; margin-bottom: 10px; }
.pdf .max-h-500 { max-height: none !important; overflow: visible !important; }
.pdf .scroll-x { overflow: visible !important; }
.pdf .sticky-head thead th { position: static; }
.pdf tr, .pdf .kpi, .pdf .tile, .pdf .chart-box { break-inside: avoid; }
.pdf .card { box-shadow: none; }
.pdf .card-header, .pdf .card-title-c { break-after: avoid; }
.pdf a { color: inherit; text-decoration: none; }
.pdf footer { padding-top: 6px !important; }
/* The print page (~1050px) can fall under Bootstrap's lg breakpoint: force the desktop grid in the PDF. */
.pdf .row > [class*="col-"] { flex: 0 0 auto; }
.pdf .col-lg-2 { width: 16.6667%; }
.pdf .col-md-3, .pdf .col-lg-3 { width: 25%; }
.pdf .col-lg-4 { width: 33.3333%; }
.pdf .col-lg-5 { width: 41.6667%; }
.pdf .col-md-6, .pdf .col-lg-6 { width: 50%; }
.pdf .col-lg-7 { width: 58.3333%; }
.pdf .col-lg-8 { width: 66.6667%; }
.pdf .col-12 { width: 100%; }
.pdf .row-cols-xl-6 > * { width: 16.6667%; }
.pdf .row-cols-xl-5 > * { width: 20%; }
.pdf .row-cols-xl-4 > * { width: 25%; }
.pdf .card.kpi .val { font-size: 1.15rem; }
/* Short sections continue on the same page instead of starting a new one. */
.pdf .tab-content > #staff, .pdf .tab-content > #cust, .pdf .tab-content > #dec, .pdf .tab-content > #ops { break-before: auto; margin-top: 22px; }
.pdf .tab-pane::before { break-after: avoid; }
.pdf .no-pdf + [class*="col-"] { width: 100%; }
.pdf .tab-content > #dec { break-before: page; margin-top: 0; }

/* ------------------------------------------------------------------ Explore (cross-filter) page */
.xf-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 6px; padding: 8px 12px; }
.xf-hint { font-size: .8rem; color: var(--muted); width: 100%; }
.xf-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--gold-light); color: var(--navy-dark); border: 1px solid var(--gold); border-radius: 14px; padding: 1px 4px 1px 10px; font-size: .8rem; }
.xf-chip button { border: 0; background: none; color: var(--navy); font-size: 1rem; line-height: 1; padding: 0 4px; cursor: pointer; }
.xf-chip button:hover { color: var(--loss); }
.xf-card .xf-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: .95rem; padding: .5rem .75rem 0; color: var(--ink); }
.xf-rec { border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 4px; font-size: .8rem; padding: 0 6px; line-height: 1.5; }
.xf-rec:hover { background: var(--gold); border-color: var(--gold); }
.xf-click tbody tr { cursor: pointer; }
.xf-busy { position: fixed; top: 12px; right: 24px; z-index: 1060; background: #fff; border-radius: 50%; padding: 6px; box-shadow: 0 2px 8px rgba(19, 48, 106, .25); }
#recModal .table thead th { position: sticky; top: 0; z-index: 1; }
