:root {
    --sidebar-w: 248px;
    /* Company brand palette. The layouts print the company's own values
       (App\Core\Settings::cssVariables(), derived from company.color) in a
       <style> after this file; these are the neutral defaults (#1f6feb) for
       pages that do not. Never hard-code a brand colour below — use these. */
    --brand: #1f6feb;               /* the company colour itself */
    --brand-rgb: 31,111,235;
    --brand-dark: #1a5ec8;          /* hover */
    --brand-darker: #164ea5;        /* active / pressed */
    --brand-light: #5793f0;         /* gradient end */
    --brand-border: #c7dbfa;        /* tinted borders */
    --brand-soft: #e9f1fd;          /* tinted backgrounds */
    --brand-softer: #f4f8fe;
    --brand-ink: #1f6feb;           /* brand as text on white (always legible) */
    --brand-ink-rgb: 31,111,235;
    --brand-ink-hover: #1a5ec8;
    --brand-head-ink: #1753b0;      /* table header text on --brand-soft */
    --brand-on-dark: #2f79ec;       /* brand accent on the dark sidebar */
    --brand-on-dark-rgb: 47,121,236;
    --brand-contrast: #ffffff;      /* text placed on --brand */
    --sidebar-top: #1f2d42;
    --sidebar-bottom: #1f4174;
    --heading: #1f2937;             /* neutral charcoal for titles */
    --grad-brand: linear-gradient(90deg, var(--heading) 0%, var(--brand-darker) 78%, var(--brand) 130%);
    --grad-brand-soft: linear-gradient(90deg, var(--brand) 0%, var(--brand-light) 100%);
    /* Sidebar: neutral charcoal at the top, tinted with the brand below. */
    --grad-sidebar: linear-gradient(180deg, var(--sidebar-top) 0%, var(--sidebar-top) 40%, var(--sidebar-bottom) 100%);
    --bg: #f5f6f8;
}

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

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--grad-sidebar);
    background-attachment: local;
    color: #d3d9e2;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    z-index: 1030;
    transition: transform .2s ease;
    box-shadow: inset -1px 0 0 rgba(255,255,255,.04);
}
/* Soft brand-coloured glow along the sidebar's right edge (dynamic feel). */
.sidebar::after {
    content: ""; position: fixed; top: 0; bottom: 0; left: calc(var(--sidebar-w) - 3px);
    width: 3px; background: linear-gradient(180deg, transparent, rgba(var(--brand-on-dark-rgb),.55), transparent);
    pointer-events: none; z-index: 1031;
}
.app-shell.sidebar-collapsed .sidebar::after { left: 63px; }
.sidebar-brand {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .45rem;
    padding: .85rem 1rem .75rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    position: sticky; top: 0; z-index: 2;
    background: var(--sidebar-top);
    backdrop-filter: blur(2px);
    text-decoration: none;
}
/* Company logo on a light plate: most logos are drawn for white paper and
   would disappear on the dark sidebar. */
