:root {
    /* ============================================================
       BRAND PALETTE — logo colors only.
       Navy, Red, Off-white (from public/img/logo.jpeg) + bold black.
       No other hues are allowed anywhere in the theme.
       ============================================================ */
    --brand-navy: #2A287B;
    --brand-red: #FA1615;
    --brand-white: #F7F7F7;
    --brand-black: #000000;

    /* Shades / tints of the SAME four colors (no new hues) */
    --brand-navy-hover: #1E1C5C;
    --brand-navy-light: rgba(42, 40, 123, 0.10);
    --brand-navy-soft: rgba(42, 40, 123, 0.06);
    --brand-red-hover: #C41110;
    --brand-red-light: rgba(250, 22, 21, 0.10);
    --brand-black-muted: rgba(0, 0, 0, 0.55);
    --brand-black-soft: rgba(0, 0, 0, 0.06);
    --brand-border: rgba(0, 0, 0, 0.12);

    /* Legacy aliases — old variable names keep working */
    --brand-primary: var(--brand-navy);
    --brand-primary-hover: var(--brand-navy-hover);
    --brand-primary-light: var(--brand-navy-light);
    --brand-danger: var(--brand-red);
    --brand-danger-light: var(--brand-red-light);
    --brand-dark: var(--brand-black);
    --brand-gray: var(--brand-black-muted);
    --brand-bg: var(--brand-white);
    --card-bg: #FFFFFF;
    --card-border: var(--brand-border);
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
    --text-main: var(--brand-black);
}

html {
    font-size: 12px;
}

body {
    background-color: var(--brand-bg);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-main);
}

.container-fluid {
    padding: 1rem !important;
}

.row {
    --bs-gutter-x: 0.75rem;
    --bs-gutter-y: 0.75rem;
}

.card {
    margin-bottom: 1rem;
}

.card-body {
    padding: 1rem !important;
}

.card-header {
    padding: 0.875rem 1rem !important;
}

.sidebar-desktop {
    width: 220px;
    transition: width 0.3s ease;
}

.main-content {
    margin-left: 220px;
    transition: margin-left 0.3s ease;
}

body.sidebar-collapsed .sidebar-desktop {
    width: 70px;
}

body.sidebar-collapsed .main-content {
    margin-left: 70px;
}

body.sidebar-collapsed .sidebar-desktop span {
    display: none;
}

body.sidebar-collapsed .sidebar-desktop h5 {
    display: none;
}

body.sidebar-collapsed .sidebar-desktop .logo-area {
    justify-content: center !important;
    padding: 1rem 0;
}

body.sidebar-collapsed .sidebar-desktop .nav-link {
    justify-content: center;
}

body.sidebar-collapsed .sidebar-desktop .nav-link i {
    margin: 0 !important;
}

.logo-area {
    padding: 1rem 1.25rem;
}

.nav-link {
    padding: 0.55rem 0.75rem;
}

.topbar {
    padding: 0.75rem 1rem;
}

.form-control, .form-select {
    padding: 0.5rem 0.75rem;
}

/* Auth Pages */
.login-bg {
    /* background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-hover)); */
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.login-card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 400px;
}

.text-dark-custom { color: var(--brand-dark) !important; }

/* Dashboard Layout */
.wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    background-color: var(--card-bg);
    color: var(--text-main);
    border-right: 1px solid var(--card-border);
}

.sidebar-desktop {
    width: 250px;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: width 0.3s ease;
    overflow-x: hidden;
}

body.sidebar-collapsed .sidebar-desktop {
    width: 80px;
}

body.sidebar-collapsed .sidebar-desktop .logo-area h5,
body.sidebar-collapsed .sidebar-desktop .nav-link span,
body.sidebar-collapsed .sidebar-desktop .logout-text {
    display: none;
}

body.sidebar-collapsed .sidebar-desktop .nav-link {
    text-align: center;
    padding: 0.75rem 0;
}

body.sidebar-collapsed .sidebar-desktop .nav-link i {
    margin: 0 !important;
    font-size: 1.25rem;
}

body.sidebar-collapsed .sidebar-desktop .logo-area {
    justify-content: center !important;
    padding: 1.5rem 0;
}

