/* =====================================================================
   SACCOms — design system
   Palette: deep co-operative green + slate navy + harvest gold
   Type:    Plus Jakarta Sans (UI/headings) + Inter (body/numerals)
   ===================================================================== */

:root {
  /* Brand */
  --brand-50:  #e8f5ef;
  --brand-100: #c7e7d9;
  --brand-200: #97d3bb;
  --brand-300: #62b998;
  --brand-400: #2f9e78;
  --brand-500: #0e7c5a;   /* primary */
  --brand-600: #0b6a4d;
  --brand-700: #08543d;
  --brand-800: #063f2e;
  --brand-900: #042a1f;

  --gold-300: #f5d68a;
  --gold-400: #eebc4f;
  --gold-500: #e5a72c;
  --gold-600: #c2861a;

  /* Neutrals */
  --ink-900: #0c1622;
  --ink-800: #16243a;
  --ink-700: #24344b;
  --ink-600: #3b4e69;
  --ink-500: #5b6e8a;
  --ink-400: #8496ae;
  --ink-300: #b3c0d1;
  --ink-200: #d8e0ea;
  --ink-100: #eaeff5;
  --ink-50:  #f5f8fb;

  /* Semantic surfaces */
  --bg:        #f2f5f9;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --border:    #e2e8f0;
  --border-strong: #cdd7e4;
  --text:      var(--ink-800);
  --text-muted:var(--ink-500);
  --sidebar-bg:  #0d1b2a;
  --sidebar-bg2: #102336;
  --sidebar-text:#a8bacd;
  --sidebar-active: rgba(255,255,255,.08);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-xs: 0 1px 2px rgba(12,22,34,.05);
  --shadow-sm: 0 1px 3px rgba(12,22,34,.07), 0 1px 2px rgba(12,22,34,.04);
  --shadow:    0 4px 14px rgba(12,22,34,.07), 0 1px 3px rgba(12,22,34,.05);
  --shadow-lg: 0 12px 32px rgba(12,22,34,.11), 0 2px 8px rgba(12,22,34,.05);

  --sidebar-w: 264px;
  --topbar-h: 68px;

  /* Bootstrap overrides */
  --bs-primary: var(--brand-500);
  --bs-primary-rgb: 14,124,90;
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-color: var(--text);
  --bs-body-bg: var(--bg);
  --bs-border-color: var(--border);
  --bs-link-color: var(--brand-600);
  --bs-link-hover-color: var(--brand-700);
  --bs-border-radius: var(--radius);
}

[data-bs-theme="dark"] {
  --bg:        #0a121c;
  --surface:   #111e2c;
  --surface-2: #16263a;
  --border:    #223449;
  --border-strong: #2e4460;
  --text:      #dde6f0;
  --text-muted:#8ba0b8;
  --ink-100:   #1a2a3d;
  --ink-50:    #16263a;
  --ink-200:   #26394f;
  --sidebar-bg:  #08121c;
  --sidebar-bg2: #0c1a28;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.35);
  --shadow:    0 4px 14px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  --bs-body-color: var(--text);
  --bs-body-bg: var(--bg);
  --bs-border-color: var(--border);
  --bs-link-color: var(--brand-300);
  --bs-emphasis-color: #fff;
}