.sidebar-brand .brand-logo-plate {
    display: flex; align-items: center; justify-content: center;
    background: #fff; border-radius: .6rem; padding: .35rem .6rem;
    max-width: 100%; box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.sidebar-brand .brand-logo {
    display: block; width: auto; max-width: 180px; height: auto; max-height: 46px;
    object-fit: contain;
}
.sidebar-brand .brand-name {
    color: #fff; font-weight: 600; font-size: .95rem; line-height: 1.2;
    text-align: center; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.sidebar-brand.no-logo { flex-direction: row; justify-content: flex-start; gap: .65rem; }
.sidebar-brand.no-logo .brand-name { text-align: left; }
/* Initials badge: shown instead of a logo when the company has none. */
.brand-initials {
    display: inline-grid; place-items: center; flex-shrink: 0;
    width: 40px; height: 40px; border-radius: .7rem;
    background: var(--grad-brand-soft); color: var(--brand-contrast);
    font-weight: 700; font-size: 1rem; letter-spacing: .02em;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.brand-initials.lg { width: 64px; height: 64px; border-radius: 1rem; font-size: 1.5rem; }

.sidebar-nav { padding: .5rem 0 2rem; }

/* Accordion section 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: .68rem; letter-spacing: .08em; font-weight: 700;
    color: #97a3b6; padding: .9rem 1.25rem .4rem;
}
.sidebar-nav .nav-section-toggle:hover { color: #fff; }
.sidebar-nav .nav-caret { font-size: .7rem; transition: transform .2s ease; }
.sidebar-nav .nav-section-toggle[aria-expanded="false"] .nav-caret { transform: rotate(-90deg); }

.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: .65rem;
    color: #d3d9e2; padding: .55rem 1.25rem; font-size: .9rem;
    border-left: 3px solid transparent; white-space: nowrap;
    transition: background .15s, color .15s;
}
.sidebar-nav .nav-link i { width: 1.1rem; text-align: center; flex-shrink: 0; color: #9aa6b8; transition: color .15s; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link:hover i { color: var(--brand-on-dark); }
.sidebar-nav .nav-link.active {
    background: linear-gradient(90deg, rgba(var(--brand-on-dark-rgb),.28), rgba(var(--brand-on-dark-rgb),.04));
    color: #fff; border-left-color: var(--brand-on-dark); font-weight: 500;
}
.sidebar-nav .nav-link.active i { color: var(--brand-on-dark); }
.sidebar-nav .nav-link span { overflow: hidden; text-overflow: ellipsis; }
/* Two-line link (active project's 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: #97a3b6; }
.sidebar-nav .nav-link.active .nav-text-2 small { color: rgba(255,255,255,.7); }
/* The always-open top block (Dashboard, active project) sits above a divider. */
.sidebar-nav .nav-group-top { padding-bottom: .35rem; margin-bottom: .2rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-nav .nav-link:focus-visible,
.sidebar-nav .nav-section-toggle:focus-visible { outline: 2px solid var(--brand-on-dark); outline-offset: -2px; }

.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: 66px; }
.app-shell.sidebar-collapsed .main { margin-left: 66px; }
.app-shell.sidebar-collapsed .sidebar .brand-logo { max-width: 34px; max-height: 34px; }
.app-shell.sidebar-collapsed .sidebar .brand-logo-plate { padding: .2rem; }
.app-shell.sidebar-collapsed .sidebar-brand { padding: .75rem .4rem; }
.app-shell.sidebar-collapsed .sidebar .brand-initials { width: 36px; height: 36px; font-size: .85rem; }
.app-shell.sidebar-collapsed .sidebar .nav-link span,
.app-shell.sidebar-collapsed .sidebar .brand-name { 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: rgba(255,255,255,.08);
}
.app-shell.sidebar-collapsed .sidebar .nav-section-toggle > * { display: none; }
.app-shell.sidebar-collapsed .sidebar .nav-link { justify-content: center; padding: .6rem 0; gap: 0; }
.app-shell.sidebar-collapsed .sidebar .nav-link i { width: auto; font-size: 1.1rem; }
.app-shell.sidebar-collapsed .sidebar .collapse:not(.show) { display: block !important; } /* show icons even if group was collapsed */

.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-ink); }

/* 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); color: var(--brand-contrast); 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; flex-wrap: wrap; gap: .25rem 1rem;
    padding: .75rem 1.25rem; color: #8a97a8; font-size: .82rem;
    border-top: 1px solid #e3e8ef; background: #fff;
}
/* Discreet product credit — the company's identity leads everywhere else. */
.powered-by { font-size: .74rem; color: #9aa6b8; }
.powered-by a { color: inherit; text-decoration: none; }
.powered-by a:hover { color: var(--brand-ink); text-decoration: underline; }

/* ---------- 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: var(--heading); }
.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-ink) !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 theme (the company's own colour) ============ */
/* 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(--heading); }

/* Primary buttons -> brand gradient; text colour chosen for legibility. */
.btn-primary {
    --bs-btn-color: var(--brand-contrast); --bs-btn-hover-color: var(--brand-contrast);
    --bs-btn-active-color: var(--brand-contrast); --bs-btn-disabled-color: var(--brand-contrast);
    --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-darker); --bs-btn-active-border-color: var(--brand-darker);
    --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: var(--brand-rgb);
    background-image: var(--grad-brand-soft); border: none;
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-ink); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: var(--brand-contrast); --bs-btn-active-color: var(--brand-contrast);
    --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-darker); --bs-btn-active-border-color: var(--brand-darker);
    --bs-btn-focus-shadow-rgb: var(--brand-rgb);
}
a { color: var(--brand-ink); }
a:hover { color: var(--brand-ink-hover); }
.text-primary { color: var(--brand-ink) !important; }
/* .bg-primary / .border-primary follow --bs-primary-rgb (set by the layout). */
.badge.bg-primary { background: var(--brand) !important; color: var(--brand-contrast) !important; }

/* Table header -> subtle brand gradient tint */
.page-card .table > thead > tr > th {
    background: linear-gradient(180deg, var(--brand-softer), var(--brand-soft));
    color: var(--brand-head-ink); border-bottom-color: var(--brand-border);
}
.page-card .table > thead th.sortable-th a { color: var(--brand-head-ink); }
.page-card .table > tbody > tr:hover > td { background: var(--brand-softer); }
.page-card .table > tfoot > tr > td { background: var(--brand-softer); border-top-color: var(--brand-border); }

/* Pagination active page -> brand colour */
.pagination {
    --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand);
    --bs-pagination-active-color: var(--brand-contrast);
    --bs-pagination-color: var(--brand-ink); --bs-pagination-hover-color: var(--brand-ink-hover);
    --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb),.2);
}

/* Tabs and list-group active states */
.nav-tabs .nav-link.active { color: var(--brand-ink); border-top: 2px solid var(--brand); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--brand); --bs-nav-pills-link-active-color: var(--brand-contrast); }
.nav-link { --bs-nav-link-hover-color: var(--brand-ink-hover); }
.list-group { --bs-list-group-active-bg: var(--brand); --bs-list-group-active-border-color: var(--brand); --bs-list-group-active-color: var(--brand-contrast); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--brand); --bs-dropdown-link-active-color: var(--brand-contrast); }
.progress, .progress-stacked { --bs-progress-bar-bg: var(--brand); }

