/* Lending Tracker design system (on top of Bootstrap 5.3). Phone first. */
:root {
  --ink: #101828; --ink-2: #344054; --muted: #667085; --line: #e4e7ec; --bg: #f3f5f9; --card: #fff;
  --brand: #0b7a5c; --brand-dark: #096249; --brand-soft: #e2f5ee;
  --blue: #2459e0; --blue-dark: #1c48ba; --blue-soft: #e8eefd;
  --amber: #a15c07; --amber-soft: #fdf0cf;
  --red: #c5283d; --red-dark: #a51f31; --red-soft: #fde7ea;
  --purple: #6d3fc4; --purple-soft: #efe8fb;
  --cyan: #0b7285; --cyan-soft: #dff3f6;
  --grey-soft: #eef1f5;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --nav-h: 3.75rem;

  --bs-body-color: var(--ink); --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted);
  --bs-primary: #2459e0; --bs-primary-rgb: 36, 89, 224;
  --bs-success: #0b7a5c; --bs-success-rgb: 11, 122, 92;
  --bs-danger: #c5283d; --bs-danger-rgb: 197, 40, 61;
  --bs-link-color: #2459e0; --bs-link-color-rgb: 36, 89, 224; --bs-link-hover-color-rgb: 28, 72, 186;
  --bs-border-radius: 10px;
}
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.btn:hover, .nav-link:hover, .dropdown-item:hover, a.lcard:hover, .topbar a:hover, .bottom-nav a:hover { text-decoration: none; }
.text-muted { color: var(--muted) !important; }
.num, .stat-value, .hero-value, .ri-amt, .table td.text-end, .table th.text-end { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Buttons & forms ---------- */
.btn { --bs-btn-border-radius: 10px; --bs-btn-font-weight: 500; }
.btn-sm { --bs-btn-border-radius: 9px; --bs-btn-padding-x: .7rem; --bs-btn-padding-y: .35rem; }
.btn-primary {
  --bs-btn-bg: var(--blue); --bs-btn-border-color: var(--blue);
  --bs-btn-hover-bg: var(--blue-dark); --bs-btn-hover-border-color: var(--blue-dark);
  --bs-btn-active-bg: var(--blue-dark); --bs-btn-active-border-color: var(--blue-dark);
  --bs-btn-disabled-bg: var(--blue); --bs-btn-disabled-border-color: var(--blue);
}
.btn-success {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark);
  --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
}
.btn-danger {
  --bs-btn-bg: var(--red); --bs-btn-border-color: var(--red);
  --bs-btn-hover-bg: var(--red-dark); --bs-btn-hover-border-color: var(--red-dark);
  --bs-btn-active-bg: var(--red-dark); --bs-btn-active-border-color: var(--red-dark);
}
.btn-outline-primary { --bs-btn-color: var(--blue); --bs-btn-border-color: #b9c8f5; --bs-btn-hover-bg: var(--blue); --bs-btn-hover-border-color: var(--blue); --bs-btn-active-bg: var(--blue); }
.btn-outline-secondary { --bs-btn-color: var(--ink-2); --bs-btn-border-color: #d0d5dd; --bs-btn-hover-bg: var(--grey-soft); --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: #d0d5dd; --bs-btn-active-bg: var(--grey-soft); --bs-btn-active-color: var(--ink); --bs-btn-active-border-color: #d0d5dd; background: #fff; }
.btn-outline-danger { --bs-btn-color: var(--red); --bs-btn-border-color: #f1b5bd; --bs-btn-hover-bg: var(--red); --bs-btn-hover-border-color: var(--red); --bs-btn-active-bg: var(--red); }
/* Soft (tinted) buttons for secondary actions */
.btn-soft { border: 0; font-weight: 600; }
.btn-soft-success { background: var(--brand-soft); color: var(--brand-dark); }
.btn-soft-success:hover, .btn-soft-success:focus-visible { background: #cdeedf; color: var(--brand-dark); }
.btn-soft-primary { background: var(--blue-soft); color: var(--blue-dark); }
.btn-soft-primary:hover, .btn-soft-primary:focus-visible { background: #d5e0fb; color: var(--blue-dark); }
.btn-soft-danger { background: var(--red-soft); color: var(--red-dark); }
.btn-soft-danger:hover, .btn-soft-danger:focus-visible { background: #f9d3d8; color: var(--red-dark); }
.btn-soft-grey { background: var(--grey-soft); color: var(--ink-2); }
.btn-soft-grey:hover, .btn-soft-grey:focus-visible { background: #e2e6ec; color: var(--ink); }
.btn-icon { width: 2.25rem; height: 2.25rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.btn.is-busy { pointer-events: none; opacity: .7; }

.form-control, .form-select { border-color: #d0d5dd; border-radius: 10px; }
.form-control:focus, .form-select:focus, .btn:focus-visible { border-color: var(--blue); box-shadow: 0 0 0 .2rem rgba(36, 89, 224, .18); }
.form-label { font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .3rem; }
.input-group-text { background: var(--grey-soft); border-color: #d0d5dd; color: var(--muted); border-radius: 10px; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-switch { padding-left: 3.1em; }
.form-switch .form-check-input { width: 2.5em; height: 1.35em; margin-top: .1em; margin-left: -3.1em; }

/* ---------- Cards, page head ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header, .card-footer { background: transparent; border-color: var(--line); }
.card-header { font-weight: 600; padding: .8rem 1rem; }
.card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card-footer:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.card > .table-responsive:last-child, .card > .rowlist:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.card > .table-responsive:first-child { border-radius: var(--radius); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; margin-bottom: 1rem; }
.page-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
.page-sub { color: var(--muted); font-size: .9rem; margin-top: .15rem; }
.back-link { display: inline-flex; align-items: center; gap: .25rem; font-size: .85rem; font-weight: 500; color: var(--muted); margin-bottom: .35rem; }
.sec-head { display: flex; align-items: center; gap: .6rem; }
.sec-ico { width: 2rem; height: 2rem; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex: none; font-size: 1rem; }
.tone-green { background: var(--brand-soft); color: var(--brand-dark); }
.tone-blue { background: var(--blue-soft); color: var(--blue-dark); }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-red { background: var(--red-soft); color: var(--red-dark); }
.tone-purple { background: var(--purple-soft); color: var(--purple); }
.tone-cyan { background: var(--cyan-soft); color: var(--cyan); }
.tone-grey { background: var(--grey-soft); color: var(--ink-2); }
.empty { color: var(--muted); text-align: center; padding: 1.25rem 1rem; margin: 0; font-size: .92rem; }
.empty i { display: block; font-size: 1.6rem; opacity: .55; margin-bottom: .25rem; }
.sub-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: .75rem 1rem .1rem; }

/* ---------- Status pills ---------- */
.status { display: inline-flex; align-items: center; gap: .3em; padding: .22em .65em; border-radius: 999px; font-size: .72rem; font-weight: 700; line-height: 1.3; white-space: nowrap; vertical-align: middle; }
.status::before { content: ""; width: .45em; height: .45em; border-radius: 50%; background: currentColor; opacity: .8; }
.status-green { background: var(--brand-soft); color: var(--brand-dark); }
.status-blue { background: var(--blue-soft); color: var(--blue-dark); }
.status-amber { background: var(--amber-soft); color: var(--amber); }
.status-red { background: var(--red-soft); color: var(--red-dark); }
.status-purple { background: var(--purple-soft); color: var(--purple); }
.status-cyan { background: var(--cyan-soft); color: var(--cyan); }
.status-grey { background: var(--grey-soft); color: var(--muted); }
.status-solid-red { background: #8f1d2c; color: #fff; }
.type-badge { display: inline-flex; align-items: center; gap: .3em; padding: .18em .6em; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--grey-soft); color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
.nav-badge { font-size: .62rem; vertical-align: top; }

/* ---------- Stat tiles & hero ---------- */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem .9rem; height: 100%; min-width: 0; }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: .4rem; }
.stat-label i { font-size: .95rem; }
.stat-value { font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em; margin-top: .15rem; overflow-wrap: anywhere; }
.stat.is-bad { background: var(--red-soft); border-color: #f6c6cc; }
.stat.is-bad .stat-value, .stat.is-bad .stat-label { color: var(--red-dark); }
.hero { border-radius: 20px; padding: 1.15rem 1.2rem; color: #fff; height: 100%;
  background: linear-gradient(135deg, #0f172a 0%, #12403a 70%, #0b7a5c 130%); box-shadow: 0 6px 18px rgba(15, 23, 42, .18); }
.hero-label { font-size: .8rem; opacity: .75; font-weight: 500; }
.hero-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin: .1rem 0 .15rem; overflow-wrap: anywhere; }
.hero-row { display: flex; gap: 1.25rem; margin-top: .9rem; padding-top: .8rem; border-top: 1px solid rgba(255, 255, 255, .16); }
.hero-row > div { min-width: 0; flex: 1; }
.hero-row .v { font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- Row lists (tasks, cheques) ---------- */
.rowlist { display: flex; flex-direction: column; }
.rowitem { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: .8rem 1rem; border-top: 1px solid var(--line); }
.rowlist > .rowitem:first-child { border-top: 0; }
.rowitem.is-warn { background: #fffaeb; }
.rowitem.is-bad { background: #fff5f6; }
.ri-main { flex: 1 1 9.5rem; min-width: 0; }
.ri-title { font-weight: 600; color: var(--ink); display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
a.ri-title:hover { color: var(--blue); text-decoration: none; }
.ri-sub { font-size: .8rem; color: var(--muted); line-height: 1.45; }
.ri-sub .late { color: var(--red-dark); font-weight: 600; }
.ri-side { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.ri-amt { font-weight: 700; white-space: nowrap; text-align: right; }
.ri-amt small { display: block; font-weight: 500; color: var(--muted); font-size: .75rem; }
.ri-actions { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.ri-actions form { display: contents; }
@media (max-width: 575.98px) {
  .ri-main { flex-basis: 6.5rem; }
  .ri-side { flex-direction: column; align-items: flex-end; gap: .4rem; }
}
.dropdown-menu { border-radius: 12px; border-color: var(--line); box-shadow: 0 10px 30px rgba(16, 24, 40, .14); padding: .35rem; min-width: 11rem; }
.dropdown-item { border-radius: 8px; padding: .55rem .7rem; display: flex; align-items: center; gap: .55rem; font-weight: 500; }
.dropdown-item.text-danger:hover { background: var(--red-soft); }

/* ---------- Phone list cards (loans, clients) ---------- */
.lcard { display: block; padding: .85rem 1rem; border-top: 1px solid var(--line); color: inherit; }
.lcard:first-child { border-top: 0; }
.lcard:active { background: var(--grey-soft); }
.lcard-top { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.lcard-name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.lcard-amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lcard-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; margin-top: .3rem; font-size: .8rem; color: var(--muted); }
.lcard-meta .push { margin-left: auto; }
.search-box { position: relative; }
.search-box i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box .form-control { padding-left: 2.3rem; background: #fff; }
.seg { display: inline-flex; background: #e6e9ef; border-radius: 12px; padding: 3px; gap: 2px; }
.seg a, .seg label { padding: .4rem .85rem; border-radius: 9px; font-size: .88rem; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; text-align: center; margin: 0; }
.seg a.active, .seg .btn-check:checked + label { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.seg .count { font-weight: 500; color: var(--muted); margin-left: .2rem; }
.seg.seg-wide { display: flex; }
.seg.seg-wide label { flex: 1; padding: .6rem .5rem; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table td, .table th { white-space: nowrap; padding: .7rem 1rem; border-color: var(--line); }
.table-sm td, .table-sm th { padding: .55rem 1rem; }
.table td.wrap { white-space: normal; }
.table thead th { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: #f9fafb; border-bottom: 1px solid var(--line); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f6f8fb; }
tr.clickable { cursor: pointer; }
tr.row-bad > td { background: #fff5f6; }
tr.row-warn > td { background: #fffaeb; }
tr.row-muted > td { background: #f9fafb; color: var(--muted); }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv.total { font-weight: 700; font-size: 1.05rem; border-bottom: 0; padding-top: .6rem; }

/* ---------- Tabs inside cards ---------- */
.nav-tabs.card-tabs { border-bottom: 1px solid var(--line); padding: 0 .5rem; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.nav-tabs.card-tabs::-webkit-scrollbar { display: none; }
.nav-tabs.card-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; font-size: .9rem; padding: .8rem .75rem; white-space: nowrap; border-radius: 0; }
.nav-tabs.card-tabs .nav-link.active { color: var(--brand-dark); border-bottom-color: var(--brand); background: transparent; }

/* ---------- Top bar & bottom nav ---------- */
.topbar { position: sticky; top: 0; z-index: 1030; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--line); margin-bottom: 1rem; padding-top: env(safe-area-inset-top); }
.topbar-inner { display: flex; align-items: center; gap: .75rem; height: 3.5rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; color: var(--ink); letter-spacing: -.01em; }
.brand-mark { width: 2rem; height: 2rem; border-radius: 10px; background: linear-gradient(135deg, #0f172a, #0b7a5c); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem; flex: none; }
.topnav { display: flex; gap: .15rem; margin-left: 1rem; }
.topnav a { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .8rem; border-radius: 10px; font-weight: 600; font-size: .92rem; color: var(--muted); }
.topnav a:hover { background: var(--grey-soft); color: var(--ink); }
.topnav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.topbar .icon-btn { width: 2.5rem; height: 2.5rem; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; gap: .4rem; }
.topbar .icon-btn:hover, .topbar .icon-btn.active { background: var(--grey-soft); color: var(--ink); }
@media (min-width: 992px) { .topbar .icon-btn { width: auto; padding: 0 .75rem; font-size: .92rem; font-weight: 600; } .topbar .icon-btn i { font-size: 1.05rem; } }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(180%) blur(10px); -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav a { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  height: var(--nav-h); font-size: .68rem; font-weight: 600; color: var(--muted); }
.bottom-nav a i { font-size: 1.3rem; line-height: 1; }
.bottom-nav a.active { color: var(--brand-dark); }
.bottom-nav a.active::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }
.bottom-nav a.add i { background: var(--brand); color: #fff; border-radius: 50%; width: 2.9rem; height: 2.9rem; display: flex; align-items: center; justify-content: center;
  margin-top: -1.5rem; box-shadow: 0 4px 12px rgba(11, 122, 92, .4); border: 3px solid #fff; font-size: 1.35rem; }
.bottom-nav a.add { color: var(--brand-dark); }
.bottom-nav .nav-badge { position: absolute; top: .45rem; left: calc(50% + .3rem); }

.test-bar { background: repeating-linear-gradient(45deg, #ffc107, #ffc107 12px, #ffcd39 12px, #ffcd39 24px); color: #212529; }
.flash { border: 0; border-radius: 12px; box-shadow: var(--shadow); display: flex; gap: .6rem; align-items: flex-start; }
.flash > i { font-size: 1.1rem; line-height: 1.35; }

/* ---------- Calendar ---------- */
.legend { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .8rem; color: var(--ink-2); }
.legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; vertical-align: -1px; margin-right: .3rem; }
.fc { --fc-border-color: var(--line); --fc-today-bg-color: #fff7df; --fc-button-bg-color: #fff; --fc-button-border-color: #d0d5dd;
  --fc-button-text-color: var(--ink-2); --fc-button-hover-bg-color: var(--grey-soft); --fc-button-hover-border-color: #d0d5dd;
  --fc-button-active-bg-color: var(--ink); --fc-button-active-border-color: var(--ink); --fc-list-event-hover-bg-color: #f6f8fb; }
.fc .fc-button { font-weight: 600; font-size: .85rem; text-transform: capitalize; box-shadow: none !important; border-radius: 9px; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { color: #fff; }
.fc .fc-button-primary:hover { color: var(--ink); }
.fc .fc-toolbar-title { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }
.fc .fc-event { cursor: pointer; font-size: .78rem; border-radius: 6px; padding: 1px 3px; }
.fc a.fc-col-header-cell-cushion, .fc a.fc-daygrid-day-number, .fc a.fc-list-day-text, .fc a.fc-list-day-side-text { color: inherit; text-decoration: none; }
.fc .fc-col-header-cell-cushion { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .5rem 0; }
.fc .fc-list-day-cushion { background: #f9fafb; }
.fc .fc-list-event td { padding: .7rem .75rem; }
.fc .fc-list-event-time { display: none; }
.fc .fc-list-event-title { font-size: .9rem; font-weight: 500; }
.fc .fc-list-event-graphic { padding-right: 0 !important; }
.fc .fc-list { border-radius: 12px; }
.modal-content { border: 0; border-radius: 18px; }
.modal-header, .modal-footer { border-color: var(--line); }
.act-box { border: 1px solid var(--line); border-radius: 12px; padding: .75rem; margin-bottom: .6rem; }

/* ---------- Login ---------- */
.login-wrap { min-height: calc(100vh - 6rem); min-height: calc(100dvh - 6rem); display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 24rem; }
.login-card .brand-mark { width: 3.25rem; height: 3.25rem; border-radius: 16px; font-size: 1.7rem; }

.cheque-row { margin-bottom: .6rem; }
@media (max-width: 767.98px) { .cheque-row { padding-bottom: .8rem; margin-bottom: .8rem; border-bottom: 1px dashed var(--line); } }
.min-w-0 { min-width: 0; }
.avatar { width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--blue-soft); color: var(--blue-dark); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; text-transform: uppercase; }
.avatar-lg { width: 3.25rem; height: 3.25rem; font-size: 1.25rem; }

@media (min-width: 992px) { .w-lg-auto { width: auto !important; } }

@media (max-width: 991.98px) {
  main.has-bottom-nav { padding-bottom: calc(var(--nav-h) + 2.25rem + env(safe-area-inset-bottom)) !important; }
}

@media (max-width: 767.98px) {
  .page-title { font-size: 1.35rem; }
  /* 16px stops iOS zooming into inputs on focus; 44px is a comfortable tap target */
  .form-control, .form-select, .input-group-text { font-size: 16px; min-height: 2.75rem; }
  .form-control-sm, .form-select-sm { min-height: 2.5rem; }
  textarea.form-control { min-height: 0; }
  .btn { --bs-btn-padding-y: .55rem; }
  .btn-sm { --bs-btn-padding-y: .45rem; --bs-btn-padding-x: .8rem; --bs-btn-font-size: .875rem; }
  .btn-icon { width: 2.5rem; height: 2.5rem; }
  .table { font-size: .875rem; }
  .table td, .table th { padding-left: .75rem; padding-right: .75rem; }
  .card-body { padding: .9rem; }
  .hero-value { font-size: 1.7rem; }
  .fc .fc-toolbar { flex-wrap: wrap; gap: .5rem; }
  .fc .fc-toolbar-title { font-size: 1.05rem; }
  .fc .fc-button { padding: .4rem .65rem; }
  .fc .fc-daygrid-event { font-size: .68rem; }
  .modal-fullscreen-sm-down .modal-content { border-radius: 0; }
}

/* ---------- Roles: admin view filter, dealer chips, permission ticks ---------- */
.view-filter .form-select { max-width: 9.5rem; font-weight: 600; border-radius: 9px; }
.view-filter .form-select.is-filtered { background-color: var(--blue-soft); border-color: var(--blue); color: var(--blue-dark); }
@media (min-width: 992px) { .view-filter .form-select { max-width: 13rem; } }
.owner-chip { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; font-weight: 600; padding: .1rem .5rem;
  border-radius: 999px; background: var(--purple-soft); color: var(--purple); white-space: nowrap; }
.owner-chip.mine { background: var(--grey-soft); color: var(--ink-2); }
.perm-list .form-check { padding: .6rem .75rem .6rem 2.6rem; border: 1px solid var(--line); border-radius: 10px; margin-bottom: .5rem; }
.perm-list .form-check-input { margin-left: -1.85rem; }
.perm-list .form-check:has(.form-check-input:checked) { background: var(--brand-soft); border-color: #b5e3d3; }
.dealer-off { opacity: .6; }
.topbar .brand, .topbar .btn, .topbar .icon-btn { white-space: nowrap; }

/* ---------- Cheque rows: Cheque | Amount | Current status | Action ---------- */
.chq-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .75rem; align-items: center; }
.chq-row .chq-c-status { grid-column: 1 / -1; padding: .4rem .6rem; background: var(--grey-soft); border-radius: 10px; }
.chq-row.is-bad .chq-c-status, .chq-row.is-warn .chq-c-status { background: rgba(255, 255, 255, .7); }
.chq-row .chq-c-act { grid-column: 1 / -1; }
.chq-row > .collapse, .chq-row > .w-100 { grid-column: 1 / -1; }
.chq-head { grid-template-columns: minmax(0, 1fr) 9.5rem minmax(0, 1.2fr) 21rem; gap: .75rem; padding: .5rem 1rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); background: #f8fafc; }
@media (min-width: 768px) {
  .chq-row { grid-template-columns: minmax(0, 1fr) 9.5rem minmax(0, 1.2fr) 21rem; }
  .chq-row .chq-c-amt { text-align: right; }
  .chq-row .chq-c-status { grid-column: auto; background: none; padding: 0; }
  .chq-row.is-bad .chq-c-status, .chq-row.is-warn .chq-c-status { background: none; }
  .chq-row .chq-c-act { grid-column: auto; }
}

/* ---------- Earnings ---------- */
:root { --c-now: #0b7a5c; --c-prev: #2459e0; }  /* validated pair (dataviz validator: CVD + contrast pass) */
.month-nav { display: flex; align-items: center; gap: .35rem; }
.month-nav .form-control { width: 10rem; }
.hero-delta { margin-top: .35rem; font-size: .85rem; }
.hero .delta { background: rgba(255, 255, 255, .14); color: #fff; }
.hero .delta-vs { color: rgba(255, 255, 255, .75); }
.delta { display: inline-flex; align-items: center; gap: .2rem; font-size: .78rem; font-weight: 700; padding: .1rem .5rem;
  border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta.up { background: var(--brand-soft); color: var(--brand-dark); }
.delta.down { background: var(--red-soft); color: var(--red-dark); }
.delta.flat { background: var(--grey-soft); color: var(--ink-2); }
.delta-vs { font-size: .78rem; color: var(--muted); }
.stat-sub { font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.chart-box { position: relative; height: 260px; }
.chart-box-sm { height: 180px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .82rem; color: var(--ink-2); margin-bottom: .5rem; }
.chart-legend .sw { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; vertical-align: -1px; margin-right: .3rem; }
.view-filter { flex-shrink: 0; }
.view-filter .form-select { width: 8.5rem; }
@media (min-width: 992px) { .view-filter .form-select { width: 10rem; } }

/* Per-page dealer filter (admin) */
.dealer-filter { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); }
.dealer-filter .form-select { width: auto; min-width: 11rem; font-weight: 600; border-radius: 9px; }
.dealer-filter .form-select.is-filtered { background-color: var(--blue-soft); border-color: var(--blue); color: var(--blue-dark); }

/* ---------- Daily collection ---------- */
.daily-cta { border: 1px solid #f5d48a; background: #fffaeb; }
.daily-cta:hover { border-color: var(--amber); }
.collect-row .collect-form { flex: 1 1 15rem; max-width: 20rem; margin-left: auto; }
.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.3rem, 1fr)); gap: 4px; }
.day-cell { border-radius: 8px; padding: .25rem .35rem; font-size: .72rem; line-height: 1.2; background: var(--grey-soft); color: var(--ink-2); }
.day-cell .dc-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.day-cell.st-paid, .dc-key.st-paid { background: var(--brand-soft); color: var(--brand-dark); }
.day-cell.st-overdue, .dc-key.st-overdue { background: var(--red-soft); color: var(--red-dark); }
.day-cell.st-today, .dc-key.st-today { background: var(--amber-soft); color: var(--amber); }
.day-cell.st-partial { background: var(--blue-soft); color: var(--blue-dark); }
.dc-key { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; vertical-align: -1px; background: var(--grey-soft); }
.day-cell.is-late, .dc-key.is-late { box-shadow: inset 0 0 0 2px var(--red); }
.dc-key.st-partial { background: var(--blue-soft); }

/* ---------- New loan: advanced settings + calculation card ---------- */
.adv-box { padding: .85rem; border: 1px dashed var(--line); border-radius: 12px; background: #f8fafc; }
.adv-toggle .adv-chev { transition: transform .2s; display: inline-block; }
.adv-toggle:not(.collapsed) .adv-chev { transform: rotate(180deg); }
.adv-toggle:not(.collapsed) { background: var(--blue-soft); color: var(--blue-dark); }
.calc-hero { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 1rem .85rem;
  background: linear-gradient(135deg, var(--brand-soft), #f4fbf8); border-bottom: 1px solid var(--line); }
.calc-label { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.calc-big { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; color: var(--ink); }
.calc-big.text-success { color: var(--brand-dark) !important; }
.calc-sec { display: flex; align-items: center; gap: .4rem; font-size: .72rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); margin: .5rem 0 .15rem; }
.calc-note { font-size: .8rem; color: var(--ink-2); background: var(--grey-soft); border-radius: 8px; padding: .45rem .6rem; margin-top: .5rem; }
.calc-note:empty { display: none; }

/* ---------- Daily loan: small month calendar ---------- */
.mcal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; max-width: 26rem; margin: 0 auto; }
.mcal-wd { text-align: center; font-size: .7rem; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.mcal-d { position: relative; aspect-ratio: 1 / 1; border: 1px solid transparent; border-radius: 9px; background: transparent;
  font-size: .85rem; font-weight: 600; color: var(--ink); display: flex; align-items: center; justify-content: center; gap: 1px;
  padding: 0; font-variant-numeric: tabular-nums; }
.mcal-d.is-due { border-color: var(--line); background: #fff; }
.mcal-d.c-paid { background: #d3f0e3; border-color: #a6dcc3; color: var(--brand-dark); }
.mcal-d.c-miss { background: #fbd5da; border-color: #f2a5b0; color: var(--red-dark); }
.mcal-d.c-part { background: linear-gradient(135deg, #d3f0e3 50%, #fff 50%); border-color: #a6dcc3; }
.mcal-d.c-extra { background: #fff6d6; border-color: #f3dc8b; }
.mcal-d.c-extra-paid { box-shadow: inset 0 -4px 0 #f3dc8b; }
.mcal-d.c-late::after { content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.mcal-d.c-skip { color: var(--muted); background: var(--grey-soft); font-weight: 500; }
.mcal-d.c-skip i, .mcal-d.c-given i { font-size: .6rem; }
.mcal-d.c-given { color: var(--blue-dark); font-weight: 500; }
.mcal-d.c-off { color: #c3c8d1; font-weight: 400; }
.mcal-d.c-today { outline: 2px solid var(--ink); outline-offset: 1px; }
.mcal-d:hover { filter: brightness(.97); }
.mcal-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem .8rem; font-size: .72rem; color: var(--ink-2); margin-top: .75rem; }
.mcal-legend .k { display: inline-block; width: .75rem; height: .75rem; border-radius: 3px; vertical-align: -1px; margin-right: .2rem;
  border: 1px solid var(--line); background: #fff; }
.mcal-legend .k-paid { background: #d3f0e3; border-color: #a6dcc3; }
.mcal-legend .k-miss { background: #fbd5da; border-color: #f2a5b0; }
.mcal-legend .k-extra { background: #fff6d6; border-color: #f3dc8b; }
.mcal-legend .k-part { background: linear-gradient(135deg, #d3f0e3 50%, #fff 50%); border-color: #a6dcc3; }
.mcal-legend .k-skip { background: var(--grey-soft); }
.mcal-legend .k-today { outline: 2px solid var(--ink); outline-offset: -1px; }

/* =====================================================================
   Collector app (dailyloans.electrohub.lk) - phone first, big and simple
   ===================================================================== */
body.cx { background: #eef2f6; font-size: 17px; padding-bottom: calc(5.2rem + env(safe-area-inset-bottom)); }
.cx [hidden] { display: none !important; }
.cx small { font-size: .72em; font-weight: 500; color: var(--muted); }
.cx-wrap { max-width: 560px; margin: 0 auto; padding: 0 12px; }
.cx-main { padding-top: 12px; }
.cx-top { position: sticky; top: 0; z-index: 1020; background: #0b7a5c; color: #fff; padding: 10px 0;
  box-shadow: 0 2px 8px rgba(16, 24, 40, .15); }
.cx-top small, .cx-top .cx-top-sub { color: rgba(255, 255, 255, .8); }
.cx-top-title { font-weight: 800; font-size: 1.15rem; line-height: 1.1; }
.cx-top-sub { font-size: .82rem; }
.cx-logo { width: 2.5rem; height: 2.5rem; border-radius: 12px; background: rgba(255, 255, 255, .18); display: inline-flex;
  align-items: center; justify-content: center; font-size: 1.35rem; flex: none; }
.cx-logo-lg { width: 4.5rem; height: 4.5rem; font-size: 2.4rem; background: #0b7a5c; color: #fff; border-radius: 20px; }
.cx-icon { width: 2.75rem; height: 2.75rem; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .15); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.cx-h1 { font-size: 1.7rem; font-weight: 800; margin: 0; }
.cx-h2 { font-size: 1.15rem; font-weight: 800; margin: 18px 2px 8px; cursor: pointer; }
.cx-card { background: #fff; border-radius: 16px; box-shadow: 0 1px 3px rgba(16, 24, 40, .08); margin-bottom: 10px; display: block;
  color: var(--ink); text-decoration: none; }
a.cx-card:hover { color: var(--ink); }
.cx-flash { display: flex; gap: .6rem; align-items: flex-start; border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; font-weight: 600; }
.cx-flash i { font-size: 1.3rem; line-height: 1.2; }
.cx-flash-success { background: #d3f0e3; color: #08583f; }
.cx-flash-danger { background: #fbd5da; color: #8f1d2c; }
.cx-flash-warning { background: #fdf0cf; color: #7a4504; }
.cx-flash-info { background: var(--blue-soft); color: var(--blue-dark); }
.cx-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.cx-sum > * { background: #fff; border-radius: 16px; padding: 10px 12px; box-shadow: 0 1px 3px rgba(16, 24, 40, .08); text-decoration: none; color: var(--ink); }
.cx-sum-cash { grid-column: 1 / -1; background: #102a22 !important; color: #fff !important; }
.cx-sum-cash small, .cx-sum-cash .cx-sum-l { color: rgba(255, 255, 255, .8); }
.cx-sum-l { font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.cx-sum-v { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cx-search { position: relative; margin-bottom: 4px; }
.cx-search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.cx-search .cx-input { padding-left: 40px; }
.cx-input { font-size: 1.1rem; min-height: 3.2rem; border-radius: 14px; }
.cx-input-money { font-size: 1.6rem; font-weight: 800; text-align: center; }
.cx-label { font-weight: 700; display: block; margin-bottom: 4px; }
.cx-client { padding: 12px; border-left: 6px solid transparent; }
.cx-client.is-missed { border-left-color: var(--red); }
.cx-client.is-visited { border-left-color: #e9a23b; opacity: .92; }
.cx-client-head { display: flex; justify-content: space-between; gap: 10px; text-decoration: none; color: var(--ink); }
.cx-name { font-size: 1.25rem; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.cx-name-sm { font-weight: 700; }
.cx-sub { font-size: .88rem; color: var(--ink-2); }
.cx-amt { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cx-badge { display: inline-block; margin-top: 4px; font-size: .78rem; font-weight: 700; border-radius: 999px; padding: 2px 8px; }
.cx-badge-red { background: #fbd5da; color: #8f1d2c; }
.cx-badge-amber { background: #fdf0cf; color: #7a4504; }
.cx-actions { display: flex; gap: 8px; margin-top: 10px; align-items: stretch; }
.cx-btn { min-height: 3.4rem; border-radius: 14px; font-size: 1.15rem; font-weight: 800; display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1.15; }
.cx-btn small { color: inherit; opacity: .85; font-weight: 600; }
.cx-btn-xl { min-height: 4.6rem; font-size: 1.3rem; }
.cx-btn-call, .cx-btn-more { min-width: 3.4rem; min-height: 3.4rem; border-radius: 14px; font-size: 1.3rem; display: inline-flex;
  align-items: center; justify-content: center; }
.cx-btn-call { background: #e2f5ee; color: #08583f; }
.cx-btn-more { background: var(--grey-soft); color: var(--ink-2); }
.cx-btn-soft { background: #fff; border: 2px solid var(--line); color: var(--ink); }
.cx-btn-soft-red { background: #fff; border: 2px solid #f2a5b0; color: #8f1d2c; }
.cx-done { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.cx-done > i:first-child { font-size: 1.4rem; }
.cx-empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.cx-empty i { font-size: 2.2rem; display: block; margin-bottom: 6px; }
.cx-empty div { font-weight: 700; color: var(--ink-2); }
.cx-back { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--ink-2); text-decoration: none;
  min-height: 2.75rem; margin-bottom: 4px; }
.cx-avatar { width: 3.2rem; height: 3.2rem; border-radius: 50%; background: var(--blue-soft); color: var(--blue-dark); font-weight: 800;
  font-size: 1.4rem; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.cx-due { background: #102a22; color: #fff; border-radius: 18px; padding: 16px; margin-bottom: 12px; text-align: center; }
.cx-due small { color: rgba(255, 255, 255, .75); }
.cx-due.is-zero { background: #08583f; }
.cx-due-l { font-weight: 700; opacity: .9; }
.cx-due-v { font-size: 2.3rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.cx-due-parts { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; font-size: .88rem; margin-top: 4px; }
.cx-due-parts .text-danger { color: #ffb3bd !important; font-weight: 700; }
.cx-kv { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
.cx-kv:first-child { border-top: 0; }
.cx-week { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); gap: 5px; }
.cx-day { border-radius: 10px; text-align: center; padding: 4px 0; font-size: .7rem; border: 1px solid var(--line); background: #fff; color: var(--ink-2); }
.cx-day strong { display: block; font-size: 1rem; color: var(--ink); }
.cx-day.st-paid { background: #d3f0e3; border-color: #a6dcc3; }
.cx-day.st-overdue { background: #fbd5da; border-color: #f2a5b0; }
.cx-day.st-partial { background: linear-gradient(135deg, #d3f0e3 50%, #fff 50%); }
.cx-day.is-today { outline: 2px solid var(--ink); outline-offset: 1px; }
.cx-legend { display: flex; gap: 12px; font-size: .78rem; color: var(--ink-2); margin-top: 8px; }
.cx-legend .k { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; border: 1px solid var(--line); background: #fff; vertical-align: -1px; }
.cx-legend .k-paid { background: #d3f0e3; }
.cx-legend .k-miss { background: #fbd5da; }
.cx-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 10px rgba(16, 24, 40, .06); }
.cx-tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 0 6px; text-decoration: none;
  color: var(--ink-2); font-weight: 700; font-size: .9rem; line-height: 1.15; }
.cx-tabs a i { font-size: 1.5rem; }
.cx-tabs a.active { color: #0b7a5c; }
.cx-login { max-width: 420px; margin: 8vh auto 0; }
.cx-modal { border-radius: 20px; font-size: 1.2rem; font-weight: 700; }
.cx-modal .btn { min-height: 3.4rem; border-radius: 14px; font-weight: 800; }

/* ---------- Admin daily collection page ---------- */
.collector-card { border: 1px solid var(--line); border-radius: 14px; padding: .85rem; background: #fff; height: 100%; }
.daily-row { display: grid; grid-template-columns: 1fr; gap: .4rem; padding: .8rem 1rem; border-top: 1px solid var(--line); }
#dailyList > .daily-row:first-child { border-top: 0; }
.daily-row.is-bad { background: #fff5f6; }
.daily-row[hidden] { display: none; }
.dr-act .input-group { max-width: 13rem; }
@media (min-width: 992px) {
  .daily-row { grid-template-columns: minmax(0, 1.6fr) minmax(0, .9fr) 11rem 12rem; align-items: center; gap: .75rem; }
}
