/* =====================================================================
   OM Enterprise and BM Associates — Loan Management System
   Design system: neutral surfaces, one brand blue, rounded cards,
   soft shadows, status badges that always pair colour + icon + text.
   ===================================================================== */

:root {
    --brand: #1d4ed8;
    --brand-600: #2563eb;
    --brand-50: #eff4ff;
    --brand-100: #dbe6ff;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e5e9f2;
    --line-2: #eef1f7;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --sidebar: #0d1b3e;
    --sidebar-2: #13244f;
    --sidebar-text: #b9c4dd;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 16px rgba(15, 23, 42, .04);
    --sidebar-w: 268px;
    --topbar-h: 64px;

    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--bg);
    --bs-primary: var(--brand);
    --bs-primary-rgb: 29, 78, 216;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 29, 78, 216;
    --bs-link-hover-color: #1e40af;
    --bs-border-color: var(--line);
    --bs-border-radius: 10px;
    --bs-border-radius-lg: 14px;
}

html { -webkit-text-size-adjust: 100%; }
body { font-size: .9375rem; background: var(--bg); color: var(--ink); overflow-x: hidden; }
h1, h2, h3, h4, h5, h6 { color: var(--ink); font-weight: 600; letter-spacing: -.01em; }
.text-muted, .text-body-secondary { color: var(--muted) !important; }
a { text-underline-offset: 2px; }

/* Accessible focus ring */
:focus-visible { outline: 3px solid rgba(37, 99, 235, .45); outline-offset: 2px; }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 .22rem rgba(37, 99, 235, .25);
    border-color: var(--brand-600);
}
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 2000; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

