/* ── ISCO brand tokens ─────────────────────────────────────────── */
:root {
    --isco-red:      #e8341c;
    --isco-red-dark: #c42a14;
    --isco-black:    #141414;
    --isco-dark:     #1e1e1e;
    --isco-grey:     #f4f4f4;
}

/* ── Global ───────────────────────────────────────────────────── */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--isco-grey);
}

/* ── Navbar ───────────────────────────────────────────────────── */
.isco-navbar {
    background-color: var(--isco-black) !important;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    min-height: 56px;
    gap: 0.5rem;
}

/* Nav pills (Sales / Cash Flow / Data) */
.navbar-nav-links { height: 56px; }

.nav-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.85rem;
    height: 100%;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.nav-pill:hover { color: rgba(255,255,255,0.85); }
.nav-pill.active {
    color: #fff;
    border-bottom-color: var(--isco-red);
}

/* ── Primary buttons → ISCO red ───────────────────────────────── */
.btn-primary {
    background-color: var(--isco-red);
    border-color:     var(--isco-red);
    color: #fff;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--isco-red-dark);
    border-color:     var(--isco-red-dark);
    color: #fff;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
    border-radius: 0.5rem;
    border: none;
}

/* accent left bar on KPI cards */
.kpi-card {
    border-left: 3px solid var(--isco-red) !important;
}

/* ── KPI icon badges ──────────────────────────────────────────── */
.kpi-icon {
    width: 38px;
    height: 38px;
    border-radius: 0.375rem;
    background-color: rgba(232,52,28,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--isco-red);
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ── Filter bar ───────────────────────────────────────────────── */
.filter-bar {
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    padding: 0.625rem 1rem;
}

.filter-bar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.25rem 0.75rem;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.25rem 0.5rem;
}

.filter-divider {
    width: 1px;
    align-self: stretch;
    background: #e5e7eb;
    margin: 2px 0.25rem;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    margin: 0;
    line-height: 1;
}