/* ------------------------------------------------------------ Base */
* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--bs-body-font-family);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4, h5, h6, .font-display, .btn, .nav-link, .badge, th {
  font-family: 'Plus Jakarta Sans', var(--bs-body-font-family);
}
h1, h2, h3, h4, h5, h6 { font-weight: 700; color: var(--text); letter-spacing: -.015em; }
a { text-decoration: none; transition: color .15s ease; }
.text-muted { color: var(--text-muted) !important; }
.tabular { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: -.01em; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 3000;
  background: var(--brand-600); color: #fff; padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; color: #fff; }

:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------ Sidebar */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040;
  background: linear-gradient(178deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.05);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.sidebar-brand {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  height: var(--topbar-h); padding: 0 1rem 0 1.1rem; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-link { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-600));
  color: #fff; display: grid; place-items: center; font-size: 1.05rem;
  box-shadow: 0 3px 10px rgba(14,124,90,.4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong {
  font-family: 'Plus Jakarta Sans'; font-size: .98rem; font-weight: 800; color: #fff;
  letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text small { font-size: .68rem; color: var(--brand-200); letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }

.sidebar-user {
  display: flex; align-items: center; gap: .65rem; padding: .85rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.06); flex-shrink: 0;
}
.su-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.su-name { font-size: .84rem; font-weight: 600; color: #e8eef5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-role { font-size: .7rem; color: var(--ink-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .6rem 1rem; scrollbar-width: thin; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

.nav-group + .nav-group { margin-top: .35rem; }
.nav-group-label {
  font-size: .64rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700;
  color: var(--ink-500); padding: .7rem .75rem .3rem;
}
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 9px;
  color: var(--sidebar-text); font-size: .845rem; font-weight: 500;
  transition: background .14s ease, color .14s ease; position: relative;
}
.sidebar-nav .nav-link i:first-child { width: 18px; text-align: center; font-size: .88rem; opacity: .85; flex-shrink: 0; }
.sidebar-nav .nav-link span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.055); color: #fff; }
.sidebar-nav .nav-link.active {
  background: var(--sidebar-active); color: #fff; font-weight: 600;
}
.sidebar-nav .nav-link.active::before {
  content: ''; position: absolute; left: -.6rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--brand-300), var(--gold-500));
}
.sidebar-nav .nav-link.active i:first-child { color: var(--brand-300); opacity: 1; }
.nav-count {
  font-style: normal; font-size: .66rem; font-weight: 700; min-width: 19px; height: 19px;
  padding: 0 5px; border-radius: 10px; display: grid; place-items: center;
  background: var(--gold-500); color: #2a1c00; flex-shrink: 0;
}
.sidebar-foot { padding: .6rem; border-top: 1px solid rgba(255,255,255,.06); flex-shrink: 0; }
.sidebar-foot .nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 9px;
  color: #f0a5a5; font-size: .845rem; font-weight: 500;
}
.sidebar-foot .nav-link:hover { background: rgba(220,38,38,.14); color: #ffc9c9; }
.sidebar-version { text-align: center; font-size: .66rem; color: var(--ink-600); padding-top: .4rem; }

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(8,18,28,.55); backdrop-filter: blur(2px);
  z-index: 1035; opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s;
}
body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }

/* ------------------------------------------------------------ Shell */
.shell {
  margin-left: var(--sidebar-w); min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .28s cubic-bezier(.4,0,.2,1);
}
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .85rem; padding: 0 1.15rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
@supports not (background: color-mix(in srgb, red, blue)) {
  .topbar { background: var(--surface); }
}
.topbar-title { min-width: 0; flex-shrink: 1; }
.topbar-title h1 { font-size: 1.09rem; margin: 0; font-weight: 700; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 0; font-size: .765rem; color: var(--text-muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }

.topbar-search { position: relative; margin-left: auto; width: min(340px, 34vw); }
.topbar-search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
  color: var(--ink-400); font-size: .82rem; pointer-events: none; }
.topbar-search input {
  padding-left: 2.2rem; height: 38px; border-radius: 999px; font-size: .84rem;
  background: var(--surface-2); border-color: var(--border);
}
.topbar-search input:focus { background: var(--surface); box-shadow: 0 0 0 3px rgba(14,124,90,.13); border-color: var(--brand-300); }

.topbar-actions { display: flex; align-items: center; gap: .3rem; margin-left: auto; }
.topbar-search ~ .topbar-actions { margin-left: 0; }

.btn-icon {
  width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent;
  color: var(--text-muted); display: grid; place-items: center; font-size: .95rem;
  transition: background .15s, color .15s; flex-shrink: 0;
}
.btn-icon:hover { background: var(--ink-100); color: var(--text); }
.dot-badge {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: #dc2626; color: #fff; font-size: .62rem; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--surface); box-sizing: content-box;
}
.user-chip {
  display: flex; align-items: center; gap: .5rem; border: 1px solid var(--border);
  background: var(--surface); border-radius: 999px; padding: .25rem .7rem .25rem .3rem;
  font-size: .84rem; font-weight: 600; color: var(--text); transition: box-shadow .15s, border-color .15s;
}
.user-chip:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }

.content { flex: 1; padding: 1.35rem 1.35rem 2rem; max-width: 1680px; width: 100%; }
.app-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .85rem 1.35rem; border-top: 1px solid var(--border);
  font-size: .75rem; color: var(--text-muted); background: var(--surface);
}
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.breadcrumb { font-size: .78rem; margin-bottom: .85rem; }
.breadcrumb-item + .breadcrumb-item::before { content: '›'; color: var(--ink-400); }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .shell { margin-left: 0; }
  .content { padding: 1rem 1rem 2rem; }
  .topbar { padding: 0 .85rem; }
  .topbar-search { display: none; }
}