/* Buttons */
.btn { font-weight: 500; border-radius: 10px; padding: .5rem .95rem; }
.btn-sm { padding: .32rem .65rem; border-radius: 8px; }
.btn-lg { padding: .7rem 1.1rem; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: #1e40af; --bs-btn-hover-border-color: #1e40af; --bs-btn-active-bg: #1e3a8a; --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: #b9ccf7; --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); }
.btn-light { --bs-btn-bg: #f1f4f9; --bs-btn-border-color: #e3e8f1; --bs-btn-hover-bg: #e6ebf3; --bs-btn-hover-border-color: #d9e0eb; color: var(--ink-2); }
.btn-soft { background: var(--brand-50); color: var(--brand); border: 1px solid transparent; }
.btn-soft:hover { background: var(--brand-100); color: #1e40af; }
.btn-icon { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; color: var(--ink-2); border: 0; background: transparent; font-size: 1.2rem; }
.btn-icon:hover { background: #eef2f8; color: var(--ink); }
.btn-action { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--ink-2); background: #f3f6fb; border: 1px solid #e6ebf3; }
.btn-action:hover { background: var(--brand-50); color: var(--brand); border-color: var(--brand-100); }
.btn-action.danger:hover { background: #fdecec; color: #c02626; border-color: #f7cfcf; }

/* Forms */
.form-label { font-weight: 500; font-size: .875rem; color: var(--ink-2); margin-bottom: .35rem; }
.form-control, .form-select { border-radius: 10px; border-color: #d8dee9; padding: .55rem .8rem; min-height: 42px; }
.form-control::placeholder { color: #9aa6ba; }
.form-control[readonly] { background: #f5f7fb; }
.input-group-text { background: #f5f7fb; border-color: #d8dee9; color: var(--muted); }
.req { color: #dc2626; margin-left: 2px; }
.form-text { color: var(--muted); }
.invalid-feedback { font-size: .8125rem; }
.form-check-input { width: 1.1em; height: 1.1em; }
.form-switch .form-check-input { width: 2.2em; }

/* ---------------------------------------------------------------------
   Layout: sidebar + top bar
   --------------------------------------------------------------------- */
.app-shell { min-height: 100vh; }
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; padding: 24px 28px 32px; min-width: 0; outline: none; }
.app-footer { display: flex; justify-content: space-between; gap: 12px; padding: 14px 28px; color: var(--muted); font-size: .8125rem; border-top: 1px solid var(--line); background: var(--surface); }

.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040;
    background: linear-gradient(180deg, var(--sidebar) 0%, #0b1733 100%);
    color: var(--sidebar-text); display: flex; flex-direction: column;
    transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; height: var(--topbar-h); border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-600); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-mark.sm { width: 34px; height: 34px; font-size: 1rem; }
.brand-mark.lg { width: 64px; height: 64px; font-size: 2rem; border-radius: 16px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { color: #fff; font-size: .875rem; font-weight: 600; white-space: normal; }
.brand-text small { color: #8ea0c6; font-size: .72rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px 24px; scrollbar-width: thin; scrollbar-color: #2a3b66 transparent; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 11px; width: 100%;
    color: var(--sidebar-text); padding: 9px 12px; border-radius: 10px; font-size: .875rem; font-weight: 500;
    background: none; border: 0; text-align: left; text-decoration: none; margin-bottom: 2px; min-height: 40px;
}
.sidebar-nav .nav-link > .bi:first-child { font-size: 1.05rem; width: 20px; text-align: center; opacity: .9; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--brand-600); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.sidebar-nav .nav-group .nav-caret { margin-left: auto; font-size: .75rem; transition: transform .2s; }
.sidebar-nav .nav-group.collapsed .nav-caret { transform: rotate(-90deg); }
.sidebar-nav .nav-group:not(.collapsed) { color: #fff; }
.nav-sub { padding: 2px 0 6px 18px; border-left: 1px solid rgba(255,255,255,.08); margin-left: 21px; }
.nav-sub .nav-link { font-size: .8375rem; padding: 7px 10px; min-height: 36px; }
.nav-sub .nav-link.active { background: rgba(37,99,235,.9); box-shadow: none; }
.nav-badge { margin-left: auto; background: rgba(255,255,255,.12); border-radius: 20px; padding: 1px 8px; font-size: .7rem; }
.sidebar-backdrop { display: none; }

.topbar {
    position: sticky; top: 0; z-index: 1030; height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px; padding: 0 20px 0 28px;
    background: rgba(255,255,255,.92); backdrop-filter: saturate(160%) blur(8px);
    border-bottom: 1px solid var(--line);
}
.topbar-brand { display: inline-flex; align-items: center; }
/* margin-right:auto pushes Text size, notifications and the user menu to the right edge */
.global-search { position: relative; flex: 1; max-width: 520px; margin-right: auto; }
.global-search > .bi-search { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.global-search .form-control { padding-left: 38px; background: #f3f6fb; border-color: transparent; }
.global-search .form-control:focus { background: #fff; }
.search-results { width: 100%; max-height: 420px; overflow-y: auto; padding: 6px; border-radius: 12px; box-shadow: var(--shadow); border-color: var(--line); }
.search-results.show { display: block; top: calc(100% + 6px); left: 0; }
.search-results .dropdown-item { border-radius: 8px; padding: 8px 10px; white-space: normal; }
.search-results .result-title { font-weight: 600; font-size: .875rem; }
.search-results .result-sub { font-size: .78rem; color: var(--muted); }
.search-results .dropdown-header { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 40px; border: 1px solid transparent; }
.user-chip:hover { background: #f1f4f9; }
.user-chip-text { flex-direction: column; align-items: flex-start; line-height: 1.15; text-align: left; }
.user-chip-text strong { font-size: .8375rem; font-weight: 600; }
.user-chip-text small { font-size: .72rem; color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-100); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .8rem; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 96px; height: 96px; font-size: 1.8rem; }

.notif-count { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 10px; background: #dc2626; color: #fff; font-size: .68rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.notif-menu { width: 360px; max-width: calc(100vw - 24px); padding: 0; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); border-color: var(--line); }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line-2); text-decoration: none; color: var(--ink); }
.notif-item:hover { background: #f7f9fc; }
.notif-item.unread { background: #f5f8ff; }
.notif-item .notif-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-50); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-item .notif-title { font-weight: 600; font-size: .8375rem; }
.notif-item .notif-msg { font-size: .8rem; color: var(--ink-2); word-break: break-word; }
.notif-item .notif-time { font-size: .72rem; color: var(--muted); }
.notif-foot { display: block; text-align: center; padding: 10px; font-size: .8375rem; font-weight: 500; text-decoration: none; background: #fafbfd; }

.crumbs .breadcrumb { font-size: .8125rem; margin-bottom: 10px; --bs-breadcrumb-divider-color: #a3aec2; }
.crumbs .breadcrumb a { color: var(--muted); text-decoration: none; }
.crumbs .breadcrumb a:hover { color: var(--brand); }

/* Page header */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 1.45rem; margin: 0; }
.page-head .page-sub { color: var(--muted); margin: 4px 0 0; font-size: .875rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------------------
   Cards, stats
   --------------------------------------------------------------------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-header h2, .card-header h3, .card-title { font-size: 1rem; margin: 0; font-weight: 600; }
.card-body { padding: 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; min-width: 0; }
a.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); color: inherit; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; color: var(--ink); word-break: break-word; }
.stat-value.money { font-size: 1.25rem; }
.stat-foot { font-size: .75rem; color: var(--muted); margin-top: 2px; }

/* Tone helpers (icon backgrounds, badges) */
.tone-secondary { background: #eef1f5; color: #475569; }
.tone-primary { background: #e6eeff; color: #1d4ed8; }
.tone-info { background: #e0f5fb; color: #0e7490; }
.tone-success { background: #e3f6ea; color: #15803d; }
.tone-teal { background: #dff5f1; color: #0f766e; }
.tone-warning { background: #fff1de; color: #b45309; }
.tone-danger { background: #fde8e8; color: #b91c1c; }
.tone-purple { background: #f1e9fe; color: #7e22ce; }
.tone-dark { background: #e5e7eb; color: #111827; }

/* Stage badges: colour + icon + text (never colour alone) */
.badge-stage { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px 4px 8px; border-radius: 20px; font-size: .75rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap; border: 1px solid transparent; line-height: 1.3; }
.badge-stage .bi { font-size: .8rem; }
.stage-secondary { background: #eef1f5; color: #3f4b5e; border-color: #dde2ea; }
.stage-primary { background: #e6eeff; color: #1e40af; border-color: #cddbfd; }
.stage-info { background: #e0f5fb; color: #0e6a82; border-color: #bfe8f4; }
.stage-success { background: #e3f6ea; color: #166534; border-color: #c4ebd2; }
.stage-teal { background: #dff5f1; color: #115e59; border-color: #bde9e1; }
.stage-warning { background: #fff1de; color: #9a4a06; border-color: #fbdcb2; }
.stage-danger { background: #fde8e8; color: #a61b1b; border-color: #f8caca; }
.stage-purple { background: #f1e9fe; color: #6b21a8; border-color: #e0cffc; }
.stage-dark { background: #e5e7eb; color: #111827; border-color: #d1d5db; }
.badge-status { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.badge-status.is-active { background: #e3f6ea; color: #166534; }
.badge-status.is-inactive { background: #eef1f5; color: #475569; }
.badge-soft { background: var(--brand-50); color: var(--brand); font-weight: 600; font-size: .72rem; padding: 3px 8px; border-radius: 6px; }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Positioned so absolutely-positioned children (e.g. .visually-hidden labels) can't leak past the scroll area. */
.table-responsive { position: relative; }
.table-app { margin: 0; font-size: .875rem; --bs-table-bg: transparent; }
.table-app thead th { background: #f7f9fc; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; border-bottom: 1px solid var(--line); padding: 11px 14px; white-space: nowrap; vertical-align: middle; }
.table-app tbody td { padding: 12px 14px; border-color: var(--line-2); vertical-align: middle; }
.table-app tbody tr:hover > * { background: #fafbfe; }
.table-app tfoot td { background: #f7f9fc; font-weight: 600; padding: 12px 14px; }
.table-app .app-no { font-weight: 600; color: var(--brand); text-decoration: none; white-space: nowrap; font-size: .8125rem; }
.table-app .app-no:hover { text-decoration: underline; }
/* Date opens the application too; looks like normal text until hovered */
.table-app .date-link { color: inherit; text-decoration: none; }
.table-app .date-link:hover, .table-app .date-link:focus-visible { color: var(--brand); text-decoration: underline; }
.th-sort { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.th-sort .bi { font-size: .7rem; opacity: .45; }
.th-sort.sorted .bi { opacity: 1; color: var(--brand); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.nowrap { white-space: nowrap; }
.min-w-0 { min-width: 0; }
/* Long text in grid cells (remarks, references): two lines max, full text on hover */
.cell-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 240px; white-space: normal; }
@media (max-width: 767.98px) { .cell-clamp { max-width: 60vw; text-align: right; } }
/* Header text-size menu */
.font-size-menu { min-width: 180px; }
.font-size-menu .font-check { visibility: hidden; color: var(--brand); }
.font-size-menu [aria-checked="true"] .font-check { visibility: visible; }
.font-size-menu [aria-checked="true"] { font-weight: 600; }
.amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-check { width: 40px; }

.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: .8375rem; color: var(--muted); }
.pagination { margin: 0; --bs-pagination-border-radius: 8px; --bs-pagination-color: var(--ink-2); --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-font-size: .8375rem; flex-wrap: wrap; gap: 4px; }
.pagination .page-link { border-radius: 8px !important; min-width: 36px; text-align: center; }
.form-select-sm.w-auto { min-width: 76px; }
.bulk-bar { display: none; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; background: var(--brand-50); border-bottom: 1px solid var(--brand-100); font-size: .875rem; }
.bulk-bar.show { display: flex; }

/* Mobile: turn tables into stacked cards */
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { border: 1px solid var(--line); border-radius: 12px; margin: 10px 12px; width: auto; background: #fff; padding: 6px 0; box-shadow: var(--shadow-sm); }
    .table-stack tbody td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 7px 14px; text-align: right; }
    .table-stack tbody td::before { content: attr(data-label); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; text-align: left; flex-shrink: 0; }
    .table-stack tbody td[data-label=""]::before { content: none; }
    .table-stack tbody td.td-primary { font-size: .9375rem; padding-top: 10px; }
    .table-stack tbody td.td-actions { justify-content: flex-end; border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 10px; }
    .table-stack tbody td.td-actions::before { content: none; }
    .table-stack tbody td.col-check { position: absolute; width: auto; padding: 10px 12px; }
    /* Cards always lead with the primary cell (e.g. application no.), whatever the column order. */
    .table-stack tbody tr { display: flex; flex-direction: column; }
    .table-stack tbody td.td-primary { order: -1; }
    .table-stack tbody td.col-check ~ td.td-primary { padding-left: 46px; justify-content: flex-start; }
    .table-stack tr { position: relative; }
    .table-stack tbody td.empty-cell { display: block; text-align: center; }
    .table-stack tbody td.empty-cell::before { content: none; }
    .table-stack tfoot { display: block; }
    .table-stack tfoot tr { display: flex; flex-wrap: wrap; margin: 10px 12px; border-radius: 12px; }
    .table-stack tfoot td { display: block; border: 0; }
    .table-stack tbody tr:hover > * { background: transparent; }
}

/* Skeleton loading */
.skeleton { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 50%, #eef1f6 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition: none !important; } }
.loading-overlay { position: absolute; inset: 0; background: rgba(255,255,255,.6); display: none; align-items: flex-start; justify-content: center; padding-top: 80px; z-index: 5; }
.loading-overlay.show { display: flex; }

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state .empty-icon { width: 72px; height: 72px; border-radius: 20px; background: var(--brand-50); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-size: 2rem; margin-bottom: 14px; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 6px; }
.empty-state p { color: var(--muted); max-width: 420px; margin: 0 auto 18px; }

/* Filters */
.filter-card .card-body { padding: 16px 18px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.filter-toggle { display: none; }
@media (max-width: 767.98px) {
    .filter-toggle { display: flex; }
    .filter-collapsible:not(.show) { display: none; }
}

/* ---------------------------------------------------------------------
   Forms: sectioned application form
   --------------------------------------------------------------------- */
.form-section { margin-bottom: 18px; }
.form-section > .card-header { background: #fafbfd; border-radius: var(--radius) var(--radius) 0 0; }
.section-title { display: flex; align-items: center; gap: 10px; }
.section-title .section-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-50); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; }
.section-title h2 { font-size: .98rem; margin: 0; }
.section-title small { color: var(--muted); font-size: .78rem; display: block; }
.app-no-field { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; color: var(--brand); letter-spacing: .02em; }
.repeat-row { border: 1px dashed #d4dbe7; border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #fcfdff; position: relative; }
.repeat-row .row-remove { position: absolute; top: 8px; right: 8px; }
.totals-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.total-box { border-radius: 12px; padding: 12px 14px; background: #f7f9fc; border: 1px solid var(--line); }
.total-box .lbl { font-size: .75rem; color: var(--muted); font-weight: 500; }
.total-box .val { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-box.good { background: #effaf3; border-color: #cdeedb; }
.total-box.warn { background: #fff7ec; border-color: #fbe0bd; }
.form-actions { position: sticky; bottom: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; box-shadow: 0 -4px 16px rgba(15,23,42,.05); }
.autocomplete-menu { position: absolute; z-index: 30; width: 100%; max-height: 260px; overflow-y: auto; }
.autocomplete-menu .dropdown-item { white-space: normal; }

/* Details page */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 20px; }
.detail-item .lbl { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.detail-item .val { font-weight: 500; word-break: break-word; }
.hero-card { background: linear-gradient(135deg, #0f2257 0%, #1d4ed8 100%); color: #fff; border: 0; }
.hero-card .lbl { color: #b7c6f2; }
.hero-card h1, .hero-card h2 { color: #fff; }
.money-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.money-strip .ms { background: rgba(255,255,255,.1); border-radius: 12px; padding: 12px 14px; }
.money-strip .ms .lbl { font-size: .75rem; }
.money-strip .ms .val { font-size: clamp(.95rem, 3.6vw, 1.2rem); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.total-box .val, .stat-value.money { white-space: nowrap; }
.progress-disb { height: 8px; background: rgba(255,255,255,.2); border-radius: 8px; }
.progress-disb .progress-bar { background: #4ade80; border-radius: 8px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 18px 46px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .tl-dot { position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); font-size: .85rem; }
.timeline .tl-title { font-weight: 600; font-size: .9rem; }
.timeline .tl-meta { font-size: .78rem; color: var(--muted); }
.timeline .tl-remarks { font-size: .8375rem; background: #f7f9fc; border-radius: 8px; padding: 6px 10px; margin-top: 6px; color: var(--ink-2); }

/* Activity feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.feed li:last-child { border-bottom: 0; }
.feed .feed-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.feed .feed-text { font-size: .8625rem; line-height: 1.4; word-break: break-word; }
.feed .feed-time { font-size: .74rem; color: var(--muted); }

/* Permission matrix */
.perm-table th, .perm-table td { text-align: center; vertical-align: middle; }
.perm-table th:first-child, .perm-table td:first-child { text-align: left; }
.perm-table .form-check-input { margin: 0; float: none; }
.perm-table .perm-na { color: #cbd3e1; }

/* Charts */
.chart-box { position: relative; height: 290px; }
.chart-box.sm { height: 250px; }

/* Toasts */
.toast { border: 0; border-radius: 12px; box-shadow: var(--shadow); min-width: 280px; }
.toast .toast-body { display: flex; gap: 10px; align-items: flex-start; font-size: .875rem; }
.confirm-icon { width: 44px; height: 44px; border-radius: 12px; background: #fde8e8; color: #b91c1c; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.confirm-icon.info { background: var(--brand-50); color: var(--brand); }

.modal-content { border: 0; border-radius: 16px; box-shadow: 0 20px 50px rgba(15,23,42,.18); }

/* flatpickr tweaks */
.flatpickr-calendar { border-radius: 12px; box-shadow: var(--shadow); }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--brand); border-color: var(--brand); }

/* ---------------------------------------------------------------------
   Auth pages
   --------------------------------------------------------------------- */
.auth-body { background: var(--bg); }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-brand { background: radial-gradient(circle at 20% 20%, #1e3a8a 0%, #0d1b3e 55%, #081229 100%); color: #dbe4ff; display: flex; align-items: center; justify-content: center; padding: 48px; }
.auth-brand-inner { max-width: 440px; }
.auth-brand h2 { color: #fff; font-size: 1.9rem; margin: 22px 0 6px; }
.auth-brand p { color: #9fb2e6; font-size: 1.05rem; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; }
.auth-points li { display: flex; gap: 10px; margin-bottom: 12px; color: #c9d5f6; }
.auth-points .bi { color: #4ade80; }
.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 18px; padding: 32px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.auth-card-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-card-brand strong { display: block; font-size: .95rem; }
.auth-card-brand small { color: var(--muted); font-size: .78rem; }
.auth-title { font-size: 1.5rem; margin-bottom: 4px; }
.auth-subtitle { color: var(--muted); margin-bottom: 22px; }
.auth-foot { margin-top: 20px; color: var(--muted); font-size: .8rem; }
@media (max-width: 991.98px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
}
@media (max-width: 575.98px) {
    .auth-card { padding: 24px 18px; border-radius: 14px; }
}

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 1199.98px) {
    .content { padding: 20px; }
    .topbar { padding: 0 16px 0 20px; }
}
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.35); }
    body.sidebar-open { overflow: hidden; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(8,15,35,.5); z-index: 1035; }
    .app-main { margin-left: 0; }
    .topbar { padding: 0 12px; gap: 6px; }
    .global-search { max-width: none; }
}
@media (max-width: 767.98px) {
    .content { padding: 16px; }
    .app-footer { padding: 12px 16px; }
    .global-search { display: none; position: absolute; left: 8px; right: 8px; top: 10px; z-index: 5; }
    body.search-open .global-search { display: block; }
    body.search-open .global-search .form-control { background: #fff; border-color: var(--line); box-shadow: var(--shadow); }
    .page-head h1 { font-size: 1.25rem; }
    .page-head { align-items: flex-start; }
    .page-actions { width: 100%; }
    .page-actions .btn, .page-actions > .dropdown, .page-actions > form, .page-actions > .btn-group { flex: 1 1 auto; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat-card { padding: 12px; gap: 10px; flex-direction: column; }
    .stat-icon { width: 36px; height: 36px; font-size: 1.05rem; border-radius: 10px; }
    .stat-value { font-size: 1.2rem; }
    .stat-value.money { font-size: 1rem; }
    .card-body { padding: 14px; }
    .card-header { padding: 12px 14px; }
    /* On phones the 5 actions would cover a quarter of the screen if sticky. */
    .form-actions { position: static; justify-content: stretch; box-shadow: none; }
    .form-actions .btn { flex: 1 1 calc(50% - 8px); }
    .chart-box { height: 240px; }
    .table-footer { justify-content: center; text-align: center; }
    .notif-menu { position: fixed !important; inset: 64px 8px auto 8px !important; transform: none !important; width: auto; max-width: none; }
}
@media (max-width: 380px) {
    .stat-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------
   Print (A4)
   --------------------------------------------------------------------- */
@media print {
    @page { size: A4; margin: 12mm; }
    body { background: #fff !important; font-size: 11pt; }
    .sidebar, .topbar, .app-footer, .crumbs, .page-actions, .no-print, .form-actions, .toast-container, .btn { display: none !important; }
    .app-main { margin: 0 !important; }
    .content { padding: 0 !important; }
    .card { box-shadow: none !important; border-color: #ccc !important; break-inside: avoid; }
    .hero-card { background: #fff !important; color: #000 !important; border: 1px solid #ccc !important; }
    .hero-card h1, .hero-card h2, .hero-card .lbl { color: #000 !important; }
    .money-strip .ms { background: #f3f3f3 !important; }
    a { color: #000; text-decoration: none; }
}
