/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
    --sidebar-width: 232px;
    --sidebar-bg: #1b2b3c;
    --sidebar-hover: rgba(255,255,255,.06);
    --sidebar-active: rgba(67,97,238,.18);
    --sidebar-active-border: #4361ee;
    --sidebar-text: #8fa8be;
    --sidebar-text-hover: #dce8f4;
    --sidebar-text-active: #7ba7f7;
    --sidebar-divider: rgba(255,255,255,.07);

    --body-bg: #eef0f5;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
    --card-radius: 8px;
    --border-color: #e2e8f0;

    --primary: #4361ee;
    --primary-dark: #3451d1;
    --text-primary: #1a2a3a;
    --text-secondary: #64748b;
    --text-muted-custom: #94a3b8;
}

/* ─── Reset / Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--body-bg);
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ─── App shell ──────────────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.22s ease, min-width 0.22s ease;
}

/* ─── Light nav theme ────────────────────────────────────────────────────── */
.sidebar--light {
    --sidebar-bg:           #f5e8e2;
    --sidebar-hover:        rgba(67,97,238,.07);
    --sidebar-active:       rgba(67,97,238,.12);
    --sidebar-active-border:#4361ee;
    --sidebar-text:         #64748b;
    --sidebar-text-hover:   #1a2a3a;
    --sidebar-text-active:  #4361ee;
    --sidebar-divider:      rgba(0,0,0,.07);
    border-right: 1px solid #f0e0d8;
}
.sidebar--light .sidebar-brand    { border-bottom: 1px solid #f0e0d8; }
.sidebar--light .sidebar-footer   { border-top: 1px solid #f0e0d8; }
.sidebar--light .sidebar-avatar   { background: #f0e0d8; color: #4361ee; }
.sidebar--light .sidebar-user-name{ color: #1a2a3a; }
.sidebar--light .sidebar-user-role{ color: #94a3b8; }
.sidebar--light .sidebar-logo     { content: url('/xacct_logo_dark.svg'); }

/* Warm content background when light nav is active */
body:has(.sidebar--light) {
    background: #FFF8F6;
}
body:has(.sidebar--light) .card {
    box-shadow: 0 1px 3px rgba(180,100,60,.06), 0 1px 2px rgba(180,100,60,.04);
}

/* ─── Collapsed sidebar (icon-only) ─────────────────────────────────────── */
.sidebar--collapsed {
    width: 56px;
    min-width: 56px;
}

.sidebar--collapsed .sidebar-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}
.sidebar--collapsed .sidebar-logo { display: none; }
.sidebar--collapsed .sidebar-brand-icon { display: inline-block !important; }

.sidebar--collapsed .sidebar-link span,
.sidebar--collapsed .sidebar-group-toggle span,
.sidebar--collapsed .sidebar-group-toggle .chevron,
.sidebar--collapsed .sidebar-submenu,
.sidebar--collapsed .sidebar-footer .overflow-hidden,
.sidebar--collapsed .sidebar-collapse-btn span { display: none; }

.sidebar--collapsed .sidebar-link,
.sidebar--collapsed .sidebar-group-toggle,
.sidebar--collapsed .sidebar-collapse-btn {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar--collapsed .sidebar-footer { justify-content: center; }

/* Collapse / expand toggle button */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 20px;
    background: none;
    border: none;
    border-top: 1px solid var(--sidebar-divider);
    color: var(--sidebar-text);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.13s, color 0.13s;
    flex-shrink: 0;
    white-space: nowrap;
}
.sidebar-collapse-btn:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-hover);
}
.sidebar-collapse-btn i { font-size: 14px; flex-shrink: 0; }

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--sidebar-divider);
    text-decoration: none;
}

.sidebar-logo {
    width: 261px;
    height: auto;
    margin-left: -10px;
    margin-top: 5px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0 6px;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--sidebar-text);
    padding: 14px 20px 5px;
    opacity: 0.55;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.13s, color 0.13s;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-hover);
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-active-border);
}