/* ------------------------------------------------------------ Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs); transition: box-shadow .18s ease, transform .18s ease;
}
.card-hover:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card-header {
  background: transparent; border-bottom: 1px solid var(--border);
  padding: .95rem 1.15rem; display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
}
.card-header h2, .card-header h3, .card-header h5, .card-header h6 { margin: 0; font-size: .95rem; font-weight: 700; }
.card-header .hdr-sub { font-size: .74rem; color: var(--text-muted); font-weight: 400; margin: 0; }
.card-body { padding: 1.15rem; }
.card-footer { background: var(--surface-2); border-top: 1px solid var(--border); padding: .8rem 1.15rem;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Stat tiles */
.stat-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.05rem 1.15rem; box-shadow: var(--shadow-xs); position: relative; overflow: hidden;
  transition: box-shadow .18s, transform .18s;
}
.stat:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--sc, var(--brand-500)), transparent 85%);
}
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.stat-label { font-size: .715rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--text-muted); }
.stat-icon {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  font-size: .95rem; background: color-mix(in srgb, var(--sc, var(--brand-500)) 12%, transparent);
  color: var(--sc, var(--brand-500)); flex-shrink: 0;
}
@supports not (background: color-mix(in srgb, red, blue)) { .stat-icon { background: var(--ink-100); } }
.stat-value {
  font-family: 'Plus Jakarta Sans'; font-size: 1.62rem; font-weight: 800; letter-spacing: -.03em;
  margin: .35rem 0 .1rem; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text);
}
.stat-value small { font-size: .62em; font-weight: 700; color: var(--text-muted); }
.stat-meta { font-size: .745rem; color: var(--text-muted); display: flex; align-items: center; gap: .3rem; }
.trend-up { color: #16a34a; font-weight: 600; }
.trend-down { color: #dc2626; font-weight: 600; }

/* ------------------------------------------------------------ Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
.table { margin: 0; --bs-table-bg: transparent; color: var(--text); }
.table > :not(caption) > * > * { background: transparent; }
.table thead th {
  font-size: .695rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  color: var(--text-muted); background: var(--surface-2); border-bottom: 1px solid var(--border);
  padding: .68rem .85rem; white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
.table tbody td { padding: .72rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .85rem; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table .num, .table .text-end { font-variant-numeric: tabular-nums; }
.table-sticky-first th:first-child, .table-sticky-first td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.table-hover.table-sticky-first tbody tr:hover td:first-child { background: var(--surface-2); }

.empty-state { text-align: center; padding: 2.75rem 1.25rem; color: var(--text-muted); }
.empty-state i { font-size: 2.4rem; opacity: .28; margin-bottom: .7rem; display: block; }
.empty-state h6 { font-size: .95rem; color: var(--text); margin-bottom: .3rem; }
.empty-state p { font-size: .82rem; margin: 0 auto; max-width: 380px; }

/* ------------------------------------------------------------ Badges & chips */
.badge { font-weight: 600; font-size: .7rem; padding: .34em .62em; border-radius: 6px; letter-spacing: .01em; }
.badge-soft-primary   { background: rgba(14,124,90,.11);  color: var(--brand-600); }
.badge-soft-success   { background: rgba(22,163,74,.12);  color: #15803d; }
.badge-soft-danger    { background: rgba(220,38,38,.11);  color: #b91c1c; }
.badge-soft-warning   { background: rgba(217,119,6,.13);  color: #b45309; }
.badge-soft-info      { background: rgba(8,145,178,.12);  color: #0e7490; }
.badge-soft-secondary { background: rgba(91,110,138,.12); color: var(--ink-600); }
.badge-soft-dark      { background: rgba(12,22,34,.1);    color: var(--ink-800); }
[data-bs-theme="dark"] .badge-soft-success   { color: #4ade80; }
[data-bs-theme="dark"] .badge-soft-danger    { color: #fca5a5; }
[data-bs-theme="dark"] .badge-soft-warning   { color: #fcd34d; }
[data-bs-theme="dark"] .badge-soft-info      { color: #67e8f9; }
[data-bs-theme="dark"] .badge-soft-primary   { color: var(--brand-300); }
[data-bs-theme="dark"] .badge-soft-secondary { color: var(--ink-300); }
[data-bs-theme="dark"] .badge-soft-dark      { color: var(--ink-200); background: rgba(255,255,255,.08); }

.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .28rem .6rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  font-size: .755rem; font-weight: 500; color: var(--text-muted);
}
.chip strong { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------ Avatars */
.avatar {
  border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0; overflow: hidden;
  font-family: 'Plus Jakarta Sans'; font-weight: 700; letter-spacing: -.02em; line-height: 1;
  background: hsl(var(--av-h, 160) 42% 88%); color: hsl(var(--av-h, 160) 55% 26%);
  border: 1px solid hsl(var(--av-h, 160) 40% 80%);
}
[data-bs-theme="dark"] .avatar { background: hsl(var(--av-h, 160) 32% 24%); color: hsl(var(--av-h, 160) 60% 78%);
  border-color: hsl(var(--av-h, 160) 30% 32%); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 26px; height: 26px; font-size: .62rem; }
.avatar-sm { width: 32px; height: 32px; font-size: .7rem; }
.avatar-md { width: 38px; height: 38px; font-size: .8rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar-xl { width: 88px; height: 88px; font-size: 1.9rem; }

/* Cell that pairs an avatar with two lines of text */
.person { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.person-body { min-width: 0; line-height: 1.3; }
.person-name { font-weight: 600; font-size: .845rem; color: var(--text); display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-meta { font-size: .735rem; color: var(--text-muted); display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------ Buttons */
.btn { font-weight: 600; font-size: .845rem; border-radius: 9px; padding: .48rem .95rem;
  transition: all .16s ease; letter-spacing: -.005em; }
.btn-sm { font-size: .785rem; padding: .34rem .7rem; border-radius: 8px; }
.btn-lg { font-size: .95rem; padding: .68rem 1.4rem; border-radius: 11px; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  border-color: var(--brand-600); box-shadow: 0 1px 2px rgba(6,63,46,.25);
}
.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(180deg, var(--brand-600), var(--brand-700));
  border-color: var(--brand-700); box-shadow: 0 3px 10px rgba(14,124,90,.3);
}
.btn-outline-primary { color: var(--brand-600); border-color: var(--brand-300); }
.btn-outline-primary:hover { background: var(--brand-500); border-color: var(--brand-500); }
.btn-gold { background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); border: 1px solid var(--gold-600); color: #2f2101; }
.btn-gold:hover { background: linear-gradient(180deg, var(--gold-500), var(--gold-600)); color: #2f2101; }
.btn-light { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-light:hover { background: var(--ink-100); border-color: var(--border-strong); color: var(--text); }
[data-bs-theme="dark"] .btn-light:hover { background: var(--surface-2); }
.btn-soft {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.btn-soft:hover { background: var(--ink-100); border-color: var(--border-strong); }
.btn-outline-secondary { color: var(--text-muted); border-color: var(--border-strong); }
.btn-outline-secondary:hover { background: var(--ink-100); color: var(--text); border-color: var(--border-strong); }

/* ------------------------------------------------------------ Forms */
.form-label { font-size: .795rem; font-weight: 600; margin-bottom: .34rem; color: var(--text); }
.form-label .text-danger { font-weight: 400; }
.form-text { font-size: .74rem; color: var(--text-muted); }
.form-control, .form-select {
  border-radius: 9px; border-color: var(--border-strong); font-size: .865rem;
  padding: .5rem .75rem; background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-400); box-shadow: 0 0 0 3px rgba(14,124,90,.13); background: var(--surface);
}
.form-control::placeholder { color: var(--ink-400); }
.form-control:disabled, .form-control[readonly], .form-select:disabled {
  background: var(--surface-2); color: var(--text-muted); }
.form-control-lg { font-size: .95rem; padding: .68rem .9rem; border-radius: 11px; }
textarea.form-control { min-height: 90px; }
.input-group-text { background: var(--surface-2); border-color: var(--border-strong);
  color: var(--text-muted); font-size: .82rem; font-weight: 600; }
.form-check-input:checked { background-color: var(--brand-500); border-color: var(--brand-500); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(14,124,90,.13); border-color: var(--brand-400); }
.form-check-label { font-size: .855rem; }
.is-invalid ~ .invalid-feedback, .invalid-feedback { font-size: .755rem; }
.was-validated .form-control:invalid, .form-control.is-invalid { border-color: #dc2626; }

fieldset.fset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem 1.1rem; margin-bottom: 1.1rem; }
fieldset.fset > legend {
  float: none; width: auto; font-size: .74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--brand-600); padding: 0 .45rem; margin: 0 0 .35rem -.45rem;
}
[data-bs-theme="dark"] fieldset.fset > legend { color: var(--brand-300); }

/* Password field with reveal toggle */
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 2.7rem; }
.pw-toggle {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; background: transparent; color: var(--ink-400);
  border-radius: 8px; display: grid; place-items: center; cursor: pointer; transition: color .15s;
}
.pw-toggle:hover { color: var(--brand-500); }

/* Password strength meter */
.pw-meter { display: flex; gap: 4px; margin-top: .45rem; }
.pw-meter span { height: 4px; flex: 1; border-radius: 2px; background: var(--ink-200); transition: background .25s; }
.pw-meter.s1 span:nth-child(1) { background: #dc2626; }
.pw-meter.s2 span:nth-child(-n+2) { background: #f59e0b; }
.pw-meter.s3 span:nth-child(-n+3) { background: #eab308; }
.pw-meter.s4 span:nth-child(-n+4) { background: #22c55e; }
.pw-hint { font-size: .73rem; color: var(--text-muted); margin-top: .3rem; }
.pw-rules { list-style: none; padding: 0; margin: .5rem 0 0; font-size: .74rem; columns: 2; }
.pw-rules li { color: var(--text-muted); padding-left: 1.15rem; position: relative; }
.pw-rules li::before { content: '\f111'; font-family: 'Font Awesome 6 Free'; font-weight: 400;
  position: absolute; left: 0; font-size: .5rem; top: .42em; }
.pw-rules li.ok { color: #16a34a; }
.pw-rules li.ok::before { content: '\f058'; font-weight: 900; font-size: .72rem; top: .1em; }

/* Filter bar */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: .55rem; align-items: flex-end;
  padding: .9rem 1.05rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 1rem; box-shadow: var(--shadow-xs);
}
.filter-bar .fb-field { display: flex; flex-direction: column; gap: .2rem; min-width: 140px; }
.filter-bar .fb-field > label { font-size: .69rem; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 700; color: var(--text-muted); }
.filter-bar .form-control, .filter-bar .form-select { height: 36px; font-size: .82rem; padding-top: .25rem; padding-bottom: .25rem; }
.filter-bar .fb-grow { flex: 1 1 200px; }

/* Segmented tabs */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a {
  padding: .34rem .78rem; border-radius: 7px; font-size: .8rem; font-weight: 600;
  color: var(--text-muted); transition: all .15s; white-space: nowrap;
}
.seg a:hover { color: var(--text); background: var(--surface); }
.seg a.active { background: var(--surface); color: var(--brand-600); box-shadow: var(--shadow-xs); }
[data-bs-theme="dark"] .seg a.active { color: var(--brand-300); }
.seg a .cnt { font-size: .68rem; opacity: .7; margin-left: .18rem; }

/* Nav tabs */
.nav-tabs { border-bottom: 1px solid var(--border); gap: .15rem; }
.nav-tabs .nav-link {
  border: 0; border-bottom: 2px solid transparent; color: var(--text-muted);
  font-size: .855rem; font-weight: 600; padding: .6rem .9rem; border-radius: 0;
}
.nav-tabs .nav-link:hover { color: var(--text); border-bottom-color: var(--border-strong); background: transparent; }
.nav-tabs .nav-link.active { color: var(--brand-600); border-bottom-color: var(--brand-500); background: transparent; }
[data-bs-theme="dark"] .nav-tabs .nav-link.active { color: var(--brand-300); }

/* ------------------------------------------------------------ Dropdowns / modals */
.dropdown-menu {
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: .35rem; font-size: .855rem; background: var(--surface); min-width: 200px;
}
.dropdown-item { border-radius: 7px; padding: .45rem .65rem; color: var(--text); font-weight: 500; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); color: var(--text); }
.dropdown-item.text-danger:hover { background: rgba(220,38,38,.09); color: #b91c1c; }
.dropdown-header { font-size: .76rem; padding: .5rem .65rem; }
.dropdown-divider { border-color: var(--border); margin: .3rem 0; }

.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); background: var(--surface); }
.modal-header { border-bottom: 1px solid var(--border); padding: 1rem 1.2rem; }
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-body { padding: 1.2rem; }
.modal-footer { border-top: 1px solid var(--border); padding: .85rem 1.2rem; background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.offcanvas { background: var(--surface); color: var(--text); }

/* Notifications dropdown */
.notif-menu { width: 340px; max-width: calc(100vw - 1.5rem); padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center;
  padding: .7rem .9rem; border-bottom: 1px solid var(--border); font-size: .85rem; }
.notif-list { max-height: 330px; overflow-y: auto; }
.notif-item { display: flex; gap: .65rem; padding: .65rem .9rem; border-bottom: 1px solid var(--border);
  color: var(--text); transition: background .12s; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: rgba(14,124,90,.045); }
.notif-item.unread .ni-body strong::after {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand-500); margin-left: .35rem; vertical-align: middle;
}
.ni-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  font-size: .78rem; flex-shrink: 0; }
.ni-body { min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.ni-body strong { font-size: .81rem; font-weight: 600; }
.ni-body small { font-size: .745rem; color: var(--text-muted); }
.ni-body time { font-size: .69rem; color: var(--ink-400); margin-top: .1rem; }
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); font-size: .82rem; }
.notif-empty i { display: block; font-size: 1.6rem; opacity: .3; margin-bottom: .4rem; }
.notif-foot { display: block; text-align: center; padding: .6rem; font-size: .8rem; font-weight: 600;
  border-top: 1px solid var(--border); color: var(--brand-600); }

/* ------------------------------------------------------------ Alerts */
.alert { border: 1px solid transparent; border-radius: var(--radius); font-size: .865rem; padding: .8rem 1rem; }
.alert-success { background: rgba(22,163,74,.09);  border-color: rgba(22,163,74,.22);  color: #15803d; }
.alert-danger  { background: rgba(220,38,38,.08);  border-color: rgba(220,38,38,.22);  color: #b91c1c; }
.alert-warning { background: rgba(217,119,6,.09);  border-color: rgba(217,119,6,.24);  color: #b45309; }
.alert-info    { background: rgba(8,145,178,.08);  border-color: rgba(8,145,178,.22);  color: #0e7490; }
[data-bs-theme="dark"] .alert-success { color: #86efac; }
[data-bs-theme="dark"] .alert-danger  { color: #fca5a5; }
[data-bs-theme="dark"] .alert-warning { color: #fcd34d; }
[data-bs-theme="dark"] .alert-info    { color: #7dd3fc; }

/* ------------------------------------------------------------ Progress */
.progress { height: 7px; border-radius: 999px; background: var(--ink-200); }
.progress-bar { background: linear-gradient(90deg, var(--brand-400), var(--brand-500)); border-radius: 999px; }
.progress-bar.bg-warning { background: linear-gradient(90deg, var(--gold-400), var(--gold-500)); }
.progress-bar.bg-danger  { background: linear-gradient(90deg, #f87171, #dc2626); }
.progress-bar.bg-success { background: linear-gradient(90deg, #4ade80, #16a34a); }
.pagination { --bs-pagination-border-radius: 8px; }
.page-link { color: var(--text); border-color: var(--border); font-size: .82rem; font-weight: 600;
  background: var(--surface); }
.page-link:hover { background: var(--surface-2); color: var(--brand-600); border-color: var(--border-strong); }
.page-item.active .page-link { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.page-item.disabled .page-link { background: var(--surface-2); color: var(--ink-400); }

/* ------------------------------------------------------------ Auth pages */
.auth-body {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr;
  font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text);
}
.auth-aside {
  background: linear-gradient(155deg, var(--brand-700) 0%, #0a3d2d 45%, var(--ink-900) 100%);
  color: #fff; padding: 2.6rem 3rem; display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
.auth-aside::before {
  content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(229,167,44,.16) 0%, transparent 65%);
  top: -180px; right: -160px;
}
.auth-aside::after {
  content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle, rgba(47,158,120,.2) 0%, transparent 65%);
  bottom: -160px; left: -120px;
}
.auth-brand { display: flex; align-items: center; gap: .8rem; position: relative; z-index: 1; }
.auth-brand .brand-mark { width: 44px; height: 44px; font-size: 1.2rem; border-radius: 13px; }
.auth-brand strong { font-family: 'Plus Jakarta Sans'; font-size: 1.16rem; font-weight: 800; letter-spacing: -.02em; }
.auth-brand small { display: block; font-size: .7rem; color: var(--brand-200); letter-spacing: .08em;
  text-transform: uppercase; font-weight: 600; }
.auth-pitch { margin-top: auto; position: relative; z-index: 1; }
.auth-pitch h2 { font-size: 2.05rem; font-weight: 800; letter-spacing: -.035em; line-height: 1.15;
  color: #fff; margin-bottom: .9rem; max-width: 15ch; }
.auth-pitch h2 em { font-style: normal; color: var(--gold-400); }
.auth-pitch p { color: rgba(255,255,255,.72); font-size: .95rem; max-width: 44ch; margin-bottom: 1.8rem; }
.auth-features { list-style: none; padding: 0; margin: 0 0 2rem; display: grid; gap: .7rem; }
.auth-features li { display: flex; align-items: center; gap: .7rem; font-size: .875rem; color: rgba(255,255,255,.85); }
.auth-features i { width: 28px; height: 28px; border-radius: 8px; background: rgba(255,255,255,.1);
  display: grid; place-items: center; font-size: .76rem; color: var(--brand-200); flex-shrink: 0; }
.auth-stats { display: flex; gap: 2rem; position: relative; z-index: 1; flex-wrap: wrap;
  padding-top: 1.4rem; border-top: 1px solid rgba(255,255,255,.12); }
.auth-stats div strong { display: block; font-family: 'Plus Jakarta Sans'; font-size: 1.45rem;
  font-weight: 800; letter-spacing: -.03em; color: #fff; }
.auth-stats div span { font-size: .72rem; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .06em; }

.auth-main { display: grid; place-items: center; padding: 2rem 1.5rem; overflow-y: auto; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: .3rem; }
.auth-card .lead-sm { color: var(--text-muted); font-size: .88rem; margin-bottom: 1.7rem; }
.auth-foot { margin-top: 1.7rem; padding-top: 1.2rem; border-top: 1px solid var(--border);
  font-size: .82rem; color: var(--text-muted); text-align: center; }
.auth-mobile-brand { display: none; }

@media (max-width: 991.98px) {
  .auth-body { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-mobile-brand { display: flex; justify-content: center; margin-bottom: 1.6rem; }
  .auth-mobile-brand .brand-mark { width: 46px; height: 46px; font-size: 1.25rem; border-radius: 13px; }
}

/* Demo credential cards on the login page */
.demo-grid { display: grid; gap: .4rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.demo-chip {
  display: flex; flex-direction: column; gap: .05rem; padding: .5rem .65rem; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  font-size: .74rem; cursor: pointer; transition: all .15s; color: var(--text);
}
.demo-chip:hover { border-color: var(--brand-400); background: var(--brand-50); }
[data-bs-theme="dark"] .demo-chip:hover { background: rgba(14,124,90,.15); }
.demo-chip strong { font-size: .77rem; font-weight: 700; }
.demo-chip span { color: var(--text-muted); font-size: .69rem; font-family: 'Inter'; }

/* ------------------------------------------------------------ Error page */
.err-body { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem;
  background: var(--bg); font-family: 'Inter', sans-serif; }
.err-card { text-align: center; max-width: 520px; background: #fff; padding: 2.5rem 2rem;
  border-radius: 20px; box-shadow: 0 12px 40px rgba(12,22,34,.1); border: 1px solid #e2e8f0; }
.err-code { font-family: 'Plus Jakarta Sans'; font-size: 4.5rem; font-weight: 800; line-height: 1;
  letter-spacing: -.05em; background: linear-gradient(140deg, var(--brand-500), var(--gold-500));
  -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: .4rem; }
.err-card h1 { font-size: 1.4rem; margin-bottom: .6rem; }
.err-card p { font-size: .9rem; margin-bottom: 1.5rem; }
.err-detail { text-align: left; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: .8rem; font-size: .74rem; color: #b91c1c; white-space: pre-wrap; margin-bottom: 1.3rem;
  max-height: 200px; overflow: auto; }

/* ------------------------------------------------------------ Timeline */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 15px; top: 8px; bottom: 8px; width: 2px;
  background: var(--border); }
.timeline li { position: relative; padding: 0 0 1.05rem 2.5rem; }
.timeline li:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: 0; top: 1px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: .72rem; background: var(--surface);
  border: 2px solid var(--border); color: var(--text-muted); z-index: 1; }
.tl-dot.ok { border-color: #16a34a; color: #16a34a; background: rgba(22,163,74,.08); }
.tl-dot.no { border-color: #dc2626; color: #dc2626; background: rgba(220,38,38,.08); }
.tl-dot.wait { border-color: var(--gold-500); color: var(--gold-600); background: rgba(229,167,44,.1); }
.tl-title { font-size: .865rem; font-weight: 600; line-height: 1.35; }
.tl-meta { font-size: .745rem; color: var(--text-muted); }
.tl-note { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; background: var(--surface-2);
  border-radius: 8px; padding: .45rem .6rem; border-left: 2px solid var(--border-strong); }

/* ------------------------------------------------------------ Key/value grid */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .1rem 1.4rem; }
.kv > div { padding: .5rem 0; border-bottom: 1px dashed var(--border); }
.kv dt, .kv .k { font-size: .705rem; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 700; color: var(--text-muted); margin: 0; }
.kv dd, .kv .v { font-size: .875rem; margin: .1rem 0 0; font-weight: 500; color: var(--text); word-break: break-word; }

/* ------------------------------------------------------------ Quill */
.ql-toolbar.ql-snow { border-color: var(--border-strong) !important; border-radius: 9px 9px 0 0;
  background: var(--surface-2); }
.ql-container.ql-snow { border-color: var(--border-strong) !important; border-radius: 0 0 9px 9px;
  background: var(--surface); font-family: var(--bs-body-font-family); font-size: .9rem; }
.ql-editor { min-height: 200px; color: var(--text); }
.ql-editor.ql-blank::before { color: var(--ink-400); font-style: normal; }
[data-bs-theme="dark"] .ql-snow .ql-stroke { stroke: var(--ink-300); }
[data-bs-theme="dark"] .ql-snow .ql-fill { fill: var(--ink-300); }
[data-bs-theme="dark"] .ql-snow .ql-picker-label { color: var(--ink-300); }
[data-bs-theme="dark"] .ql-snow .ql-picker-options { background: var(--surface); border-color: var(--border); }

/* Rendered rich text */
.rich { font-size: .9rem; line-height: 1.7; color: var(--text); }
.rich h1 { font-size: 1.4rem; } .rich h2 { font-size: 1.2rem; } .rich h3 { font-size: 1.05rem; }
.rich > *:first-child { margin-top: 0; }
.rich > *:last-child { margin-bottom: 0; }
.rich img { max-width: 100%; height: auto; border-radius: 10px; }
.rich blockquote { border-left: 3px solid var(--brand-300); padding-left: 1rem; margin-left: 0;
  color: var(--text-muted); font-style: italic; }
.rich pre { background: var(--surface-2); padding: .8rem; border-radius: 9px; overflow-x: auto; font-size: .82rem; }
.rich table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .85rem; }
.rich table td, .rich table th { border: 1px solid var(--border); padding: .45rem .6rem; }
.rich ul, .rich ol { padding-left: 1.4rem; }

/* ------------------------------------------------------------ Misc utilities */
.hr-soft { border: 0; border-top: 1px solid var(--border); margin: 1.15rem 0; }
.dashed-top { border-top: 1px dashed var(--border); }
.sticky-top-card { position: sticky; top: calc(var(--topbar-h) + 1rem); }
.text-brand { color: var(--brand-600) !important; }
[data-bs-theme="dark"] .text-brand { color: var(--brand-300) !important; }
.text-gold { color: var(--gold-600) !important; }
.bg-surface-2 { background: var(--surface-2) !important; }
.fs-7 { font-size: .8rem !important; }
.fs-8 { font-size: .73rem !important; }
.min-w-0 { min-width: 0; }
.cursor-pointer { cursor: pointer; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.copy-btn { border: 0; background: transparent; color: var(--ink-400); padding: 0 .25rem;
  font-size: .75rem; cursor: pointer; transition: color .15s; }
.copy-btn:hover { color: var(--brand-500); }

.toast-host { position: fixed; top: calc(var(--topbar-h) + .75rem); right: 1rem; z-index: 2000;
  display: flex; flex-direction: column; gap: .5rem; max-width: min(360px, calc(100vw - 2rem)); }
.mini-toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand-500);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: .7rem .9rem; font-size: .845rem;
  display: flex; gap: .6rem; align-items: flex-start; animation: slideIn .25s ease;
}
.mini-toast.err { border-left-color: #dc2626; }
.mini-toast.warn { border-left-color: var(--gold-500); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* Amortisation / schedule rows */
tr.row-paid td { background: rgba(22,163,74,.045); }
tr.row-overdue td { background: rgba(220,38,38,.05); }
tr.row-next td { background: rgba(229,167,44,.07); font-weight: 500; }

/* Receipt / printable */
@media print {
  .sidebar, .topbar, .app-foot, .page-actions, .filter-bar, .no-print, .breadcrumb { display: none !important; }
  .shell { margin-left: 0; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: #fff; font-size: 11pt; }
  a { color: #000 !important; }
  .table thead th { background: #f1f1f1 !important; }
}
.receipt { max-width: 560px; margin: 0 auto; }
.receipt-head { text-align: center; padding-bottom: 1rem; border-bottom: 2px dashed var(--border); }
.receipt-rows { list-style: none; padding: 0; margin: 1rem 0; }
.receipt-rows li { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0;
  border-bottom: 1px dotted var(--border); font-size: .875rem; }
.receipt-rows li span:first-child { color: var(--text-muted); }
.receipt-rows li span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.receipt-total { display: flex; justify-content: space-between; padding: .7rem 0; margin-top: .5rem;
  border-top: 2px solid var(--text); font-weight: 800; font-size: 1.05rem; font-family: 'Plus Jakarta Sans'; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
  html { scroll-behavior: auto; }
}