.btn-filter {
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #212529;
    border-radius: 0.375rem;
    text-align: left;
    white-space: nowrap;
    line-height: 1.4;
}
.btn-filter:hover { background: #f9fafb; border-color: #9ca3af; }
.btn-filter:focus { box-shadow: 0 0 0 0.2rem rgba(232,52,28,.15); border-color: var(--isco-red); outline: none; }
.btn-filter.show  { background: #fff5f4; border-color: var(--isco-red); color: var(--isco-red); }

.filter-select {
    font-size: 0.8rem;
    padding: 0.3rem 1.75rem 0.3rem 0.65rem;
    border-color: #d1d5db;
    line-height: 1.4;
}
.filter-select:focus {
    border-color: var(--isco-red);
    box-shadow: 0 0 0 0.2rem rgba(232,52,28,.15);
}

/* ── Sync bar ─────────────────────────────────────────────────── */
#syncBar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb !important;
    font-size: 0.8rem;
}

/* ── Sortable table headers ───────────────────────────────────── */
th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
th.sortable:hover { background-color: #f3f4f6; }
th.sortable i {
    font-size: 0.7rem;
    opacity: 0.4;
    margin-left: 2px;
}

/* ── Table ────────────────────────────────────────────────────── */
.table th {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid #e5e7eb;
}
.table td {
    font-size: 0.82rem;
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
    color: #374151;
}
.table tbody tr:hover { background-color: #fff8f7; }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Tab nav ──────────────────────────────────────────────────── */
.nav-tabs .nav-link {
    font-size: 0.82rem;
    font-weight: 600;
    color: #6b7280;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.6rem 1rem;
}
.nav-tabs .nav-link:hover { color: var(--isco-red); border-bottom-color: rgba(232,52,28,0.3); }
.nav-tabs .nav-link.active {
    color: var(--isco-red);
    border-bottom: 2px solid var(--isco-red);
    background: transparent;
}

/* ── Loading overlay ──────────────────────────────────────────── */
#loadingSpinner { padding: 5rem 0; }

/* ── Negative values ──────────────────────────────────────────── */
.text-negative { color: #dc2626 !important; }

/* ── Mobile filter toggle button ─────────────────────────────── */
#filterToggle { display: none; }

/* ── Responsive: phones (< 768px) ────────────────────────────── */
@media (max-width: 767px) {

    /* Navbar: tighter, icon-only on mobile */
    .isco-navbar { min-height: 48px; padding-left: 0.5rem !important; padding-right: 0.5rem !important; gap: 0.25rem !important; }
    .isco-navbar .btn span.btn-label { display: none; }
    .isco-navbar .btn i { margin: 0 !important; }
    .navbar-nav-links { height: 48px; }
    .nav-pill { padding: 0 0.5rem; gap: 0.25rem; font-size: 0.72rem; }
    .nav-pill-label { display: none; }

    /* Filter bar: collapsed behind toggle */
    #filterToggle {
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        font-size: 0.82rem;
        font-weight: 600;
        color: #374151;
        background: none;
        border: none;
        padding: 0.25rem 0;
    }
    #filterPanel {
        display: none;
        padding-top: 0.5rem;
        border-top: 1px solid #e5e7eb;
        margin-top: 0.5rem;
    }
    #filterPanel.open { display: block; }

    /* Filter items stack full-width */
    .filter-bar-inner { gap: 0.5rem; }
    .filter-group { width: 100%; gap: 0.4rem; }
    .filter-divider { display: none; }
    .filter-item { width: calc(50% - 0.2rem); min-width: 0 !important; }
    .filter-item .btn-filter,
    .filter-item .form-select { width: 100%; }
    .filter-actions { width: 100%; }
    .filter-actions .d-flex { width: 100%; justify-content: stretch; }
    .filter-actions .d-flex .btn { flex: 1; }

    /* Sync bar: stack on very small screens */
    #syncBar { flex-wrap: wrap; gap: 0.4rem !important; }
    #syncBar #syncBtn { margin-left: 0 !important; width: 100%; justify-content: center; }

    /* KPI cards: tighter */
    .kpi-card .card-body { padding: 0.75rem; }
    .kpi-card .fs-4 { font-size: 1.2rem !important; }
    .kpi-icon { width: 30px; height: 30px; font-size: 0.9rem; }

    /* Charts */
    #chartMonthly, #chartYTD { height: 220px !important; }
    #chartCustomers, #chartArticleGroups { height: 500px !important; }

    /* Tables: tighter padding */
    .table th { font-size: 0.7rem; padding: 0.4rem 0.5rem; }
    .table td { font-size: 0.78rem; padding: 0.4rem 0.5rem; }

    /* Less outer padding */
    .px-3 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .row.g-3.px-3 { --bs-gutter-x: 0.75rem; padding-left: 0.75rem !important; padding-right: 0.75rem !important; }

    /* Reauth alert stacks nicely */
    #reauthAlert { flex-wrap: wrap; }
    #reauthAlert a.btn { width: 100%; text-align: center; }
}

/* ── Responsive chart height (tablets) ───────────────────────── */
@media (min-width: 768px) and (max-width: 991px) {
    #chartMonthly, #chartYTD { height: 260px !important; }
    #chartCustomers, #chartArticleGroups { height: 600px !important; }
}

/* ── legacy label class ───────────────────────────────────────── */
.form-label-sm {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ─── Print stylesheet (used when user saves the page as PDF) ─── */
@media print {
    @page { size: A4 landscape; margin: 10mm; }
    body { background: #fff !important; }
    /* Hide chrome: nav, filter bar, action buttons, spinners */
    nav, .navbar, .filter-bar, #filterPanel, .filter-bar-inner,
    #filterToggle, .export-actions, #loadingSpinner,
    #consolLoadingSpinner, #bsConsolLoadingSpinner,
    .no-print {
        display: none !important;
    }
    /* Give the printed table room and prevent split rows where possible */
    .card { border: none !important; box-shadow: none !important; }
    .table { font-size: 9pt !important; }
    .table th, .table td { padding: 2px 4px !important; }
    thead { display: table-header-group; }
    tr, td, th { page-break-inside: avoid; }
    /* Preserve background colours for subtotal / KPI rows */
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    /* Show the report title at the top */
    .print-title {
        display: block !important;
        font-size: 14pt;
        font-weight: bold;
        margin: 0 0 6pt 0;
    }
}
@media screen {
    .print-title { display: none; }
}