.main-content {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

body.sidebar-collapsed .main-content {
    margin-left: 80px;
}

@media (max-width: 767.98px) {
    .main-content { margin-left: 0; }
}

.logo-area {
    padding: 1.5rem;
    border-bottom: 1px solid var(--brand-border);
}
.nav-link {
    color: var(--brand-gray);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.25rem;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover, .nav-link.active {
    color: var(--brand-primary);
    background-color: var(--brand-primary-light);
}

.nav-link.active {
    color: var(--brand-primary);
    background-color: var(--brand-primary-light);
    font-weight: 600;
}

.topbar {
    background: var(--brand-bg);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Cards & Elements */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--card-border);
    padding: 1.25rem 1.5rem;
}

.btn-primary {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-primary:hover {
    background-color: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
}

/* Form controls */
.form-control, .form-select {
    border-radius: 8px;
    padding: 0.6rem 1rem;
    border-color: var(--brand-border);
}

/* Buttons share the inputs' vertical padding so a control and a button sitting
   in the same row are exactly the same height. The rule above overrides
   Bootstrap's own form-control padding; without matching the buttons, every
   input + button row came out uneven (inputs 32px, buttons 24px). */
.btn {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

/* Same for the small tier — Bootstrap's .form-control-sm padding is overridden
   by the rule above too, so .btn-sm has to track it rather than its own. */
.btn-sm {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

/* btn-close is an icon box, not a text button — keep Bootstrap's own sizing. */
.btn-close {
    padding-top: 0.25em;
    padding-bottom: 0.25em;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 0.25rem rgba(42, 40, 123, 0.25);
}

/* Custom Checkbox Highlights */
.service-check-wrapper {
    border: 1px solid var(--brand-border);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s;
    cursor: pointer;
    background: #FFFFFF;
}
.service-check-wrapper:hover {
    border-color: var(--brand-primary);
}
.service-check-wrapper.checked {
    border-color: var(--brand-primary);
    background-color: var(--brand-primary-light);
}

.timeline {
    /* Line geometry lives here so the marker can be centred off it rather than
       a hand-tuned offset that drifts whenever the padding changes. */
    --timeline-line: 2px;
    --timeline-gap: 1.5rem;
    --timeline-dot: 14px;

    border-left: var(--timeline-line) solid var(--brand-border);
    padding-left: var(--timeline-gap);
    position: relative;
    margin-left: 1rem;
}
.timeline-item {
    margin-bottom: 1.5rem;
    position: relative;
}
/* The single timeline marker. Its horizontal centre sits exactly on the
   vertical line: step back the padding, then half the line, then half the dot. */
.timeline-item::before {
    content: '';
    position: absolute;
    left: calc(-1 * (var(--timeline-gap) + var(--timeline-line) / 2 + var(--timeline-dot) / 2));
    top: 0.35rem;
    width: var(--timeline-dot);
    height: var(--timeline-dot);
    border-radius: 50%;
    background: var(--brand-navy);
    border: 3px solid #FFFFFF;
    box-shadow: 0 0 0 2px var(--brand-navy);
}

/* ============================================================
   BOOTSTRAP COLOR REMAP
   Every Bootstrap semantic color is folded onto the logo palette:
     primary / info / success  -> navy
     danger  / warning         -> red
     secondary / muted         -> black @ 55%
     light                     -> off-white
     dark / body               -> black
   Loaded after bootstrap.min.css, so these win.
   ============================================================ */
:root {
    --bs-primary: #2A287B;
    --bs-primary-rgb: 42, 40, 123;
    --bs-info: #2A287B;
    --bs-info-rgb: 42, 40, 123;
    --bs-success: #2A287B;
    --bs-success-rgb: 42, 40, 123;

    --bs-danger: #FA1615;
    --bs-danger-rgb: 250, 22, 21;
    --bs-warning: #FA1615;
    --bs-warning-rgb: 250, 22, 21;

    --bs-secondary: #000000;
    --bs-secondary-rgb: 0, 0, 0;

    --bs-light: #F7F7F7;
    --bs-light-rgb: 247, 247, 247;
    --bs-dark: #000000;
    --bs-dark-rgb: 0, 0, 0;

    --bs-body-color: #000000;
    --bs-body-color-rgb: 0, 0, 0;
    --bs-body-bg: #F7F7F7;
    --bs-body-bg-rgb: 247, 247, 247;
    --bs-emphasis-color: #000000;
    --bs-secondary-color: rgba(0, 0, 0, 0.55);
    --bs-tertiary-color: rgba(0, 0, 0, 0.4);
    --bs-border-color: rgba(0, 0, 0, 0.12);
    --bs-border-color-translucent: rgba(0, 0, 0, 0.12);

    --bs-link-color: #2A287B;
    --bs-link-color-rgb: 42, 40, 123;
    --bs-link-hover-color: #1E1C5C;
    --bs-link-hover-color-rgb: 30, 28, 92;

    --bs-heading-color: #000000;
    --bs-highlight-bg: rgba(250, 22, 21, 0.15);
    --bs-focus-ring-color: rgba(42, 40, 123, 0.25);
}

/* --- Text utilities --- */
.text-muted,
.text-secondary,
.text-body-secondary { color: var(--brand-black-muted) !important; }
.text-dark,
.text-body,
.text-black { color: var(--brand-black) !important; }
.text-primary,
.text-info,
.text-success { color: var(--brand-navy) !important; }
.text-danger,
.text-warning { color: var(--brand-red) !important; }
.text-light { color: var(--brand-white) !important; }

/* Headings + strong text stay bold black */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 { color: var(--brand-black); font-weight: 700; }

/* ...but a heading inside a container that has already set light text on a
   brand background must stay light. Without this, .modal-title (an <h5>) went
   black on a navy .modal-header. */
.text-white h1, .text-white h2, .text-white h3,
.text-white h4, .text-white h5, .text-white h6,
.text-white .h1, .text-white .h2, .text-white .h3,
.text-white .h4, .text-white .h5, .text-white .h6,
.text-white .modal-title, .text-white .card-title,
.bg-primary h1, .bg-primary h2, .bg-primary h3,
.bg-primary h4, .bg-primary h5, .bg-primary h6, .bg-primary .modal-title,
.bg-dark h1, .bg-dark h2, .bg-dark h3,
.bg-dark h4, .bg-dark h5, .bg-dark h6, .bg-dark .modal-title,
.bg-danger h1, .bg-danger h2, .bg-danger h3,
.bg-danger h4, .bg-danger h5, .bg-danger h6, .bg-danger .modal-title {
    color: #FFFFFF !important;
}

/* White text on every solid brand-colored button, in all states.
   Declared after the .btn-* variable blocks so it beats Bootstrap's
   `color: var(--bs-btn-color)` regardless of utility classes on the button. */
.btn-primary, .btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active, .btn-primary:disabled, .btn-primary.disabled,
.btn-info, .btn-info:hover, .btn-info:focus, .btn-info:active,
.btn-success, .btn-success:hover, .btn-success:focus, .btn-success:active,
.btn-danger, .btn-danger:hover, .btn-danger:focus, .btn-danger:active,
.btn-warning, .btn-warning:hover, .btn-warning:focus, .btn-warning:active,
.btn-secondary, .btn-secondary:hover, .btn-secondary:focus, .btn-secondary:active,
.btn-dark, .btn-dark:hover, .btn-dark:focus, .btn-dark:active,
.btn-outline-primary:hover, .btn-outline-primary:active, .btn-outline-primary.active,
.btn-outline-info:hover, .btn-outline-info:active,
.btn-outline-success:hover, .btn-outline-success:active,
.btn-outline-danger:hover, .btn-outline-danger:active,
.btn-outline-warning:hover, .btn-outline-warning:active,
.btn-outline-secondary:hover, .btn-outline-secondary:active,
.btn-outline-dark:hover, .btn-outline-dark:active {
    color: #FFFFFF !important;
}

/* Buttons that get their brand background from an inline style */
.btn[style*="--brand-navy"],
.btn[style*="--brand-red"],
.btn[style*="--brand-black"] {
    color: #FFFFFF !important;
}

/* Avatars / pills painted with a brand background */
.avatar-circle { color: #FFFFFF !important; }

/* --- Background utilities --- */
.bg-primary,
.bg-info,
.bg-success { background-color: rgba(42, 40, 123, var(--bs-bg-opacity, 1)) !important; }
.bg-danger,
.bg-warning { background-color: rgba(250, 22, 21, var(--bs-bg-opacity, 1)) !important; }
.bg-secondary { background-color: rgba(0, 0, 0, calc(0.55 * var(--bs-bg-opacity, 1))) !important; }
.bg-dark { background-color: rgba(0, 0, 0, var(--bs-bg-opacity, 1)) !important; }
.bg-light { background-color: rgba(247, 247, 247, var(--bs-bg-opacity, 1)) !important; }
.bg-body,
.bg-body-tertiary { background-color: var(--brand-white) !important; }

.bg-primary-subtle,
.bg-info-subtle,
.bg-success-subtle { background-color: var(--brand-navy-light) !important; }
.bg-danger-subtle,
.bg-warning-subtle { background-color: var(--brand-red-light) !important; }
.bg-secondary-subtle,
.bg-dark-subtle,
.bg-light-subtle { background-color: var(--brand-black-soft) !important; }

/* --- Borders --- */
.border-primary,
.border-info,
.border-success { border-color: var(--brand-navy) !important; }
.border-danger,
.border-warning { border-color: var(--brand-red) !important; }
.border-secondary,
.border-light,
.border-dark { border-color: var(--brand-border) !important; }

/* --- Solid buttons --- */
.btn-primary, .btn-info, .btn-success {
    --bs-btn-color: #FFFFFF;
    --bs-btn-bg: #2A287B;
    --bs-btn-border-color: #2A287B;
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: #1E1C5C;
    --bs-btn-hover-border-color: #1E1C5C;
    --bs-btn-active-color: #FFFFFF;
    --bs-btn-active-bg: #1E1C5C;
    --bs-btn-active-border-color: #1E1C5C;
    --bs-btn-disabled-color: #FFFFFF;
    --bs-btn-disabled-bg: #2A287B;
    --bs-btn-disabled-border-color: #2A287B;
    --bs-btn-focus-shadow-rgb: 42, 40, 123;
}

.btn-danger, .btn-warning {
    --bs-btn-color: #FFFFFF;
    --bs-btn-bg: #FA1615;
    --bs-btn-border-color: #FA1615;
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: #C41110;
    --bs-btn-hover-border-color: #C41110;
    --bs-btn-active-color: #FFFFFF;
    --bs-btn-active-bg: #C41110;
    --bs-btn-active-border-color: #C41110;
    --bs-btn-disabled-color: #FFFFFF;
    --bs-btn-disabled-bg: #FA1615;
    --bs-btn-disabled-border-color: #FA1615;
    --bs-btn-focus-shadow-rgb: 250, 22, 21;
}

.btn-dark, .btn-secondary {
    --bs-btn-color: #FFFFFF;
    --bs-btn-bg: #000000;
    --bs-btn-border-color: #000000;
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: #1A1A1A;
    --bs-btn-hover-border-color: #1A1A1A;
    --bs-btn-active-color: #FFFFFF;
    --bs-btn-active-bg: #1A1A1A;
    --bs-btn-active-border-color: #1A1A1A;
    --bs-btn-disabled-color: #FFFFFF;
    --bs-btn-disabled-bg: #000000;
    --bs-btn-disabled-border-color: #000000;
    --bs-btn-focus-shadow-rgb: 0, 0, 0;
}

.btn-light {
    --bs-btn-color: #000000;
    --bs-btn-bg: #F7F7F7;
    --bs-btn-border-color: rgba(0, 0, 0, 0.12);
    --bs-btn-hover-color: #000000;
    --bs-btn-hover-bg: #EBEBEB;
    --bs-btn-hover-border-color: rgba(0, 0, 0, 0.2);
    --bs-btn-active-color: #000000;
    --bs-btn-active-bg: #E2E2E2;
    --bs-btn-active-border-color: rgba(0, 0, 0, 0.2);
    --bs-btn-focus-shadow-rgb: 0, 0, 0;
}

/* --- Outline buttons --- */
.btn-outline-primary, .btn-outline-info, .btn-outline-success {
    --bs-btn-color: #2A287B;
    --bs-btn-border-color: #2A287B;
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: #2A287B;
    --bs-btn-hover-border-color: #2A287B;
    --bs-btn-active-color: #FFFFFF;
    --bs-btn-active-bg: #2A287B;
    --bs-btn-active-border-color: #2A287B;
    --bs-btn-disabled-color: #2A287B;
    --bs-btn-disabled-border-color: #2A287B;
    --bs-btn-focus-shadow-rgb: 42, 40, 123;
}

.btn-outline-danger, .btn-outline-warning {
    --bs-btn-color: #FA1615;
    --bs-btn-border-color: #FA1615;
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: #FA1615;
    --bs-btn-hover-border-color: #FA1615;
    --bs-btn-active-color: #FFFFFF;
    --bs-btn-active-bg: #FA1615;
    --bs-btn-active-border-color: #FA1615;
    --bs-btn-disabled-color: #FA1615;
    --bs-btn-disabled-border-color: #FA1615;
    --bs-btn-focus-shadow-rgb: 250, 22, 21;
}

.btn-outline-secondary, .btn-outline-dark, .btn-outline-light {
    --bs-btn-color: #000000;
    --bs-btn-border-color: rgba(0, 0, 0, 0.2);
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: #000000;
    --bs-btn-hover-border-color: #000000;
    --bs-btn-active-color: #FFFFFF;
    --bs-btn-active-bg: #000000;
    --bs-btn-active-border-color: #000000;
    --bs-btn-disabled-color: rgba(0, 0, 0, 0.55);
    --bs-btn-disabled-border-color: rgba(0, 0, 0, 0.2);
    --bs-btn-focus-shadow-rgb: 0, 0, 0;
}

.btn-link {
    --bs-btn-color: #2A287B;
    --bs-btn-hover-color: #1E1C5C;
    --bs-btn-active-color: #1E1C5C;
}

/* --- Badges --- */
/* Backgrounds come from the .bg-* rules above (which honour bg-opacity-*).
   Only set a colour where the markup hasn't chosen one — a tinted chip like
   `badge bg-primary bg-opacity-10 text-primary` must keep its navy text. */
.badge.bg-primary:not([class*="text-"]),
.badge.bg-info:not([class*="text-"]),
.badge.bg-success:not([class*="text-"]),
.badge.bg-danger:not([class*="text-"]),
.badge.bg-warning:not([class*="text-"]),
.badge.bg-secondary:not([class*="text-"]),
.badge.bg-dark:not([class*="text-"]) { color: #FFFFFF; }
.badge.bg-light:not([class*="text-"]) { color: var(--brand-black); }

/* --- Alerts --- */
.alert-primary, .alert-info, .alert-success {
    --bs-alert-color: #2A287B;
    --bs-alert-bg: rgba(42, 40, 123, 0.10);
    --bs-alert-border-color: rgba(42, 40, 123, 0.25);
    --bs-alert-link-color: #1E1C5C;
}
.alert-danger, .alert-warning {
    --bs-alert-color: #C41110;
    --bs-alert-bg: rgba(250, 22, 21, 0.10);
    --bs-alert-border-color: rgba(250, 22, 21, 0.25);
    --bs-alert-link-color: #C41110;
}
.alert-secondary, .alert-dark, .alert-light {
    --bs-alert-color: #000000;
    --bs-alert-bg: rgba(0, 0, 0, 0.06);
    --bs-alert-border-color: rgba(0, 0, 0, 0.12);
    --bs-alert-link-color: #000000;
}

/* --- Tables --- */
.table {
    --bs-table-color: #000000;
    --bs-table-border-color: rgba(0, 0, 0, 0.12);
    --bs-table-striped-bg: rgba(0, 0, 0, 0.03);
    --bs-table-hover-bg: rgba(42, 40, 123, 0.06);
}
.table-primary, .table-info, .table-success {
    --bs-table-bg: rgba(42, 40, 123, 0.10);
    --bs-table-color: #2A287B;
}
.table-danger, .table-warning {
    --bs-table-bg: rgba(250, 22, 21, 0.10);
    --bs-table-color: #C41110;
}
.table-secondary, .table-light, .table-dark {
    --bs-table-bg: rgba(0, 0, 0, 0.06);
    --bs-table-color: #000000;
}
.table > thead { color: var(--brand-black); }

/* --- Forms, focus, controls --- */
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--brand-navy);
    box-shadow: 0 0 0 0.25rem rgba(42, 40, 123, 0.25);
}
.form-check-input:checked {
    background-color: var(--brand-navy);
    border-color: var(--brand-navy);
}
.form-switch .form-check-input:checked { background-color: var(--brand-navy); }
.form-label { color: var(--brand-black); font-weight: 600; }
.invalid-feedback, .form-text.text-danger { color: var(--brand-red) !important; }
.form-control.is-invalid, .was-validated .form-control:invalid { border-color: var(--brand-red); }

/* --- Nav, tabs, pagination, dropdown, progress, spinner --- */
.nav-tabs .nav-link.active { color: var(--brand-navy); border-bottom-color: var(--brand-navy); }
.nav-pills .nav-link.active { background-color: var(--brand-navy); color: #FFFFFF; }
.page-link { color: var(--brand-navy); }
.page-item.active .page-link { background-color: var(--brand-navy); border-color: var(--brand-navy); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--brand-navy); --bs-dropdown-link-color: var(--brand-black); }
.progress-bar { background-color: var(--brand-navy); }
.spinner-border, .spinner-grow { color: var(--brand-navy); }
.list-group-item.active { background-color: var(--brand-navy); border-color: var(--brand-navy); }
a { color: var(--brand-navy); }
a:hover { color: var(--brand-navy-hover); }

/* --- Kill any leftover gradient backgrounds --- */
.avatar-circle { background: var(--brand-navy) !important; }

/* ============================================================
   FILE CARDS — Drive-style tiles for documents and certificates
   Header (type icon + title + ⋮ menu) over a thumbnail of the file.
   ============================================================ */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.file-card {
    background: var(--brand-white);
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
    display: flex;
    flex-direction: column;
}

.file-card:hover {
    border-color: rgba(42, 40, 123, 0.35);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.file-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.5rem 0.625rem 0.75rem;
    background: var(--brand-white);
}

.file-icon {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    color: #FFFFFF;
}

.file-icon-image   { background: var(--brand-navy); }
.file-icon-pdf     { background: var(--brand-red); }
.file-icon-doc     { background: var(--brand-navy); }
.file-icon-sheet   { background: var(--brand-navy); }
.file-icon-missing { background: rgba(0, 0, 0, 0.35); }

.file-card-title {
    font-weight: 600;
    color: var(--brand-black);
    font-size: 0.95rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.file-card-menu {
    border: 0;
    background: transparent;
    color: var(--brand-black-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    line-height: 1;
    flex: 0 0 auto;
}

.file-card-menu:hover,
.file-card-menu[aria-expanded="true"] {
    background: rgba(0, 0, 0, 0.06);
    color: var(--brand-black);
}

/* The thumbnail. Fixed aspect so a grid of mixed file types stays even, and
   the content is top-anchored like a page preview rather than centred. */
.file-card-preview {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #FFFFFF;
    border-top: 1px solid var(--brand-border);
    overflow: hidden;
}

.file-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    background: #FFFFFF;
    display: block;
}

.file-card-preview iframe {
    /* Render at 2x and scale down so the PDF's first page is legible rather
       than a cropped corner. Offset slightly so Chrome's PDF viewer draws its
       hard black page outline outside the clipped area. */
    position: absolute;
    top: -6px;
    left: -6px;
    width: calc(200% + 24px);
    height: calc(200% + 24px);
    border: 0;
    transform: scale(0.5);
    transform-origin: top left;
    pointer-events: none;
    background: #FFFFFF;

    /* Chrome's PDF viewer paints a dark backdrop while it loads, which flashes
       black inside the tile — especially in a tab that starts hidden. Stay
       transparent over the white preview until the document has rendered. */
    opacity: 0;
    transition: opacity 0.2s ease;
}

.file-card-preview iframe.is-loaded { opacity: 1; }

/* Clickable layer over the iframe, which cannot take pointer events itself. */
.file-card-preview-overlay {
    position: absolute;
    inset: 0;
    display: block;
}

.file-card-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    color: var(--brand-black-muted);
    background: var(--brand-white);
}

.file-card-placeholder i { font-size: 2rem; }
.file-card-placeholder span { font-size: 0.75rem; font-weight: 600; }

.file-card-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--brand-border);
    background: var(--brand-white);
}

.file-card-missing { border-style: dashed; }