.sidebar-link i {
    font-size: 15px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* ─── Collapsible group toggle ───────────────────────────────────────────── */
.sidebar-group-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 20px;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.13s, color 0.13s;
    text-align: left;
}

.sidebar-group-toggle:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-hover);
}

.sidebar-group-toggle.open {
    color: var(--sidebar-text-hover);
}

.sidebar-group-toggle .chevron {
    font-size: 11px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.sidebar-group-toggle.open .chevron {
    transform: rotate(90deg);
}

.sidebar-submenu { background: rgba(0,0,0,.12); }

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--sidebar-divider);
    margin: 4px 16px;
    opacity: 1;
}

.sidebar-submenu .sidebar-link {
    padding-left: 44px;
    font-size: 13px;
    font-weight: 400;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--sidebar-divider);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar {
    width: 31px;
    height: 31px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #dce8f4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--sidebar-text);
}

/* ─── Main wrapper ───────────────────────────────────────────────────────── */
.main-wrapper {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.main-content {
    flex: 1;
    padding: 28px 32px 40px;
    max-width: 1400px;
    width: 100%;
}

/* ─── Page header ────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* ─── Toolbar (search / filter row) ─────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ─── Table container (white card wrapping a table) ─────────────────────── */
.table-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table {
    margin-bottom: 0;
    font-size: 13.5px;
}

.table thead th {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-secondary);
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    padding: 9px 14px;
    white-space: nowrap;
}

.table tbody td {
    padding: 8px 14px;
    border-color: var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tfoot td {
    padding: 9px 14px;
    background: #f8fafc;
    border-top: 2px solid var(--border-color);
    color: var(--text-primary);
}

.table-hover tbody tr:hover td { background: #f3f6ff; }

/* ─── Sortable column headers ─────────────────────────────────────────────── */
.table thead th.sortable {
    cursor: pointer;
    user-select: none;
}
.table thead th.sortable:hover {
    background: #eef1f7;
    color: var(--primary);
}
.table thead th.sortable .sort-icon {
    font-size: 9px;
    margin-left: 4px;
    opacity: 0.3;
    vertical-align: middle;
}
.table thead th.sortable.sorted {
    color: var(--primary);
}
.table thead th.sortable.sorted .sort-icon {
    opacity: 1;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    padding: 14px 20px;
    font-size: 14px;
}

.card-body { padding: 20px; }

/* ─── Stat cards ─────────────────────────────────────────────────────────── */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 18px 20px;
}

.stat-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-card--danger {
    border-color: #fecaca;
    background: #fff8f8;
}

/* ─── Dashboard colored stat cards ──────────────────────────────────────── */
.dash-card {
    border-radius: 14px;
    padding: 22px 22px 18px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 18px rgba(0,0,0,.13);
    display: block;
    height: 100%;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: default;
}

a.dash-card { cursor: pointer; }
a.dash-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(0,0,0,.18);
    color: #fff;
}

/* large decorative background icon */
.dash-card-icon {
    position: absolute;
    right: 18px;
    bottom: 12px;
    font-size: 72px;
    opacity: 0.15;
    line-height: 1;
    pointer-events: none;
}

.dash-card-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    opacity: 0.85;
    margin-bottom: 10px;
}

