/* App-wide look and feel, layered over Bootstrap 5.3. Colours come from the
   B&N crest: near-black navy (primary) and metallic gold (accent), with
   green kept for "good" states. Structure is shared with procurement-system;
   only the palette below differs. */

:root {
    --bnltd-blue: #1b3157;
    --bnltd-blue-dark: #0f1c36;
    --bnltd-blue-soft: #eceff6;
    --bnltd-green: #2f7d3a;
    --bnltd-gold: #d8b060;
    --bnltd-gold-bright: #f8d078;
    --bnltd-gold-deep: #86671f;
    --bnltd-ink: #1f2937;
    --bnltd-muted: #667085;
    --bnltd-line: #e4e8ef;
    --bnltd-surface: #ffffff;
    --bnltd-radius: 0.75rem;
    --bnltd-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px rgba(16, 24, 40, 0.06);
    --bnltd-shadow-lift: 0 4px 6px rgba(16, 24, 40, 0.05), 0 12px 24px rgba(16, 24, 40, 0.1);

    --bs-primary: var(--bnltd-blue);
    --bs-primary-rgb: 27, 49, 87;
    --bs-link-color: var(--bnltd-blue);
    --bs-link-color-rgb: 27, 49, 87;
    --bs-link-hover-color: var(--bnltd-blue-dark);
    --bs-link-hover-color-rgb: 15, 28, 54;
    --bs-body-bg: #f3f5f9;
    --bs-body-color: var(--bnltd-ink);
    --bs-secondary-color: var(--bnltd-muted);
    --bs-border-color: var(--bnltd-line);
    --bs-border-radius: 0.6rem;
    --bs-body-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: 0.95rem;
}

