:root {
    --sidebar-w: 248px;
    /* Brand palette derived from the Prime Geostructures logo (orange mark). */
    --brand: #1f2937;         /* deep charcoal — sidebar / headers base */
    --brand-2: #ea7a1e;       /* logo orange — primary accent */
    --brand-orange: #ea7a1e;
    --brand-orange-2: #f59e3b;/* lighter orange for gradients */
    --brand-dark: #1f2937;
    --grad-brand: linear-gradient(90deg, #1f2937 0%, #b8621a 78%, #ea7a1e 130%);
    --grad-brand-soft: linear-gradient(90deg, #ea7a1e 0%, #f59e3b 100%);
    /* Sidebar gradient: deep charcoal top → warm dark-orange/brown bottom,
       harmonising with the orange logo. */
    --grad-sidebar: linear-gradient(180deg, #242c39 0%, #2b2a2f 42%, #4a3320 82%, #6b4318 100%);
    --bg: #f5f6f8;
}

* { box-sizing: border-box; }
body { background: var(--bg); }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    --sb-bg: #141a24;
    --sb-bg-2: #1a2130;
    --sb-line: rgba(255,255,255,.07);
    --sb-text: #c3cad6;
    --sb-muted: #7c8698;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sb-bg-2) 0%, var(--sb-bg) 100%);
    color: var(--sb-text);
    position: fixed;
    inset: 0 auto 0 0;
    display: flex; flex-direction: column;
    z-index: 1030;
    transition: transform .2s ease, width .2s ease;
    border-right: 1px solid rgba(0,0,0,.25);
}
.sidebar-brand {
    display: flex; align-items: center; justify-content: center;
    padding: 1rem 1rem .9rem; flex-shrink: 0;
    border-bottom: 1px solid var(--sb-line);
}
/* Wide banner logo: a light wordmark that sits directly on the dark sidebar. */
.sidebar-brand .brand-logo {
    display: block; width: auto; max-width: 180px; height: auto; max-height: 50px;
    object-fit: contain;
}
.sidebar-brand .brand-fallback {
    display: none; align-items: center; gap: .5rem;
    font-size: 1.15rem; font-weight: 700; color: #fff;
}
.sidebar-brand .brand-fallback i { color: var(--brand-orange); font-size: 1.4rem; }

.sidebar-nav {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: .4rem 0 1rem;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.14) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }

.sidebar-nav .nav-group-top { padding-bottom: .35rem; margin-bottom: .2rem; border-bottom: 1px solid var(--sb-line); }

/* Section header (accordion toggle) */
.sidebar-nav .nav-section-toggle {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    background: none; border: 0; cursor: pointer;
    text-transform: uppercase; font-size: .66rem; letter-spacing: .09em; font-weight: 600;
    color: var(--sb-muted); padding: .95rem 1.4rem .4rem;
    transition: color .15s;
}
.sidebar-nav .nav-section-toggle:hover { color: #e6eaf0; }
.sidebar-nav .nav-caret { font-size: .65rem; transition: transform .2s ease; }
.sidebar-nav .nav-section-toggle[aria-expanded="false"] .nav-caret { transform: rotate(-90deg); }

/* Links: inset pills with a slim accent bar when active */
.sidebar-nav .nav-link {
    position: relative;
    display: flex; align-items: center; gap: .7rem;
    margin: 1px .7rem; padding: .5rem .75rem;
    color: var(--sb-text); font-size: .875rem; border-radius: .5rem;
    white-space: nowrap; text-decoration: none;
    transition: background .15s, color .15s;
}
.sidebar-nav .nav-link span { overflow: hidden; text-overflow: ellipsis; }
/* Two-line link (project name + caption) */
.sidebar-nav .nav-link .nav-text-2 { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.sidebar-nav .nav-link .nav-text-2 small { font-size: .7rem; font-weight: 400; color: var(--sb-muted); }
.sidebar-nav .nav-link.active .nav-text-2 small { color: #e9b98c; }
.sidebar-nav .nav-link i { width: 1.15rem; font-size: 1rem; text-align: center; flex-shrink: 0; color: var(--sb-muted); transition: color .15s; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.055); color: #fff; }
.sidebar-nav .nav-link:hover i { color: #e6eaf0; }
.sidebar-nav .nav-link.active { background: rgba(234,122,30,.15); color: #fff; font-weight: 600; }
.sidebar-nav .nav-link.active i { color: var(--brand-orange-2); }
.sidebar-nav .nav-link.active::before {
    content: ""; position: absolute; left: -.7rem; top: 22%; bottom: 22%;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-orange);
}
.sidebar-nav .nav-link:focus-visible,
.sidebar-nav .nav-section-toggle:focus-visible { outline: 2px solid var(--brand-orange-2); outline-offset: 1px; }

.sidebar-foot {
    flex-shrink: 0; display: flex; justify-content: space-between; gap: .5rem;
    padding: .7rem 1.4rem; font-size: .72rem; color: var(--sb-muted);
    border-top: 1px solid var(--sb-line);
}
.sidebar-foot span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-backdrop { display: none; }

.main {
    flex: 1; margin-left: var(--sidebar-w);
    display: flex; flex-direction: column; min-width: 0;
    transition: margin-left .2s ease;
}

/* ---------- Collapsed (icon-only) sidebar on desktop ---------- */
.app-shell.sidebar-collapsed .sidebar { width: 68px; }
.app-shell.sidebar-collapsed .main { margin-left: 68px; }
.app-shell.sidebar-collapsed .sidebar-brand { padding: .9rem .4rem; }
.app-shell.sidebar-collapsed .sidebar .brand-logo { max-width: 52px; }
.app-shell.sidebar-collapsed .sidebar .nav-link span,
.app-shell.sidebar-collapsed .sidebar .brand-fallback span,
.app-shell.sidebar-collapsed .sidebar-foot { display: none; }
/* Section labels become thin dividers; every group's icons stay visible. */
.app-shell.sidebar-collapsed .sidebar .nav-section-toggle {
    pointer-events: none; padding: 0; margin: .55rem 1.1rem; height: 1px; background: var(--sb-line);
}
.app-shell.sidebar-collapsed .sidebar .nav-section-toggle > * { display: none; }
.app-shell.sidebar-collapsed .sidebar .collapse:not(.show) { display: block !important; }
.app-shell.sidebar-collapsed .sidebar .nav-link { justify-content: center; margin: 1px .6rem; padding: .55rem 0; gap: 0; }
.app-shell.sidebar-collapsed .sidebar .nav-link.active::before { left: -.6rem; }
.app-shell.sidebar-collapsed .sidebar .nav-link i { width: auto; font-size: 1.1rem; }

.topbar {
    display: flex; align-items: center; gap: .9rem;
    background: #fff; padding: .6rem 1.25rem;
    border-bottom: 1px solid #e3e8ef; position: sticky; top: 0; z-index: 1020;
    min-height: 58px;
}
.topbar-burger { border: 1px solid #e3e8ef; }
.topbar-title { font-size: 1.15rem; margin: 0; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

/* Notification bell */
.topbar-icon-btn {
    width: 38px; height: 38px; display: grid; place-items: center;
    border-radius: 50%; color: #41506a; background: #f1f4f8; text-decoration: none;
    font-size: 1.05rem; transition: background .15s;
}
.topbar-icon-btn:hover { background: #e4e9f1; color: var(--brand); }

/* User button */
.user-btn {
    display: flex; align-items: center; gap: .55rem;
    background: #f1f4f8; border: 1px solid #e3e8ef; border-radius: 30px;
    padding: .25rem .7rem .25rem .3rem; cursor: pointer;
}
.user-btn:hover { background: #e9eef5; }
.user-btn::after { margin-left: .1rem; color: #8a97a8; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    background: var(--brand-2); color: #fff; font-weight: 700;
    display: grid; place-items: center; font-size: .9rem;
}
.user-meta { flex-direction: column; align-items: flex-start; line-height: 1.1; }
.user-meta .user-name { font-size: .85rem; font-weight: 600; color: #1d2b45; }
.user-meta .user-role { font-size: .7rem; color: #8a97a8; }

.content { padding: 1.5rem; flex: 1; }
.footer {
    display: flex; justify-content: space-between;
    padding: .75rem 1.25rem; color: #8a97a8; font-size: .82rem;
    border-top: 1px solid #e3e8ef; background: #fff;
}

/* ---------- KPI cards ---------- */
.kpi-card {
    background: #fff; border-radius: .65rem; padding: 1.1rem 1.25rem;
    border: 1px solid #e7ebf1; height: 100%;
}
.kpi-card .kpi-label { color: #7a8699; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 700; color: #1d3557; }
.kpi-card .kpi-icon {
    width: 2.5rem; height: 2.5rem; border-radius: .55rem;
    display: grid; place-items: center; font-size: 1.2rem;
}

/* ---------- Misc ---------- */
.card { border: 1px solid #e7ebf1; border-radius: .65rem; }
.table-sm td, .table-sm th { vertical-align: middle; }
.page-card { background: #fff; border: 1px solid #e7ebf1; border-radius: .65rem; padding: 1.25rem; }

/* ---------- Rich data tables (app-wide) ---------- */
/* Applies to every list: the .page-card wrapping a .table-responsive > table. */
.page-card > .table-responsive { border: 1px solid #eef1f5; border-radius: .55rem; overflow: hidden; }
.page-card .table {
    margin-bottom: 0; border-collapse: separate; border-spacing: 0;
    font-size: .9rem;
}
/* Header: solid tint, uppercase, sticky-ready */
.page-card .table > thead > tr > th {
    background: #f6f8fb; color: #46566f; font-weight: 600;
    text-transform: uppercase; letter-spacing: .03em; font-size: .74rem;
    border-bottom: 2px solid #e6ebf2; border-top: 0;
    padding: .7rem .85rem; white-space: nowrap; vertical-align: middle;
}
.page-card .table > tbody > tr > td {
    padding: .62rem .85rem; border-top: 1px solid #eef1f5; vertical-align: middle; color: #2f3a4d;
}
/* Zebra striping */
.page-card .table > tbody > tr:nth-of-type(odd)  > td { background: #ffffff; }
.page-card .table > tbody > tr:nth-of-type(even) > td { background: #f8fafc; }
/* Row hover highlight */
.page-card .table > tbody > tr:hover > td { background: #eef5f4; }
/* First column a touch bolder for scan-ability */
.page-card .table > tbody > tr > td:first-child { font-weight: 500; }
/* Footer totals row */
.page-card .table > tfoot > tr > td {
    background: #f6f8fb; border-top: 2px solid #e6ebf2; padding: .6rem .85rem; font-weight: 600;
}
/* Action buttons cluster in the last column */
.page-card .table td .btn { padding: .2rem .45rem; }
/* Keep sortable header links looking like headers */
.page-card .table > thead th.sortable-th a { color: #46566f; }
.page-card .table > thead th.sortable-th a:hover { color: var(--brand-2) !important; }

/* Toolbar above tables (New button + filters row) spacing */
.list-toolbar { gap: .5rem; }

/* Pagination rendered as an ATTACHED table footer bar (part of the table, not floating).
   The .table-pagination is the sibling right after .table-responsive inside a .page-card.
   We bleed it to the card edges with negative margins and drop the gap so it reads as
   one continuous table unit. */
.page-card > .table-responsive:has(+ .table-pagination) { border-radius: .55rem .55rem 0 0; }
.page-card > .table-pagination {
    margin: 0 -1.25rem -1.25rem;          /* bleed to the card edges (cancels card padding) */
    padding: .6rem 1.1rem;
    background: #f8fafc;
    border-top: 1px solid #eef1f5;
    border-radius: 0 0 .55rem .55rem;
}
.table-pagination .form-select-sm { border-radius: .4rem; }
.table-pagination .pagination { --bs-pagination-border-color: #e6ebf2; }
/* Remove the little top margin the responsive wrapper had, so table meets footer flush */
.page-card > .table-responsive:has(+ .table-pagination) { margin-bottom: 0; }

/* ============ Brand gradient theme (Prime Geostructures orange) ============ */
/* Topbar gets a subtle gradient accent underline in the brand colour. */
.topbar { border-bottom: 2px solid transparent; border-image: var(--grad-brand-soft) 1; }
.topbar-title { color: var(--brand-dark); }

/* Primary buttons -> brand orange gradient */
.btn-primary {
    --bs-btn-bg: var(--brand-orange); --bs-btn-border-color: var(--brand-orange);
    --bs-btn-hover-bg: #d76c14; --bs-btn-hover-border-color: #d76c14;
    --bs-btn-active-bg: #c25f10; --bs-btn-active-border-color: #c25f10;
    --bs-btn-disabled-bg: var(--brand-orange); --bs-btn-disabled-border-color: var(--brand-orange);
    background-image: var(--grad-brand-soft); border: none;
}
.btn-outline-primary {
    --bs-btn-color: #c25f10; --bs-btn-border-color: var(--brand-orange);
    --bs-btn-hover-bg: var(--brand-orange); --bs-btn-hover-border-color: var(--brand-orange);
    --bs-btn-active-bg: #c25f10;
}
a { color: #c25f10; }
a:hover { color: #b8621a; }
.text-primary { color: var(--brand-orange) !important; }
.badge.bg-primary { background: var(--brand-orange) !important; }

/* Table header -> subtle brand gradient tint */
.page-card .table > thead > tr > th {
    background: linear-gradient(180deg, #fff6ee, #fdeede);
    color: #7a4a17; border-bottom-color: #f2d9bf;
}
.page-card .table > thead th.sortable-th a { color: #7a4a17; }
.page-card .table > tbody > tr:hover > td { background: #fff4ea; }
.page-card .table > tfoot > tr > td { background: #fff6ee; border-top-color: #f2d9bf; }

/* Pagination active page -> brand orange */
.pagination { --bs-pagination-active-bg: var(--brand-orange); --bs-pagination-active-border-color: var(--brand-orange); --bs-pagination-color: #c25f10; --bs-pagination-hover-color: #b8621a; }

/* KPI card icons already pass their own colours; give card headings the brand tint */
.page-card > h2, .page-card .h6 { color: var(--brand-dark); }

/* User avatar + notification bell use the brand orange */
.user-avatar { background: var(--brand-orange); }
.topbar-icon-btn:hover { color: var(--brand-orange); }
.user-btn { border-color: #f0d7be; }


/* Rich page section card header strip (optional, for detail pages) */
.card-brand-head {
    background: var(--grad-brand); color: #fff; padding: .7rem 1rem;
    border-radius: .55rem .55rem 0 0; font-weight: 600;
}

/* ================= Design refinement pass ================= */
/* Content rhythm */
.content { padding: 1.5rem 1.75rem; }
.topbar-title { letter-spacing: -.01em; }

/* KPI cards: lift + coloured left accent, tighter numbers */
.kpi-card { border-radius: .7rem; position: relative; overflow: hidden; transition: box-shadow .18s, transform .18s; }
.kpi-card::before { content:""; position:absolute; left:0; top:0; bottom:0; width:4px; background: var(--grad-brand-soft); opacity:.9; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(31,41,55,.08); }
.kpi-card .kpi-value { letter-spacing: -.02em; }

/* Clickable KPI tiles (dashboard) — drill into the detail screen. */
a.kpi-link { cursor: pointer; transition: box-shadow .18s, transform .18s, border-color .18s; }
a.kpi-link:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(31,41,55,.08); border-color: #c9d4e3; }
a.kpi-link:focus-visible { outline: 2px solid var(--bs-primary, #1d3557); outline-offset: 2px; }

/* Filter/search toolbar above every list — consistent pill inputs */
.list-toolbar, form.d-flex.gap-2 { align-items: center; }
.content .form-select-sm, .content .form-control-sm { border-radius: .5rem; }

/* Badges: rounded pill, medium weight */
.badge { font-weight: 500; border-radius: 50rem; padding: .34em .7em; letter-spacing: .01em; }
.badge-soft { background: #eef2f7; color: #46566f; }
.badge.bg-success { background: #1f9d6b !important; }
.badge.bg-warning { background: #f0a028 !important; }
.badge.bg-danger  { background: #e5484d !important; }
.badge.bg-secondary { background: #8a97a8 !important; }
.badge.bg-info { background: #3aa6d6 !important; color:#fff !important; }
.badge.bg-dark { background: #40506a !important; }

/* Status text pills used in reports/tables */
.status-pill { display:inline-block; padding:.2rem .6rem; border-radius:50rem; font-size:.76rem; font-weight:500; }

/* Empty-state rows: friendlier */
.table td.text-center.text-muted { padding: 2.4rem 1rem !important; }
.empty-state { text-align:center; padding: 2.5rem 1rem; color:#8a97a8; }
.empty-state i { font-size: 2rem; display:block; margin-bottom:.5rem; color:#c4ccd8; }

/* Page action row (New button + filters) — give it breathing room */
.content > .d-flex:first-child { margin-bottom: 1rem !important; }

/* Cards a touch rounder + consistent */
.page-card { border-radius: .7rem; }

/* Buttons in toolbars slightly larger tap target */
.content .btn-sm { padding: .38rem .75rem; }

/* Inputs in the top filter bars align nicely */
.input-group-sm > .form-control, .input-group-sm > .form-select { min-height: 34px; }

/* Drawer: title icon + smoother body */
#appDrawer .offcanvas-title { display:flex; align-items:center; gap:.5rem; }
#appDrawer .offcanvas-body .row.g-3 { --bs-gutter-y: 1rem; }

/* Subtle divider under the topbar title area on mobile */
@media (max-width: 575.98px) {
    .content { padding: 1rem; }
    .user-meta { display: none !important; }
}

/* Print-friendly (reports) */
@media print { .table-pagination, .list-toolbar { display: none !important; } }

/* ================= Modern forms & cards (app-wide) ================= */
/* Cards: softer shadow, lift on hover, subtle top accent */
.page-card {
    box-shadow: 0 1px 2px rgba(31,41,55,.04), 0 6px 18px rgba(31,41,55,.05);
    transition: box-shadow .18s ease, transform .18s ease;
}
.page-card:hover { box-shadow: 0 2px 6px rgba(31,41,55,.06), 0 12px 28px rgba(31,41,55,.08); }

/* Card headings get a small orange bar + spacing */
.page-card > h2:first-child, .page-card > .h6:first-child {
    display: flex; align-items: center; gap: .55rem;
    padding-bottom: .7rem; margin-bottom: 1rem;
    border-bottom: 1px solid #eef1f5; font-weight: 700;
}
.page-card > h2:first-child::before, .page-card > .h6:first-child::before {
    content: ""; width: 4px; height: 18px; border-radius: 3px;
    background: var(--grad-brand-soft); display: inline-block;
}

/* Labels: uppercase, spaced, muted, with orange required-star */
.form-label {
    font-weight: 600; font-size: .78rem; letter-spacing: .02em;
    color: #55647d; margin-bottom: .35rem; text-transform: uppercase;
}
.form-label.required::after, .required::after { content: " *"; color: var(--brand-orange); }

/* Inputs: taller, rounded, soft border, animated focus glow */
.form-control, .form-select {
    border: 1.5px solid #e2e8f1; border-radius: .55rem;
    padding: .5rem .8rem; font-size: .92rem; background: #fcfdfe;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.form-control:hover, .form-select:hover { border-color: #cfd8e6; }
.form-control:focus, .form-select:focus {
    border-color: var(--brand-orange); background: #fff;
    box-shadow: 0 0 0 .22rem rgba(234,122,30,.14);
}
.form-control::placeholder { color: #aeb8c7; }
textarea.form-control { min-height: 90px; }

/* Input groups (search, project switch) share the rounded look */
.input-group-text { background: #f6f8fb; border: 1.5px solid #e2e8f1; }

/* Switches in the brand colour */
.form-check-input:checked { background-color: var(--brand-orange); border-color: var(--brand-orange); }
.form-check-input:focus { border-color: var(--brand-orange); box-shadow: 0 0 0 .2rem rgba(234,122,30,.15); }

/* Buttons: a bit more presence + gentle hover lift */
.btn { border-radius: .55rem; font-weight: 500; transition: transform .12s ease, box-shadow .15s ease, background .15s; }
.btn-primary { box-shadow: 0 4px 12px rgba(234,122,30,.28); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(234,122,30,.36); }
.btn-light { background: #f1f4f8; border-color: #e3e8ef; }

/* Invalid field feedback in a clearer red */
.form-control.is-invalid, .form-select.is-invalid { border-color: #e5484d; box-shadow: 0 0 0 .2rem rgba(229,72,77,.12); }
.invalid-feedback { font-size: .8rem; }

/* Drawer forms inherit all the above; give the drawer body a light gradient wash */
#appDrawer .offcanvas-body { background: linear-gradient(180deg, #fbfcfe 0%, #f6f8fb 100%); }

/* Section dividers inside forms */
.page-card hr { border-color: #eef1f5; opacity: 1; }
.required::after { content: " *"; color: #dc3545; }
.badge-soft { background: #eef2f7; color: #41506a; font-weight: 500; }

/* Chart containers — fixed height so Chart.js (maintainAspectRatio:false)
   has a bounded box and doesn't grow/"jump" on every resize. */
.chart-box { position: relative; height: 300px; width: 100%; }
.chart-box canvas { max-height: 300px; }

/* Sortable table headers */
.sortable-th a { cursor: pointer; white-space: nowrap; }
.sortable-th a:hover { color: var(--brand-2) !important; }
.sortable-th .bi-arrow-down-up { font-size: .7rem; }

/* Drawer (offcanvas) polish — branded header in the logo gradient (charcoal→orange) */
#appDrawer .offcanvas-header {
    background: var(--grad-brand);
    color: #fff; padding: 1rem 1.25rem; border-bottom: 3px solid var(--brand-orange);
}
#appDrawer .offcanvas-title { font-weight: 600; font-size: 1.1rem; color: #fff; letter-spacing: .01em; }
#appDrawer .offcanvas-header .btn-close {
    filter: invert(1) grayscale(1) brightness(1.6); opacity: .85;
}
#appDrawer .offcanvas-header .btn-close:hover { opacity: 1; }
#appDrawer .offcanvas-body { padding: 1.35rem; }
#appDrawer .page-card { border: none; padding: 0; box-shadow: none; background: transparent; }
#appDrawer.drawer-wide { width: min(900px, 96vw) !important; }
/* Drawer form field polish */
#appDrawer .form-label { font-weight: 600; font-size: .82rem; color: #46566f; margin-bottom: .25rem; }
#appDrawer .form-control, #appDrawer .form-select { border-color: #dbe2ec; }
#appDrawer .form-control:focus, #appDrawer .form-select:focus {
    border-color: var(--brand-2); box-shadow: 0 0 0 .2rem rgba(42,157,143,.15);
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.35); }
    .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 1029;
        background: rgba(15,20,30,.45); opacity: 0; visibility: hidden; transition: opacity .2s;
    }
    .sidebar.open + .sidebar-backdrop { opacity: 1; visibility: visible; }
    .main, .app-shell.sidebar-collapsed .main { margin-left: 0; }
    /* On mobile the collapsed preference is ignored: the drawer is always full width. */
    .app-shell.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
    .app-shell.sidebar-collapsed .sidebar .nav-link span { display: initial; }
    .app-shell.sidebar-collapsed .sidebar .nav-link .nav-text-2 { display: flex; }
    .app-shell.sidebar-collapsed .sidebar-foot { display: flex; }
    .app-shell.sidebar-collapsed .sidebar .nav-link { justify-content: flex-start; margin: 1px .7rem; padding: .5rem .75rem; gap: .7rem; }
    .app-shell.sidebar-collapsed .sidebar .nav-section-toggle { pointer-events: auto; padding: .95rem 1.4rem .4rem; margin: 0; height: auto; background: none; }
    .app-shell.sidebar-collapsed .sidebar .nav-section-toggle > * { display: initial; }
}

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg,#1d3557,#2a9d8f); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: .9rem; padding: 2rem; box-shadow: 0 18px 40px rgba(0,0,0,.18); }
.login-brand { text-align: center; margin-bottom: 1.25rem; }
/* Dark plate so the light company logo is visible on the white login card. */
.login-logo-plate {
    display: inline-block; background: var(--brand); border-radius: 12px;
    padding: 14px 20px; box-shadow: 0 6px 16px rgba(29,53,87,.25);
}
.login-logo-plate img { max-height: 56px; max-width: 220px; height: auto; display: block; }
.login-brand i { font-size: 2.4rem; color: var(--brand-2); }

@media print {
    .sidebar, .topbar, .footer, .no-print { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; }
}

/* ---------- All-projects home dashboard ---------- */
.project-card {
    display: block; background: #fff; border: 1px solid #e7ebf1; border-radius: .65rem;
    padding: 1.1rem 1.25rem; color: inherit; cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.project-card:hover, .project-card:focus-visible {
    border-color: var(--brand-orange); box-shadow: 0 6px 18px rgba(234, 122, 30, .15);
    transform: translateY(-2px); outline: none;
}
.project-card-name { font-size: 1.1rem; font-weight: 600; color: #1d3557; }
.project-card-open { color: var(--brand-orange); font-weight: 600; }
.project-split { display: flex; height: .5rem; border-radius: 1rem; overflow: hidden; background: #eef1f5; }
.project-split > span { display: block; height: 100%; }
.project-costs .kpi-label { font-size: .7rem; color: #7a8699; text-transform: uppercase; letter-spacing: .03em; }
.project-costs .fw-semibold, .project-costs .fw-bold { font-size: .9rem; }

/* Drill-down breadcrumb on scoped reports (Division › Section › Sub-section) */
.report-scope {
    display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
    padding: .55rem .9rem; border-radius: .55rem; font-size: .88rem;
    background: #fff7ef; border: 1px solid #f6d9bd; color: #7a4a17;
}
.report-scope > span { font-weight: 600; }
.report-scope > .bi-funnel-fill { color: var(--brand-orange); }

/* Compact KPI cards — five across on the analysis pages */
.kpi-card.kpi-compact { padding: .8rem .9rem; }
.kpi-card.kpi-compact .kpi-icon { width: 2.1rem; height: 2.1rem; font-size: 1rem; flex-shrink: 0; }
.kpi-card.kpi-compact .kpi-label { font-size: .68rem; }
.kpi-card.kpi-compact .kpi-value { font-size: 1.08rem; white-space: nowrap; }

/* Report family tabs (single-table report pages) */
.report-tabs { background: #fff; border: 1px solid #e7ebf1; border-radius: .65rem; padding: .35rem .75rem 0; }
.report-tabs .nav-tabs { border-bottom: 0; }
.report-tabs .nav-link { border: 0; border-bottom: 3px solid transparent; color: #46566f; padding: .6rem .9rem; }
.report-tabs .nav-link:hover { color: var(--brand-orange); }
.report-tabs .nav-link.active { color: var(--brand-orange); border-bottom-color: var(--brand-orange); background: none; font-weight: 600; }
.report-tabs .report-tabs-analysis { color: var(--brand-dark); }

/* Back button in the top bar (every page) */
.topbar-back { white-space: nowrap; }
@media (max-width: 575.98px) { .topbar-back { padding: .2rem .45rem; } .topbar-back .bi + * { display: none; } }

/* Contextual row colours must win over the table cell background above */
.page-card .table > tbody > tr.table-danger > td { background: #fdecec; }
.page-card .table > tbody > tr.table-warning > td { background: #fff6e0; }
.page-card .table > tbody > tr.table-success > td { background: #eaf7ef; }