.dash-card-value {
    font-size: 34px;
    font-weight: 700;
    line-height: 1.05;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.dash-card-footer {
    font-size: 12px;
    opacity: 0.88;
}

/* colour variants */
.dash-card--blue  { background: linear-gradient(135deg, #4361ee 0%, #738af8 100%); }
.dash-card--red   { background: linear-gradient(135deg, #ef4444 0%, #f87171 100%); }
.dash-card--green { background: linear-gradient(135deg, #16a34a 0%, #4ade80 100%); }
.dash-card--amber { background: linear-gradient(135deg, #d97706 0%, #fbbf24 100%); }
.dash-card--teal  { background: linear-gradient(135deg, #0d9488 0%, #34d399 100%); }

/* ─── Dashboard section label ────────────────────────────────────────────── */
.dash-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

/* ─── Dashboard quick-action cards ──────────────────────────────────────── */
.dash-action {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 18px;
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: var(--card-shadow);
    height: 100%;
    transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s;
}

.dash-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,.09);
    border-color: #c7d2fe;
    color: var(--text-primary);
    text-decoration: none;
}

.dash-action-icon {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.dash-action-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.dash-action-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ─── Bill / edit-page banner header ────────────────────────────────────── */
.edit-page-banner {
    background: linear-gradient(135deg, #2e4a63 0%, #3d6080 100%);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}
.edit-page-banner .banner-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
}

/* ─── Status pill (read-only indicator, not a button) ───────────────────── */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 11px;
    border-radius: 20px;
    cursor: default;
    user-select: none;
    letter-spacing: .01em;
}
.status-pill .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: currentColor;
    opacity: .85;
}
.status-pill--open         { color: #4361ee; background: rgba(67,97,238,.1);  }
.status-pill--partialpaid  { color: #b45309; background: rgba(180,83,9,.1);   }
.status-pill--paid         { color: #16a34a; background: rgba(22,163,74,.1);  }
.status-pill--void         { color: #6c757d; background: rgba(108,117,125,.1);}

/* Dark-background variants (used inside the banner header) */
.status-pill--dark.status-pill--open        { color: #93c5fd; background: rgba(147,197,253,.18); }
.status-pill--dark.status-pill--partialpaid { color: #fcd34d; background: rgba(252,211,77,.18);  }
.status-pill--dark.status-pill--paid        { color: #86efac; background: rgba(134,239,172,.18); }
.status-pill--dark.status-pill--void        { color: rgba(255,255,255,.55); background: rgba(255,255,255,.1); }

/* ─── Clickable report cards ─────────────────────────────────────────────── */
.report-card {
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s;
}
.report-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,.09);
}

/* Large decorative icon sitting in the bottom-right of the card */
.report-card-bg-icon {
    position: absolute;
    bottom: -8px;
    right: 10px;
    font-size: 80px;
    opacity: 0.08;
    pointer-events: none;
    line-height: 1;
    transition: opacity 0.14s;
}
.report-card:hover .report-card-bg-icon {
    opacity: 0.13;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 6px;
    padding: 7px 16px;
    transition: all 0.14s;
}

.btn-sm { padding: 4px 10px; font-size: 12.5px; }

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-color);
    background: #fff;
}
.btn-outline-secondary:hover {
    background: #f1f5f9;
    color: var(--text-primary);
    border-color: #cbd5e1;
}

/* ─── Form controls ──────────────────────────────────────────────────────── */
.form-control, .form-select {
    border-color: var(--border-color);
    border-radius: 6px;
    font-size: 13.5px;
    padding: 8px 12px;
    color: var(--text-primary);
    background-color: #fff;
    transition: border-color .15s, box-shadow .15s;
}

/* Restore Bootstrap's caret clearance (our padding override kills the 2.25rem right padding) */
.form-select { padding-right: 2.25rem; }

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,.12);
    outline: none;
}

.form-label {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.form-check-input[type=checkbox] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid #b8c9d9;
    border-radius: 5px;
    background-color: #fff;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
    vertical-align: middle;
    margin-top: 0.1em;
    flex-shrink: 0;
}

.form-check-input[type=checkbox]:hover {
    border-color: var(--primary);
}

.form-check-input[type=checkbox]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='m2.5 8 4 4 7-8'/%3e%3c/svg%3e");
    background-size: 11px 11px;
    background-repeat: no-repeat;
    background-position: center;
}

.form-check-input[type=checkbox]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,.15);
    outline: none;
}

.form-check-input[type=checkbox]:indeterminate {
    background-color: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-width='2.5' d='M3 8h10'/%3e%3c/svg%3e");
    background-size: 11px 11px;
    background-repeat: no-repeat;
    background-position: center;
}

.form-check-label {
    cursor: pointer;
    vertical-align: middle;
    line-height: 1.4;
}

.form-control-sm { padding: 5px 9px; font-size: 13px; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.2px;
}

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert { border-radius: 7px; font-size: 13.5px; }

/* ─── Modals ─────────────────────────────────────────────────────────────── */
.modal-content {
    border: none;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
}

.modal-header { border-bottom: 1px solid var(--border-color); padding: 16px 20px; }
.modal-footer { border-top: 1px solid var(--border-color); padding: 14px 20px; }
.modal-body { padding: 20px; font-size: 14px; }

/* ─── Validation ─────────────────────────────────────────────────────────── */
.valid.modified:not([type=checkbox]) { outline: 2px solid #22c55e; outline-offset: -1px; }
.invalid { outline: 2px solid #ef4444; outline-offset: -1px; }
.validation-message { color: #dc2626; font-size: 12px; margin-top: 3px; }

/* ─── Blazor error boundary ──────────────────────────────────────────────── */
.blazor-error-boundary {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 7px;
    padding: 1rem 1rem 1rem 3.5rem;
    color: #991b1b;
}
.blazor-error-boundary::before {
    content: "⚠";
    font-size: 1.5rem;
    margin-right: .5rem;
    float: left;
}

#blazor-error-ui {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    bottom: 16px;
    right: 16px;
    padding: 12px 16px;
    position: fixed;
    font-size: 13px;
    z-index: 9999;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    margin-left: 10px;
    font-weight: bold;
    float: right;
    opacity: .6;
}
#blazor-error-ui .dismiss:hover { opacity: 1; }

/* ─── Mobile topbar ──────────────────────────────────────────────────────── */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: var(--sidebar-bg);
    z-index: 1060;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.hamburger-btn {
    background: none;
    border: none;
    color: var(--sidebar-text-hover);
    font-size: 20px;
    padding: 4px 6px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.13s;
    flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--sidebar-hover); }

.mobile-brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--sidebar-text-hover);
    text-decoration: none;
}
.mobile-brand:hover { color: var(--sidebar-text-hover); }

/* ─── Sidebar overlay (mobile backdrop) ─────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1045;
}

/* ─── Responsive breakpoint ──────────────────────────────────────────────── */
@media (max-width: 767.98px) {
    /* Show the mobile topbar */
    .mobile-topbar { display: flex; }

    /* Hide the desktop collapse button on mobile */
    .sidebar-collapse-btn { display: none; }

    /* When collapsed on desktop and viewed on mobile, skip the slide-off animation
       so the sidebar is immediately hidden and the hamburger appears at once.
       Opening animation is preserved because .mobile-open removes this selector match. */
    .sidebar--collapsed:not(.mobile-open) {
        transition: none;
    }

    /* Show the backdrop when sidebar is open */
    .sidebar-overlay { display: block; }

    /* Sidebar becomes a fixed off-screen drawer; override collapse width */
    .sidebar,
    .sidebar--collapsed {
        position: fixed;
        top: 0; left: 0;
        height: 100%;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: none;
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
    }

    /* Slide in when open */
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.3);
    }

    /* Main content fills full width and clears the topbar */
    .main-wrapper { width: 100%; }
    .main-content { padding-top: 72px; }

    /* When a collapsed sidebar is opened via the hamburger, restore full layout */
    .sidebar--collapsed.mobile-open .sidebar-logo { display: inline; }
    .sidebar--collapsed.mobile-open .sidebar-brand-icon { display: none !important; }
    .sidebar--collapsed.mobile-open .sidebar-brand { padding: 16px 18px 14px; }

    .sidebar--collapsed.mobile-open .sidebar-link span,
    .sidebar--collapsed.mobile-open .sidebar-group-toggle span,
    .sidebar--collapsed.mobile-open .sidebar-group-toggle .chevron { display: inline; }

    .sidebar--collapsed.mobile-open .sidebar-submenu { display: block; }
    .sidebar--collapsed.mobile-open .sidebar-footer .overflow-hidden { display: block; }

    .sidebar--collapsed.mobile-open .sidebar-link,
    .sidebar--collapsed.mobile-open .sidebar-group-toggle {
        justify-content: flex-start;
        padding: 9px 20px;
    }

    .sidebar--collapsed.mobile-open .sidebar-footer { justify-content: flex-start; }
}

/* ─── Tab switcher ───────────────────────────────────────────────────────── */
.tab-switcher {
    display: flex;
    align-items: flex-end;
    border-bottom: 2px solid #d0d8ea;
    margin-bottom: 24px;
    gap: 3px;
    padding: 0 2px;
}

.tab-switcher-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    border: 1px solid #d0d8ea;
    border-bottom: none;
    border-radius: 7px 7px 0 0;
    background: #d4dae8;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    line-height: 1.3;
    margin-bottom: -2px;
}

.tab-switcher-btn:hover:not(.tab-switcher-btn--active) {
    background: #c8cfe0;
    color: var(--text-primary);
}

.tab-switcher-btn--active {
    background: #fff;
    color: var(--primary);
    font-weight: 600;
    border-color: #d0d8ea;
    border-bottom-color: #fff;
}

.tab-switcher-btn i {
    font-size: 14px;
    opacity: 0.75;
}

.tab-switcher-btn--active i {
    opacity: 1;
}

/* ─── Vendor searchable select ──────────────────────────────────────────── */
.vendor-select-wrap {
    position: relative;
}

/* The input looks like a form-select but without the dropdown arrow — we draw our own list */
.vendor-select-wrap input.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    cursor: text;
}

.vendor-dd-list {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,.10);
    z-index: 1055;
    max-height: 240px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.vendor-dd-item {
    padding: 8px 12px;
    font-size: 13.5px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vendor-dd-item:hover,
.vendor-dd-item--active {
    background: #f3f6ff;
    color: var(--primary);
}

.vendor-dd-item--active {
    font-weight: 600;
}

.vendor-dd-code {
    font-size: 11px;
    font-weight: 700;
    background: var(--primary);
    color: #fff;
    border-radius: 3px;
    padding: 1px 5px;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.vendor-dd-empty {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
}

.vendor-dd-item--all {
    border-bottom: 1px solid #e2e8f0;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ─── Scrollbars ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5cfe0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Telerik Report Viewer ──────────────────────────────────────────────── */
.report-viewer-wrapper {
    /* Fill the remaining vertical space in the content area */
    height: calc(100vh - 140px);
    min-height: 500px;
    overflow: hidden;
}

/* Make the viewer itself fill its container */
.report-viewer-wrapper .trv-report-viewer {
    width: 100%;
    height: 100%;
}

/* ─── AP Aging Report ────────────────────────────────────────────────────── */
.aging-summary thead th {
    font-size: 12px;
    white-space: nowrap;
}

.vendor-group-heading {
    background: #f1f5f9;
    border-left: 3px solid var(--primary);
    padding: 6px 12px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    border-radius: 0 4px 4px 0;
    margin-bottom: 0;
}

/* ─── Print styles ───────────────────────────────────────────────────────── */
@media print {
    /* Hide navigation chrome */
    .sidebar,
    .mobile-topbar,
    .sidebar-overlay {
        display: none !important;
    }

    /* Let the main wrapper fill the page */
    .app-layout {
        display: block;
        height: auto;
        overflow: visible;
    }

    .main-wrapper {
        overflow: visible;
        width: 100%;
    }

    .main-content {
        padding: 16px 24px;
    }

    /* Avoid breaking cards and rows mid-page */
    .card          { break-inside: avoid; }
    tr             { break-inside: avoid; }
    thead          { display: table-header-group; }   /* repeat on every page */

    /* Keep vendor headings glued to their table */
    .vendor-group-heading { break-after: avoid; }

    /* Colour adjustments for print */
    .table-dark,
    .table-dark th,
    .table-dark td {
        background-color: #1b2b3c !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .table-light,
    .table-light th,
    .table-light td {
        background-color: #f8f9fa !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Ensure alternating row colours print */
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ─── Placeholder text ───────────────────────────────────────────────────── */
::placeholder {
    color: #b0bec5 !important;
    opacity: 1;
}