/* KPI card icons already pass their own colours; card headings stay neutral */
.page-card > h2, .page-card .h6 { color: var(--heading); }

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

/* Nav caret + section hover in the brand tint */
.sidebar-nav .nav-section-toggle:hover { color: var(--brand-on-dark); }

/* 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(--brand); 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; } }

/* 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: #f5f8fc; border: 1px solid #dfe6f0; color: #33445e;
}
.report-scope > span { font-weight: 600; }
.report-scope > .bi-funnel-fill { color: var(--brand); }

/* ================= 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-ink); }

/* 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); background: #fff;
    box-shadow: 0 0 0 .22rem rgba(var(--brand-rgb),.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); border-color: var(--brand); }
.form-check-input:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb),.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(var(--brand-rgb),.28); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(var(--brand-rgb),.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-ink) !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);
}
#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); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb),.15);
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .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::after { left: calc(var(--sidebar-w) - 3px); }
    .app-shell.sidebar-collapsed .sidebar .nav-link span,
    .app-shell.sidebar-collapsed .sidebar .brand-name { display: initial; }
    .app-shell.sidebar-collapsed .sidebar .nav-link .nav-text-2 { display: flex; }
    .app-shell.sidebar-collapsed .sidebar .nav-link { justify-content: flex-start; padding: .55rem 1.25rem; gap: .65rem; }
    .app-shell.sidebar-collapsed .sidebar .nav-link i { width: 1.1rem; font-size: inherit; }
    .app-shell.sidebar-collapsed .sidebar .nav-section-toggle { pointer-events: auto; padding: .9rem 1.25rem .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; align-content: center; gap: 1rem;
    padding: 1.5rem 1rem;
    background: linear-gradient(135deg, var(--heading) 0%, var(--brand-darker) 55%, var(--brand) 100%);
}
.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; }
/* The logo sits on the white card as drawn; the plate only bounds its size. */
.login-logo-plate { display: inline-flex; align-items: center; justify-content: center; }
.login-logo-plate img { max-height: 72px; max-width: 240px; height: auto; display: block; object-fit: contain; }
.login-company { margin: .75rem 0 0; font-size: 1.25rem; font-weight: 700; color: var(--heading); }
.login-brand i { font-size: 2.4rem; color: var(--brand-ink); }
.login-powered { color: rgba(255,255,255,.72); font-size: .76rem; text-align: center; }
.login-powered a { color: #fff; text-decoration: none; }
.login-powered a:hover { text-decoration: underline; }

/* ---------- Company settings (branding) ---------- */
.brand-swatch {
    width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; padding: 0;
    box-shadow: 0 0 0 1px #d5dce6; cursor: pointer; transition: transform .12s;
}
.brand-swatch:hover, .brand-swatch:focus-visible { transform: scale(1.12); outline: none; box-shadow: 0 0 0 2px var(--brand); }
.brand-logo-box {
    width: 180px; height: 96px; display: grid; place-items: center; flex-shrink: 0;
    border: 1.5px dashed #d5dce6; border-radius: .7rem; background: #fff; padding: .5rem;
}
.brand-logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-preview { display: flex; border: 1px solid #e3e8ef; border-radius: .6rem; overflow: hidden; min-height: 220px; }
.brand-preview-side { width: 44%; background: var(--grad-sidebar); color: #d3d9e2; }
.brand-preview-side .sidebar-brand { position: static; padding: .7rem .6rem; }
.brand-preview-side .brand-logo { max-width: 100%; max-height: 34px; }
.brand-preview-side .brand-name { font-size: .8rem; }
.brand-preview-side .brand-initials { width: 32px; height: 32px; font-size: .8rem; }
.brand-preview-side .sidebar-nav { padding: .4rem 0; }
.brand-preview-side .sidebar-nav .nav-link { padding: .4rem .7rem; font-size: .78rem; cursor: default; }
.brand-preview-main { flex: 1; padding: .8rem; background: var(--bg); min-width: 0; }
.brand-preview-main .btn { pointer-events: none; }

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

/* ---------- List toolbars ----------
   Filter / search forms wrap, and never push a page wider than a phone:
   a dropdown would otherwise keep the width of its longest option. */
#pageContent form.d-flex.flex-wrap { max-width: 100%; min-width: 0; }
#pageContent form.d-flex.flex-wrap > .form-select,
#pageContent form.d-flex.flex-wrap > .form-control { width: auto; max-width: 100%; min-width: 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); box-shadow: 0 6px 18px rgba(var(--brand-rgb), .15);
    transform: translateY(-2px); outline: none;
}
.project-card-name { font-size: 1.1rem; font-weight: 600; color: var(--heading); }
.project-card-open { color: var(--brand-ink); 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; }