html { scroll-behavior: smooth; }
body { min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
main.app-main { flex: 1 0 auto; }

/* ---- headings -------------------------------------------------------- */
h1, .h1, h2, .h2, h3, .h3 { color: var(--bnltd-blue-dark); letter-spacing: -0.01em; }
h1.h3 { font-weight: 700; }
.page-subtitle { color: var(--bnltd-muted); margin-bottom: 1.25rem; }

/* ---- navbar ---------------------------------------------------------- */
.app-nav {
    background: linear-gradient(180deg, #1b3157 0%, #0a1424 100%);
    border-bottom: 3px solid var(--bnltd-gold);
    box-shadow: 0 2px 10px rgba(16, 24, 40, 0.15);
    position: sticky;
    top: 0;
    z-index: 1030;
}
.app-nav .navbar-brand { display: flex; align-items: center; gap: 0.65rem; font-weight: 650; font-size: 1rem; line-height: 1.15; color: #fff; max-width: 22rem; white-space: normal; }
.app-nav .brand-logo { height: 40px; width: auto; background: #fff; border-radius: 8px; padding: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25); }
.app-nav .nav-link { color: rgba(255, 255, 255, 0.78); font-weight: 500; padding: 0.5rem 0.85rem; border-radius: 0.5rem; transition: background 0.15s, color 0.15s; }
.app-nav .nav-link:hover, .app-nav .nav-link:focus { color: #fff; background: rgba(255, 255, 255, 0.1); }
.app-nav .nav-link.active { color: #fff; background: rgba(255, 255, 255, 0.16); box-shadow: inset 0 -2px 0 var(--bnltd-gold); }
.app-nav .navbar-toggler { border-color: rgba(255, 255, 255, 0.4); }
.user-chip { display: inline-flex; align-items: center; gap: 0.5rem; color: #fff; background: rgba(255, 255, 255, 0.1); border: 0; border-radius: 999px; padding: 0.25rem 0.75rem 0.25rem 0.3rem; font-weight: 500; }
.user-chip:hover, .user-chip:focus, .user-chip.show { background: rgba(255, 255, 255, 0.2); color: #fff; }
.user-chip .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--bnltd-gold); color: var(--bnltd-blue-dark); display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; }
.dropdown-menu { border: 0; border-radius: var(--bnltd-radius); box-shadow: var(--bnltd-shadow-lift); padding: 0.4rem; }
.dropdown-item { border-radius: 0.45rem; }

/* ---- cards ----------------------------------------------------------- */
.card { border: 0; border-radius: var(--bnltd-radius); box-shadow: var(--bnltd-shadow); background: var(--bnltd-surface); }
.card-body { padding: 1.25rem 1.35rem; }
.card-title { font-weight: 650; color: var(--bnltd-blue-dark); }
.card .card { box-shadow: none; border: 1px solid var(--bnltd-line); }
.card h2.h6.card-title { display: flex; align-items: center; gap: 0.4rem; font-size: 1rem; }
.card h2.h6.card-title::before { content: ""; width: 4px; height: 1.05em; border-radius: 2px; background: var(--bnltd-gold); display: inline-block; }
.card-link-tile { transition: transform 0.15s, box-shadow 0.15s; color: inherit; text-decoration: none; display: block; height: 100%; }
.card-link-tile:hover { transform: translateY(-2px); box-shadow: var(--bnltd-shadow-lift); color: inherit; }

/* ---- buttons --------------------------------------------------------- */
.btn { font-weight: 550; border-radius: 0.6rem; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { --bs-btn-bg: var(--bnltd-blue); --bs-btn-border-color: var(--bnltd-blue); --bs-btn-hover-bg: var(--bnltd-blue-dark); --bs-btn-hover-border-color: var(--bnltd-blue-dark); --bs-btn-active-bg: var(--bnltd-blue-dark); --bs-btn-active-border-color: var(--bnltd-blue-dark); --bs-btn-disabled-bg: var(--bnltd-blue); --bs-btn-disabled-border-color: var(--bnltd-blue); --bs-btn-focus-shadow-rgb: 27, 49, 87; box-shadow: 0 1px 2px rgba(10, 20, 36, 0.25); }
.btn-outline-primary { --bs-btn-color: var(--bnltd-blue); --bs-btn-border-color: #b8c2d8; --bs-btn-hover-bg: var(--bnltd-blue); --bs-btn-hover-border-color: var(--bnltd-blue); --bs-btn-active-bg: var(--bnltd-blue-dark); --bs-btn-active-border-color: var(--bnltd-blue-dark); --bs-btn-focus-shadow-rgb: 27, 49, 87; --bs-btn-disabled-color: var(--bnltd-blue); --bs-btn-disabled-border-color: #b8c2d8; }
.btn-outline-secondary { --bs-btn-color: #475467; --bs-btn-border-color: #d0d5dd; --bs-btn-hover-bg: #f2f4f7; --bs-btn-hover-color: var(--bnltd-ink); --bs-btn-hover-border-color: #b8bfca; --bs-btn-active-bg: #e4e7ec; --bs-btn-active-color: var(--bnltd-ink); --bs-btn-active-border-color: #b8bfca; }
.btn-link { text-decoration-thickness: 1px; text-underline-offset: 2px; }
.btn.is-busy { opacity: 0.7; pointer-events: none; }
.btn.is-busy::after { content: ""; display: inline-block; width: 0.85em; height: 0.85em; margin-left: 0.5em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -0.1em; animation: bnltd-spin 0.7s linear infinite; }
@keyframes bnltd-spin { to { transform: rotate(360deg); } }

/* ---- forms ----------------------------------------------------------- */
.form-label { font-weight: 550; color: #344054; margin-bottom: 0.3rem; }
.form-control, .form-select { background-color: #fff; border-color: #d0d5dd; border-radius: 0.6rem; padding: 0.55rem 0.8rem; }
.form-control-sm, .form-select-sm { padding: 0.3rem 0.6rem; border-radius: 0.5rem; }
.form-control:focus, .form-select:focus { border-color: #7889ad; box-shadow: 0 0 0 0.22rem rgba(27, 49, 87, 0.15); }
.form-control::placeholder { color: #98a2b3; }
.form-text { color: var(--bnltd-muted); }
.form-check-input:checked { background-color: var(--bnltd-blue); border-color: var(--bnltd-blue); }
textarea.form-control { min-height: 5rem; }
/* Green "valid" ticks on every untouched filter box are noise - only errors get decoration. */
.form-control.is-valid, .form-select.is-valid { border-color: #d0d5dd; background-image: none; padding-right: 0.8rem; }
.form-select.is-valid { background-image: var(--bs-form-select-bg-img); padding-right: 2.25rem; }
.form-control.is-valid:focus, .form-select.is-valid:focus { border-color: #7889ad; box-shadow: 0 0 0 0.22rem rgba(27, 49, 87, 0.15); }
.valid-feedback { display: none !important; }
/* Filter bars: compact, one tidy row where there is room. */
form.row-cols-lg-auto { --bs-gutter-x: 0.75rem; --bs-gutter-y: 0.6rem; }
form.row-cols-lg-auto .mb-3 { margin-bottom: 0 !important; }
form.row-cols-lg-auto .form-label { font-size: 0.78rem; margin-bottom: 0.15rem; color: var(--bnltd-muted); }
form.row-cols-lg-auto .form-control, form.row-cols-lg-auto .form-select { padding: 0.35rem 0.6rem; font-size: 0.86rem; }

/* ---- tables ---------------------------------------------------------- */
.table-responsive { border-radius: var(--bnltd-radius); box-shadow: var(--bnltd-shadow); background: var(--bnltd-surface); margin-bottom: 1rem; }
.table-responsive > .table { margin-bottom: 0; }
.table { --bs-table-bg: transparent; --bs-table-hover-bg: #f6f8fc; font-size: 0.9rem; vertical-align: middle; }
.table > :not(caption) > * > * { padding: 0.7rem 0.85rem; border-color: var(--bnltd-line); }
.table thead th { background: #eef2f8; color: #475467; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid #d9e0ec; white-space: nowrap; }
.table-bordered > :not(caption) > * { border-width: 0 0 1px; }
.table-bordered > :not(caption) > * > * { border-width: 0; border-bottom: 1px solid var(--bnltd-line); }
.table > tbody > tr:last-child > * { border-bottom: 0; }
.table > tbody > tr { transition: background 0.1s; }
.table > tbody > tr:hover > * { background: #f6f8fc; }
.table-sm > :not(caption) > * > * { padding: 0.45rem 0.65rem; }

/* ---- badges, alerts, misc --------------------------------------------- */
.badge { font-weight: 600; letter-spacing: 0.01em; border-radius: 999px; padding: 0.4em 0.75em; }
.badge.text-bg-secondary { background-color: #e9edf4 !important; color: #3b4a63 !important; }
.badge.text-bg-success { background-color: #dff3e3 !important; color: #1e6b2c !important; }
.badge.text-bg-warning { background-color: #f6ecd2 !important; color: #7a5a00 !important; }
.badge.text-bg-danger { background-color: #fbe0de !important; color: #a1261b !important; }
.badge.text-bg-info { background-color: #dcecfb !important; color: #14507f !important; }
.badge.text-bg-primary { background-color: var(--bnltd-blue-soft) !important; color: var(--bnltd-blue-dark) !important; }

.alert { border: 0; border-left: 4px solid; border-radius: 0.65rem; box-shadow: var(--bnltd-shadow); }
.alert-success { background: #eaf7ed; border-left-color: var(--bnltd-green); color: #1e5a2a; }
.alert-danger { background: #fdeceb; border-left-color: #d92d20; color: #8a1f17; }
.alert-warning { background: #fff7e0; border-left-color: var(--bnltd-gold); color: #6b4e00; }
.alert-info { background: var(--bnltd-blue-soft); border-left-color: var(--bnltd-blue); color: var(--bnltd-blue-dark); }
.alert-secondary { background: #f2f4f7; border-left-color: #98a2b3; color: #344054; }
.messages-stack { margin-top: 1rem; }

dl.row dt { color: var(--bnltd-muted); font-weight: 550; }
hr { border-color: var(--bnltd-line); opacity: 1; }
.text-muted { color: var(--bnltd-muted) !important; }
.pagination { --bs-pagination-active-bg: var(--bnltd-blue); --bs-pagination-active-border-color: var(--bnltd-blue); --bs-pagination-color: var(--bnltd-blue); }
a:focus-visible, button:focus-visible, .btn:focus-visible { outline: 3px solid rgba(216, 176, 96, 0.8); outline-offset: 2px; }

/* ---- footer ---------------------------------------------------------- */
.app-footer { flex-shrink: 0; margin-top: 3rem; padding: 1.25rem 0; border-top: 1px solid var(--bnltd-line); color: var(--bnltd-muted); font-size: 0.82rem; background: rgba(255, 255, 255, 0.6); }

/* ---- home dashboard --------------------------------------------------- */
.hero { background: linear-gradient(120deg, #0a1424 0%, #1b3157 60%, #2d4a7c 100%); color: #fff; border-radius: 1rem; padding: 1.75rem 1.75rem; position: relative; overflow: hidden; box-shadow: var(--bnltd-shadow-lift); }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(248, 208, 120, 0.28), rgba(248, 208, 120, 0) 70%); }
.hero h1 { color: #fff; font-weight: 700; margin-bottom: 0.25rem; }
.hero p { color: rgba(255, 255, 255, 0.82); margin-bottom: 0.75rem; }
.hero .badge { background: rgba(255, 255, 255, 0.16) !important; color: #fff !important; font-weight: 550; }
.section-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--bnltd-muted); margin: 1.75rem 0 0.75rem; }

.attention-card { display: flex; align-items: center; gap: 0.9rem; padding: 1rem 1.1rem; border-radius: var(--bnltd-radius); background: #fff; box-shadow: var(--bnltd-shadow); text-decoration: none; color: inherit; border-left: 4px solid var(--bnltd-gold); transition: transform 0.15s, box-shadow 0.15s; height: 100%; }
.attention-card:hover { transform: translateY(-2px); box-shadow: var(--bnltd-shadow-lift); color: inherit; }
.attention-card .count { font-size: 1.75rem; font-weight: 750; line-height: 1; color: var(--bnltd-blue-dark); min-width: 2.2rem; text-align: center; }
.attention-card .what { font-weight: 600; line-height: 1.25; }
.attention-card .hint { color: var(--bnltd-muted); font-size: 0.82rem; }
.attention-card .bi-chevron-right { margin-left: auto; color: #98a2b3; }
.all-clear { background: #eaf7ed; border-radius: var(--bnltd-radius); color: #1e5a2a; padding: 1rem 1.25rem; display: flex; gap: 0.75rem; align-items: center; }

.tile { padding: 1.25rem; }
.tile .tile-icon { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--bnltd-blue-soft); color: var(--bnltd-blue); font-size: 1.35rem; margin-bottom: 0.75rem; }
.tile h2 { font-size: 1.05rem; font-weight: 650; margin-bottom: 0.2rem; }
.tile p { color: var(--bnltd-muted); font-size: 0.86rem; margin-bottom: 0.9rem; }
.tile-green .tile-icon { background: #e2f3e5; color: var(--bnltd-green); }
.tile-gold .tile-icon { background: #f6ecd2; color: #86671f; }

.workspace-list { list-style: none; padding: 0; margin: 0; }
.workspace-list li { padding: 0.3rem 0; border-bottom: 1px dashed var(--bnltd-line); }
.workspace-list li:last-child { border-bottom: 0; }

/* ---- sign-in pages ----------------------------------------------------- */
body.auth-page { background: radial-gradient(1200px 500px at 50% -10%, #e6eaf3 0%, rgba(243, 245, 249, 0) 70%), var(--bs-body-bg); }
.auth-card { background: #fff; border-radius: 1.1rem; padding: 2rem 2rem 1.75rem; box-shadow: var(--bnltd-shadow-lift); margin-top: 1.5rem; }
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand img { height: 84px; width: auto; margin-bottom: 0.6rem; }
.auth-brand .org { font-weight: 700; color: var(--bnltd-blue-dark); line-height: 1.2; }
.auth-brand .app { color: var(--bnltd-muted); font-size: 0.85rem; }
.auth-card h1 { font-size: 1.25rem; text-align: center; margin-bottom: 1rem; }
.auth-card .btn-primary { width: 100%; padding: 0.6rem; }

@media (max-width: 575.98px) {
    /* filter bars: two fields per row on a phone instead of one long column */
    form.row-cols-lg-auto > * { flex: 0 0 auto; width: 50%; }
    form.row-cols-lg-auto > *:last-child { width: 100%; }
    .app-nav .navbar-brand { max-width: 15rem; font-size: 0.88rem; }
    .app-nav .brand-logo { height: 34px; }
    .hero { padding: 1.25rem; }
    .card-body { padding: 1rem; }
    .auth-card { padding: 1.5rem 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print { .app-nav, .app-footer { display: none; } body { background: #fff; } }


/* ======================================================================
   Small screens: phones (< 768px), tablets (768-991px), small laptops
   (992-1199px). Mobile-first fixes layered on the base look above.
   ====================================================================== */
[id] { scroll-margin-top: 84px; }  /* anchors land below the sticky bar */
img, svg, video { max-width: 100%; height: auto; }
.card-body, dd, .alert, .form-text { overflow-wrap: anywhere; }  /* long names/emails never push the page wide */
/* Table cells use break-word, not anywhere: "anywhere" lets the browser shrink a
   column below its longest word, so a wide table squeezed words apart
   ("Main Ware house") instead of scrolling sideways inside .table-responsive. */
.table td, .table th { overflow-wrap: break-word; }

/* Small laptops: 6 links + the user chip must still fit on one line. */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .app-nav .navbar-brand { max-width: 12.5rem; font-size: 0.85rem; }
    .app-nav .brand-logo { height: 34px; }
    .app-nav .nav-link { padding: 0.5rem 0.5rem; font-size: 0.86rem; white-space: nowrap; }
    .app-nav .nav-link i { display: none; }
    /* the name moves into the menu; the round initial stays as the button */
    .app-nav .user-chip > span:last-child { display: none; }
    .app-nav .user-chip { padding-right: 0.5rem; }
}

/* Tablets and phones: the menu opens as a tidy panel. */
@media (max-width: 991.98px) {
    .app-nav .navbar-collapse { padding: 0.5rem 0 0.75rem; }
    .app-nav .navbar-nav { gap: 0.15rem; }
    .app-nav .nav-link { padding: 0.65rem 0.85rem; }
    .app-nav .dropdown { margin-top: 0.5rem; padding-top: 0.6rem; border-top: 1px solid rgba(255, 255, 255, 0.18); }
    .app-nav .user-chip { width: 100%; justify-content: flex-start; }
    .app-nav .dropdown-menu { width: 100%; }
}

/* Phones and portrait tablets */
@media (max-width: 767.98px) {
    /* 16px+ text in fields stops iOS from zooming the page when one is tapped */
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { font-size: 16px !important; }

    /* Filter bars fold away behind a button (see app.js) */
    form.filters-collapsed { display: none !important; }
    .filter-toggle + form { margin-top: 1rem; }

    /* Pagination / export bars wrap instead of squeezing */
    .pagination { flex-wrap: wrap; }
    .hero h1 { font-size: 1.35rem; }
    h1.h3 { font-size: 1.4rem; }
    .btn-lg { width: 100%; }
    dl.row dt { margin-top: 0.5rem; }
    dl.row dd { margin-bottom: 0.15rem; }
}

/* Touch screens (any width): comfortable tap targets */
@media (pointer: coarse) {
    .btn-sm { --bs-btn-padding-y: 0.5rem; --bs-btn-padding-x: 0.85rem; --bs-btn-font-size: 0.9rem; }
    .btn-link.btn-sm, .btn.p-0 { padding: 0.35rem 0.25rem !important; }
    .form-control-sm, .form-select-sm { min-height: 42px; padding: 0.45rem 0.7rem; }
    .dropdown-item { padding: 0.65rem 0.9rem; }
    .page-link { padding: 0.55rem 0.85rem; }
    .form-check-input { width: 1.3em; height: 1.3em; }
    .workspace-list li { padding: 0.5rem 0; }
}

.filter-toggle { display: flex; align-items: center; }
@media (min-width: 768px) { .filter-toggle { display: none; } }

/* Tablets and phones: list tables become cards */
@media (max-width: 991.98px) {
    /* List tables turn into one card per row (two across on a tablet), labelled from the column headers (see app.js) */
    .table-responsive.has-cards { box-shadow: none; background: transparent; overflow: visible; border-radius: 0; }
    table.table.table-cards, table.table.table-cards tbody, table.table.table-cards tr, table.table.table-cards td { display: block; width: 100%; }
    table.table.table-cards thead { display: none; }
    table.table.table-cards { background: transparent !important; }
    table.table.table-cards tr { background: #fff; border-radius: var(--bnltd-radius); box-shadow: var(--bnltd-shadow); margin-bottom: 0.8rem; padding: 0.35rem 0; }
    table.table.table-cards > tbody > tr > td { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 0.4rem 1rem; border: 0; text-align: right; background: transparent; }
    table.table.table-cards > tbody > tr > td::before { content: attr(data-label); flex: 0 0 38%; max-width: 38%; text-align: left; color: var(--bnltd-muted); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 0.25rem; }
    table.table.table-cards > tbody > tr > td:not([data-label])::before, table.table.table-cards > tbody > tr > td[colspan]::before { display: none; }
    table.table.table-cards > tbody > tr > td[colspan] { display: block; text-align: left; }
    table.table.table-cards .cell-value { display: block; flex: 1 1 auto; min-width: 0; }
    table.table.table-cards > tbody > tr:hover > * { background: transparent; }
    table.table.table-cards > tbody > tr > td:first-child { padding-top: 0.6rem; }
    table.table.table-cards > tbody > tr > td:last-child { padding-bottom: 0.6rem; }

    /* minmax(0, ...): a plain 1fr track will not shrink below its widest unbreakable content, which is how one long email address
       used to push a whole card (and the page) wider than the screen. */
    table.table.table-cards > tbody { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.8rem; }
    table.table.table-cards > tbody > tr { margin-bottom: 0; }
    table.table.table-cards > tbody > tr:has(> td[colspan]) { grid-column: 1 / -1; }
    /* A totals row becomes one more card under the rows, its cells side by side. */
    table.table.table-cards > tfoot, table.table.table-cards > tfoot > tr { display: block; width: 100%; }
    table.table.table-cards > tfoot > tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.2rem 1rem; background: #fff; border-radius: var(--bnltd-radius); box-shadow: var(--bnltd-shadow); padding: 0.6rem 1rem; }
    table.table.table-cards > tfoot > tr > th, table.table.table-cards > tfoot > tr > td { display: block; border: 0; padding: 0; background: transparent; }
    table.table.table-cards > tfoot > tr > [colspan] { flex: 1 1 100%; }
    /* Inputs inside a card cell fill the cell instead of keeping their desktop widths. */
    table.table.table-cards td .form-control, table.table.table-cards td .form-select { min-width: 0; max-width: 100%; }
    table.table.table-cards td form.d-flex { flex-wrap: wrap; }
    /* "Void" / "Add invoice" style disclosures open into the whole width of the card, not the width of their button. */
    table.table.table-cards td details { width: 100%; text-align: left; }
    table.table.table-cards td .cell-value { min-width: 0; overflow-wrap: anywhere; }
    /* Nowrap keeps columns tidy on a desktop; in a card it only pushes the value out of it. An amount may drop to a second line
       after its currency ("RWF" / "125,000,000") but is never cut in the middle of the number. */
    table.table.table-cards .text-nowrap, table.table.table-cards td.money, table.table.table-cards td .money { white-space: normal !important; }
    table.table.table-cards td.money .cell-value, table.table.table-cards td .money.cell-value { overflow-wrap: break-word; }
}
@media (min-width: 576px) and (max-width: 991.98px) {
    table.table.table-cards > tbody { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    /* Filter bars: three across rather than one long column */
    form.row-cols-lg-auto > * { flex: 0 0 auto; width: 33.333%; }
    form.row-cols-lg-auto > *:last-child { width: 100%; }
}

/* Actions card: the one place a decision is made, so it carries a coloured edge
   and its buttons are full-size (see core_tags.action_class for the colours). */
.actions-card { border-left: 4px solid var(--bnltd-blue); }
.actions-card .btn { min-height: 44px; }
/* From a laptop up the actions stay in view while the payments and documents scroll past (their own scroll if taller than the screen) */
@media (min-width: 992px) {
    .actions-card { position: sticky; top: 5.5rem; max-height: calc(100vh - 7rem); overflow-y: auto; }
}
@media (max-width: 575.98px) { .actions-card .btn { flex: 1 1 100%; } }
/* Lease actions: one row per change, opening only the fields it needs (a <details>), and "More" for the rare ones */
.actions-card .action-row > summary { list-style: none; cursor: pointer; min-height: 44px; }
.actions-card .action-row > summary::-webkit-details-marker { display: none; }
.actions-card .action-row[open] > summary .bi-chevron-down { transform: rotate(180deg); }
.actions-card a.action-row { color: inherit; min-height: 44px; }
.actions-card .action-row .btn-link { min-height: 0; text-decoration: none; }
.actions-card .waiting-signoffs { background: var(--bs-warning-bg-subtle); border-color: var(--bs-warning-border-subtle) !important; }
/* Settle the lease: one line per thing left to close it, ticked when done, opening on what to do */
.settle-card .settle-row > summary { list-style: none; cursor: pointer; min-height: 44px; }
.settle-card .settle-row > summary::-webkit-details-marker { display: none; }


/* ======================================================================
   Apartment-management additions (everything above is shared, verbatim,
   with procurement-system so the two apps look like one family).
   ====================================================================== */

/* ---- nav: red "waiting" counts, and the More dropdown --------------- */
/* A real <sup>, so the count reads as an exponent next to the link text. */
.app-nav .navbar-toggler .nav-badge, .app-nav .user-chip .nav-badge, .app-nav .dropdown-item .nav-badge, .app-nav .nav-link .nav-badge { display: inline-block; margin-left: 0.3rem; padding: 0.12em 0.48em; border-radius: 999px; background: #d92d20; color: #fff; font-size: 0.66rem; font-weight: 700; line-height: 1.25; box-shadow: 0 0 0 2px rgba(10, 20, 36, 0.9); }
.app-nav .dropdown-toggle::after { vertical-align: 0.15em; }
.app-nav .dropdown-menu .dropdown-item.active, .app-nav .dropdown-menu .dropdown-item:active { background: var(--bnltd-blue); color: #fff; }
/* On a phone the menu slides out from the side (an offcanvas): each menu is a heading over its pages, nothing to unfold. From a laptop
   up, Bootstrap lays the same panel out as the bar. */
.app-nav .navbar-toggler { position: relative; }
.app-nav .navbar-toggler .nav-badge { position: absolute; top: -0.4rem; right: -0.4rem; }
@media (max-width: 991.98px) {
    .app-offcanvas { background: linear-gradient(180deg, #1b3157 0%, #0a1424 100%); color: #fff; --bs-offcanvas-width: min(320px, 86vw); }
    .app-offcanvas .offcanvas-header { border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
    .app-offcanvas .offcanvas-body { display: flex; flex-direction: column; gap: 0.75rem; }
    .mobile-nav { display: flex; flex-direction: column; }
    .mobile-nav-heading { margin: 0.9rem 0 0.25rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--bnltd-gold); }
    .mobile-nav-link { display: flex; align-items: center; min-height: 44px; padding: 0 0.75rem; border-radius: 0.5rem; color: rgba(255, 255, 255, 0.85); text-decoration: none; }
    .mobile-nav-heading + .mobile-nav-link, .mobile-nav-heading ~ .mobile-nav-link:not(.mobile-nav-top) { padding-left: 1.6rem; }
    .mobile-nav-link:hover, .mobile-nav-link:focus { background: rgba(255, 255, 255, 0.1); color: #fff; }
    .mobile-nav-link.active { background: rgba(255, 255, 255, 0.16); color: #fff; box-shadow: inset 3px 0 0 var(--bnltd-gold); }
    .mobile-nav-top { margin-top: 0.35rem; }
    .mobile-nav .nav-badge { display: inline-block; margin-left: 0.4rem; padding: 0.12em 0.48em; border-radius: 999px; background: #d92d20; color: #fff; font-size: 0.66rem; font-weight: 700; line-height: 1.25; }
    .app-offcanvas .dropdown { margin-top: auto; }
}
@media (max-width: 991.98px) {
    /* a menu opens inline inside the panel (the account menu, on a phone) */
    .app-nav .navbar-nav .dropdown-menu { background: rgba(255, 255, 255, 0.08); box-shadow: none; padding: 0.25rem; margin: 0.15rem 0 0.35rem 0.85rem; }
    .app-nav .navbar-nav .dropdown-item { color: rgba(255, 255, 255, 0.85); }
    .app-nav .navbar-nav .dropdown-item:hover, .app-nav .navbar-nav .dropdown-item:focus { background: rgba(255, 255, 255, 0.12); color: #fff; }
    .app-nav .navbar-nav .dropdown-item.active { background: rgba(255, 255, 255, 0.18); color: #fff; box-shadow: inset 3px 0 0 var(--bnltd-gold); }
}

/* ---- page header: title on the left, actions on the right ----------- */
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.1rem; }
.page-head h1 { margin: 0; }
.page-head .page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--bnltd-muted); text-decoration: none; font-size: 0.86rem; margin-bottom: 0.6rem; }
.back-link:hover { color: var(--bnltd-blue); }

/* ---- status stepper (dots in lists, labelled pipeline on details) ---- */
.status-stepper { display: inline-flex; align-items: center; gap: 5px; }
.status-stepper__step { width: 10px; height: 10px; border-radius: 50%; background-color: #d5dbe6; display: inline-block; flex-shrink: 0; }
.status-stepper__step--done { background-color: #7a8aa3; }
.status-stepper__step--current { background-color: var(--bnltd-blue); width: 14px; height: 14px; box-shadow: 0 0 0 3px rgba(27, 49, 87, 0.22); }
.status-stepper-label { display: block; line-height: 1.2; }

.pipeline { display: flex; gap: 0; margin: 0 0 1.25rem; padding: 0; list-style: none; overflow-x: auto; }
.pipeline li { flex: 1 1 0; min-width: 5.2rem; overflow-wrap: anywhere; position: relative; text-align: center; font-size: 0.74rem; font-weight: 600; color: #98a2b3; padding-top: 1.7rem; }
.pipeline li::before { content: ""; position: absolute; top: 0.55rem; left: 50%; width: 0.85rem; height: 0.85rem; margin-left: -0.425rem; border-radius: 50%; background: #d5dbe6; z-index: 1; }
.pipeline li::after { content: ""; position: absolute; top: 0.9rem; left: -50%; width: 100%; height: 3px; background: #d5dbe6; }
.pipeline li:first-child::after { display: none; }
.pipeline li.is-done { color: #475467; }
.pipeline li.is-done::before, .pipeline li.is-done::after { background: var(--bnltd-blue); opacity: 0.55; }
.pipeline li.is-current { color: var(--bnltd-blue-dark); }
.pipeline li.is-current::before { background: var(--bnltd-blue); opacity: 1; box-shadow: 0 0 0 4px rgba(27, 49, 87, 0.2); }
.pipeline li.is-current::after { background: var(--bnltd-blue); opacity: 0.55; }

/* ---- availability strip (units list) -------------------------------- */
.calendar-strip { display: flex; gap: 2px; }
.calendar-day { width: 8px; height: 22px; border-radius: 2px; background-color: #cfe9d4; transition: transform 0.1s; }
.calendar-day.booked { background-color: #f1b8b3; }
.calendar-day:hover { transform: scaleY(1.25); }
.legend-swatch { display: inline-block; width: 10px; height: 14px; border-radius: 2px; vertical-align: -2px; margin: 0 0.2rem 0 0.5rem; }

/* ---- stat tiles (finance dashboard, broker/contractor scorecards) ---- */
.stat { padding: 1rem 1.15rem; height: 100%; }
.stat .stat-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--bnltd-muted); }
/* The tile is its own container, so a long amount ("RWF 125,000,000") shrinks to fit the tile it is in - two to a row on a phone -
   instead of running out of it; if it still does not fit it wraps at the space after the currency, never mid-number. */
.stat { container-type: inline-size; }
.stat .stat-value { font-size: clamp(1rem, 11cqw, 1.6rem); font-weight: 750; line-height: 1.15; color: var(--bnltd-blue-dark); margin-top: 0.2rem; overflow-wrap: anywhere; }
.stat .stat-value.money { white-space: normal; overflow-wrap: break-word; }
.stat .stat-hint { font-size: 0.8rem; color: var(--bnltd-muted); margin-top: 0.15rem; }
.stat.stat-alert .stat-value { color: #b42318; }
.stat.stat-good .stat-value { color: var(--bnltd-green); }

/* ---- messages inbox / threads ---------------------------------------- */
.inbox-row { display: flex; gap: 0.9rem; align-items: flex-start; padding: 0.9rem 1.1rem; background: #fff; border-radius: var(--bnltd-radius); box-shadow: var(--bnltd-shadow); text-decoration: none; color: inherit; margin-bottom: 0.65rem; border-left: 4px solid transparent; transition: transform 0.15s, box-shadow 0.15s; }
.inbox-row:hover { transform: translateY(-1px); box-shadow: var(--bnltd-shadow-lift); color: inherit; }
.inbox-row.is-unread { border-left-color: var(--bnltd-gold); background: #fffdf5; }
.inbox-row .avatar-lg { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; background: var(--bnltd-blue-soft); color: var(--bnltd-blue-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.inbox-row.is-unread .avatar-lg { background: var(--bnltd-gold); }
.inbox-row .subject { font-weight: 600; }
.inbox-row.is-unread .subject { font-weight: 750; }
.inbox-row .snippet { color: var(--bnltd-muted); font-size: 0.88rem; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.bubble { background: #fff; border-radius: var(--bnltd-radius); box-shadow: var(--bnltd-shadow); padding: 0.9rem 1.1rem; margin-bottom: 0.8rem; }
.bubble.is-mine { background: var(--bnltd-blue-soft); box-shadow: none; border: 1px solid #cfd7e8; margin-left: 12%; }
.bubble.is-theirs { margin-right: 12%; }
.bubble .who { font-weight: 650; }
@media (max-width: 575.98px) { .bubble.is-mine { margin-left: 0; } .bubble.is-theirs { margin-right: 0; } }
.attachment-chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.65rem; border-radius: 999px; background: #f2f4f7; border: 1px solid var(--bnltd-line); color: var(--bnltd-ink); text-decoration: none; font-size: 0.82rem; margin: 0 0.35rem 0.35rem 0; }
.attachment-chip a { color: inherit; text-decoration: none; }
.attachment-chip:hover { background: var(--bnltd-blue-soft); color: var(--bnltd-blue-dark); }
.attachment-chip a:hover { text-decoration: underline; }

/* ---- empty states ------------------------------------------------------ */
.empty-state { text-align: center; color: var(--bnltd-muted); padding: 2.25rem 1rem; }
.empty-state i { font-size: 2rem; color: #b6c2d6; display: block; margin-bottom: 0.4rem; }

/* ---- small utilities --------------------------------------------------- */
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .table { margin-bottom: 0; }

.profile-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--bnltd-gold); color: var(--bnltd-blue-dark); display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 750; flex: 0 0 auto; }

/* ---- nav fit: this app has more top-level links than procurement ----- */
.app-nav .nav-link { white-space: nowrap; }
@media (min-width: 992px) and (max-width: 1399.98px) {
    /* Icons are what push eight links past one line; the labels carry it. */
    .app-nav .nav-link > i { display: none; }
    .app-nav .navbar-brand { max-width: 13.5rem; font-size: 0.85rem; }
    .app-nav .brand-logo { height: 34px; }
    .app-nav .nav-link { padding: 0.5rem 0.55rem; font-size: 0.88rem; }
    .app-nav .user-chip > span:last-child { display: none; }
    .app-nav .user-chip { padding-right: 0.5rem; }
}
@media (min-width: 1400px) {
    .app-nav .navbar-brand { max-width: 17rem; }
    .app-nav .nav-link { padding: 0.5rem 0.7rem; }
}

/* Bootstrap's yellow outline button has unreadably pale text on white. */
.btn-outline-warning { --bs-btn-color: #86671f; --bs-btn-border-color: #e7c56a; --bs-btn-hover-bg: #f6ecd2; --bs-btn-hover-color: #6b4e00; --bs-btn-hover-border-color: #e0b43f; --bs-btn-active-bg: #fbe6a0; --bs-btn-active-color: #6b4e00; --bs-btn-active-border-color: #e0b43f; }

/* ---- two-line brand: main name + subtitle ------------------------------ */
.app-nav .brand-text { display: flex; flex-direction: column; min-width: 0; }
.app-nav .brand-main { line-height: 1.15; }
.app-nav .brand-sub { font-size: 0.7rem; font-weight: 500; color: #f8d078; letter-spacing: 0.02em; line-height: 1.2; margin-top: 0.1rem; }
.auth-brand .org-sub { font-size: 0.8rem; font-weight: 600; color: #86671f; letter-spacing: 0.02em; }
@media (min-width: 992px) and (max-width: 1399.98px) { .app-nav .navbar-brand { max-width: 15.5rem; } .app-nav .brand-sub { font-size: 0.64rem; } }
.app-nav .brand-logo { object-fit: contain; }
.auth-brand img { border-radius: 14px; box-shadow: 0 2px 8px rgba(16, 24, 40, 0.18); }
.calendar-day { width: 7px; }

/* The crest is a dark square with gold line-work: frame it in gold, not white. */
.app-nav .brand-logo { background: #0a1424; padding: 0; border-radius: 9px; box-shadow: 0 0 0 1.5px var(--bnltd-gold); }
.auth-brand img { box-shadow: 0 0 0 2px var(--bnltd-gold), 0 4px 14px rgba(10, 20, 36, 0.25); }
.app-nav .nav-link.active { box-shadow: inset 0 -2px 0 var(--bnltd-gold-bright); }

/* ---- phone fit ---- */
/* In the card layout the 30-day availability strip shares the row with its label, so the days
   shrink to fit the card instead of pushing it wider than the screen. */
@media (max-width: 991.98px) {
    table.table.table-cards .calendar-strip { width: 100%; }
    table.table.table-cards .calendar-day { flex: 1 1 0; width: auto; min-width: 2px; }
}
/* Six labelled steps have to fit a 375px screen: smaller labels, no minimum width. */
@media (max-width: 575.98px) {
    .pipeline li { min-width: 0; font-size: 0.62rem; padding-top: 1.55rem; line-height: 1.15; }
}

/* ---- tables that are a statement, not a list ------------------------------ */
/* A worked-out payslip: label, a small note, an amount. On a phone the amount stays beside its label and the note drops underneath,
   instead of three columns squeezed side by side. */
@media (max-width: 575.98px) {
    table.table-statement, table.table-statement > tbody { display: block; width: 100%; }
    table.table-statement > tbody > tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 0.75rem; border-bottom: 1px solid var(--bs-border-color-translucent, #e5e7eb); }
    table.table-statement > tbody > tr > * { border: 0; padding: 0.3rem 0.4rem; min-width: 0; overflow-wrap: anywhere; }
    table.table-statement > tbody > tr > :first-child { grid-column: 1; grid-row: 1; }
    table.table-statement > tbody > tr > :last-child { grid-column: 2; grid-row: 1; text-align: right; }
    table.table-statement > tbody > tr > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; padding-top: 0; }
    table.table-statement > tbody > tr > td:nth-child(2):empty { display: none; }
}

/* Rows of inputs that must stay a table (the payroll bands): equal columns that shrink with the screen. */
table.table-fixed { table-layout: fixed; width: 100%; }
table.table-fixed .form-control, table.table-fixed .form-select { min-width: 0; width: 100%; }

/* ---- sorting a table by its column headings (core/js/app.js) ------------------------------------------ */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable::after { content: "\2195"; margin-left: 0.35em; font-size: 0.8em; opacity: 0.25; }
th.sortable:hover::after { opacity: 0.6; }
th.sortable[aria-sort="ascending"]::after { content: "\2191"; opacity: 0.95; }
th.sortable[aria-sort="descending"]::after { content: "\2193"; opacity: 0.95; }
th.sortable:focus-visible { outline: 2px solid var(--bnltd-blue); outline-offset: -2px; }
/* Where the headings are hidden (cards, below 992px) a small bar above the list does the sorting. */
.table-sortbar { display: none; gap: 0.5rem; align-items: center; margin-bottom: 0.6rem; }
.table-sortbar .form-select { flex: 1 1 auto; min-width: 0; }
@media (max-width: 991.98px) { .table-sortbar { display: flex; } }
/* The resident's rent, on their home page */
.rent-card { color: inherit; border-left: 4px solid var(--bs-border-color); }
.rent-card.rent-overdue { border-left-color: var(--bs-danger); }
.rent-card.rent-due_soon { border-left-color: var(--bs-warning); }
.rent-card.rent-settled { border-left-color: var(--bs-success); }
/* A maintenance request's photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.5rem; }
.photo-thumb { position: relative; display: block; aspect-ratio: 1; border-radius: 0.5rem; overflow: hidden; background: var(--bs-tertiary-bg); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 0.15rem 0.35rem; font-size: 0.7rem; color: #fff; background: rgba(0, 0, 0, 0.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
