/* ==========================================================
   Loan Management — bank-style UI (Poppins)
   ========================================================== */
:root {
    --navy-900: #071a33;
    --navy-800: #0b2545;
    --navy-700: #13315c;
    --navy-600: #1b3f73;
    --blue-600: #1a56b8;
    --blue-500: #2468d6;
    --blue-50: #eaf1fd;
    --gold-500: #d4a12a;
    --gold-400: #e5b844;
    --gold-50: #fdf6e3;
    --green-600: #0f7b55;
    --green-50: #e6f5ee;
    --red-600: #c0362c;
    --red-50: #fdecea;
    --amber-600: #a86b0c;
    --amber-50: #fff5e0;
    --bg: #f2f5fa;
    --card: #ffffff;
    --border: #e1e7ef;
    --border-strong: #cfd8e3;
    --text: #18212f;
    --text-2: #4a5568;
    --muted: #7a8699;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(11, 37, 69, .06);
    --shadow: 0 1px 3px rgba(11, 37, 69, .08), 0 6px 20px rgba(11, 37, 69, .05);
    --sidebar-w: 256px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--navy-800); }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 .75em; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.mono, .num { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-green { color: var(--green-600); }
.text-red { color: var(--red-600); }
.text-amber { color: var(--amber-600); }
.fw-600 { font-weight: 600; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
    background: linear-gradient(180deg, var(--navy-800) 0%, var(--navy-900) 100%);
    color: #c9d5e6; display: flex; flex-direction: column;
    transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo {
    width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--gold-400), var(--gold-500)); color: var(--navy-900); font-weight: 700; font-size: 17px;
}
.brand-name { color: #fff; font-weight: 600; font-size: 15px; line-height: 1.25; }
.brand-sub { font-size: 11px; color: #8fa3c0; letter-spacing: .04em; text-transform: uppercase; }
.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #6f86a8; padding: 14px 12px 6px; }
.nav a {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0; border-radius: 8px;
    color: #c9d5e6; font-weight: 500; font-size: 13.5px; text-decoration: none; position: relative;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(212,161,42,.14); color: #fff; }
.nav a.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold-400); }
.nav a.active svg.i { color: var(--gold-400); }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #8fa3c0; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30; height: 64px; background: var(--card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px; padding: 0 24px;
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .title h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs { font-size: 12px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; border-radius: 8px; color: var(--navy-800); cursor: pointer; }
.lang { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; font-size: 12px; }
.lang a { padding: 4px 11px; color: var(--text-2); text-decoration: none; }
.lang a.on { background: var(--navy-800); color: #fff; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--border); position: relative; cursor: pointer; background: none; font: inherit; color: inherit; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--navy-700); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); min-width: 200px; padding: 6px; display: none; z-index: 50; }
.dropdown.open { display: block; }
.dropdown a, .dropdown button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px 10px; border-radius: 6px; color: var(--text); font: inherit; font-size: 13px; background: none; border: 0; cursor: pointer; text-align: left; text-decoration: none; }
.dropdown a:hover, .dropdown button:hover { background: var(--bg); }

.content { padding: 24px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.footer { padding: 14px 24px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); background: var(--card); }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 18px; }
.grid > .card, .grid > .account { margin: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: #fafbfd; border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack > * + * { margin-top: 18px; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stats-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 1500px) { .stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .stats-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--shadow-sm); }
.stat-ico { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--blue-50); color: var(--blue-600); }
.stat-ico.gold { background: var(--gold-50); color: var(--gold-500); }
.stat-ico.green { background: var(--green-50); color: var(--green-600); }
.stat-ico.red { background: var(--red-50); color: var(--red-600); }
.stat-ico.navy { background: #e8edf5; color: var(--navy-700); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 21px; font-weight: 600; color: var(--navy-800); line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--muted); }

/* Account card: bank passbook style summary */
.account {
    border-radius: var(--radius); color: #fff; padding: 20px 22px; position: relative; overflow: hidden;
    background: radial-gradient(circle at 100% 0%, rgba(229,184,68,.25), transparent 45%), linear-gradient(135deg, var(--navy-700), var(--navy-900));
    box-shadow: var(--shadow);
}
.account-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.account-code { font-size: 22px; font-weight: 600; letter-spacing: .04em; }
.account-type { display: inline-block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; background: rgba(255,255,255,.14); padding: 2px 10px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.account-name { color: #d5deeb; font-size: 13px; margin-top: 2px; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin-top: 18px; }
.account-grid .k { font-size: 11px; color: #9fb2cd; text-transform: uppercase; letter-spacing: .06em; }
.account-grid .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.account-grid .v.gold { color: var(--gold-400); }
.progress { height: 6px; background: rgba(255,255,255,.15); border-radius: 999px; overflow: hidden; margin-top: 16px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-400), #f5d47a); border-radius: 999px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
    border: 1px solid transparent; font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; text-decoration: none !important; white-space: nowrap;
    background: var(--blue-600); color: #fff; transition: background .15s, box-shadow .15s;
}
.btn:hover { background: #1649a0; }
.btn:focus-visible { outline: 3px solid rgba(36,104,214,.3); outline-offset: 1px; }
.btn-navy { background: var(--navy-800); }
.btn-navy:hover { background: var(--navy-900); }
.btn-gold { background: var(--gold-500); color: var(--navy-900); }
.btn-gold:hover { background: #c39222; }
.btn-green { background: var(--green-600); }
.btn-green:hover { background: #0b6545; }
.btn-red { background: var(--red-600); }
.btn-red:hover { background: #a42c23; }
.btn-light { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-light:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--blue-600); }
.btn-ghost:hover { background: var(--blue-50); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 6px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
.field label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.field label .req { color: var(--red-600); }
.input, select.input, textarea.input {
    width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font: inherit; font-size: 14px; color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(36,104,214,.15); }
.input[readonly] { background: #f6f8fb; color: var(--text-2); }
.input.is-invalid { border-color: var(--red-600); }
.input-lg { height: 48px; font-size: 16px; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; height: auto; }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.input-prefix .input { padding-left: 28px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.error { font-size: 12px; color: var(--red-600); margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 17px; height: 17px; accent-color: var(--blue-600); }
.section-title { grid-column: span 12; display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--navy-700); text-transform: uppercase; letter-spacing: .06em; padding-top: 6px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { min-width: 140px; flex: 1 1 140px; }
.filters .field.sm { flex: 0 1 150px; min-width: 140px; }
.filters .input { height: 38px; }
.file-drop { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 14px; text-align: center; color: var(--muted); font-size: 13px; background: #fafbfd; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.radio-card { border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.radio-card:has(input:checked) { border-color: var(--blue-500); background: var(--blue-50); }
.radio-card input { margin-top: 3px; accent-color: var(--blue-600); }
.radio-card b { display: block; font-weight: 600; font-size: 13.5px; }
.radio-card span { font-size: 12px; color: var(--muted); }

/* Lookup dropdown */
.lookup { position: relative; }
.lookup-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); z-index: 20; max-height: 280px; overflow-y: auto; display: none; }
.lookup-list.open { display: block; }
.lookup-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; }
.lookup-item:last-child { border-bottom: 0; }
.lookup-item:hover, .lookup-item.hl { background: var(--blue-50); }
.picked { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--green-50); border: 1px solid #bfe3d1; margin-top: 8px; font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); background: #f6f8fc; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #f9fbfe; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 600; background: #f6f8fc; border-top: 2px solid var(--border-strong); padding: 11px 14px; }
.table .num, .table .text-right { text-align: right; white-space: nowrap; }
.table .sub { font-size: 12px; color: var(--muted); }
.table tr.row-muted td { color: var(--muted); }
.table tr.row-paid td { background: #f6fbf8; }
.table tr.row-due td { background: #fff9f0; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg.i { width: 36px; height: 36px; color: var(--border-strong); display: block; margin: 0 auto 8px; }
.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); cursor: zoom-in; background: var(--bg); }
.thumb-lg { width: 96px; height: 96px; border-radius: 12px; }
.thumb-none { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; background: var(--bg); color: var(--muted); font-size: 11px; border: 1px dashed var(--border-strong); }
.code { font-weight: 600; color: var(--navy-700); letter-spacing: .02em; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; background: #eef1f6; color: var(--text-2); }
.badge-blue { background: var(--blue-50); color: var(--blue-600); }
.badge-green { background: var(--green-50); color: var(--green-600); }
.badge-red { background: var(--red-50); color: var(--red-600); }
.badge-amber { background: var(--amber-50); color: var(--amber-600); }
.badge-gold { background: var(--gold-50); color: #8a6512; }
.badge-navy { background: var(--navy-800); color: #fff; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; padding: 0 8px; }
.tabs a { padding: 12px 14px; font-size: 13.5px; font-weight: 500; color: var(--text-2); border-bottom: 2.5px solid transparent; white-space: nowrap; text-decoration: none; margin-bottom: -1px; }
.tabs a:hover { color: var(--navy-800); }
.tabs a.on { color: var(--navy-800); border-color: var(--gold-500); font-weight: 600; }

/* Alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.alert svg.i { margin-top: 1px; }
.alert-success { background: var(--green-50); border-color: #bfe3d1; color: #0c5b40; }
.alert-error { background: var(--red-50); border-color: #f2c4bf; color: #8f2820; }
.alert-warning { background: var(--amber-50); border-color: #f0d9a6; color: #7a4f08; }
.alert-info { background: var(--blue-50); border-color: #c7d9f6; color: #1a4384; }
.alert .grow { flex: 1; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.banner-danger { background: var(--red-600); color: #fff; padding: 10px 24px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.banner-danger a { color: #fff; text-decoration: underline; }

/* Definition list */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pager ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.pager li a, .pager li span { display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--border); color: var(--text-2); font-size: 13px; text-decoration: none; }
.pager li a:hover { background: var(--bg); }
.pager li.on span { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.pager li.off span { opacity: .45; }

/* Modal & lightbox */
.modal { position: fixed; inset: 0; background: rgba(7,26,51,.55); z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal.open { display: flex; }
.modal-box { background: #fff; border-radius: 14px; width: 100%; max-width: 440px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-box .card-head { border-radius: 14px 14px 0 0; }
.lightbox img { max-width: 92vw; max-height: 86vh; border-radius: 10px; background: #fff; }
.lightbox-close { position: absolute; top: 14px; right: 18px; color: #fff; font-size: 30px; background: none; border: 0; cursor: pointer; }

/* Search hero (Repayment / Close / Edit) */
.search-hero { background: linear-gradient(135deg, #fff, #f4f7fc); }
.search-hero form { display: flex; gap: 10px; max-width: 560px; }
.search-hero .input { height: 48px; font-size: 16px; text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.search-hero .btn { height: 48px; padding: 0 22px; }

/* Bar chart (dashboard) */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar span { width: 100%; max-width: 30px; background: linear-gradient(180deg, var(--blue-500), var(--navy-600)); border-radius: 5px 5px 2px 2px; min-height: 2px; position: relative; }
.bar span:hover::after { content: attr(data-v); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--navy-900); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.bar small { font-size: 10px; color: var(--muted); white-space: nowrap; }
.bar.today span { background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); }

/* Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side {
    background: radial-gradient(circle at 20% 20%, rgba(229,184,68,.18), transparent 40%), linear-gradient(150deg, var(--navy-700), var(--navy-900));
    color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side h2 { color: #fff; font-size: 30px; line-height: 1.3; font-weight: 600; margin: 0 0 14px; }
.auth-side p { color: #b9c7dc; max-width: 420px; }
.auth-feats { display: grid; gap: 14px; margin-top: 28px; }
.auth-feats div { display: flex; gap: 12px; align-items: center; color: #d8e1ee; font-size: 14px; }
.auth-feats svg.i { color: var(--gold-400); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: #fff; }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 24px; margin-bottom: 4px; }
.secure { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 22px; justify-content: center; }

/* Mobile-stack tables: rows become cards under 640px */
@media (max-width: 640px) {
    table.stack-sm thead { display: none; }
    table.stack-sm, table.stack-sm tbody, table.stack-sm tr, table.stack-sm td { display: block; width: 100%; }
    table.stack-sm tr { border-bottom: 1px solid var(--border); padding: 8px 4px; }
    table.stack-sm td { border: 0; padding: 4px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: right !important; }
    table.stack-sm td::before { content: attr(data-label); font-weight: 500; color: var(--muted); font-size: 12px; text-align: left; }
    table.stack-sm td[data-label=""]::before { content: none; }
    table.stack-sm tfoot { display: block; }
    table.stack-sm tfoot tr { display: flex; justify-content: space-between; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
    body.nav-open .scrim { display: block; }
    .scrim { display: none; position: fixed; inset: 0; background: rgba(7,26,51,.45); z-index: 35; }
    .main { margin-left: 0; }
    .menu-btn { display: inline-flex; }
    .auth { grid-template-columns: 1fr; }
    .auth-side { display: none; }
    .grid-2 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
}
@media (max-width: 640px) {
    body { font-size: 13.5px; }
    .content { padding: 16px; }
    .topbar { padding: 0 12px; gap: 8px; height: 58px; }
    .topbar .title h1 { font-size: 16px; }
    .crumbs, .user-chip .uname, .hide-sm { display: none !important; }
    .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-grid > [class*="col-"] { grid-column: span 12; }
    .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat { padding: 12px; flex-direction: column; gap: 8px; }
    .stat-ico { width: 34px; height: 34px; }
    .stat-value { font-size: 17px; }
    .card-body { padding: 14px; }
    .card-head { padding: 12px 14px; }
    .dl { grid-template-columns: 1fr 1.4fr; }
    .page-head .btn-group { width: 100%; }
    .search-hero form { flex-direction: column; }
    .filters .field, .filters .field.sm { flex: 1 1 100%; }
    .account { padding: 16px; }
    .account-grid { grid-template-columns: 1fr 1fr; }
    .footer { padding: 12px 16px; }
}

@media print {
    .sidebar, .topbar, .no-print, .footer, .filters, .pager, .tabs { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    .card { border: 0; box-shadow: none; }
    body { background: #fff; }
}

/* Footer action bars span the card; long ledgers scroll inside their card */
.card-foot.btn-group { display: flex; }
.scroll-y { max-height: 640px; overflow-y: auto; }
.scroll-y .table th { position: sticky; top: 0; z-index: 1; }
.grid > * { min-width: 0; }
code { word-break: break-all; font-size: 12px; }
@media (max-width: 640px) {
    .bars { gap: 3px; }
    .bar small { font-size: 8.5px; }
}
